]> git.ipfire.org Git - thirdparty/linux.git/commit
arm64: kernel: Create initial ID map from C code
authorArd Biesheuvel <ardb@kernel.org>
Wed, 14 Feb 2024 12:29:07 +0000 (13:29 +0100)
committerCatalin Marinas <catalin.marinas@arm.com>
Fri, 16 Feb 2024 12:42:34 +0000 (12:42 +0000)
commit84b04d3e6bdbc7551e62b75dd97cae4a8bddb1b6
treef09161e2bd992aa7ec549cfd2811de399266e598
parent34b98e55f6840cab938d480968c0f600a2ed97d5
arm64: kernel: Create initial ID map from C code

The asm code that creates the initial ID map is rather intricate and
hard to follow. This is problematic because it makes adding support for
things like LPA2 or WXN more difficult than necessary. Also, it is
parameterized like the rest of the MM code to run with a configurable
number of levels, which is rather pointless, given that all AArch64 CPUs
implement support for 48-bit virtual addressing, and that many systems
exist with DRAM located outside of the 39-bit addressable range, which
is the only smaller VA size that is widely used, and we need additional
tricks to make things work in that combination.

So let's bite the bullet, and rip out all the asm macros, and fiddly
code, and replace it with a C implementation based on the newly added
routines for creating the early kernel VA mappings. And while at it,
create the initial ID map based on 48-bit virtual addressing as well,
regardless of the number of configured levels for the kernel proper.

Note that this code may execute with the MMU and caches disabled, and is
therefore not permitted to make unaligned accesses. This shouldn't
generally happen in any case for the algorithm as implemented, but to be
sure, let's pass -mstrict-align to the compiler just in case.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/r/20240214122845.2033971-66-ardb+git@google.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/include/asm/assembler.h
arch/arm64/include/asm/kernel-pgtable.h
arch/arm64/include/asm/mmu_context.h
arch/arm64/kernel/head.S
arch/arm64/kernel/image-vars.h
arch/arm64/kernel/pi/Makefile
arch/arm64/kernel/pi/map_kernel.c
arch/arm64/kernel/pi/map_range.c
arch/arm64/kernel/pi/pi.h
arch/arm64/mm/mmu.c
arch/arm64/mm/proc.S