KVM: x86: properly update ready_for_interrupt_injection
authorMarcelo Tosatti <mtosatti@redhat.com>
Tue, 4 May 2010 02:04:27 +0000 (23:04 -0300)
committerAvi Kivity <avi@redhat.com>
Wed, 19 May 2010 08:36:33 +0000 (11:36 +0300)
The recent changes to emulate string instructions without entering guest
mode exposed a bug where pending interrupts are not properly reflected
in ready_for_interrupt_injection.

The result is that userspace overwrites a previously queued interrupt,
when irqchip's are emulated in userspace.

Fix by always updating state before returning to userspace.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
arch/x86/kvm/x86.c

index 6b2ce1d2d7489eb58f690ba4f03e835dffd1c5e5..dff08e527ec734056e28d49f3b4b4adbe305ff64 100644 (file)
@@ -4653,7 +4653,6 @@ static int __vcpu_run(struct kvm_vcpu *vcpu)
        }
 
        srcu_read_unlock(&kvm->srcu, vcpu->srcu_idx);
-       post_kvm_run_save(vcpu);
 
        vapic_exit(vcpu);
 
@@ -4703,6 +4702,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
        r = __vcpu_run(vcpu);
 
 out:
+       post_kvm_run_save(vcpu);
        if (vcpu->sigset_active)
                sigprocmask(SIG_SETMASK, &sigsaved, NULL);