aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm
diff options
context:
space:
mode:
authorYang Zhang <yang.z.zhang@Intel.com>2013-04-11 07:25:16 -0400
committerMarcelo Tosatti <mtosatti@redhat.com>2013-04-16 15:32:41 -0400
commit5a71785dde307f6ac80e83c0ad3fd694912010a1 (patch)
treecb765262ff74e583d314ef3f14b4f41a506b2cb2 /arch/x86/kvm
parenta20ed54d6e470bf0d28921b7aadb6ca0da0ff0c3 (diff)
KVM: VMX: Use posted interrupt to deliver virtual interrupt
If posted interrupt is avaliable, then uses it to inject virtual interrupt to guest. Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com> Reviewed-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r--arch/x86/kvm/lapic.c30
-rw-r--r--arch/x86/kvm/vmx.c2
-rw-r--r--arch/x86/kvm/x86.c1
3 files changed, 21 insertions, 12 deletions
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index dbf74c922aa1..e29883c604ff 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -353,6 +353,7 @@ static inline int apic_find_highest_irr(struct kvm_lapic *apic)
353 if (!apic->irr_pending) 353 if (!apic->irr_pending)
354 return -1; 354 return -1;
355 355
356 kvm_x86_ops->sync_pir_to_irr(apic->vcpu);
356 result = apic_search_irr(apic); 357 result = apic_search_irr(apic);
357 ASSERT(result == -1 || result >= 16); 358 ASSERT(result == -1 || result >= 16);
358 359
@@ -683,18 +684,25 @@ static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode,
683 if (dest_map) 684 if (dest_map)
684 __set_bit(vcpu->vcpu_id, dest_map); 685 __set_bit(vcpu->vcpu_id, dest_map);
685 686
686 result = !apic_test_and_set_irr(vector, apic); 687 if (kvm_x86_ops->deliver_posted_interrupt) {
687 trace_kvm_apic_accept_irq(vcpu->vcpu_id, delivery_mode, 688 result = 1;
688 trig_mode, vector, !result); 689 kvm_x86_ops->deliver_posted_interrupt(vcpu, vector);
689 if (!result) { 690 } else {
690 if (trig_mode) 691 result = !apic_test_and_set_irr(vector, apic);
691 apic_debug("level trig mode repeatedly for "
692 "vector %d", vector);
693 break;
694 }
695 692
696 kvm_make_request(KVM_REQ_EVENT, vcpu); 693 if (!result) {
697 kvm_vcpu_kick(vcpu); 694 if (trig_mode)
695 apic_debug("level trig mode repeatedly "
696 "for vector %d", vector);
697 goto out;
698 }
699
700 kvm_make_request(KVM_REQ_EVENT, vcpu);
701 kvm_vcpu_kick(vcpu);
702 }
703out:
704 trace_kvm_apic_accept_irq(vcpu->vcpu_id, delivery_mode,
705 trig_mode, vector, !result);
698 break; 706 break;
699 707
700 case APIC_DM_REMRD: 708 case APIC_DM_REMRD:
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 3a14d8a0ee46..5a87a58af49d 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -84,7 +84,7 @@ module_param(vmm_exclusive, bool, S_IRUGO);
84static bool __read_mostly fasteoi = 1; 84static bool __read_mostly fasteoi = 1;
85module_param(fasteoi, bool, S_IRUGO); 85module_param(fasteoi, bool, S_IRUGO);
86 86
87static bool __read_mostly enable_apicv; 87static bool __read_mostly enable_apicv = 1;
88module_param(enable_apicv, bool, S_IRUGO); 88module_param(enable_apicv, bool, S_IRUGO);
89 89
90/* 90/*
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 276b4a9a5605..50e2e10b8041 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2692,6 +2692,7 @@ void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
2692static int kvm_vcpu_ioctl_get_lapic(struct kvm_vcpu *vcpu, 2692static int kvm_vcpu_ioctl_get_lapic(struct kvm_vcpu *vcpu,
2693 struct kvm_lapic_state *s) 2693 struct kvm_lapic_state *s)
2694{ 2694{
2695 kvm_x86_ops->sync_pir_to_irr(vcpu);
2695 memcpy(s->regs, vcpu->arch.apic->regs, sizeof *s); 2696 memcpy(s->regs, vcpu->arch.apic->regs, sizeof *s);
2696 2697
2697 return 0; 2698 return 0;