Skip to content

Commit 5978d4e

Browse files
ouptonMarc Zyngier
authored andcommitted
KVM: arm64: vgic: Don't check for vgic_ready() when setting NR_IRQS
KVM commits to a particular sizing of SPIs when the vgic is initialized, which is before the point a vgic becomes ready. On top of that, KVM supplies a default amount of SPIs should userspace not explicitly configure this. As such, the check for vgic_ready() in the handling of KVM_DEV_ARM_VGIC_GRP_NR_IRQS is completely wrong, and testing if nr_spis is nonzero is sufficient for preventing userspace from playing games with us. Signed-off-by: Oliver Upton <oliver.upton@linux.dev> Link: https://lore.kernel.org/r/20241017001947.2707312-2-oliver.upton@linux.dev Signed-off-by: Marc Zyngier <maz@kernel.org>
1 parent c6c167a commit 5978d4e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

arch/arm64/kvm/vgic/vgic-kvm-device.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,12 @@ static int vgic_set_common_attr(struct kvm_device *dev,
236236

237237
mutex_lock(&dev->kvm->arch.config_lock);
238238

239-
if (vgic_ready(dev->kvm) || dev->kvm->arch.vgic.nr_spis)
239+
/*
240+
* Either userspace has already configured NR_IRQS or
241+
* the vgic has already been initialized and vgic_init()
242+
* supplied a default amount of SPIs.
243+
*/
244+
if (dev->kvm->arch.vgic.nr_spis)
240245
ret = -EBUSY;
241246
else
242247
dev->kvm->arch.vgic.nr_spis =

0 commit comments

Comments
 (0)