mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
KVM: arm64: Advertise STALL_SLOT* in PMCEID1 under strict PMUv3 UAPI
Skip masking STALL_SLOT, STALL_SLOT_FRONTEND and STALL_SLOT_BACKEND out of PMCEID1 when KVM_ARM_VCPU_PMU_V3_STRICT is set, because this is when PMMIR_EL1.SLOTS is exposed to guests, making these events meaningful for collection. Change the parameter of compute_pmceid1() from arm_pmu to kvm_vcpu, to check if KVM_ARM_VCPU_PMU_V3_STRICT is set. Also updated the signature of compute_pmceid0() for consistency. Signed-off-by: Congkai Tan <congkai@amazon.com> Reviewed-by: Geoff Blake <blakgeof@amazon.com> Reviewed-by: Haris Okanovic <harisokn@amazon.com> Reviewed-by: Stanislav Spassov <stanspas@amazon.de> Reviewed-by: Fuad Tabba <fuad.tabba@linux.dev> Tested-by: Fuad Tabba <fuad.tabba@linux.dev> Link: https://patch.msgid.link/20260722202702.4165917-3-congkai@amazon.com Signed-off-by: Oliver Upton <oupton@kernel.org>
This commit is contained in:
parent
453f6ff04b
commit
203b22f76d
|
|
@ -838,9 +838,9 @@ static u64 __compute_pmceid(struct arm_pmu *pmu, bool pmceid1)
|
|||
return ((u64)hi[pmceid1] << 32) | lo[pmceid1];
|
||||
}
|
||||
|
||||
static u64 compute_pmceid0(struct arm_pmu *pmu)
|
||||
static u64 compute_pmceid0(struct kvm_vcpu *vcpu)
|
||||
{
|
||||
u64 val = __compute_pmceid(pmu, 0);
|
||||
u64 val = __compute_pmceid(vcpu->kvm->arch.arm_pmu, 0);
|
||||
|
||||
/* always support SW_INCR */
|
||||
val |= BIT(ARMV8_PMUV3_PERFCTR_SW_INCR);
|
||||
|
|
@ -849,32 +849,33 @@ static u64 compute_pmceid0(struct arm_pmu *pmu)
|
|||
return val;
|
||||
}
|
||||
|
||||
static u64 compute_pmceid1(struct arm_pmu *pmu)
|
||||
static u64 compute_pmceid1(struct kvm_vcpu *vcpu)
|
||||
{
|
||||
u64 val = __compute_pmceid(pmu, 1);
|
||||
u64 val = __compute_pmceid(vcpu->kvm->arch.arm_pmu, 1);
|
||||
|
||||
/*
|
||||
* Don't advertise STALL_SLOT*, as PMMIR_EL0 is handled
|
||||
* as RAZ
|
||||
* If KVM_ARM_VCPU_PMU_V3_STRICT is not set, PMMIR_EL1 is
|
||||
* unconditionally RAZ, so don't advertise STALL_SLOT* events.
|
||||
*/
|
||||
val &= ~(BIT_ULL(ARMV8_PMUV3_PERFCTR_STALL_SLOT - 32) |
|
||||
BIT_ULL(ARMV8_PMUV3_PERFCTR_STALL_SLOT_FRONTEND - 32) |
|
||||
BIT_ULL(ARMV8_PMUV3_PERFCTR_STALL_SLOT_BACKEND - 32));
|
||||
if (!kvm_vcpu_has_pmuv3_strict(vcpu))
|
||||
val &= ~(BIT_ULL(ARMV8_PMUV3_PERFCTR_STALL_SLOT - 32) |
|
||||
BIT_ULL(ARMV8_PMUV3_PERFCTR_STALL_SLOT_FRONTEND - 32) |
|
||||
BIT_ULL(ARMV8_PMUV3_PERFCTR_STALL_SLOT_BACKEND - 32));
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
u64 kvm_pmu_get_pmceid(struct kvm_vcpu *vcpu, bool pmceid1)
|
||||
{
|
||||
struct arm_pmu *cpu_pmu = vcpu->kvm->arch.arm_pmu;
|
||||
unsigned long *bmap = vcpu->kvm->arch.pmu_filter;
|
||||
u64 val, mask = 0;
|
||||
int base, i, nr_events;
|
||||
|
||||
if (!pmceid1) {
|
||||
val = compute_pmceid0(cpu_pmu);
|
||||
val = compute_pmceid0(vcpu);
|
||||
base = 0;
|
||||
} else {
|
||||
val = compute_pmceid1(cpu_pmu);
|
||||
val = compute_pmceid1(vcpu);
|
||||
base = 32;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user