efi/libstub: simplify arm64 kernel image loading
Get series with b4
b4 am [email protected]Versions newest first
- v2 Latest8 patches 8 repliesIn review
Patches in v2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/8 | efi/libstub/random: align allocate size to EFI_ALLOC_ALIGNdrivers/ | +3 | 0 replies | |
| 2/8 | efi/libstub/random: increase random alloc granularitydrivers/ | +1 | 0 replies | |
| 3/8 | efi/libstub/arm64: replace 'preferred' offset with alignment checkdrivers/ | +25 | 2 replies | |
| 4/8 | efi/libstub/arm64: simplify randomized loading of kernel imagedrivers/ | +5 | 0 replies | |
| 5/8 | efi/libstub/arm64: align PE/COFF sections to segment alignmentarch/ arch/ | +3 | 2 replies | |
| 6/8 | efi/libstub: add API function to allocate aligned memorydrivers/ drivers/ drivers/ +1 more | +71 | 1 reply | |
| 7/8 | efi/libstub/arm64: switch to ordinary page allocator for kernel imagedrivers/ | +2 | 1 reply | |
| 8/8 | efi/libstub: move efi_relocate_kernel() into separate source filedrivers/ drivers/ drivers/ +1 more | +175 | 0 replies |
Reviews trailers per patch
3 of 8 patches have a Reviewed-by or Acked-by.
| Patch | Atish Patra |
|---|---|
| 1/8 | |
| 2/8 | |
| 3/8 | R-b |
| 4/8 | |
| 5/8 | |
| 6/8 | R-b |
| 7/8 | R-b |
| 8/8 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v2 0/8] efi/libstub: simplify arm64 kernel image loading
On arm64, the kernel image used to be virtually mapped via the linear region, making the two mappings correlated in a way that required the kernel to be located at the start of the linear region, or the memory below would not be accessible. For this reason, the EFI stub loader code for arm64 has the notion of a 'preferred offset' for the physical placement of the kernel image, and tries to put the kernel there, or at least as low as possible in physical memory (unless KASLR is active, in which case the placement is randomized)
When KASLR was introduced, the virtual mapping of the kernel was moved into the vmalloc region, and now, regardless of whether KASLR support is built in or active, the kernel can be placed anywhere in physical memory without any detrimental side effects on the linear region.
This means that we can drop the notion of 'preferred offset' entirely, and invoke the kernel in place if the PE/COFF loader loaded it at the right offset. If not, we can invoke the ordinary UEFI top down page allocator to reallocate it elsewhere in memory. By updating the PE/COFF metadata, we can inform the PE/COFF loader about the desired alignment, making it less likely that we need to move the kernel image in the first place.
Ard Biesheuvel (8):
efi/libstub/random: align allocate size to EFI_ALLOC_ALIGN efi/libstub/random: increase random alloc granularity efi/libstub/arm64: replace 'preferred' offset with alignment check efi/libstub/arm64: simplify randomized loading of kernel image efi/libstub/arm64: align PE/COFF sections to segment alignment efi/libstub: add API function to allocate aligned memory efi/libstub/arm64: switch to ordinary page allocator for kernel image efi/libstub: move efi_relocate_kernel() into separate source file
arch/arm64/kernel/efi-header.S | 2 +- arch/arm64/kernel/vmlinux.lds.S | 3 +- drivers/firmware/efi/libstub/Makefile | 3 +- drivers/firmware/efi/libstub/alignedmem.c | 57 ++++++ drivers/firmware/efi/libstub/arm64-stub.c | 92 +++------- drivers/firmware/efi/libstub/efistub.h | 18 +- drivers/firmware/efi/libstub/mem.c | 191 +------------------- drivers/firmware/efi/libstub/randomalloc.c | 6 +- drivers/firmware/efi/libstub/relocate.c | 174 ++++++++++++++++++ 9 files changed, 280 insertions(+), 266 deletions(-) create mode 100644 drivers/firmware/efi/libstub/alignedmem.c create mode 100644 drivers/firmware/efi/libstub/relocate.c
Signature · 1 line
2.17.1