efi: libstub: use EFI_LOADER_CODE region when moving the kernel in memory
authorArd Biesheuvel <ardb@kernel.org>
Tue, 2 Aug 2022 09:00:16 +0000 (11:00 +0200)
committerArd Biesheuvel <ardb@kernel.org>
Fri, 18 Nov 2022 08:14:08 +0000 (09:14 +0100)
commit9cf42bca30e98a1c6c9e8abf876940a551eaa3d1
tree9f3dc73b8f91db7baefbf1d81ccefaaa1f76d29d
parent977122898ea5e3d568014ec9fe089cfba7c73e76
efi: libstub: use EFI_LOADER_CODE region when moving the kernel in memory

The EFI spec is not very clear about which permissions are being given
when allocating pages of a certain type. However, it is quite obvious
that EFI_LOADER_CODE is more likely to permit execution than
EFI_LOADER_DATA, which becomes relevant once we permit booting the
kernel proper with the firmware's 1:1 mapping still active.

Ostensibly, recent systems such as the Surface Pro X grant executable
permissions to EFI_LOADER_CODE regions but not EFI_LOADER_DATA regions.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
drivers/firmware/efi/libstub/alignedmem.c
drivers/firmware/efi/libstub/arm64-stub.c
drivers/firmware/efi/libstub/efistub.h
drivers/firmware/efi/libstub/mem.c
drivers/firmware/efi/libstub/randomalloc.c