diff options
author | David Hildenbrand <david@redhat.com> | 2017-04-07 10:50:30 +0200 |
---|---|---|
committer | Radim Krčmář <rkrcmar@redhat.com> | 2017-04-12 20:17:14 +0200 |
commit | 445ee82d7a9752a2ab3b678fc348c91a54c1782e (patch) | |
tree | 52e0827f6dd6006e07bbec60f4cda766622cef17 | |
parent | 49f520b99af13d8cafec6f227dabf6acf236c887 (diff) | |
download | linux-445ee82d7a9752a2ab3b678fc348c91a54c1782e.tar.gz linux-445ee82d7a9752a2ab3b678fc348c91a54c1782e.tar.bz2 linux-445ee82d7a9752a2ab3b678fc348c91a54c1782e.zip |
KVM: x86: KVM_IRQCHIP_PIC_MASTER only has 8 pins
Currently, one could set pin 8-15, implicitly referring to
KVM_IRQCHIP_PIC_SLAVE.
Get rid of the two local variables max_pin and delta on the way.
Signed-off-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
-rw-r--r-- | arch/x86/kvm/irq_comm.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/arch/x86/kvm/irq_comm.c b/arch/x86/kvm/irq_comm.c index d82fc1443a63..fb1e37ea2674 100644 --- a/arch/x86/kvm/irq_comm.c +++ b/arch/x86/kvm/irq_comm.c @@ -279,8 +279,6 @@ int kvm_set_routing_entry(struct kvm *kvm, const struct kvm_irq_routing_entry *ue) { int r = -EINVAL; - int delta; - unsigned max_pin; /* also allow creation of routes during KVM_IRQCHIP_INIT_IN_PROGRESS */ if (kvm->arch.irqchip_mode == KVM_IRQCHIP_NONE) @@ -292,26 +290,25 @@ int kvm_set_routing_entry(struct kvm *kvm, case KVM_IRQ_ROUTING_IRQCHIP: if (irqchip_split(kvm)) goto out; - delta = 0; + e->irqchip.pin = ue->u.irqchip.pin; switch (ue->u.irqchip.irqchip) { case KVM_IRQCHIP_PIC_SLAVE: - delta = 8; + e->irqchip.pin += PIC_NUM_PINS / 2; /* fall through */ case KVM_IRQCHIP_PIC_MASTER: + if (ue->u.irqchip.pin >= PIC_NUM_PINS / 2) + goto out; e->set = kvm_set_pic_irq; - max_pin = PIC_NUM_PINS; break; case KVM_IRQCHIP_IOAPIC: - max_pin = KVM_IOAPIC_NUM_PINS; + if (ue->u.irqchip.pin >= KVM_IOAPIC_NUM_PINS) + goto out; e->set = kvm_set_ioapic_irq; break; default: goto out; } e->irqchip.irqchip = ue->u.irqchip.irqchip; - e->irqchip.pin = ue->u.irqchip.pin + delta; - if (e->irqchip.pin >= max_pin) - goto out; break; case KVM_IRQ_ROUTING_MSI: e->set = kvm_set_msi; |