Skip to content

Commit 1408e73

Browse files
author
Marc Zyngier
committed
KVM: arm64: Restructure the point where has_run_once is advertised
Restructure kvm_vcpu_first_run_init() to set the has_run_once flag after having completed all the "run once" activities. This includes moving the flip of the userspace irqchip static key to a point where nothing can fail. Reviewed-by: Andrew Jones <[email protected]> Signed-off-by: Marc Zyngier <[email protected]>
1 parent 052f064 commit 1408e73

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

arch/arm64/kvm/arm.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -600,8 +600,6 @@ static int kvm_vcpu_first_run_init(struct kvm_vcpu *vcpu)
600600
if (!kvm_arm_vcpu_is_finalized(vcpu))
601601
return -EPERM;
602602

603-
vcpu->arch.has_run_once = true;
604-
605603
kvm_arm_vcpu_init_debug(vcpu);
606604

607605
if (likely(irqchip_in_kernel(kvm))) {
@@ -612,19 +610,25 @@ static int kvm_vcpu_first_run_init(struct kvm_vcpu *vcpu)
612610
ret = kvm_vgic_map_resources(kvm);
613611
if (ret)
614612
return ret;
615-
} else {
616-
/*
617-
* Tell the rest of the code that there are userspace irqchip
618-
* VMs in the wild.
619-
*/
620-
static_branch_inc(&userspace_irqchip_in_use);
621613
}
622614

623615
ret = kvm_timer_enable(vcpu);
624616
if (ret)
625617
return ret;
626618

627619
ret = kvm_arm_pmu_v3_enable(vcpu);
620+
if (ret)
621+
return ret;
622+
623+
if (!irqchip_in_kernel(kvm)) {
624+
/*
625+
* Tell the rest of the code that there are userspace irqchip
626+
* VMs in the wild.
627+
*/
628+
static_branch_inc(&userspace_irqchip_in_use);
629+
}
630+
631+
vcpu->arch.has_run_once = true;
628632

629633
/*
630634
* Initialize traps for protected VMs.

0 commit comments

Comments
 (0)