diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 4749b0e0e48f..0efb87949ef1 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -608,6 +608,8 @@ static int kvm_vcpu_first_run_init(struct kvm_vcpu *vcpu) if (!kvm_arm_vcpu_is_finalized(vcpu)) return -EPERM; + vcpu->arch.has_run_once = true; + kvm_arm_vcpu_init_debug(vcpu); if (likely(irqchip_in_kernel(kvm))) { @@ -618,17 +620,7 @@ static int kvm_vcpu_first_run_init(struct kvm_vcpu *vcpu) ret = kvm_vgic_map_resources(kvm); if (ret) return ret; - } - - ret = kvm_timer_enable(vcpu); - if (ret) - return ret; - - ret = kvm_arm_pmu_v3_enable(vcpu); - if (ret) - return ret; - - if (!irqchip_in_kernel(kvm)) { + } else { /* * Tell the rest of the code that there are userspace irqchip * VMs in the wild. @@ -636,7 +628,11 @@ static int kvm_vcpu_first_run_init(struct kvm_vcpu *vcpu) static_branch_inc(&userspace_irqchip_in_use); } - vcpu->arch.has_run_once = true; + ret = kvm_timer_enable(vcpu); + if (ret) + return ret; + + ret = kvm_arm_pmu_v3_enable(vcpu); /* * Initialize traps for protected VMs.