efi/libstub: arm32: Use low allocation for the uncompressed kernel
authorArd Biesheuvel <ardb@kernel.org>
Wed, 9 Sep 2020 14:11:50 +0000 (17:11 +0300)
committerArd Biesheuvel <ardb@kernel.org>
Wed, 16 Sep 2020 15:55:02 +0000 (18:55 +0300)
commit762cd288fc4a24a372f36408e69b1885967f94bb
tree9eba2c04a2d47ebba1fdcdf3d03f78710ac891fb
parent1a895dbf4b66456bfb7da646cc9b1be3e24f4a1d
efi/libstub: arm32: Use low allocation for the uncompressed kernel

Before commit

  d0f9ca9be11f25ef ("ARM: decompressor: run decompressor in place if loaded via UEFI")

we were rather limited in the choice of base address for the uncompressed
kernel, as we were relying on the logic in the decompressor that blindly
rounds down the decompressor execution address to the next multiple of 128
MiB, and decompresses the kernel there. For this reason, we have a lot of
complicated memory region handling code, to ensure that this memory window
is available, even though it could be occupied by reserved regions or
other allocations that may or may not collide with the uncompressed image.

Today, we simply pass the target address for the decompressed image to the
decompressor directly, and so we can choose a suitable window just by
finding a 16 MiB aligned region, while taking TEXT_OFFSET and the region
for the swapper page tables into account.

So let's get rid of the complicated logic, and instead, use the existing
bottom up allocation routine to allocate a suitable window as low as
possible, and carve out a memory region that has the right properties.

Note that this removes any dependencies on the 'dram_base' argument to
handle_kernel_image(), and so this is removed as well. Given that this
was the only remaining use of dram_base, the code that produces it is
removed entirely as well.

Reviewed-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Tested-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
drivers/firmware/efi/libstub/arm32-stub.c
drivers/firmware/efi/libstub/arm64-stub.c
drivers/firmware/efi/libstub/efi-stub.c
drivers/firmware/efi/libstub/efistub.h