KVM: arm64: Don't populate TPIDR_EL2 in finalise_el2()
Will Deacon
maintainerPATCH 1/1 KVM: arm64: Don't populate TPIDR_EL2 in finalise_el2()
When running with VHE, TPIDR_EL2 is only used for the percpu offset once the ARM64_HAS_VIRT_HOST_EXTN capability has been detected, at which point cpu_copy_el2regs() will populate its contents from TPIDR_EL1.
Remove the redundant initialisation of TPIDR_EL2 from finalise_el2().
---
I spotted this by inspection as part of an ill-fated (abandoned) attempt at repurposing tpidr_elx for something else.
arch/arm64/kernel/hyp-stub.S | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
arch/arm64/kernel/hyp-stub.S +1 -3
@@ -105,11 +105,9 @@ SYM_CODE_START_LOCAL(__finalise_el2) msr_hcr_el2 x0 isb - // Use the EL1 allocated stack, per-cpu offset + // Use the EL1 allocated stack mrs x0, sp_el1 mov sp, x0 - mrs x0, tpidr_el1 - msr tpidr_el2, x0 // FP configuration, vectors mrs_s x0, SYS_CPACR_EL12
Signature · 1 line
2.53.0.1018.g2bb0e51243-goog
Quoted 5 lines · Will Deacon
When running with VHE,
TPIDR_EL2is only used for the percpu offset once theARM64_HAS_VIRT_HOST_EXTNcapability has been detected, at which pointcpu_copy_el2regs()will populate its contents fromTPIDR_EL1.Remove the redundant initialisation of
TPIDR_EL2fromfinalise_el2().
It wasn't clear to me how this worked for both the boot CPU and secondaries, since they both call finalise_el2(). How about a slightly more elaborate commit message, e.g.
| Currently, it is not necessary for __finalise_el2() to configure | TPIDR_EL2: | | * The hyp stub code does not consume the value of TPIDR_EL2. | | * On the boot cpu, TPIDR_EL1 is used for the percpu offset until the | ARM64_HAS_VIRT_HOST_EXTN cpucap is detected and boot alternatives | are patched. Before boot alternatives are patched, | cpu_copy_el2regs() will copy TPIDR_EL1 into TPIDR_EL2. It is not | necessary for __finalise_el2() to initialise TPIDR_EL2 before this. | | * Secondary CPUs are brought up after boot alternatives have been | patched, and __secondary_switched() will initialize TPIDR_EL2 in | 'init_cpu_task', after finalise_el2() calls __finalise_el2() | | * KVM hyp code which may consume TPIDR_EL2 is brought up after all | secondaries have been booted, once TPIDR_El2 has been configured on | all CPUs. | | Remove the redundant initialisation from __finalise_el2().
Quoted 5 lines
Cc Oliver Upton <[email protected]>Cc Marc Zyngier <[email protected]>Cc Catalin Marinas <[email protected]>Cc Mark Rutland <[email protected]>Signed-off-by Will Deacon <[email protected]>
Mark.
Quoted 28 lines
---
I spotted this by inspection as part of an ill-fated (abandoned) attempt at repurposing
tpidr_elxfor something else.arch/arm64/kernel/hyp-stub.S | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)arch/arm64/kernel/hyp-stub.S +1
-3@@ -105,11 +105,9 @@ SYM_CODE_START_LOCAL(__finalise_el2) msr_hcr_el2 x0 isb - // Use the EL1 allocated stack, per-cpu offset + // Use the EL1 allocated stack mrs x0, sp_el1 mov sp, x0 - mrs x0, tpidr_el1 - msr tpidr_el2, x0 // FP configuration, vectors mrs_s x0, SYS_CPACR_EL12Signature · 1 line
2.53.0.1018.g2bb0e51243-goog