aboutsummaryrefslogtreecommitdiffstats
path: root/virt/kvm/irq_comm.c
diff options
context:
space:
mode:
Diffstat (limited to 'virt/kvm/irq_comm.c')
-rw-r--r--virt/kvm/irq_comm.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c
index 9b077342ab54..9fd5b3ebc517 100644
--- a/virt/kvm/irq_comm.c
+++ b/virt/kvm/irq_comm.c
@@ -302,6 +302,7 @@ static int setup_routing_entry(struct kvm_irq_routing_table *rt,
302{ 302{
303 int r = -EINVAL; 303 int r = -EINVAL;
304 int delta; 304 int delta;
305 unsigned max_pin;
305 struct kvm_kernel_irq_routing_entry *ei; 306 struct kvm_kernel_irq_routing_entry *ei;
306 struct hlist_node *n; 307 struct hlist_node *n;
307 308
@@ -322,12 +323,15 @@ static int setup_routing_entry(struct kvm_irq_routing_table *rt,
322 switch (ue->u.irqchip.irqchip) { 323 switch (ue->u.irqchip.irqchip) {
323 case KVM_IRQCHIP_PIC_MASTER: 324 case KVM_IRQCHIP_PIC_MASTER:
324 e->set = kvm_set_pic_irq; 325 e->set = kvm_set_pic_irq;
326 max_pin = 16;
325 break; 327 break;
326 case KVM_IRQCHIP_PIC_SLAVE: 328 case KVM_IRQCHIP_PIC_SLAVE:
327 e->set = kvm_set_pic_irq; 329 e->set = kvm_set_pic_irq;
330 max_pin = 16;
328 delta = 8; 331 delta = 8;
329 break; 332 break;
330 case KVM_IRQCHIP_IOAPIC: 333 case KVM_IRQCHIP_IOAPIC:
334 max_pin = KVM_IOAPIC_NUM_PINS;
331 e->set = kvm_set_ioapic_irq; 335 e->set = kvm_set_ioapic_irq;
332 break; 336 break;
333 default: 337 default:
@@ -335,7 +339,7 @@ static int setup_routing_entry(struct kvm_irq_routing_table *rt,
335 } 339 }
336 e->irqchip.irqchip = ue->u.irqchip.irqchip; 340 e->irqchip.irqchip = ue->u.irqchip.irqchip;
337 e->irqchip.pin = ue->u.irqchip.pin + delta; 341 e->irqchip.pin = ue->u.irqchip.pin + delta;
338 if (e->irqchip.pin >= KVM_IOAPIC_NUM_PINS) 342 if (e->irqchip.pin >= max_pin)
339 goto out; 343 goto out;
340 rt->chip[ue->u.irqchip.irqchip][e->irqchip.pin] = ue->gsi; 344 rt->chip[ue->u.irqchip.irqchip][e->irqchip.pin] = ue->gsi;
341 break; 345 break;