[PATCH v2 06/16] Use EVENTINJ to inject interrupts.

Gleb Natapov
2009-04-21T14:45:16Z

Use VINT only for detecting when IRQ windows is open again.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
arch/x86/kvm/svm.c | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 053370d..3b4c00f 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -2236,13 +2236,19 @@ static inline void svm_inject_irq(struct vcpu_svm *svm, int irq)
((/*control->int_vector >> 4*/ 0xf) << V_INTR_PRIO_SHIFT);
}

+static void svm_queue_irq(struct vcpu_svm *svm, unsigned nr)
+{
+ svm->vmcb->control.event_inj = nr |
+ SVM_EVTINJ_VALID | SVM_EVTINJ_TYPE_INTR;
+}
+
static void svm_set_irq(struct kvm_vcpu *vcpu, int irq)
{
struct vcpu_svm *svm = to_svm(vcpu);

nested_svm_intr(svm);

- svm_inject_irq(svm, irq);
+ svm_queue_irq(svm, irq);
}

static void update_cr8_intercept(struct kvm_vcpu *vcpu)
@@ -2285,7 +2291,7 @@ static void svm_intr_inject(struct kvm_vcpu *vcpu)
{
/* try to reinject previous events if any */
if (vcpu->arch.interrupt.pending) {
- svm_inject_irq(to_svm(vcpu), vcpu->arch.interrupt.nr);
+ svm_queue_irq(to_svm(vcpu), vcpu->arch.interrupt.nr);
return;
}

@@ -2293,7 +2299,7 @@ static void svm_intr_inject(struct kvm_vcpu *vcpu)
if (kvm_cpu_has_interrupt(vcpu)) {
if (vcpu->arch.interrupt_window_open) {
kvm_queue_interrupt(vcpu, kvm_cpu_get_interrupt(vcpu));
- svm_inject_irq(to_svm(vcpu), vcpu->arch.interrupt.nr);
+ svm_queue_irq(to_svm(vcpu), vcpu->arch.interrupt.nr);
}
}
}
--
1.5.6.5