aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcelo Tosatti <mtosatti@redhat.com>2009-01-27 12:12:38 -0500
committerAvi Kivity <avi@redhat.com>2009-03-24 05:03:08 -0400
commit44882eed2ebe7f75f8cdae5671ab1d6e0fa40dbc (patch)
treee026a4067370e2dac1a5a3a9d9995e2b6f82ba49
parent934d534f8a5a39e20d5682b3a3a45ff351706b59 (diff)
KVM: make irq ack notifications aware of routing table
IRQ ack notifications assume an identity mapping between pin->gsi, which might not be the case with, for example, HPET. Translate before acking. Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> Acked-by: Gleb Natapov <gleb@redhat.com>
-rw-r--r--arch/x86/kvm/i8259.c5
-rw-r--r--arch/x86/kvm/irq.h2
-rw-r--r--include/linux/kvm_host.h2
-rw-r--r--virt/kvm/ioapic.c10
-rw-r--r--virt/kvm/irq_comm.c13
5 files changed, 21 insertions, 11 deletions
diff --git a/arch/x86/kvm/i8259.c b/arch/x86/kvm/i8259.c
index 179dcb0103fd..93160375c841 100644
--- a/arch/x86/kvm/i8259.c
+++ b/arch/x86/kvm/i8259.c
@@ -49,7 +49,8 @@ static void pic_unlock(struct kvm_pic *s)
49 spin_unlock(&s->lock); 49 spin_unlock(&s->lock);
50 50
51 while (acks) { 51 while (acks) {
52 kvm_notify_acked_irq(kvm, __ffs(acks)); 52 kvm_notify_acked_irq(kvm, SELECT_PIC(__ffs(acks)),
53 __ffs(acks));
53 acks &= acks - 1; 54 acks &= acks - 1;
54 } 55 }
55 56
@@ -232,7 +233,7 @@ int kvm_pic_read_irq(struct kvm *kvm)
232 } 233 }
233 pic_update_irq(s); 234 pic_update_irq(s);
234 pic_unlock(s); 235 pic_unlock(s);
235 kvm_notify_acked_irq(kvm, irq); 236 kvm_notify_acked_irq(kvm, SELECT_PIC(irq), irq);
236 237
237 return intno; 238 return intno;
238} 239}
diff --git a/arch/x86/kvm/irq.h b/arch/x86/kvm/irq.h
index 82579ee538d0..9f593188129e 100644
--- a/arch/x86/kvm/irq.h
+++ b/arch/x86/kvm/irq.h
@@ -32,6 +32,8 @@
32#include "lapic.h" 32#include "lapic.h"
33 33
34#define PIC_NUM_PINS 16 34#define PIC_NUM_PINS 16
35#define SELECT_PIC(irq) \
36 ((irq) < 8 ? KVM_IRQCHIP_PIC_MASTER : KVM_IRQCHIP_PIC_SLAVE)
35 37
36struct kvm; 38struct kvm;
37struct kvm_vcpu; 39struct kvm_vcpu;
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index ce285e01bd57..c03a0a9a8584 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -352,7 +352,7 @@ void kvm_unregister_irq_mask_notifier(struct kvm *kvm, int irq,
352void kvm_fire_mask_notifiers(struct kvm *kvm, int irq, bool mask); 352void kvm_fire_mask_notifiers(struct kvm *kvm, int irq, bool mask);
353 353
354void kvm_set_irq(struct kvm *kvm, int irq_source_id, int irq, int level); 354void kvm_set_irq(struct kvm *kvm, int irq_source_id, int irq, int level);
355void kvm_notify_acked_irq(struct kvm *kvm, unsigned gsi); 355void kvm_notify_acked_irq(struct kvm *kvm, unsigned irqchip, unsigned pin);
356void kvm_register_irq_ack_notifier(struct kvm *kvm, 356void kvm_register_irq_ack_notifier(struct kvm *kvm,
357 struct kvm_irq_ack_notifier *kian); 357 struct kvm_irq_ack_notifier *kian);
358void kvm_unregister_irq_ack_notifier(struct kvm_irq_ack_notifier *kian); 358void kvm_unregister_irq_ack_notifier(struct kvm_irq_ack_notifier *kian);
diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c
index e85a2bcd2db1..1c986ac59ad6 100644
--- a/virt/kvm/ioapic.c
+++ b/virt/kvm/ioapic.c
@@ -293,20 +293,20 @@ void kvm_ioapic_set_irq(struct kvm_ioapic *ioapic, int irq, int level)
293 } 293 }
294} 294}
295 295
296static void __kvm_ioapic_update_eoi(struct kvm_ioapic *ioapic, int gsi, 296static void __kvm_ioapic_update_eoi(struct kvm_ioapic *ioapic, int pin,
297 int trigger_mode) 297 int trigger_mode)
298{ 298{
299 union ioapic_redir_entry *ent; 299 union ioapic_redir_entry *ent;
300 300
301 ent = &ioapic->redirtbl[gsi]; 301 ent = &ioapic->redirtbl[pin];
302 302
303 kvm_notify_acked_irq(ioapic->kvm, gsi); 303 kvm_notify_acked_irq(ioapic->kvm, KVM_IRQCHIP_IOAPIC, pin);
304 304
305 if (trigger_mode == IOAPIC_LEVEL_TRIG) { 305 if (trigger_mode == IOAPIC_LEVEL_TRIG) {
306 ASSERT(ent->fields.trig_mode == IOAPIC_LEVEL_TRIG); 306 ASSERT(ent->fields.trig_mode == IOAPIC_LEVEL_TRIG);
307 ent->fields.remote_irr = 0; 307 ent->fields.remote_irr = 0;
308 if (!ent->fields.mask && (ioapic->irr & (1 << gsi))) 308 if (!ent->fields.mask && (ioapic->irr & (1 << pin)))
309 ioapic_service(ioapic, gsi); 309 ioapic_service(ioapic, pin);
310 } 310 }
311} 311}
312 312
diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c
index a797fa5e6420..7aa5086c8622 100644
--- a/virt/kvm/irq_comm.c
+++ b/virt/kvm/irq_comm.c
@@ -59,10 +59,19 @@ void kvm_set_irq(struct kvm *kvm, int irq_source_id, int irq, int level)
59 e->set(e, kvm, !!(*irq_state)); 59 e->set(e, kvm, !!(*irq_state));
60} 60}
61 61
62void kvm_notify_acked_irq(struct kvm *kvm, unsigned gsi) 62void kvm_notify_acked_irq(struct kvm *kvm, unsigned irqchip, unsigned pin)
63{ 63{
64 struct kvm_kernel_irq_routing_entry *e;
64 struct kvm_irq_ack_notifier *kian; 65 struct kvm_irq_ack_notifier *kian;
65 struct hlist_node *n; 66 struct hlist_node *n;
67 unsigned gsi = pin;
68
69 list_for_each_entry(e, &kvm->irq_routing, link)
70 if (e->irqchip.irqchip == irqchip &&
71 e->irqchip.pin == pin) {
72 gsi = e->gsi;
73 break;
74 }
66 75
67 hlist_for_each_entry(kian, n, &kvm->arch.irq_ack_notifier_list, link) 76 hlist_for_each_entry(kian, n, &kvm->arch.irq_ack_notifier_list, link)
68 if (kian->gsi == gsi) 77 if (kian->gsi == gsi)
@@ -237,8 +246,6 @@ out:
237#define ROUTING_ENTRY1(irq) IOAPIC_ROUTING_ENTRY(irq) 246#define ROUTING_ENTRY1(irq) IOAPIC_ROUTING_ENTRY(irq)
238 247
239#ifdef CONFIG_X86 248#ifdef CONFIG_X86
240#define SELECT_PIC(irq) \
241 ((irq) < 8 ? KVM_IRQCHIP_PIC_MASTER : KVM_IRQCHIP_PIC_SLAVE)
242# define PIC_ROUTING_ENTRY(irq) \ 249# define PIC_ROUTING_ENTRY(irq) \
243 { .gsi = irq, .type = KVM_IRQ_ROUTING_IRQCHIP, \ 250 { .gsi = irq, .type = KVM_IRQ_ROUTING_IRQCHIP, \
244 .u.irqchip.irqchip = SELECT_PIC(irq), .u.irqchip.pin = (irq) % 8 } 251 .u.irqchip.irqchip = SELECT_PIC(irq), .u.irqchip.pin = (irq) % 8 }