Skip to content

Commit 9bae7a0

Browse files
committed
KVM: x86/pmu: Move initialization of valid PMCs bitmask to common x86
Move all initialization of all_valid_pmc_idx to common code, as the logic is 100% common to Intel and AMD, and KVM heavily relies on Intel and AMD having the same semantics. E.g. the fact that AMD doesn't support fixed counters doesn't allow KVM to use all_valid_pmc_idx[63:32] for other purposes. Tested-by: Xudong Hao <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent 30c0267 commit 9bae7a0

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

arch/x86/kvm/pmu.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,10 @@ void kvm_pmu_refresh(struct kvm_vcpu *vcpu)
888888
*/
889889
if (kvm_pmu_has_perf_global_ctrl(pmu) && pmu->nr_arch_gp_counters)
890890
pmu->global_ctrl = GENMASK_ULL(pmu->nr_arch_gp_counters - 1, 0);
891+
892+
bitmap_set(pmu->all_valid_pmc_idx, 0, pmu->nr_arch_gp_counters);
893+
bitmap_set(pmu->all_valid_pmc_idx, KVM_FIXED_PMC_BASE_IDX,
894+
pmu->nr_arch_fixed_counters);
891895
}
892896

893897
void kvm_pmu_init(struct kvm_vcpu *vcpu)

arch/x86/kvm/svm/pmu.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ static void amd_pmu_refresh(struct kvm_vcpu *vcpu)
210210
/* not applicable to AMD; but clean them to prevent any fall out */
211211
pmu->counter_bitmask[KVM_PMC_FIXED] = 0;
212212
pmu->nr_arch_fixed_counters = 0;
213-
bitmap_set(pmu->all_valid_pmc_idx, 0, pmu->nr_arch_gp_counters);
214213
}
215214

216215
static void amd_pmu_init(struct kvm_vcpu *vcpu)

arch/x86/kvm/vmx/pmu_intel.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -579,11 +579,6 @@ static void intel_pmu_refresh(struct kvm_vcpu *vcpu)
579579
pmu->raw_event_mask |= (HSW_IN_TX|HSW_IN_TX_CHECKPOINTED);
580580
}
581581

582-
bitmap_set(pmu->all_valid_pmc_idx,
583-
0, pmu->nr_arch_gp_counters);
584-
bitmap_set(pmu->all_valid_pmc_idx,
585-
INTEL_PMC_MAX_GENERIC, pmu->nr_arch_fixed_counters);
586-
587582
perf_capabilities = vcpu_get_perf_capabilities(vcpu);
588583
if (intel_pmu_lbr_is_compatible(vcpu) &&
589584
(perf_capabilities & PERF_CAP_LBR_FMT))

0 commit comments

Comments
 (0)