diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2012-04-11 11:49:55 -0400 |
---|---|---|
committer | Marcelo Tosatti <mtosatti@redhat.com> | 2012-04-16 19:36:38 -0400 |
commit | a0c9a822bf37e6282eb6006b407ec5aec22e08fb (patch) | |
tree | 62e0ba3e3b031ded8187b1c37681015ec920ebe2 /virt | |
parent | e59717550e5cf0e7159c5b7af1d1ead35fef49dd (diff) |
KVM: dont clear TMR on EOI
Intel spec says that TMR needs to be set/cleared
when IRR is set, but kvm also clears it on EOI.
I did some tests on a real (AMD based) system,
and I see same TMR values both before
and after EOI, so I think it's a minor bug in kvm.
This patch fixes TMR to be set/cleared on IRR set
only as per spec.
And now that we don't clear TMR, we can save
an atomic read of TMR on EOI that's not propagated
to ioapic, by checking whether ioapic needs
a specific vector first and calculating
the mode afterwards.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'virt')
-rw-r--r-- | virt/kvm/ioapic.c | 10 | ||||
-rw-r--r-- | virt/kvm/ioapic.h | 1 |
2 files changed, 8 insertions, 3 deletions
diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c index dcaf272c26c0..26fd54dc459e 100644 --- a/virt/kvm/ioapic.c +++ b/virt/kvm/ioapic.c | |||
@@ -254,13 +254,17 @@ static void __kvm_ioapic_update_eoi(struct kvm_ioapic *ioapic, int vector, | |||
254 | } | 254 | } |
255 | } | 255 | } |
256 | 256 | ||
257 | bool kvm_ioapic_handles_vector(struct kvm *kvm, int vector) | ||
258 | { | ||
259 | struct kvm_ioapic *ioapic = kvm->arch.vioapic; | ||
260 | smp_rmb(); | ||
261 | return test_bit(vector, ioapic->handled_vectors); | ||
262 | } | ||
263 | |||
257 | void kvm_ioapic_update_eoi(struct kvm *kvm, int vector, int trigger_mode) | 264 | void kvm_ioapic_update_eoi(struct kvm *kvm, int vector, int trigger_mode) |
258 | { | 265 | { |
259 | struct kvm_ioapic *ioapic = kvm->arch.vioapic; | 266 | struct kvm_ioapic *ioapic = kvm->arch.vioapic; |
260 | 267 | ||
261 | smp_rmb(); | ||
262 | if (!test_bit(vector, ioapic->handled_vectors)) | ||
263 | return; | ||
264 | spin_lock(&ioapic->lock); | 268 | spin_lock(&ioapic->lock); |
265 | __kvm_ioapic_update_eoi(ioapic, vector, trigger_mode); | 269 | __kvm_ioapic_update_eoi(ioapic, vector, trigger_mode); |
266 | spin_unlock(&ioapic->lock); | 270 | spin_unlock(&ioapic->lock); |
diff --git a/virt/kvm/ioapic.h b/virt/kvm/ioapic.h index 0b190c34ccc3..32872a09b63f 100644 --- a/virt/kvm/ioapic.h +++ b/virt/kvm/ioapic.h | |||
@@ -71,6 +71,7 @@ int kvm_apic_match_dest(struct kvm_vcpu *vcpu, struct kvm_lapic *source, | |||
71 | int short_hand, int dest, int dest_mode); | 71 | int short_hand, int dest, int dest_mode); |
72 | int kvm_apic_compare_prio(struct kvm_vcpu *vcpu1, struct kvm_vcpu *vcpu2); | 72 | int kvm_apic_compare_prio(struct kvm_vcpu *vcpu1, struct kvm_vcpu *vcpu2); |
73 | void kvm_ioapic_update_eoi(struct kvm *kvm, int vector, int trigger_mode); | 73 | void kvm_ioapic_update_eoi(struct kvm *kvm, int vector, int trigger_mode); |
74 | bool kvm_ioapic_handles_vector(struct kvm *kvm, int vector); | ||
74 | int kvm_ioapic_init(struct kvm *kvm); | 75 | int kvm_ioapic_init(struct kvm *kvm); |
75 | void kvm_ioapic_destroy(struct kvm *kvm); | 76 | void kvm_ioapic_destroy(struct kvm *kvm); |
76 | int kvm_ioapic_set_irq(struct kvm_ioapic *ioapic, int irq, int level); | 77 | int kvm_ioapic_set_irq(struct kvm_ioapic *ioapic, int irq, int level); |