]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
KVM: x86/vPMU: introduce pmu.h header
authorWei Huang <wehuang@redhat.com>
Fri, 19 Jun 2015 11:54:23 +0000 (13:54 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 19 Jun 2015 15:16:29 +0000 (17:16 +0200)
This will be used for private function used by AMD- and Intel-specific
PMU implementations.

Signed-off-by: Wei Huang <wei@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/cpuid.c
arch/x86/kvm/pmu.c
arch/x86/kvm/pmu.h [new file with mode: 0644]
arch/x86/kvm/x86.c

index d92d7edc016b186a680bbb8f209241c2bbc0e032..534dfa324e3521155bab53e44bd5e8e664a0486c 100644 (file)
@@ -1195,18 +1195,6 @@ void kvm_complete_insn_gp(struct kvm_vcpu *vcpu, int err);
 
 int kvm_is_in_guest(void);
 
-void kvm_pmu_init(struct kvm_vcpu *vcpu);
-void kvm_pmu_destroy(struct kvm_vcpu *vcpu);
-void kvm_pmu_reset(struct kvm_vcpu *vcpu);
-void kvm_pmu_refresh(struct kvm_vcpu *vcpu);
-bool kvm_pmu_is_valid_msr(struct kvm_vcpu *vcpu, u32 msr);
-int kvm_pmu_get_msr(struct kvm_vcpu *vcpu, u32 msr, u64 *data);
-int kvm_pmu_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info);
-int kvm_pmu_is_valid_msr_idx(struct kvm_vcpu *vcpu, unsigned pmc);
-int kvm_pmu_rdpmc(struct kvm_vcpu *vcpu, unsigned pmc, u64 *data);
-void kvm_pmu_handle_event(struct kvm_vcpu *vcpu);
-void kvm_pmu_deliver_pmi(struct kvm_vcpu *vcpu);
-
 int __x86_set_memory_region(struct kvm *kvm,
                            const struct kvm_userspace_memory_region *mem);
 int x86_set_memory_region(struct kvm *kvm,
index 9d69f76aa0fa0f2155632b9349f866e1a2f429b4..a64cc76ea92f2af2ba24f9a666602ad5bee0daac 100644 (file)
@@ -24,6 +24,7 @@
 #include "lapic.h"
 #include "mmu.h"
 #include "trace.h"
+#include "pmu.h"
 
 static u32 xstate_required_size(u64 xstate_bv, bool compacted)
 {
index d6a4506f62a869876e69d26ea56ba6c5ab15fcaa..3d2990207be2e66026982c324d35f44e2fcd67c7 100644 (file)
 #include "x86.h"
 #include "cpuid.h"
 #include "lapic.h"
+#include "pmu.h"
 
-static struct kvm_arch_event_perf_mapping {
-       u8 eventsel;
-       u8 unit_mask;
-       unsigned event_type;
-       bool inexact;
-} arch_events[] = {
+static struct kvm_event_hw_type_mapping arch_events[] = {
        /* Index must match CPUID 0x0A.EBX bit vector */
        [0] = { 0x3c, 0x00, PERF_COUNT_HW_CPU_CYCLES },
        [1] = { 0xc0, 0x00, PERF_COUNT_HW_INSTRUCTIONS },
diff --git a/arch/x86/kvm/pmu.h b/arch/x86/kvm/pmu.h
new file mode 100644 (file)
index 0000000..19bf017
--- /dev/null
@@ -0,0 +1,26 @@
+#ifndef __KVM_X86_PMU_H
+#define __KVM_X86_PMU_H
+
+#define vcpu_to_pmu(vcpu) (&(vcpu)->arch.pmu)
+#define pmu_to_vcpu(pmu)  (container_of((pmu), struct kvm_vcpu, arch.pmu))
+#define pmc_to_pmu(pmc)   (&(pmc)->vcpu->arch.pmu)
+
+struct kvm_event_hw_type_mapping {
+       u8 eventsel;
+       u8 unit_mask;
+       unsigned event_type;
+};
+
+void kvm_pmu_deliver_pmi(struct kvm_vcpu *vcpu);
+void kvm_pmu_handle_event(struct kvm_vcpu *vcpu);
+int kvm_pmu_rdpmc(struct kvm_vcpu *vcpu, unsigned pmc, u64 *data);
+int kvm_pmu_is_valid_msr_idx(struct kvm_vcpu *vcpu, unsigned idx);
+bool kvm_pmu_is_valid_msr(struct kvm_vcpu *vcpu, u32 msr);
+int kvm_pmu_get_msr(struct kvm_vcpu *vcpu, u32 msr, u64 *data);
+int kvm_pmu_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info);
+void kvm_pmu_refresh(struct kvm_vcpu *vcpu);
+void kvm_pmu_reset(struct kvm_vcpu *vcpu);
+void kvm_pmu_init(struct kvm_vcpu *vcpu);
+void kvm_pmu_destroy(struct kvm_vcpu *vcpu);
+
+#endif /* __KVM_X86_PMU_H */
index c34b52c828ea0c0ad4b1b7e91277601947d1f8ad..c386f0bd183060df3a7865fdff54000b161af968 100644 (file)
@@ -28,6 +28,7 @@
 #include "x86.h"
 #include "cpuid.h"
 #include "assigned-dev.h"
+#include "pmu.h"
 
 #include <linux/clocksource.h>
 #include <linux/interrupt.h>