arm64: head: pass ID map root table address to __enable_mmu()
authorArd Biesheuvel <ardb@kernel.org>
Fri, 24 Jun 2022 15:06:39 +0000 (17:06 +0200)
committerWill Deacon <will@kernel.org>
Fri, 24 Jun 2022 16:18:09 +0000 (17:18 +0100)
We will be adding an initial ID map that covers the entire kernel image,
so we will pass the actual ID map root table to use to __enable_mmu(),
rather than hard code it.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/r/20220624150651.1358849-10-ardb@kernel.org
Signed-off-by: Will Deacon <will@kernel.org>
arch/arm64/kernel/head.S
arch/arm64/kernel/sleep.S

index 1cbc52097bf9a488e6653469f9bbeab06cb00c97..70c462bbd6bfd2aed7df5631c952342f923c87d1 100644 (file)
@@ -595,6 +595,7 @@ SYM_FUNC_START_LOCAL(secondary_startup)
        bl      __cpu_secondary_check52bitva
        bl      __cpu_setup                     // initialise processor
        adrp    x1, swapper_pg_dir
+       adrp    x2, idmap_pg_dir
        bl      __enable_mmu
        ldr     x8, =__secondary_switched
        br      x8
@@ -648,6 +649,7 @@ SYM_FUNC_END(__secondary_too_slow)
  *
  *  x0  = SCTLR_EL1 value for turning on the MMU.
  *  x1  = TTBR1_EL1 value
+ *  x2  = ID map root table address
  *
  * Returns to the caller via x30/lr. This requires the caller to be covered
  * by the .idmap.text section.
@@ -656,14 +658,13 @@ SYM_FUNC_END(__secondary_too_slow)
  * If it isn't, park the CPU
  */
 SYM_FUNC_START(__enable_mmu)
-       mrs     x2, ID_AA64MMFR0_EL1
-       ubfx    x2, x2, #ID_AA64MMFR0_TGRAN_SHIFT, 4
-       cmp     x2, #ID_AA64MMFR0_TGRAN_SUPPORTED_MIN
+       mrs     x3, ID_AA64MMFR0_EL1
+       ubfx    x3, x3, #ID_AA64MMFR0_TGRAN_SHIFT, 4
+       cmp     x3, #ID_AA64MMFR0_TGRAN_SUPPORTED_MIN
        b.lt    __no_granule_support
-       cmp     x2, #ID_AA64MMFR0_TGRAN_SUPPORTED_MAX
+       cmp     x3, #ID_AA64MMFR0_TGRAN_SUPPORTED_MAX
        b.gt    __no_granule_support
-       update_early_cpu_boot_status 0, x2, x3
-       adrp    x2, idmap_pg_dir
+       update_early_cpu_boot_status 0, x3, x4
        phys_to_ttbr x1, x1
        phys_to_ttbr x2, x2
        msr     ttbr0_el1, x2                   // load TTBR0
@@ -819,6 +820,7 @@ SYM_FUNC_START_LOCAL(__primary_switch)
 #endif
 
        adrp    x1, init_pg_dir
+       adrp    x2, idmap_pg_dir
        bl      __enable_mmu
 #ifdef CONFIG_RELOCATABLE
 #ifdef CONFIG_RELR
index 4ea9392f86e017a4a509a4324ade8177caf977ff..e36b09d942f7dd59f5f3be379647b97cc0302859 100644 (file)
@@ -104,6 +104,7 @@ SYM_CODE_START(cpu_resume)
        bl      __cpu_setup
        /* enable the MMU early - so we can access sleep_save_stash by va */
        adrp    x1, swapper_pg_dir
+       adrp    x2, idmap_pg_dir
        bl      __enable_mmu
        ldr     x8, =_cpu_resume
        br      x8