]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
KVM: arm64: nv: Advertise support for FEAT_HPMN0
authorOliver Upton <oliver.upton@linux.dev>
Fri, 25 Oct 2024 18:23:46 +0000 (18:23 +0000)
committerOliver Upton <oliver.upton@linux.dev>
Thu, 31 Oct 2024 19:00:40 +0000 (19:00 +0000)
Everything is in place now for KVM to actually handle MDCR_EL2.HPMN. Not
only that, the emulation is capable of doing FEAT_HPMN0. Advertise
support for the feature in the VM's ID registers. It is possible to
emulate FEAT_HPMN0 on hardware that doesn't support it since KVM
currently traps all PMU registers. Having said that, let's only
advertise the feature on supporting hardware in case KVM ever provides
'direct' PMU support to VMs w/o involving host perf.

Reviewed-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20241025182354.3364124-12-oliver.upton@linux.dev
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
arch/arm64/kvm/nested.c

index 676e2de78fdd97a3068054d3183e4bded86821d4..2cbd8ac19d83953b8a9180c96d74fb207c65b8ff 100644 (file)
@@ -917,12 +917,13 @@ static void limit_nv_id_regs(struct kvm *kvm)
                                  ID_AA64MMFR4_EL1_E2H0_NI_NV1);
        kvm_set_vm_id_reg(kvm, SYS_ID_AA64MMFR4_EL1, val);
 
-       /* Only limited support for PMU, Debug, BPs and WPs */
+       /* Only limited support for PMU, Debug, BPs, WPs, and HPMN0 */
        val = kvm_read_vm_id_reg(kvm, SYS_ID_AA64DFR0_EL1);
        val &= (NV_FTR(DFR0, PMUVer)    |
                NV_FTR(DFR0, WRPs)      |
                NV_FTR(DFR0, BRPs)      |
-               NV_FTR(DFR0, DebugVer));
+               NV_FTR(DFR0, DebugVer)  |
+               NV_FTR(DFR0, HPMN0));
 
        /* Cap Debug to ARMv8.1 */
        tmp = FIELD_GET(NV_FTR(DFR0, DebugVer), val);