aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGleb Natapov <gleb@redhat.com>2009-04-21 10:44:58 -0400
committerAvi Kivity <avi@redhat.com>2009-06-10 04:48:45 -0400
commit1f21e79aaced0a041e9399346960ce26ae0f5a4e (patch)
tree4e6121d90c5a01f701ac2ddeaa4b9688b374013c
parent863e8e658ee9ac6e5931b295eb7428456e450a0f (diff)
KVM: VMX: Cleanup vmx_intr_assist()
Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
-rw-r--r--arch/x86/kvm/vmx.c55
1 files changed, 30 insertions, 25 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 06252f7465d6..9eb518fb907b 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -3309,6 +3309,34 @@ static void vmx_complete_interrupts(struct vcpu_vmx *vmx)
3309 } 3309 }
3310} 3310}
3311 3311
3312static void vmx_intr_inject(struct kvm_vcpu *vcpu)
3313{
3314 /* try to reinject previous events if any */
3315 if (vcpu->arch.nmi_injected) {
3316 vmx_inject_nmi(vcpu);
3317 return;
3318 }
3319
3320 if (vcpu->arch.interrupt.pending) {
3321 vmx_inject_irq(vcpu, vcpu->arch.interrupt.nr);
3322 return;
3323 }
3324
3325 /* try to inject new event if pending */
3326 if (vcpu->arch.nmi_pending) {
3327 if (vcpu->arch.nmi_window_open) {
3328 vcpu->arch.nmi_pending = false;
3329 vcpu->arch.nmi_injected = true;
3330 vmx_inject_nmi(vcpu);
3331 }
3332 } else if (kvm_cpu_has_interrupt(vcpu)) {
3333 if (vcpu->arch.interrupt_window_open) {
3334 kvm_queue_interrupt(vcpu, kvm_cpu_get_interrupt(vcpu));
3335 vmx_inject_irq(vcpu, vcpu->arch.interrupt.nr);
3336 }
3337 }
3338}
3339
3312static void vmx_intr_assist(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) 3340static void vmx_intr_assist(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
3313{ 3341{
3314 bool req_int_win = !irqchip_in_kernel(vcpu->kvm) && 3342 bool req_int_win = !irqchip_in_kernel(vcpu->kvm) &&
@@ -3323,32 +3351,9 @@ static void vmx_intr_assist(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
3323 GUEST_INTR_STATE_STI | 3351 GUEST_INTR_STATE_STI |
3324 GUEST_INTR_STATE_MOV_SS); 3352 GUEST_INTR_STATE_MOV_SS);
3325 3353
3326 if (vcpu->arch.nmi_pending && !vcpu->arch.nmi_injected) { 3354 vmx_intr_inject(vcpu);
3327 if (vcpu->arch.interrupt.pending) {
3328 enable_nmi_window(vcpu);
3329 } else if (vcpu->arch.nmi_window_open) {
3330 vcpu->arch.nmi_pending = false;
3331 vcpu->arch.nmi_injected = true;
3332 } else {
3333 enable_nmi_window(vcpu);
3334 return;
3335 }
3336 }
3337
3338 if (vcpu->arch.nmi_injected) {
3339 vmx_inject_nmi(vcpu);
3340 goto out;
3341 }
3342
3343 if (!vcpu->arch.interrupt.pending && kvm_cpu_has_interrupt(vcpu)) {
3344 if (vcpu->arch.interrupt_window_open)
3345 kvm_queue_interrupt(vcpu, kvm_cpu_get_interrupt(vcpu));
3346 }
3347
3348 if (vcpu->arch.interrupt.pending)
3349 vmx_inject_irq(vcpu, vcpu->arch.interrupt.nr);
3350 3355
3351out: 3356 /* enable NMI/IRQ window open exits if needed */
3352 if (vcpu->arch.nmi_pending) 3357 if (vcpu->arch.nmi_pending)
3353 enable_nmi_window(vcpu); 3358 enable_nmi_window(vcpu);
3354 else if (kvm_cpu_has_interrupt(vcpu) || req_int_win) 3359 else if (kvm_cpu_has_interrupt(vcpu) || req_int_win)