efi/mokvar: Reserve the table only if it is in boot services data
authorBorislav Petkov <bp@suse.de>
Tue, 20 Jul 2021 07:28:09 +0000 (09:28 +0200)
committerArd Biesheuvel <ardb@kernel.org>
Tue, 20 Jul 2021 07:28:09 +0000 (09:28 +0200)
commit47e1e233e9d822dfda068383fb9a616451bda703
tree9396321dbeaf91ea62bbb857def82121aff58d4c
parent947228cb9f1a2c69a5da5279c48f02bb4f49ce32
efi/mokvar: Reserve the table only if it is in boot services data

One of the SUSE QA tests triggered:

  localhost kernel: efi: Failed to lookup EFI memory descriptor for 0x000000003dcf8000

which comes from x86's version of efi_arch_mem_reserve() trying to
reserve a memory region. Usually, that function expects
EFI_BOOT_SERVICES_DATA memory descriptors but the above case is for the
MOKvar table which is allocated in the EFI shim as runtime services.

That lead to a fix changing the allocation of that table to boot services.

However, that fix broke booting SEV guests with that shim leading to
this kernel fix

  8d651ee9c71b ("x86/ioremap: Map EFI-reserved memory as encrypted for SEV")

which extended the ioremap hint to map reserved EFI boot services as
decrypted too.

However, all that wasn't needed, IMO, because that error message in
efi_arch_mem_reserve() was innocuous in this case - if the MOKvar table
is not in boot services, then it doesn't need to be reserved in the
first place because it is, well, in runtime services which *should* be
reserved anyway.

So do that reservation for the MOKvar table only if it is allocated
in boot services data. I couldn't find any requirement about where
that table should be allocated in, unlike the ESRT which allocation is
mandated to be done in boot services data by the UEFI spec.

Signed-off-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
drivers/firmware/efi/mokvar-table.c