Use the GICv5 PPI specifier in the DT. KVM also expects the PMU IRQ attribute to contain the GICv5 interrupt type in the upper bits, so encode it before setting KVM_ARM_VCPU_PMU_V3_IRQ. Signed-off-by: Sascha Bischoff --- arm64/pmu.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/arm64/pmu.c b/arm64/pmu.c index ef7faca1..bc52d5fc 100644 --- a/arm64/pmu.c +++ b/arm64/pmu.c @@ -214,16 +214,22 @@ static int find_pmu(struct kvm *kvm) void pmu__generate_fdt_nodes(void *fdt, struct kvm *kvm) { const char compatible[] = "arm,armv8-pmuv3"; + int irq = KVM_ARM_PMUv3_PPI; + u32 irq_prop[3]; u32 cpu_mask = gic__get_fdt_irq_cpumask(kvm); - u32 irq_prop[] = { - cpu_to_fdt32(GIC_FDT_IRQ_TYPE_PPI), - cpu_to_fdt32(KVM_ARM_PMUv3_PPI - 16), - cpu_to_fdt32(cpu_mask | IRQ_TYPE_LEVEL_HIGH), - }; if (!kvm->cfg.arch.has_pmuv3) return; + if (gic__is_v5()) { + irq_prop[0] = cpu_to_fdt32(GICV5_IRQ_TYPE_PPI); + irq_prop[1] = cpu_to_fdt32(irq); + } else { + irq_prop[0] = cpu_to_fdt32(GIC_FDT_IRQ_TYPE_PPI); + irq_prop[1] = cpu_to_fdt32(irq - 16); + } + irq_prop[2] = cpu_to_fdt32(cpu_mask | IRQ_TYPE_LEVEL_HIGH); + _FDT(fdt_begin_node(fdt, "pmu")); _FDT(fdt_property(fdt, "compatible", compatible, sizeof(compatible))); _FDT(fdt_property(fdt, "interrupts", irq_prop, sizeof(irq_prop))); @@ -248,6 +254,13 @@ int pmu__init(struct kvm *kvm) } } + /* + * For GICv5, we must encode the full IntID by adding the type (PPI) + * when setting the PMUIRQ. + */ + if (gic__is_v5()) + irq |= GICV5_IRQ_TYPE_PPI << GICV5_IRQ_TYPE_SHIFT; + for (i = 0; i < kvm->nrcpus; i++) { vcpu = kvm->cpus[i]; set_pmu_attr(vcpu, &irq, KVM_ARM_VCPU_PMU_V3_IRQ); -- 2.34.1