Skip to content

Commit 25462f7

Browse files
Wei Huangbonzini
authored andcommitted
KVM: x86/vPMU: Define kvm_pmu_ops to support vPMU function dispatch
This patch defines a new function pointer struct (kvm_pmu_ops) to support vPMU for both Intel and AMD. The functions pointers defined in this new struct will be linked with Intel and AMD functions later. In the meanwhile the struct that maps from event_sel bits to PERF_TYPE_HARDWARE events is renamed and moved from Intel specific code to kvm_host.h as a common struct. Reviewed-by: Joerg Roedel <[email protected]> Tested-by: Joerg Roedel <[email protected]> Signed-off-by: Wei Huang <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 41aac14 commit 25462f7

File tree

8 files changed

+606
-338
lines changed

8 files changed

+606
-338
lines changed

arch/x86/include/asm/kvm_host.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,8 @@ struct kvm_pmu {
336336
u64 reprogram_pmi;
337337
};
338338

339+
struct kvm_pmu_ops;
340+
339341
enum {
340342
KVM_DEBUGREG_BP_ENABLED = 1,
341343
KVM_DEBUGREG_WONT_EXIT = 2,
@@ -854,6 +856,8 @@ struct kvm_x86_ops {
854856
void (*enable_log_dirty_pt_masked)(struct kvm *kvm,
855857
struct kvm_memory_slot *slot,
856858
gfn_t offset, unsigned long mask);
859+
/* pmu operations of sub-arch */
860+
const struct kvm_pmu_ops *pmu_ops;
857861
};
858862

859863
struct kvm_arch_async_pf {

arch/x86/kvm/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ kvm-$(CONFIG_KVM_ASYNC_PF) += $(KVM)/async_pf.o
1414
kvm-y += x86.o mmu.o emulate.o i8259.o irq.o lapic.o \
1515
i8254.o ioapic.o irq_comm.o cpuid.o pmu.o mtrr.o
1616
kvm-$(CONFIG_KVM_DEVICE_ASSIGNMENT) += assigned-dev.o iommu.o
17-
kvm-intel-y += vmx.o
18-
kvm-amd-y += svm.o
17+
kvm-intel-y += vmx.o pmu_intel.o
18+
kvm-amd-y += svm.o pmu_amd.o
1919

2020
obj-$(CONFIG_KVM) += kvm.o
2121
obj-$(CONFIG_KVM_INTEL) += kvm-intel.o

0 commit comments

Comments
 (0)