Commit 6fe407f2d18a4f94216263f91cb7d1f08fa5887c

Authored by Christoffer Dall
1 parent 3d9cd95f90

KVM: arm64: Require in-kernel irqchip for PMU support

If userspace creates a PMU for the VCPU, but doesn't create an in-kernel
irqchip, then we end up in a nasty path where we try to take an
uninitialized spinlock, which can lead to all sorts of breakages.

Luckily, QEMU always creates the VGIC before the PMU, so we can
establish this as ABI and check for the VGIC in the PMU init stage.
This can be relaxed at a later time if we want to support PMU with a
userspace irqchip.

Cc: stable@vger.kernel.org
Cc: Shannon Zhao <shannon.zhao@linaro.org>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>

Showing 2 changed files with 11 additions and 1 deletions Side-by-side Diff

Documentation/virtual/kvm/devices/vcpu.txt
... ... @@ -30,5 +30,7 @@
30 30 attribute
31 31 -EBUSY: PMUv3 already initialized
32 32  
33   -Request the initialization of the PMUv3.
  33 +Request the initialization of the PMUv3. This must be done after creating the
  34 +in-kernel irqchip. Creating a PMU with a userspace irqchip is currently not
  35 +supported.
... ... @@ -423,6 +423,14 @@
423 423 if (!kvm_arm_support_pmu_v3())
424 424 return -ENODEV;
425 425  
  426 + /*
  427 + * We currently require an in-kernel VGIC to use the PMU emulation,
  428 + * because we do not support forwarding PMU overflow interrupts to
  429 + * userspace yet.
  430 + */
  431 + if (!irqchip_in_kernel(vcpu->kvm) || !vgic_initialized(vcpu->kvm))
  432 + return -ENODEV;
  433 +
426 434 if (!test_bit(KVM_ARM_VCPU_PMU_V3, vcpu->arch.features) ||
427 435 !kvm_arm_pmu_irq_initialized(vcpu))
428 436 return -ENXIO;