Re: [PATCH] x86/ioremap: Map EFI runtime services data as encrypted for SEV

From: Joerg Roedel
Date: Tue Mar 10 2020 - 06:25:07 EST


Hi Tom,

On Tue, Feb 25, 2020 at 09:42:07AM -0600, Tom Lendacky wrote:
> diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
> index 44e4beb4239f..382b6ca66820 100644
> --- a/arch/x86/mm/ioremap.c
> +++ b/arch/x86/mm/ioremap.c
> @@ -135,6 +135,13 @@ static void __ioremap_check_mem(resource_size_t addr, unsigned long size,
> memset(desc, 0, sizeof(struct ioremap_desc));
>
> walk_mem_res(start, end, desc, __ioremap_collect_map_flags);
> +
> + /*
> + * The EFI runtime services data area is not covered by walk_mem_res(),
> + * but must be mapped encrypted when SEV is active.
> + */
> + if (sev_active() && efi_mem_type(addr) == EFI_RUNTIME_SERVICES_DATA)
> + desc->flags |= IORES_MAP_ENCRYPTED;
> }

I can confirm that this fixes dmi-decode on my SEV guest. While
reviewing I looked into using walk_system_ram_range(), but since this is
only for the EFI_RUNTIME_SERVICES_DATA, it is not needed, so:

Reviewed-by: Joerg Roedel <jroedel@xxxxxxx>
Tested-by: Joerg Roedel <jroedel@xxxxxxx>