[PATCH 0/6] arm64: efi: boot with MMU and caches on if possible

Ard Biesheuvel ardb at kernel.org
Thu Jun 30 07:42:24 PDT 2022


This small series is what remains now that much of the prerequisite
changes that are shared with other work have landed. This is a follow-up
to [0], and implements the necessary changes that allow the EFI stub to
enter the kernel proper with MMU and caches enabled.

This is possible because the EFI spec mandates that all of memory is
mapped, and so we can rely on this mapping to set up the initial ID map,
instead of taking down the MMU first, and populating those page tables
using non-cacheable accesses that require special care in terms of cache
coherency. This also means that there is no need to clean the executable
image to the point of coherency (with the exception of the contents of
.idmap.text, which contains the code that switches from the firmware's
ID map to the kernel one)

Given that the image will typically be mapped by the firmware according
to the section descriptors in the PE/COFF header (R-X for .text and
.rodata, RW- for .data and .bss), this also has a slight robustness
advantage.

Note that this does not update the documented boot protocol [yet],
although any loader could take advantage of this, and load the kernel
image at any 64k aligned physical offset, and enter the image with the
MMU still enabled, either at EL2 or EL1.

[0] https://lore.kernel.org/linux-arm-kernel/20220330154205.2483167-1-ardb@kernel.org/

Cc: Will Deacon <will at kernel.org>
Cc: Marc Zyngier <maz at kernel.org>
Cc: Pierre-Clément Tosi <ptosi at google.com>
Cc: Quentin Perret <qperret at google.com>
Cc: Mark Rutland <mark.rutland at arm.com>

Ard Biesheuvel (6):
  arm64: lds: reduce effective minimum image alignment to 64k
  arm64: kernel: move ID map out of .text mapping
  arm64: head: record the MMU state at primary entry
  arm64: head: avoid cache invalidation when entering with the MMU on
  arm64: head: clean the ID map page to the PoC
  arm64: efi/libstub: enter with the MMU on if executing in place

 arch/arm64/include/asm/efi.h              |  7 ---
 arch/arm64/kernel/efi-entry.S             |  4 ++
 arch/arm64/kernel/head.S                  | 45 ++++++++++++++++++--
 arch/arm64/kernel/vmlinux.lds.S           | 13 +++++-
 arch/arm64/mm/proc.S                      |  2 -
 drivers/firmware/efi/libstub/arm64-stub.c |  2 +-
 include/linux/efi.h                       |  6 +--
 7 files changed, 58 insertions(+), 21 deletions(-)

-- 
2.35.1




More information about the linux-arm-kernel mailing list