[RFC PATCH 45/73] KVM: x86/PVM: Add dummy PMU related callbacks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Lai Jiangshan <jiangshan.ljs@xxxxxxxxxxxx>

Currently, PMU virtualization is not implemented, so dummy PMU related
callbacks are added to make PVM work. In the future, the existing code
in pmu_intel.c and pmu_amd.c will be reused to implement PMU
virtualization for PVM.

Signed-off-by: Lai Jiangshan <jiangshan.ljs@xxxxxxxxxxxx>
Signed-off-by: Hou Wenlong <houwenlong.hwl@xxxxxxxxxxxx>
---
 arch/x86/kvm/pvm/pvm.c | 72 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 72 insertions(+)

diff --git a/arch/x86/kvm/pvm/pvm.c b/arch/x86/kvm/pvm/pvm.c
index f2cd1a1c199d..e6464095d40b 100644
--- a/arch/x86/kvm/pvm/pvm.c
+++ b/arch/x86/kvm/pvm/pvm.c
@@ -21,6 +21,7 @@
 #include "cpuid.h"
 #include "lapic.h"
 #include "mmu.h"
+#include "pmu.h"
 #include "trace.h"
 #include "x86.h"
 #include "pvm.h"
@@ -2701,6 +2702,76 @@ static void hardware_unsetup(void)
 {
 }
 
+//====== start of dummy pmu ===========
+//TODO: split kvm-pmu-intel.ko & kvm-pmu-amd.ko from kvm-intel.ko & kvm-amd.ko.
+static bool dummy_pmu_hw_event_available(struct kvm_pmc *pmc)
+{
+	return true;
+}
+
+static struct kvm_pmc *dummy_pmc_idx_to_pmc(struct kvm_pmu *pmu, int pmc_idx)
+{
+	return NULL;
+}
+
+static struct kvm_pmc *dummy_pmu_rdpmc_ecx_to_pmc(struct kvm_vcpu *vcpu,
+						  unsigned int idx, u64 *mask)
+{
+	return NULL;
+}
+
+static bool dummy_pmu_is_valid_rdpmc_ecx(struct kvm_vcpu *vcpu, unsigned int idx)
+{
+	return false;
+}
+
+static struct kvm_pmc *dummy_pmu_msr_idx_to_pmc(struct kvm_vcpu *vcpu, u32 msr)
+{
+	return NULL;
+}
+
+static bool dummy_pmu_is_valid_msr(struct kvm_vcpu *vcpu, u32 msr)
+{
+	return 0;
+}
+
+static int dummy_pmu_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
+{
+	return 1;
+}
+
+static int dummy_pmu_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
+{
+	return 1;
+}
+
+static void dummy_pmu_refresh(struct kvm_vcpu *vcpu)
+{
+}
+
+static void dummy_pmu_init(struct kvm_vcpu *vcpu)
+{
+}
+
+static void dummy_pmu_reset(struct kvm_vcpu *vcpu)
+{
+}
+
+struct kvm_pmu_ops dummy_pmu_ops = {
+	.hw_event_available = dummy_pmu_hw_event_available,
+	.pmc_idx_to_pmc = dummy_pmc_idx_to_pmc,
+	.rdpmc_ecx_to_pmc = dummy_pmu_rdpmc_ecx_to_pmc,
+	.msr_idx_to_pmc = dummy_pmu_msr_idx_to_pmc,
+	.is_valid_rdpmc_ecx = dummy_pmu_is_valid_rdpmc_ecx,
+	.is_valid_msr = dummy_pmu_is_valid_msr,
+	.get_msr = dummy_pmu_get_msr,
+	.set_msr = dummy_pmu_set_msr,
+	.refresh = dummy_pmu_refresh,
+	.init = dummy_pmu_init,
+	.reset = dummy_pmu_reset,
+};
+//========== end of dummy pmu =============
+
 struct kvm_x86_nested_ops pvm_nested_ops = {};
 
 static struct kvm_x86_ops pvm_x86_ops __initdata = {
@@ -2811,6 +2882,7 @@ static struct kvm_x86_init_ops pvm_init_ops __initdata = {
 	.hardware_setup = hardware_setup,
 
 	.runtime_ops = &pvm_x86_ops,
+	.pmu_ops = &dummy_pmu_ops,
 };
 
 static void pvm_exit(void)
-- 
2.19.1.6.gb485710b





[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux