From: Ard Biesheuvel <ardb@kernel.org>
efi_memattr_init() should call efi_mem_reserve() rather than
memblock_reserve() to preserve the memory contents of the region when
the EFI memory attributes table is loaded by the firmware.
However, efi_mem_reserve() can only be called later during the boot on
x86, due to the fact that it may need to memblock_alloc() memory for the
EFI memory map.
So move the call to efi_memattr_init() to a later stage when building
for x86_64.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
arch/x86/platform/efi/efi.c | 2 ++
drivers/firmware/efi/efi.c | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index f32276bd8d4e..107dcdf354ba 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -167,6 +167,8 @@ static void __init do_add_efi_memmap(void)
void __init efi_init_reservations(void)
{
+ if (IS_ENABLED(CONFIG_X86_64) && efi_enabled(EFI_MEMMAP))
+ efi_memattr_init();
efi_find_mirror();
efi_esrt_init();
efi_mokvar_table_init();
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index b2fb92a4bbd1..d28ed1ce9a33 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -761,7 +761,7 @@ int __init efi_config_parse_tables(const efi_config_table_t *config_tables,
}
}
- if (!IS_ENABLED(CONFIG_X86_32) && efi_enabled(EFI_MEMMAP))
+ if (!IS_ENABLED(CONFIG_X86) && efi_enabled(EFI_MEMMAP))
efi_memattr_init();
efi_tpm_eventlog_init();
--
2.53.0.1018.g2bb0e51243-goog