diff options
author | Ard Biesheuvel <ardb@kernel.org> | 2022-08-02 11:00:16 +0200 |
---|---|---|
committer | Ard Biesheuvel <ardb@kernel.org> | 2022-11-18 09:14:08 +0100 |
commit | 9cf42bca30e98a1c6c9e8abf876940a551eaa3d1 (patch) | |
tree | 9f3dc73b8f91db7baefbf1d81ccefaaa1f76d29d /drivers/firmware/efi/libstub/randomalloc.c | |
parent | 977122898ea5e3d568014ec9fe089cfba7c73e76 (diff) | |
download | linux-9cf42bca30e98a1c6c9e8abf876940a551eaa3d1.tar.bz2 |
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>
Diffstat (limited to 'drivers/firmware/efi/libstub/randomalloc.c')
-rw-r--r-- | drivers/firmware/efi/libstub/randomalloc.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/firmware/efi/libstub/randomalloc.c b/drivers/firmware/efi/libstub/randomalloc.c index 9fb5869896be..ec44bb7e092f 100644 --- a/drivers/firmware/efi/libstub/randomalloc.c +++ b/drivers/firmware/efi/libstub/randomalloc.c @@ -53,7 +53,8 @@ static unsigned long get_entry_num_slots(efi_memory_desc_t *md, efi_status_t efi_random_alloc(unsigned long size, unsigned long align, unsigned long *addr, - unsigned long random_seed) + unsigned long random_seed, + int memory_type) { unsigned long total_slots = 0, target_slot; unsigned long total_mirrored_slots = 0; @@ -118,7 +119,7 @@ efi_status_t efi_random_alloc(unsigned long size, pages = size / EFI_PAGE_SIZE; status = efi_bs_call(allocate_pages, EFI_ALLOCATE_ADDRESS, - EFI_LOADER_DATA, pages, &target); + memory_type, pages, &target); if (status == EFI_SUCCESS) *addr = target; break; |