Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

efi: arm: reduce minimum alignment of uncompressed kernel

Now that we reduced the minimum relative alignment between PHYS_OFFSET
and PAGE_OFFSET to 2 MiB, we can take this into account when allocating
memory for the decompressed kernel when booting via EFI. This minimizes
the amount of unusable memory we may end up with due to the base of DRAM
being occupied by firmware.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>

+6 -7
+6 -7
arch/arm/include/asm/efi.h
··· 66 66 #define MAX_UNCOMP_KERNEL_SIZE SZ_32M 67 67 68 68 /* 69 - * phys-to-virt patching requires that the physical to virtual offset fits 70 - * into the immediate field of an add/sub instruction, which comes down to the 71 - * 24 least significant bits being zero, and so the offset should be a multiple 72 - * of 16 MB. Since PAGE_OFFSET itself is a multiple of 16 MB, the physical 73 - * base should be aligned to 16 MB as well. 69 + * phys-to-virt patching requires that the physical to virtual offset is a 70 + * multiple of 2 MiB. However, using an alignment smaller than TEXT_OFFSET 71 + * here throws off the memory allocation logic, so let's use the lowest power 72 + * of two greater than 2 MiB and greater than TEXT_OFFSET. 74 73 */ 75 - #define EFI_PHYS_ALIGN SZ_16M 74 + #define EFI_PHYS_ALIGN max(SZ_2M, roundup_pow_of_two(TEXT_OFFSET)) 76 75 77 76 /* on ARM, the FDT should be located in a lowmem region */ 78 77 static inline unsigned long efi_get_max_fdt_addr(unsigned long image_addr) ··· 82 83 /* on ARM, the initrd should be loaded in a lowmem region */ 83 84 static inline unsigned long efi_get_max_initrd_addr(unsigned long image_addr) 84 85 { 85 - return round_down(image_addr, EFI_PHYS_ALIGN) + SZ_512M; 86 + return round_down(image_addr, SZ_4M) + SZ_512M; 86 87 } 87 88 88 89 struct efi_arm_entry_state {