[PATCH v7 04/41] KVM: arm64: Init vcpu prior to the timers and PMU

Sascha Bischoff Sascha.Bischoff at arm.com
Thu Mar 19 08:50:45 PDT 2026


In kvm_arch_vcpu_create() the vcpus, timers, pmu are
initialised. Prior to this change, the timer and PMU initialisation
was happening before the vcpu initialisation. This causes a bit of an
issue as it means that private irqs are yet to be initialised at that
stage. This means that any operations (mapping, setting irq_ops, etc)
on private irqs are not possible in the timer and PMU init code.

In order to address this, re-order the initialisation to initialise
the vcpu prior to the timers and PMU. This ensures that the private
IRQs have been initialised at the stage where the timer and PMUs are.

Signed-off-by: Sascha Bischoff <sascha.bischoff at arm.com>
---
 arch/arm64/kvm/arm.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
index 410ffd41fd73a..4e46336798946 100644
--- a/arch/arm64/kvm/arm.c
+++ b/arch/arm64/kvm/arm.c
@@ -523,15 +523,6 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu)
 
 	vcpu->arch.mmu_page_cache.gfp_zero = __GFP_ZERO;
 
-	/* Set up the timer */
-	kvm_timer_vcpu_init(vcpu);
-
-	kvm_pmu_vcpu_init(vcpu);
-
-	kvm_arm_pvtime_vcpu_init(&vcpu->arch);
-
-	vcpu->arch.hw_mmu = &vcpu->kvm->arch.mmu;
-
 	/*
 	 * This vCPU may have been created after mpidr_data was initialized.
 	 * Throw out the pre-computed mappings if that is the case which forces
@@ -543,6 +534,15 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu)
 	if (err)
 		return err;
 
+	/* Set up the timer */
+	kvm_timer_vcpu_init(vcpu);
+
+	kvm_pmu_vcpu_init(vcpu);
+
+	kvm_arm_pvtime_vcpu_init(&vcpu->arch);
+
+	vcpu->arch.hw_mmu = &vcpu->kvm->arch.mmu;
+
 	err = kvm_share_hyp(vcpu, vcpu + 1);
 	if (err)
 		kvm_vgic_vcpu_destroy(vcpu);
-- 
2.34.1



More information about the linux-arm-kernel mailing list