• Ard Biesheuvel's avatar
    arm64: kernel: Create initial ID map from C code · 84b04d3e
    Ard Biesheuvel authored
    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: default avatarArd Biesheuvel <ardb@kernel.org>
    Link: https://lore.kernel.org/r/20240214122845.2033971-66-ardb+git@google.comSigned-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
    84b04d3e
mmu.c 39.9 KB