Skip to content

Commit fe827f9

Browse files
committed
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>
1 parent 9d15f82 commit fe827f9

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

arch/arm64/kvm/pmu-emul.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -620,8 +620,15 @@ void kvm_pmu_handle_pmcr(struct kvm_vcpu *vcpu, u64 val)
620620
static bool kvm_pmu_counter_is_enabled(struct kvm_pmc *pmc)
621621
{
622622
struct kvm_vcpu *vcpu = kvm_pmc_to_vcpu(pmc);
623-
return (kvm_vcpu_read_pmcr(vcpu) & ARMV8_PMU_PMCR_E) &&
624-
(__vcpu_sys_reg(vcpu, PMCNTENSET_EL0) & BIT(pmc->idx));
623+
unsigned int mdcr = __vcpu_sys_reg(vcpu, MDCR_EL2);
624+
625+
if (!(__vcpu_sys_reg(vcpu, PMCNTENSET_EL0) & BIT(pmc->idx)))
626+
return false;
627+
628+
if (kvm_pmu_counter_is_hyp(vcpu, pmc->idx))
629+
return mdcr & MDCR_EL2_HPME;
630+
631+
return kvm_vcpu_read_pmcr(vcpu) & ARMV8_PMU_PMCR_E;
625632
}
626633

627634
static bool kvm_pmc_counts_at_el0(struct kvm_pmc *pmc)

0 commit comments

Comments
 (0)