Skip to content

Commit 3944382

Browse files
Marc Zyngieroupton
authored andcommitted
arm64: Treat HCR_EL2.E2H as RES1 when ID_AA64MMFR4_EL1.E2H0 is negative
For CPUs that have ID_AA64MMFR4_EL1.E2H0 as negative, it is important to avoid the boot path that sets HCR_EL2.E2H=0. Fortunately, we already have this path to cope with fruity CPUs. Tweak init_el2 to look at ID_AA64MMFR4_EL1.E2H0 first. Reviewed-by: Suzuki K Poulose <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Reviewed-by: Catalin Marinas <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Oliver Upton <[email protected]>
1 parent da9af50 commit 3944382

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

arch/arm64/kernel/head.S

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -584,25 +584,32 @@ SYM_INNER_LABEL(init_el2, SYM_L_LOCAL)
584584
mov_q x1, INIT_SCTLR_EL1_MMU_OFF
585585

586586
/*
587-
* Fruity CPUs seem to have HCR_EL2.E2H set to RES1,
588-
* making it impossible to start in nVHE mode. Is that
589-
* compliant with the architecture? Absolutely not!
587+
* Compliant CPUs advertise their VHE-onlyness with
588+
* ID_AA64MMFR4_EL1.E2H0 < 0. HCR_EL2.E2H can be
589+
* RES1 in that case.
590+
*
591+
* Fruity CPUs seem to have HCR_EL2.E2H set to RES1, but
592+
* don't advertise it (they predate this relaxation).
590593
*/
594+
mrs_s x0, SYS_ID_AA64MMFR4_EL1
595+
ubfx x0, x0, #ID_AA64MMFR4_EL1_E2H0_SHIFT, #ID_AA64MMFR4_EL1_E2H0_WIDTH
596+
tbnz x0, #(ID_AA64MMFR4_EL1_E2H0_SHIFT + ID_AA64MMFR4_EL1_E2H0_WIDTH - 1), 1f
597+
591598
mrs x0, hcr_el2
592599
and x0, x0, #HCR_E2H
593-
cbz x0, 1f
594-
600+
cbz x0, 2f
601+
1:
595602
/* Set a sane SCTLR_EL1, the VHE way */
596603
pre_disable_mmu_workaround
597604
msr_s SYS_SCTLR_EL12, x1
598605
mov x2, #BOOT_CPU_FLAG_E2H
599-
b 2f
606+
b 3f
600607

601-
1:
608+
2:
602609
pre_disable_mmu_workaround
603610
msr sctlr_el1, x1
604611
mov x2, xzr
605-
2:
612+
3:
606613
__init_el2_nvhe_prepare_eret
607614

608615
mov w0, #BOOT_CPU_MODE_EL2

0 commit comments

Comments
 (0)