diff options
author | Yang Zhang <yang.z.zhang@Intel.com> | 2013-04-11 07:25:14 -0400 |
---|---|---|
committer | Marcelo Tosatti <mtosatti@redhat.com> | 2013-04-16 15:32:40 -0400 |
commit | cf9e65b773394c5ad8fa7455c43268bc8ec2109f (patch) | |
tree | dea4e116da3ecc13c8b6383ec2145a73480d66f0 | |
parent | 3d81bc7e96d6bca0b8f8b7d1bf6ea72caa3aac57 (diff) |
KVM: Set TMR when programming ioapic entry
We already know the trigger mode of a given interrupt when programming
the ioapice entry. So it's not necessary to set it in each interrupt
delivery.
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>
-rw-r--r-- | arch/x86/kvm/lapic.c | 15 | ||||
-rw-r--r-- | arch/x86/kvm/lapic.h | 1 | ||||
-rw-r--r-- | arch/x86/kvm/x86.c | 5 | ||||
-rw-r--r-- | virt/kvm/ioapic.c | 12 | ||||
-rw-r--r-- | virt/kvm/ioapic.h | 3 |
5 files changed, 25 insertions, 11 deletions
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index 34a8ca845280..d197579435d0 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c | |||
@@ -468,6 +468,15 @@ static inline int apic_find_highest_isr(struct kvm_lapic *apic) | |||
468 | return result; | 468 | return result; |
469 | } | 469 | } |
470 | 470 | ||
471 | void kvm_apic_update_tmr(struct kvm_vcpu *vcpu, u32 *tmr) | ||
472 | { | ||
473 | struct kvm_lapic *apic = vcpu->arch.apic; | ||
474 | int i; | ||
475 | |||
476 | for (i = 0; i < 8; i++) | ||
477 | apic_set_reg(apic, APIC_TMR + 0x10 * i, tmr[i]); | ||
478 | } | ||
479 | |||
471 | static void apic_update_ppr(struct kvm_lapic *apic) | 480 | static void apic_update_ppr(struct kvm_lapic *apic) |
472 | { | 481 | { |
473 | u32 tpr, isrv, ppr, old_ppr; | 482 | u32 tpr, isrv, ppr, old_ppr; |
@@ -661,12 +670,6 @@ static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode, | |||
661 | if (dest_map) | 670 | if (dest_map) |
662 | __set_bit(vcpu->vcpu_id, dest_map); | 671 | __set_bit(vcpu->vcpu_id, dest_map); |
663 | 672 | ||
664 | if (trig_mode) { | ||
665 | apic_debug("level trig mode for vector %d", vector); | ||
666 | apic_set_vector(vector, apic->regs + APIC_TMR); | ||
667 | } else | ||
668 | apic_clear_vector(vector, apic->regs + APIC_TMR); | ||
669 | |||
670 | result = !apic_test_and_set_irr(vector, apic); | 673 | result = !apic_test_and_set_irr(vector, apic); |
671 | trace_kvm_apic_accept_irq(vcpu->vcpu_id, delivery_mode, | 674 | trace_kvm_apic_accept_irq(vcpu->vcpu_id, delivery_mode, |
672 | trig_mode, vector, !result); | 675 | trig_mode, vector, !result); |
diff --git a/arch/x86/kvm/lapic.h b/arch/x86/kvm/lapic.h index 16304b1a8cba..7fe0c9180ea1 100644 --- a/arch/x86/kvm/lapic.h +++ b/arch/x86/kvm/lapic.h | |||
@@ -53,6 +53,7 @@ void kvm_lapic_set_base(struct kvm_vcpu *vcpu, u64 value); | |||
53 | u64 kvm_lapic_get_base(struct kvm_vcpu *vcpu); | 53 | u64 kvm_lapic_get_base(struct kvm_vcpu *vcpu); |
54 | void kvm_apic_set_version(struct kvm_vcpu *vcpu); | 54 | void kvm_apic_set_version(struct kvm_vcpu *vcpu); |
55 | 55 | ||
56 | void kvm_apic_update_tmr(struct kvm_vcpu *vcpu, u32 *tmr); | ||
56 | int kvm_apic_match_physical_addr(struct kvm_lapic *apic, u16 dest); | 57 | int kvm_apic_match_physical_addr(struct kvm_lapic *apic, u16 dest); |
57 | int kvm_apic_match_logical_addr(struct kvm_lapic *apic, u8 mda); | 58 | int kvm_apic_match_logical_addr(struct kvm_lapic *apic, u8 mda); |
58 | int kvm_apic_set_irq(struct kvm_vcpu *vcpu, struct kvm_lapic_irq *irq, | 59 | int kvm_apic_set_irq(struct kvm_vcpu *vcpu, struct kvm_lapic_irq *irq, |
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 87a05df3eae4..276b4a9a5605 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -5664,14 +5664,17 @@ static void kvm_gen_update_masterclock(struct kvm *kvm) | |||
5664 | static void vcpu_scan_ioapic(struct kvm_vcpu *vcpu) | 5664 | static void vcpu_scan_ioapic(struct kvm_vcpu *vcpu) |
5665 | { | 5665 | { |
5666 | u64 eoi_exit_bitmap[4]; | 5666 | u64 eoi_exit_bitmap[4]; |
5667 | u32 tmr[8]; | ||
5667 | 5668 | ||
5668 | if (!kvm_apic_hw_enabled(vcpu->arch.apic)) | 5669 | if (!kvm_apic_hw_enabled(vcpu->arch.apic)) |
5669 | return; | 5670 | return; |
5670 | 5671 | ||
5671 | memset(eoi_exit_bitmap, 0, 32); | 5672 | memset(eoi_exit_bitmap, 0, 32); |
5673 | memset(tmr, 0, 32); | ||
5672 | 5674 | ||
5673 | kvm_ioapic_scan_entry(vcpu, eoi_exit_bitmap); | 5675 | kvm_ioapic_scan_entry(vcpu, eoi_exit_bitmap, tmr); |
5674 | kvm_x86_ops->load_eoi_exitmap(vcpu, eoi_exit_bitmap); | 5676 | kvm_x86_ops->load_eoi_exitmap(vcpu, eoi_exit_bitmap); |
5677 | kvm_apic_update_tmr(vcpu, tmr); | ||
5675 | } | 5678 | } |
5676 | 5679 | ||
5677 | static int vcpu_enter_guest(struct kvm_vcpu *vcpu) | 5680 | static int vcpu_enter_guest(struct kvm_vcpu *vcpu) |
diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c index f2157a985a1f..2d682977ce82 100644 --- a/virt/kvm/ioapic.c +++ b/virt/kvm/ioapic.c | |||
@@ -193,7 +193,8 @@ static void update_handled_vectors(struct kvm_ioapic *ioapic) | |||
193 | smp_wmb(); | 193 | smp_wmb(); |
194 | } | 194 | } |
195 | 195 | ||
196 | void kvm_ioapic_scan_entry(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap) | 196 | void kvm_ioapic_scan_entry(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap, |
197 | u32 *tmr) | ||
197 | { | 198 | { |
198 | struct kvm_ioapic *ioapic = vcpu->kvm->arch.vioapic; | 199 | struct kvm_ioapic *ioapic = vcpu->kvm->arch.vioapic; |
199 | union kvm_ioapic_redirect_entry *e; | 200 | union kvm_ioapic_redirect_entry *e; |
@@ -207,8 +208,13 @@ void kvm_ioapic_scan_entry(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap) | |||
207 | kvm_irq_has_notifier(ioapic->kvm, KVM_IRQCHIP_IOAPIC, | 208 | kvm_irq_has_notifier(ioapic->kvm, KVM_IRQCHIP_IOAPIC, |
208 | index) || index == RTC_GSI)) { | 209 | index) || index == RTC_GSI)) { |
209 | if (kvm_apic_match_dest(vcpu, NULL, 0, | 210 | if (kvm_apic_match_dest(vcpu, NULL, 0, |
210 | e->fields.dest_id, e->fields.dest_mode)) | 211 | e->fields.dest_id, e->fields.dest_mode)) { |
211 | __set_bit(e->fields.vector, (unsigned long *)eoi_exit_bitmap); | 212 | __set_bit(e->fields.vector, |
213 | (unsigned long *)eoi_exit_bitmap); | ||
214 | if (e->fields.trig_mode == IOAPIC_LEVEL_TRIG) | ||
215 | __set_bit(e->fields.vector, | ||
216 | (unsigned long *)tmr); | ||
217 | } | ||
212 | } | 218 | } |
213 | } | 219 | } |
214 | spin_unlock(&ioapic->lock); | 220 | spin_unlock(&ioapic->lock); |
diff --git a/virt/kvm/ioapic.h b/virt/kvm/ioapic.h index 674a388612b4..615d8c995c3c 100644 --- a/virt/kvm/ioapic.h +++ b/virt/kvm/ioapic.h | |||
@@ -97,6 +97,7 @@ int kvm_irq_delivery_to_apic(struct kvm *kvm, struct kvm_lapic *src, | |||
97 | int kvm_get_ioapic(struct kvm *kvm, struct kvm_ioapic_state *state); | 97 | int kvm_get_ioapic(struct kvm *kvm, struct kvm_ioapic_state *state); |
98 | int kvm_set_ioapic(struct kvm *kvm, struct kvm_ioapic_state *state); | 98 | int kvm_set_ioapic(struct kvm *kvm, struct kvm_ioapic_state *state); |
99 | void kvm_vcpu_request_scan_ioapic(struct kvm *kvm); | 99 | void kvm_vcpu_request_scan_ioapic(struct kvm *kvm); |
100 | void kvm_ioapic_scan_entry(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap); | 100 | void kvm_ioapic_scan_entry(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap, |
101 | u32 *tmr); | ||
101 | 102 | ||
102 | #endif | 103 | #endif |