* [PATCH v2] KVM: arm64: Don't populate TPIDR_EL2 in finalise_el2()
@ 2026-05-18 15:31 Will Deacon
2026-05-18 15:39 ` Marc Zyngier
0 siblings, 1 reply; 4+ messages in thread
From: Will Deacon @ 2026-05-18 15:31 UTC (permalink / raw)
To: kvmarm
Cc: linux-arm-kernel, Will Deacon, Oliver Upton, Marc Zyngier,
Catalin Marinas, Mark Rutland
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().
Cc: Oliver Upton <oupton@kernel.org>
Cc: Marc Zyngier <maz@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Will Deacon <will@kernel.org>
---
v2: Use Mark's commit message, add his R-b tag, rebase onto -rc4.
Link to v1: https://lore.kernel.org/r/20260330152927.26300-1-will@kernel.org
arch/arm64/kernel/hyp-stub.S | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/arch/arm64/kernel/hyp-stub.S b/arch/arm64/kernel/hyp-stub.S
index 634ddc904244..37c6976e44a4 100644
--- a/arch/arm64/kernel/hyp-stub.S
+++ b/arch/arm64/kernel/hyp-stub.S
@@ -104,11 +104,9 @@ SYM_CODE_START_LOCAL(__finalise_el2)
mov_q x0, HCR_HOST_VHE_FLAGS
msr_hcr_el2 x0
- // 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
--
2.54.0.563.g4f69b47b94-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] KVM: arm64: Don't populate TPIDR_EL2 in finalise_el2()
2026-05-18 15:31 [PATCH v2] KVM: arm64: Don't populate TPIDR_EL2 in finalise_el2() Will Deacon
@ 2026-05-18 15:39 ` Marc Zyngier
2026-05-18 15:41 ` Marc Zyngier
0 siblings, 1 reply; 4+ messages in thread
From: Marc Zyngier @ 2026-05-18 15:39 UTC (permalink / raw)
To: Will Deacon
Cc: kvmarm, linux-arm-kernel, Oliver Upton, Catalin Marinas,
Mark Rutland
On Mon, 18 May 2026 16:31:26 +0100,
Will Deacon <will@kernel.org> wrote:
>
> 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().
>
> Cc: Oliver Upton <oupton@kernel.org>
> Cc: Marc Zyngier <maz@kernel.org>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Reviewed-by: Mark Rutland <mark.rutland@arm.com>
> Signed-off-by: Will Deacon <will@kernel.org>
Reviewed-by: Marc Zyngier <maz@kernel.org>
M.
--
Without deviation from the norm, progress is not possible.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] KVM: arm64: Don't populate TPIDR_EL2 in finalise_el2()
2026-05-18 15:39 ` Marc Zyngier
@ 2026-05-18 15:41 ` Marc Zyngier
2026-05-18 15:55 ` Will Deacon
0 siblings, 1 reply; 4+ messages in thread
From: Marc Zyngier @ 2026-05-18 15:41 UTC (permalink / raw)
To: Will Deacon
Cc: kvmarm, linux-arm-kernel, Oliver Upton, Catalin Marinas,
Mark Rutland
On Mon, 18 May 2026 16:39:30 +0100,
Marc Zyngier <maz@kernel.org> wrote:
>
> On Mon, 18 May 2026 16:31:26 +0100,
> Will Deacon <will@kernel.org> wrote:
> >
> > 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().
> >
> > Cc: Oliver Upton <oupton@kernel.org>
> > Cc: Marc Zyngier <maz@kernel.org>
> > Cc: Catalin Marinas <catalin.marinas@arm.com>
> > Reviewed-by: Mark Rutland <mark.rutland@arm.com>
> > Signed-off-by: Will Deacon <will@kernel.org>
>
> Reviewed-by: Marc Zyngier <maz@kernel.org>
Ah, realised too late you intended for this to go via the KVM tree.
I'll queue that for 7.2.
Thanks,
M.
--
Without deviation from the norm, progress is not possible.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] KVM: arm64: Don't populate TPIDR_EL2 in finalise_el2()
2026-05-18 15:41 ` Marc Zyngier
@ 2026-05-18 15:55 ` Will Deacon
0 siblings, 0 replies; 4+ messages in thread
From: Will Deacon @ 2026-05-18 15:55 UTC (permalink / raw)
To: Marc Zyngier
Cc: kvmarm, linux-arm-kernel, Oliver Upton, Catalin Marinas,
Mark Rutland
On Mon, May 18, 2026 at 04:41:15PM +0100, Marc Zyngier wrote:
> On Mon, 18 May 2026 16:39:30 +0100,
> Marc Zyngier <maz@kernel.org> wrote:
> >
> > On Mon, 18 May 2026 16:31:26 +0100,
> > Will Deacon <will@kernel.org> wrote:
> > >
> > > 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().
> > >
> > > Cc: Oliver Upton <oupton@kernel.org>
> > > Cc: Marc Zyngier <maz@kernel.org>
> > > Cc: Catalin Marinas <catalin.marinas@arm.com>
> > > Reviewed-by: Mark Rutland <mark.rutland@arm.com>
> > > Signed-off-by: Will Deacon <will@kernel.org>
> >
> > Reviewed-by: Marc Zyngier <maz@kernel.org>
>
> Ah, realised too late you intended for this to go via the KVM tree.
>
> I'll queue that for 7.2.
Thanks, Marc!
Will
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-05-18 15:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-18 15:31 [PATCH v2] KVM: arm64: Don't populate TPIDR_EL2 in finalise_el2() Will Deacon
2026-05-18 15:39 ` Marc Zyngier
2026-05-18 15:41 ` Marc Zyngier
2026-05-18 15:55 ` Will Deacon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox