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

From: Joerg Roedel
Date: Tue Mar 10 2020 - 09:03:32 EST


On Tue, Mar 10, 2020 at 01:40:03PM +0100, Borislav Petkov wrote:
> On Tue, Feb 25, 2020 at 09:42:07AM -0600, Tom Lendacky wrote:
> > @@ -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;
> > }
>
> Why isn't this done in __ioremap_check_encrypted() which is exactly for
> SEV stuff like that?

See the comment added in the patch, walk_mem_res() does not iterate over
the resource which contains EFI_RUNTIME_SERVICES_DATA, so
__ioremap_check_encrypted() will not be called on that resource.

walk_system_ram_range() might do the job, but calling it only for
EFI_RUNTIME_SERVICES_DATA has some overhead.

Regards,

Joerg