Skip to content

Commit 474a5bb

Browse files
Wei Huangbonzini
authored andcommitted
KVM: x86/vPMU: introduce pmu.h header
This will be used for private function used by AMD- and Intel-specific PMU implementations. Signed-off-by: Wei Huang <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent c6702c9 commit 474a5bb

File tree

5 files changed

+30
-18
lines changed

5 files changed

+30
-18
lines changed

arch/x86/include/asm/kvm_host.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,18 +1195,6 @@ void kvm_complete_insn_gp(struct kvm_vcpu *vcpu, int err);
11951195

11961196
int kvm_is_in_guest(void);
11971197

1198-
void kvm_pmu_init(struct kvm_vcpu *vcpu);
1199-
void kvm_pmu_destroy(struct kvm_vcpu *vcpu);
1200-
void kvm_pmu_reset(struct kvm_vcpu *vcpu);
1201-
void kvm_pmu_refresh(struct kvm_vcpu *vcpu);
1202-
bool kvm_pmu_is_valid_msr(struct kvm_vcpu *vcpu, u32 msr);
1203-
int kvm_pmu_get_msr(struct kvm_vcpu *vcpu, u32 msr, u64 *data);
1204-
int kvm_pmu_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info);
1205-
int kvm_pmu_is_valid_msr_idx(struct kvm_vcpu *vcpu, unsigned pmc);
1206-
int kvm_pmu_rdpmc(struct kvm_vcpu *vcpu, unsigned pmc, u64 *data);
1207-
void kvm_pmu_handle_event(struct kvm_vcpu *vcpu);
1208-
void kvm_pmu_deliver_pmi(struct kvm_vcpu *vcpu);
1209-
12101198
int __x86_set_memory_region(struct kvm *kvm,
12111199
const struct kvm_userspace_memory_region *mem);
12121200
int x86_set_memory_region(struct kvm *kvm,

arch/x86/kvm/cpuid.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "lapic.h"
2525
#include "mmu.h"
2626
#include "trace.h"
27+
#include "pmu.h"
2728

2829
static u32 xstate_required_size(u64 xstate_bv, bool compacted)
2930
{

arch/x86/kvm/pmu.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,9 @@
1919
#include "x86.h"
2020
#include "cpuid.h"
2121
#include "lapic.h"
22+
#include "pmu.h"
2223

23-
static struct kvm_arch_event_perf_mapping {
24-
u8 eventsel;
25-
u8 unit_mask;
26-
unsigned event_type;
27-
bool inexact;
28-
} arch_events[] = {
24+
static struct kvm_event_hw_type_mapping arch_events[] = {
2925
/* Index must match CPUID 0x0A.EBX bit vector */
3026
[0] = { 0x3c, 0x00, PERF_COUNT_HW_CPU_CYCLES },
3127
[1] = { 0xc0, 0x00, PERF_COUNT_HW_INSTRUCTIONS },

arch/x86/kvm/pmu.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#ifndef __KVM_X86_PMU_H
2+
#define __KVM_X86_PMU_H
3+
4+
#define vcpu_to_pmu(vcpu) (&(vcpu)->arch.pmu)
5+
#define pmu_to_vcpu(pmu) (container_of((pmu), struct kvm_vcpu, arch.pmu))
6+
#define pmc_to_pmu(pmc) (&(pmc)->vcpu->arch.pmu)
7+
8+
struct kvm_event_hw_type_mapping {
9+
u8 eventsel;
10+
u8 unit_mask;
11+
unsigned event_type;
12+
};
13+
14+
void kvm_pmu_deliver_pmi(struct kvm_vcpu *vcpu);
15+
void kvm_pmu_handle_event(struct kvm_vcpu *vcpu);
16+
int kvm_pmu_rdpmc(struct kvm_vcpu *vcpu, unsigned pmc, u64 *data);
17+
int kvm_pmu_is_valid_msr_idx(struct kvm_vcpu *vcpu, unsigned idx);
18+
bool kvm_pmu_is_valid_msr(struct kvm_vcpu *vcpu, u32 msr);
19+
int kvm_pmu_get_msr(struct kvm_vcpu *vcpu, u32 msr, u64 *data);
20+
int kvm_pmu_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info);
21+
void kvm_pmu_refresh(struct kvm_vcpu *vcpu);
22+
void kvm_pmu_reset(struct kvm_vcpu *vcpu);
23+
void kvm_pmu_init(struct kvm_vcpu *vcpu);
24+
void kvm_pmu_destroy(struct kvm_vcpu *vcpu);
25+
26+
#endif /* __KVM_X86_PMU_H */

arch/x86/kvm/x86.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "x86.h"
2929
#include "cpuid.h"
3030
#include "assigned-dev.h"
31+
#include "pmu.h"
3132

3233
#include <linux/clocksource.h>
3334
#include <linux/interrupt.h>

0 commit comments

Comments
 (0)