KVM: arm/arm64: vgic: Cap SPIs to the VM-defined maximum
authorMarc Zyngier <marc.zyngier@arm.com>
Tue, 4 Dec 2018 17:11:19 +0000 (17:11 +0000)
committerMarc Zyngier <marc.zyngier@arm.com>
Tue, 18 Dec 2018 15:14:50 +0000 (15:14 +0000)
SPIs should be checked against the VMs specific configuration, and
not the architectural maximum.

Cc: stable@vger.kernel.org
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
virt/kvm/arm/vgic/vgic.c

index 7cfdfbc910e0c48e38b9f6eaaefacbbe71d043fc..8ab0491bcc94130438300952692d49e06a76bedc 100644 (file)
@@ -108,8 +108,8 @@ struct vgic_irq *vgic_get_irq(struct kvm *kvm, struct kvm_vcpu *vcpu,
        }
 
        /* SPIs */
-       if (intid <= VGIC_MAX_SPI) {
-               intid = array_index_nospec(intid, VGIC_MAX_SPI);
+       if (intid < (kvm->arch.vgic.nr_spis + VGIC_NR_PRIVATE_IRQS)) {
+               intid = array_index_nospec(intid, kvm->arch.vgic.nr_spis + VGIC_NR_PRIVATE_IRQS);
                return &kvm->arch.vgic.spis[intid - VGIC_NR_PRIVATE_IRQS];
        }