aboutsummaryrefslogtreecommitdiffstats
path: root/virt
diff options
context:
space:
mode:
authorMarc Zyngier <marc.zyngier@arm.com>2015-06-17 09:43:35 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-07-10 12:49:37 -0400
commitda75b45af7778af80c7c1d9853868e9bb4b75065 (patch)
treeac609ab43e64264a837e9a4f703f697333435449 /virt
parentaae3d9fecc22c1c7565c94f0818704a1908543ce (diff)
KVM: arm/arm64: vgic: Avoid injecting reserved IRQ numbers
commit 4839ddc27b7212ec58874f62c97da7400c8523be upstream. Commit fd1d0ddf2ae9 (KVM: arm/arm64: check IRQ number on userland injection) rightly limited the range of interrupts userspace can inject in a guest, but failed to consider the (unlikely) case where a guest is configured with 1024 interrupts. In this case, interrupts ranging from 1020 to 1023 are unuseable, as they have a special meaning for the GIC CPU interface. Make sure that these number cannot be used as an IRQ. Also delete a redundant (and similarily buggy) check in kvm_set_irq. Reported-by: Peter Maydell <peter.maydell@linaro.org> Cc: Andre Przywara <andre.przywara@arm.com> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'virt')
-rw-r--r--virt/kvm/arm/vgic.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
index 78fb8201014f..950064a0942d 100644
--- a/virt/kvm/arm/vgic.c
+++ b/virt/kvm/arm/vgic.c
@@ -1561,7 +1561,7 @@ int kvm_vgic_inject_irq(struct kvm *kvm, int cpuid, unsigned int irq_num,
1561 goto out; 1561 goto out;
1562 } 1562 }
1563 1563
1564 if (irq_num >= kvm->arch.vgic.nr_irqs) 1564 if (irq_num >= min(kvm->arch.vgic.nr_irqs, 1020))
1565 return -EINVAL; 1565 return -EINVAL;
1566 1566
1567 vcpu_id = vgic_update_irq_pending(kvm, cpuid, irq_num, level); 1567 vcpu_id = vgic_update_irq_pending(kvm, cpuid, irq_num, level);
@@ -2161,10 +2161,7 @@ int kvm_set_irq(struct kvm *kvm, int irq_source_id,
2161 2161
2162 BUG_ON(!vgic_initialized(kvm)); 2162 BUG_ON(!vgic_initialized(kvm));
2163 2163
2164 if (spi > kvm->arch.vgic.nr_irqs)
2165 return -EINVAL;
2166 return kvm_vgic_inject_irq(kvm, 0, spi, level); 2164 return kvm_vgic_inject_irq(kvm, 0, spi, level);
2167
2168} 2165}
2169 2166
2170/* MSI not implemented yet */ 2167/* MSI not implemented yet */