Skip to content

Commit 1ff2fc0

Browse files
tlendackyardbiesheuvel
authored andcommitted
x86/sme: Explicitly map new EFI memmap table as encrypted
Reserving memory using efi_mem_reserve() calls into the x86 efi_arch_mem_reserve() function. This function will insert a new EFI memory descriptor into the EFI memory map representing the area of memory to be reserved and marking it as EFI runtime memory. As part of adding this new entry, a new EFI memory map is allocated and mapped. The mapping is where a problem can occur. This new memory map is mapped using early_memremap() and generally mapped encrypted, unless the new memory for the mapping happens to come from an area of memory that is marked as EFI_BOOT_SERVICES_DATA memory. In this case, the new memory will be mapped unencrypted. However, during replacement of the old memory map, efi_mem_type() is disabled, so the new memory map will now be long-term mapped encrypted (in efi.memmap), resulting in the map containing invalid data and causing the kernel boot to crash. Since it is known that the area will be mapped encrypted going forward, explicitly map the new memory map as encrypted using early_memremap_prot(). Cc: <[email protected]> # 4.14.x Fixes: 8f716c9 ("x86/mm: Add support to access boot related data in the clear") Link: https://lore.kernel.org/all/ebf1eb2940405438a09d51d121ec0d02c8755558.1634752931.git.thomas.lendacky@amd.com/ Signed-off-by: Tom Lendacky <[email protected]> [ardb: incorporate Kconfig fix by Arnd] Signed-off-by: Ard Biesheuvel <[email protected]>
1 parent fa55b7d commit 1ff2fc0

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

arch/x86/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1932,6 +1932,7 @@ config EFI
19321932
depends on ACPI
19331933
select UCS2_STRING
19341934
select EFI_RUNTIME_WRAPPERS
1935+
select ARCH_USE_MEMREMAP_PROT
19351936
help
19361937
This enables the kernel to use EFI runtime services that are
19371938
available (such as the EFI variable services).

arch/x86/platform/efi/quirks.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,8 @@ void __init efi_arch_mem_reserve(phys_addr_t addr, u64 size)
277277
return;
278278
}
279279

280-
new = early_memremap(data.phys_map, data.size);
280+
new = early_memremap_prot(data.phys_map, data.size,
281+
pgprot_val(pgprot_encrypted(FIXMAP_PAGE_NORMAL)));
281282
if (!new) {
282283
pr_err("Failed to map new boot services memmap\n");
283284
return;

0 commit comments

Comments
 (0)