Skip to content

Commit

Permalink
KVM: rearrange injection cancelling code
Browse files Browse the repository at this point in the history
Each time we need to cancel injection we invoke same code
(cancel_injection callback).  Move it towards the end of function using
the familiar goto on error pattern.

Will make it easier to do more cleanups for PV EOI.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
  • Loading branch information
Michael S. Tsirkin authored and Avi Kivity committed Jun 25, 2012
1 parent 5cfb1d5 commit d905c06
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions arch/x86/kvm/x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -5296,8 +5296,7 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)

r = kvm_mmu_reload(vcpu);
if (unlikely(r)) {
kvm_x86_ops->cancel_injection(vcpu);
goto out;
goto cancel_injection;
}

preempt_disable();
Expand All @@ -5322,9 +5321,8 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
smp_wmb();
local_irq_enable();
preempt_enable();
kvm_x86_ops->cancel_injection(vcpu);
r = 1;
goto out;
goto cancel_injection;
}

srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx);
Expand Down Expand Up @@ -5392,6 +5390,10 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
kvm_lapic_sync_from_vapic(vcpu);

r = kvm_x86_ops->handle_exit(vcpu);
return r;

cancel_injection:
kvm_x86_ops->cancel_injection(vcpu);
out:
return r;
}
Expand Down

0 comments on commit d905c06

Please sign in to comment.