[PATCH] arm64/relocate_kernel: remove redundant but misleading code
Pingfan Liu
kernelfans at gmail.com
Thu Aug 6 04:26:18 EDT 2020
The kexec switch sequence looks like the following:
SYM_CODE_START(__cpu_soft_restart)
...
pre_disable_mmu_workaround
msr sctlr_el1, x12
...
br x8
SYM_CODE_START(arm64_relocate_new_kernel)
...
pre_disable_mmu_workaround
msr sctlr_el2, x0
...
"msr sctlr_el2, x0" is misleading, because "br x8" jump to a physical
address, which has no entry in idmap. It implies that MMU has already been
fully off after "msr sctlr_el1, x12".
And according to "D12.2.101 SCTLR_EL2, System Control Register (EL2)" in
"ARM Architecture Reference Manual", actually, EL2&0 host accesses
to SCTLR_EL2 when using mnemonic SCTLR_EL1.
Hence removing the redundant but misleading code.
Signed-off-by: Pingfan Liu <kernelfans at gmail.com>
Cc: Geoff Levand <geoff at infradead.org>
Cc: Catalin Marinas <catalin.marinas at arm.com>
Cc: Will Deacon <will at kernel.org>
Cc: Mark Rutland <mark.rutland at arm.com>
Cc: Mark Brown <broonie at kernel.org>
Cc: Kees Cook <keescook at chromium.org>
Cc: Remi Denis-Courmont <remi.denis.courmont at huawei.com>
Cc: Ard Biesheuvel <ardb at kernel.org>
To: linux-arm-kernel at lists.infradead.org
---
arch/arm64/kernel/cpu-reset.S | 4 ++++
arch/arm64/kernel/relocate_kernel.S | 12 ------------
2 files changed, 4 insertions(+), 12 deletions(-)
diff --git a/arch/arm64/kernel/cpu-reset.S b/arch/arm64/kernel/cpu-reset.S
index 4a18055..37721eb 100644
--- a/arch/arm64/kernel/cpu-reset.S
+++ b/arch/arm64/kernel/cpu-reset.S
@@ -35,6 +35,10 @@ SYM_CODE_START(__cpu_soft_restart)
mov_q x13, SCTLR_ELx_FLAGS
bic x12, x12, x13
pre_disable_mmu_workaround
+ /*
+ * either disable EL1&0 translation regime or disable EL2&0 translation
+ * regime if HCR_EL2.E2H == 1
+ */
msr sctlr_el1, x12
isb
diff --git a/arch/arm64/kernel/relocate_kernel.S b/arch/arm64/kernel/relocate_kernel.S
index 542d6ed..84eec95 100644
--- a/arch/arm64/kernel/relocate_kernel.S
+++ b/arch/arm64/kernel/relocate_kernel.S
@@ -36,18 +36,6 @@ SYM_CODE_START(arm64_relocate_new_kernel)
mov x14, xzr /* x14 = entry ptr */
mov x13, xzr /* x13 = copy dest */
- /* Clear the sctlr_el2 flags. */
- mrs x0, CurrentEL
- cmp x0, #CurrentEL_EL2
- b.ne 1f
- mrs x0, sctlr_el2
- mov_q x1, SCTLR_ELx_FLAGS
- bic x0, x0, x1
- pre_disable_mmu_workaround
- msr sctlr_el2, x0
- isb
-1:
-
/* Check if the new image needs relocation. */
tbnz x16, IND_DONE_BIT, .Ldone
--
2.7.5
More information about the linux-arm-kernel
mailing list