diff options
author | Yang Zhang <yang.z.zhang@Intel.com> | 2013-04-11 07:25:13 -0400 |
---|---|---|
committer | Marcelo Tosatti <mtosatti@redhat.com> | 2013-04-16 15:32:40 -0400 |
commit | 3d81bc7e96d6bca0b8f8b7d1bf6ea72caa3aac57 (patch) | |
tree | 3e8d83b8d80c87c38cc0bb1d3caef6286ad9dd48 /virt | |
parent | 01e439be7753c163932538276f04f95cb1b66697 (diff) |
KVM: Call common update function when ioapic entry changed.
Both TMR and EOI exit bitmap need to be updated when ioapic changed
or vcpu's id/ldr/dfr changed. So use common function instead eoi exit
bitmap specific function.
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 'virt')
-rw-r--r-- | virt/kvm/ioapic.c | 22 | ||||
-rw-r--r-- | virt/kvm/ioapic.h | 6 | ||||
-rw-r--r-- | virt/kvm/irq_comm.c | 4 | ||||
-rw-r--r-- | virt/kvm/kvm_main.c | 4 |
4 files changed, 19 insertions, 17 deletions
diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c index 97c67a50f904..f2157a985a1f 100644 --- a/virt/kvm/ioapic.c +++ b/virt/kvm/ioapic.c | |||
@@ -193,15 +193,13 @@ static void update_handled_vectors(struct kvm_ioapic *ioapic) | |||
193 | smp_wmb(); | 193 | smp_wmb(); |
194 | } | 194 | } |
195 | 195 | ||
196 | void kvm_ioapic_calculate_eoi_exitmap(struct kvm_vcpu *vcpu, | 196 | void kvm_ioapic_scan_entry(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap) |
197 | u64 *eoi_exit_bitmap) | ||
198 | { | 197 | { |
199 | struct kvm_ioapic *ioapic = vcpu->kvm->arch.vioapic; | 198 | struct kvm_ioapic *ioapic = vcpu->kvm->arch.vioapic; |
200 | union kvm_ioapic_redirect_entry *e; | 199 | union kvm_ioapic_redirect_entry *e; |
201 | int index; | 200 | int index; |
202 | 201 | ||
203 | spin_lock(&ioapic->lock); | 202 | spin_lock(&ioapic->lock); |
204 | /* traverse ioapic entry to set eoi exit bitmap*/ | ||
205 | for (index = 0; index < IOAPIC_NUM_PINS; index++) { | 203 | for (index = 0; index < IOAPIC_NUM_PINS; index++) { |
206 | e = &ioapic->redirtbl[index]; | 204 | e = &ioapic->redirtbl[index]; |
207 | if (!e->fields.mask && | 205 | if (!e->fields.mask && |
@@ -215,16 +213,22 @@ void kvm_ioapic_calculate_eoi_exitmap(struct kvm_vcpu *vcpu, | |||
215 | } | 213 | } |
216 | spin_unlock(&ioapic->lock); | 214 | spin_unlock(&ioapic->lock); |
217 | } | 215 | } |
218 | EXPORT_SYMBOL_GPL(kvm_ioapic_calculate_eoi_exitmap); | ||
219 | 216 | ||
220 | void kvm_ioapic_make_eoibitmap_request(struct kvm *kvm) | 217 | #ifdef CONFIG_X86 |
218 | void kvm_vcpu_request_scan_ioapic(struct kvm *kvm) | ||
221 | { | 219 | { |
222 | struct kvm_ioapic *ioapic = kvm->arch.vioapic; | 220 | struct kvm_ioapic *ioapic = kvm->arch.vioapic; |
223 | 221 | ||
224 | if (!kvm_apic_vid_enabled(kvm) || !ioapic) | 222 | if (!ioapic) |
225 | return; | 223 | return; |
226 | kvm_make_update_eoibitmap_request(kvm); | 224 | kvm_make_scan_ioapic_request(kvm); |
227 | } | 225 | } |
226 | #else | ||
227 | void kvm_vcpu_request_scan_ioapic(struct kvm *kvm) | ||
228 | { | ||
229 | return; | ||
230 | } | ||
231 | #endif | ||
228 | 232 | ||
229 | static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val) | 233 | static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val) |
230 | { | 234 | { |
@@ -267,7 +271,7 @@ static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val) | |||
267 | if (e->fields.trig_mode == IOAPIC_LEVEL_TRIG | 271 | if (e->fields.trig_mode == IOAPIC_LEVEL_TRIG |
268 | && ioapic->irr & (1 << index)) | 272 | && ioapic->irr & (1 << index)) |
269 | ioapic_service(ioapic, index, false); | 273 | ioapic_service(ioapic, index, false); |
270 | kvm_ioapic_make_eoibitmap_request(ioapic->kvm); | 274 | kvm_vcpu_request_scan_ioapic(ioapic->kvm); |
271 | break; | 275 | break; |
272 | } | 276 | } |
273 | } | 277 | } |
@@ -586,7 +590,7 @@ int kvm_set_ioapic(struct kvm *kvm, struct kvm_ioapic_state *state) | |||
586 | spin_lock(&ioapic->lock); | 590 | spin_lock(&ioapic->lock); |
587 | memcpy(ioapic, state, sizeof(struct kvm_ioapic_state)); | 591 | memcpy(ioapic, state, sizeof(struct kvm_ioapic_state)); |
588 | update_handled_vectors(ioapic); | 592 | update_handled_vectors(ioapic); |
589 | kvm_ioapic_make_eoibitmap_request(kvm); | 593 | kvm_vcpu_request_scan_ioapic(kvm); |
590 | kvm_rtc_eoi_tracking_restore_all(ioapic); | 594 | kvm_rtc_eoi_tracking_restore_all(ioapic); |
591 | spin_unlock(&ioapic->lock); | 595 | spin_unlock(&ioapic->lock); |
592 | return 0; | 596 | return 0; |
diff --git a/virt/kvm/ioapic.h b/virt/kvm/ioapic.h index 554157bbb586..674a388612b4 100644 --- a/virt/kvm/ioapic.h +++ b/virt/kvm/ioapic.h | |||
@@ -96,9 +96,7 @@ int kvm_irq_delivery_to_apic(struct kvm *kvm, struct kvm_lapic *src, | |||
96 | struct kvm_lapic_irq *irq, unsigned long *dest_map); | 96 | struct kvm_lapic_irq *irq, unsigned long *dest_map); |
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_ioapic_make_eoibitmap_request(struct kvm *kvm); | 99 | void kvm_vcpu_request_scan_ioapic(struct kvm *kvm); |
100 | void kvm_ioapic_calculate_eoi_exitmap(struct kvm_vcpu *vcpu, | 100 | void kvm_ioapic_scan_entry(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap); |
101 | u64 *eoi_exit_bitmap); | ||
102 | |||
103 | 101 | ||
104 | #endif | 102 | #endif |
diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c index 8efb580edfef..25ab48007adb 100644 --- a/virt/kvm/irq_comm.c +++ b/virt/kvm/irq_comm.c | |||
@@ -285,7 +285,7 @@ void kvm_register_irq_ack_notifier(struct kvm *kvm, | |||
285 | mutex_lock(&kvm->irq_lock); | 285 | mutex_lock(&kvm->irq_lock); |
286 | hlist_add_head_rcu(&kian->link, &kvm->irq_ack_notifier_list); | 286 | hlist_add_head_rcu(&kian->link, &kvm->irq_ack_notifier_list); |
287 | mutex_unlock(&kvm->irq_lock); | 287 | mutex_unlock(&kvm->irq_lock); |
288 | kvm_ioapic_make_eoibitmap_request(kvm); | 288 | kvm_vcpu_request_scan_ioapic(kvm); |
289 | } | 289 | } |
290 | 290 | ||
291 | void kvm_unregister_irq_ack_notifier(struct kvm *kvm, | 291 | void kvm_unregister_irq_ack_notifier(struct kvm *kvm, |
@@ -295,7 +295,7 @@ void kvm_unregister_irq_ack_notifier(struct kvm *kvm, | |||
295 | hlist_del_init_rcu(&kian->link); | 295 | hlist_del_init_rcu(&kian->link); |
296 | mutex_unlock(&kvm->irq_lock); | 296 | mutex_unlock(&kvm->irq_lock); |
297 | synchronize_rcu(); | 297 | synchronize_rcu(); |
298 | kvm_ioapic_make_eoibitmap_request(kvm); | 298 | kvm_vcpu_request_scan_ioapic(kvm); |
299 | } | 299 | } |
300 | 300 | ||
301 | int kvm_request_irq_source_id(struct kvm *kvm) | 301 | int kvm_request_irq_source_id(struct kvm *kvm) |
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index ac3182eed462..65a9e0716a8d 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c | |||
@@ -217,9 +217,9 @@ void kvm_make_mclock_inprogress_request(struct kvm *kvm) | |||
217 | make_all_cpus_request(kvm, KVM_REQ_MCLOCK_INPROGRESS); | 217 | make_all_cpus_request(kvm, KVM_REQ_MCLOCK_INPROGRESS); |
218 | } | 218 | } |
219 | 219 | ||
220 | void kvm_make_update_eoibitmap_request(struct kvm *kvm) | 220 | void kvm_make_scan_ioapic_request(struct kvm *kvm) |
221 | { | 221 | { |
222 | make_all_cpus_request(kvm, KVM_REQ_EOIBITMAP); | 222 | make_all_cpus_request(kvm, KVM_REQ_SCAN_IOAPIC); |
223 | } | 223 | } |
224 | 224 | ||
225 | int kvm_vcpu_init(struct kvm_vcpu *vcpu, struct kvm *kvm, unsigned id) | 225 | int kvm_vcpu_init(struct kvm_vcpu *vcpu, struct kvm *kvm, unsigned id) |