From ebdea88d57d5e67b8f6e6cf615300eedbc7200a9 Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Mon, 11 Oct 2021 15:10:23 +0300 Subject: efi_loader: Fix loaded image alignment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We are ignoring the alignment communicated via the PE/COFF header. Starting 5.10 the Linux kernel will loudly complain about it. For more details look at [1] (in linux kernel). So add a function that can allocate aligned EFI memory and use it for our relocated loaded image. [1] c32ac11da3f83 ("efi/libstub: arm64: Double check image alignment at entry") Signed-off-by: Ilias Apalodimas Tested-by: Vincent Stehlé Acked-by: Ard Biesheuvel Reviewed-by: Heinrich Schuchardt --- include/efi_loader.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/efi_loader.h') diff --git a/include/efi_loader.h b/include/efi_loader.h index c440962fe52..5cdc72345e5 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -675,6 +675,8 @@ struct efi_device_path *efi_get_dp_from_boot(const efi_guid_t guid); #define efi_size_in_pages(size) (((size) + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT) /* Generic EFI memory allocator, call this to get memory */ void *efi_alloc(uint64_t len, int memory_type); +/* Allocate pages on the specified alignment */ +void *efi_alloc_aligned_pages(u64 len, int memory_type, size_t align); /* More specific EFI memory allocator, called by EFI payloads */ efi_status_t efi_allocate_pages(enum efi_allocate_type type, enum efi_memory_type memory_type, -- cgit v1.2.3