diff options
author | Oliver Upton <oliver.upton@linux.dev> | 2024-10-25 18:23:50 +0000 |
---|---|---|
committer | Oliver Upton <oliver.upton@linux.dev> | 2024-10-31 19:00:40 +0000 |
commit | fe827f9166622dbe384605b78092c285d5e92b76 (patch) | |
tree | 973d373b5b63124761dfec5d58ad457946f55959 /arch/arm64 | |
parent | 9d15f8290a228ccd74a6ca8c082df350009e9e06 (diff) | |
download | lwn-fe827f9166622dbe384605b78092c285d5e92b76.tar.gz lwn-fe827f9166622dbe384605b78092c285d5e92b76.zip |
KVM: arm64: nv: Honor MDCR_EL2.HPME
When the PMU is configured with split counter ranges, HPME becomes the
enable bit for the counters reserved for EL2.
Reviewed-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20241025182354.3364124-16-oliver.upton@linux.dev
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
Diffstat (limited to 'arch/arm64')
-rw-r--r-- | arch/arm64/kvm/pmu-emul.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/arch/arm64/kvm/pmu-emul.c b/arch/arm64/kvm/pmu-emul.c index 03cd1ad7a55a..349886f03fd5 100644 --- a/arch/arm64/kvm/pmu-emul.c +++ b/arch/arm64/kvm/pmu-emul.c @@ -620,8 +620,15 @@ void kvm_pmu_handle_pmcr(struct kvm_vcpu *vcpu, u64 val) static bool kvm_pmu_counter_is_enabled(struct kvm_pmc *pmc) { struct kvm_vcpu *vcpu = kvm_pmc_to_vcpu(pmc); - return (kvm_vcpu_read_pmcr(vcpu) & ARMV8_PMU_PMCR_E) && - (__vcpu_sys_reg(vcpu, PMCNTENSET_EL0) & BIT(pmc->idx)); + unsigned int mdcr = __vcpu_sys_reg(vcpu, MDCR_EL2); + + if (!(__vcpu_sys_reg(vcpu, PMCNTENSET_EL0) & BIT(pmc->idx))) + return false; + + if (kvm_pmu_counter_is_hyp(vcpu, pmc->idx)) + return mdcr & MDCR_EL2_HPME; + + return kvm_vcpu_read_pmcr(vcpu) & ARMV8_PMU_PMCR_E; } static bool kvm_pmc_counts_at_el0(struct kvm_pmc *pmc) |