diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2012-06-24 12:25:00 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2012-06-25 05:40:50 -0400 |
commit | d905c0693514e6f713b207377b67c9972c5d7d49 (patch) | |
tree | a5387b1ab6f44e06b2a7de5c1dca2811ce508f5e /arch/x86/kvm/x86.c | |
parent | 5cfb1d5a65dd96d2d3a0751a1e4e81dc84c1f08f (diff) |
KVM: rearrange injection cancelling code
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>
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r-- | arch/x86/kvm/x86.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index c1f870690a64..7ea0f611bc89 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -5296,8 +5296,7 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) | |||
5296 | 5296 | ||
5297 | r = kvm_mmu_reload(vcpu); | 5297 | r = kvm_mmu_reload(vcpu); |
5298 | if (unlikely(r)) { | 5298 | if (unlikely(r)) { |
5299 | kvm_x86_ops->cancel_injection(vcpu); | 5299 | goto cancel_injection; |
5300 | goto out; | ||
5301 | } | 5300 | } |
5302 | 5301 | ||
5303 | preempt_disable(); | 5302 | preempt_disable(); |
@@ -5322,9 +5321,8 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) | |||
5322 | smp_wmb(); | 5321 | smp_wmb(); |
5323 | local_irq_enable(); | 5322 | local_irq_enable(); |
5324 | preempt_enable(); | 5323 | preempt_enable(); |
5325 | kvm_x86_ops->cancel_injection(vcpu); | ||
5326 | r = 1; | 5324 | r = 1; |
5327 | goto out; | 5325 | goto cancel_injection; |
5328 | } | 5326 | } |
5329 | 5327 | ||
5330 | srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx); | 5328 | srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx); |
@@ -5392,6 +5390,10 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) | |||
5392 | kvm_lapic_sync_from_vapic(vcpu); | 5390 | kvm_lapic_sync_from_vapic(vcpu); |
5393 | 5391 | ||
5394 | r = kvm_x86_ops->handle_exit(vcpu); | 5392 | r = kvm_x86_ops->handle_exit(vcpu); |
5393 | return r; | ||
5394 | |||
5395 | cancel_injection: | ||
5396 | kvm_x86_ops->cancel_injection(vcpu); | ||
5395 | out: | 5397 | out: |
5396 | return r; | 5398 | return r; |
5397 | } | 5399 | } |