Skip to content

Commit 985e537

Browse files
tlendackysuryasaimadhu
authored andcommitted
x86/ioremap: Map EFI runtime services data as encrypted for SEV
The dmidecode program fails to properly decode the SMBIOS data supplied by OVMF/UEFI when running in an SEV guest. The SMBIOS area, under SEV, is encrypted and resides in reserved memory that is marked as EFI runtime services data. As a result, when memremap() is attempted for the SMBIOS data, it can't be mapped as regular RAM (through try_ram_remap()) and, since the address isn't part of the iomem resources list, it isn't mapped encrypted through the fallback ioremap(). Add a new __ioremap_check_other() to deal with memory types like EFI_RUNTIME_SERVICES_DATA which are not covered by the resource ranges. This allows any runtime services data which has been created encrypted, to be mapped encrypted too. [ bp: Move functionality to a separate function. ] Signed-off-by: Tom Lendacky <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Reviewed-by: Joerg Roedel <[email protected]> Tested-by: Joerg Roedel <[email protected]> Cc: <[email protected]> # 5.3 Link: https://lkml.kernel.org/r/2d9e16eb5b53dc82665c95c6764b7407719df7a0.1582645327.git.thomas.lendacky@amd.com
1 parent 2c523b3 commit 985e537

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

arch/x86/mm/ioremap.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,19 @@ static unsigned int __ioremap_check_encrypted(struct resource *res)
106106
return 0;
107107
}
108108

109+
/*
110+
* The EFI runtime services data area is not covered by walk_mem_res(), but must
111+
* be mapped encrypted when SEV is active.
112+
*/
113+
static void __ioremap_check_other(resource_size_t addr, struct ioremap_desc *desc)
114+
{
115+
if (!sev_active())
116+
return;
117+
118+
if (efi_mem_type(addr) == EFI_RUNTIME_SERVICES_DATA)
119+
desc->flags |= IORES_MAP_ENCRYPTED;
120+
}
121+
109122
static int __ioremap_collect_map_flags(struct resource *res, void *arg)
110123
{
111124
struct ioremap_desc *desc = arg;
@@ -124,6 +137,9 @@ static int __ioremap_collect_map_flags(struct resource *res, void *arg)
124137
* To avoid multiple resource walks, this function walks resources marked as
125138
* IORESOURCE_MEM and IORESOURCE_BUSY and looking for system RAM and/or a
126139
* resource described not as IORES_DESC_NONE (e.g. IORES_DESC_ACPI_TABLES).
140+
*
141+
* After that, deal with misc other ranges in __ioremap_check_other() which do
142+
* not fall into the above category.
127143
*/
128144
static void __ioremap_check_mem(resource_size_t addr, unsigned long size,
129145
struct ioremap_desc *desc)
@@ -135,6 +151,8 @@ static void __ioremap_check_mem(resource_size_t addr, unsigned long size,
135151
memset(desc, 0, sizeof(struct ioremap_desc));
136152

137153
walk_mem_res(start, end, desc, __ioremap_collect_map_flags);
154+
155+
__ioremap_check_other(addr, desc);
138156
}
139157

140158
/*

0 commit comments

Comments
 (0)