提交 d9597589 编写于 作者: M Ma Wupeng 提交者: Yang Yingliang

efi: Make efi_find_mirror() public

hulk inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I4SK3S
CVE: NA

--------------------------------

Commit b05b9f5f ("x86, mirror: x86 enabling - find mirrored memory
ranges") introduce the efi_find_mirror function on x86. In order to reuse
the API we make it public in preparation for arm64 to support mirrord
memory.
Co-developed-by: NJing Xiangfeng <jingxiangfeng@huawei.com>
Signed-off-by: NMa Wupeng <mawupeng1@huawei.com>
Reviewed-by: NKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 e16eb8d7
...@@ -101,26 +101,6 @@ static efi_status_t __init phys_efi_set_virtual_address_map( ...@@ -101,26 +101,6 @@ static efi_status_t __init phys_efi_set_virtual_address_map(
return status; return status;
} }
void __init efi_find_mirror(void)
{
efi_memory_desc_t *md;
u64 mirror_size = 0, total_size = 0;
for_each_efi_memory_desc(md) {
unsigned long long start = md->phys_addr;
unsigned long long size = md->num_pages << EFI_PAGE_SHIFT;
total_size += size;
if (md->attribute & EFI_MEMORY_MORE_RELIABLE) {
memblock_mark_mirror(start, size);
mirror_size += size;
}
}
if (mirror_size)
pr_info("Memory: %lldM/%lldM mirrored memory\n",
mirror_size>>20, total_size>>20);
}
/* /*
* Tell the kernel about the EFI memory map. This might include * Tell the kernel about the EFI memory map. This might include
* more than the max 128 entries that can fit in the e820 legacy * more than the max 128 entries that can fit in the e820 legacy
......
...@@ -404,6 +404,26 @@ static int __init efisubsys_init(void) ...@@ -404,6 +404,26 @@ static int __init efisubsys_init(void)
subsys_initcall(efisubsys_init); subsys_initcall(efisubsys_init);
void __init efi_find_mirror(void)
{
efi_memory_desc_t *md;
u64 mirror_size = 0, total_size = 0;
for_each_efi_memory_desc(md) {
unsigned long long start = md->phys_addr;
unsigned long long size = md->num_pages << EFI_PAGE_SHIFT;
total_size += size;
if (md->attribute & EFI_MEMORY_MORE_RELIABLE) {
memblock_mark_mirror(start, size);
mirror_size += size;
}
}
if (mirror_size)
pr_info("Memory: %lldM/%lldM mirrored memory\n",
mirror_size>>20, total_size>>20);
}
/* /*
* Find the efi memory descriptor for a given physical address. Given a * Find the efi memory descriptor for a given physical address. Given a
* physical address, determine if it exists within an EFI Memory Map entry, * physical address, determine if it exists within an EFI Memory Map entry,
......
...@@ -1017,7 +1017,6 @@ extern void efi_free_boot_services(void); ...@@ -1017,7 +1017,6 @@ extern void efi_free_boot_services(void);
extern efi_status_t efi_query_variable_store(u32 attributes, extern efi_status_t efi_query_variable_store(u32 attributes,
unsigned long size, unsigned long size,
bool nonblocking); bool nonblocking);
extern void efi_find_mirror(void);
#else #else
static inline void efi_free_boot_services(void) {} static inline void efi_free_boot_services(void) {}
...@@ -1181,6 +1180,7 @@ static inline bool efi_enabled(int feature) ...@@ -1181,6 +1180,7 @@ static inline bool efi_enabled(int feature)
extern void efi_reboot(enum reboot_mode reboot_mode, const char *__unused); extern void efi_reboot(enum reboot_mode reboot_mode, const char *__unused);
extern bool efi_is_table_address(unsigned long phys_addr); extern bool efi_is_table_address(unsigned long phys_addr);
extern void efi_find_mirror(void);
#else #else
static inline bool efi_enabled(int feature) static inline bool efi_enabled(int feature)
{ {
...@@ -1199,6 +1199,8 @@ static inline bool efi_is_table_address(unsigned long phys_addr) ...@@ -1199,6 +1199,8 @@ static inline bool efi_is_table_address(unsigned long phys_addr)
{ {
return false; return false;
} }
static inline void efi_find_mirror(void) {}
#endif #endif
extern int efi_status_to_err(efi_status_t status); extern int efi_status_to_err(efi_status_t status);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册