]> git.baikalelectronics.ru Git - kernel.git/commit
efi: runtime: Don't assume virtual mappings are missing if VA == PA == 0
authorArd Biesheuvel <ardb@kernel.org>
Thu, 20 Oct 2022 13:16:09 +0000 (15:16 +0200)
committerArd Biesheuvel <ardb@kernel.org>
Fri, 21 Oct 2022 09:09:41 +0000 (11:09 +0200)
commite5d7d83fd6b312406243efd4b5056185947fe9ff
tree0b60b29e2fa95de6d198043055027ef3044b2005
parent5fbad00626295c0dde3ba2c814cdddf31a6f3170
efi: runtime: Don't assume virtual mappings are missing if VA == PA == 0

The generic EFI stub can be instructed to avoid SetVirtualAddressMap(),
and simply run with the firmware's 1:1 mapping. In this case, it
populates the virtual address fields of the runtime regions in the
memory map with the physical address of each region, so that the mapping
code has to be none the wiser. Only if SetVirtualAddressMap() fails, the
virtual addresses are wiped and the kernel code knows that the regions
cannot be mapped.

However, wiping amounts to setting it to zero, and if a runtime region
happens to live at physical address 0, its valid 1:1 mapped virtual
address could be mistaken for a wiped field, resulting on loss of access
to the EFI services at runtime.

So let's only assume that VA == 0 means 'no runtime services' if the
region in question does not live at PA 0x0.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
drivers/firmware/efi/arm-runtime.c
drivers/firmware/efi/libstub/fdt.c
drivers/firmware/efi/riscv-runtime.c