Skip to content

Commit 8de1854

Browse files
Like Xusean-jc
authored andcommitted
KVM: x86/pmu: Move reprogram_counters() to pmu.h
Move reprogram_counters() out of Intel specific PMU code and into pmu.h so that it can be used to implement AMD PMU v2 support. No functional change intended. Suggested-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Like Xu <likexu@tencent.com> [sean: rewrite changelog] Link: https://lore.kernel.org/r/20230603011058.1038821-3-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 53550b8 commit 8de1854

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

arch/x86/kvm/pmu.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,18 @@ static inline void kvm_pmu_request_counter_reprogram(struct kvm_pmc *pmc)
201201
kvm_make_request(KVM_REQ_PMU, pmc->vcpu);
202202
}
203203

204+
static inline void reprogram_counters(struct kvm_pmu *pmu, u64 diff)
205+
{
206+
int bit;
207+
208+
if (!diff)
209+
return;
210+
211+
for_each_set_bit(bit, (unsigned long *)&diff, X86_PMC_IDX_MAX)
212+
set_bit(bit, pmu->reprogram_pmi);
213+
kvm_make_request(KVM_REQ_PMU, pmu_to_vcpu(pmu));
214+
}
215+
204216
void kvm_pmu_deliver_pmi(struct kvm_vcpu *vcpu);
205217
void kvm_pmu_handle_event(struct kvm_vcpu *vcpu);
206218
int kvm_pmu_rdpmc(struct kvm_vcpu *vcpu, unsigned pmc, u64 *data);

arch/x86/kvm/vmx/pmu_intel.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,6 @@ static struct kvm_pmc *intel_pmc_idx_to_pmc(struct kvm_pmu *pmu, int pmc_idx)
7373
}
7474
}
7575

76-
static void reprogram_counters(struct kvm_pmu *pmu, u64 diff)
77-
{
78-
int bit;
79-
80-
if (!diff)
81-
return;
82-
83-
for_each_set_bit(bit, (unsigned long *)&diff, X86_PMC_IDX_MAX)
84-
set_bit(bit, pmu->reprogram_pmi);
85-
kvm_make_request(KVM_REQ_PMU, pmu_to_vcpu(pmu));
86-
}
87-
8876
static bool intel_hw_event_available(struct kvm_pmc *pmc)
8977
{
9078
struct kvm_pmu *pmu = pmc_to_pmu(pmc);

0 commit comments

Comments
 (0)