Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6fe407f2 authored by Christoffer Dall's avatar Christoffer Dall
Browse files

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: default avatarMarc Zyngier <marc.zyngier@arm.com>
Signed-off-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
parent 3d9cd95f
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -30,4 +30,6 @@ Returns: -ENODEV: PMUv3 not supported
                 attribute
                 attribute
         -EBUSY: PMUv3 already initialized
         -EBUSY: PMUv3 already initialized


Request the initialization of the PMUv3.
Request the initialization of the PMUv3.  This must be done after creating the
in-kernel irqchip.  Creating a PMU with a userspace irqchip is currently not
supported.
+8 −0
Original line number Original line Diff line number Diff line
@@ -423,6 +423,14 @@ static int kvm_arm_pmu_v3_init(struct kvm_vcpu *vcpu)
	if (!kvm_arm_support_pmu_v3())
	if (!kvm_arm_support_pmu_v3())
		return -ENODEV;
		return -ENODEV;


	/*
	 * We currently require an in-kernel VGIC to use the PMU emulation,
	 * because we do not support forwarding PMU overflow interrupts to
	 * userspace yet.
	 */
	if (!irqchip_in_kernel(vcpu->kvm) || !vgic_initialized(vcpu->kvm))
		return -ENODEV;

	if (!test_bit(KVM_ARM_VCPU_PMU_V3, vcpu->arch.features) ||
	if (!test_bit(KVM_ARM_VCPU_PMU_V3, vcpu->arch.features) ||
	    !kvm_arm_pmu_irq_initialized(vcpu))
	    !kvm_arm_pmu_irq_initialized(vcpu))
		return -ENXIO;
		return -ENXIO;