Skip to contentSkip to conversation

: Fake emulate Intel perfctr MSRs

PATCH In review Chris Lalancette 1 participant 2 messages May 29, 2008 – Jun 10, 2008

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : Fake emulate Intel perfctr MSRs

Attached is a patch for fake emulating Intel perfctr MSRs, similar to the recent patch to fake emulate the AMD perfctr MSRs. This is needed for a reason similar for the previous patch; older linux guests (in this case, 2.6.9) can attempt to access the MSR's without a fixup section, and injecting a GPF kills the guest. Tested by me on RHEL-4 i386 and x86_64 guests, as well as F-9 guests.

arch/x86/kvm/vmx.c +13 -0
index aaa99ed..f28789e 100644
@@ -29,6 +29,7 @@
 
 #include <asm/io.h>
 #include <asm/desc.h>
+#include <asm/intel_arch_perfmon.h>
 
 #define __ex(x) __kvm_handle_fault_on_reboot(x)
 
@@ -916,6 +917,18 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 data)
 	case MSR_IA32_TIME_STAMP_COUNTER:
 		guest_write_tsc(data);
 		break;
+	case MSR_ARCH_PERFMON_EVENTSEL0:
+	case MSR_ARCH_PERFMON_EVENTSEL1:
+	case MSR_ARCH_PERFMON_PERFCTR0:
+	case MSR_ARCH_PERFMON_PERFCTR1:
+		/*
+		 * Just discard all writes to the performance counters; this
+		 * should keep both older linux and windows 64-bit guests
+		 * happy
+		 */
+		pr_unimpl(vcpu, "unimplemented perfctr wrmsr: 0x%x data 0x%llx\n", msr_index, data);
+
+		break;
 	default:
 		msr = find_msr_entry(vmx, msr_index);
 		if (msr) {
#1 lore raw
Quoted 8 lines · Chris Lalancette

Attached is a patch for fake emulating Intel perfctr MSRs, similar to the recent patch to fake emulate the AMD perfctr MSRs. This is needed for a reason similar for the previous patch; older linux guests (in this case, 2.6.9) can attempt to access the MSR's without a fixup section, and injecting a GPF kills the guest. Tested by me on RHEL-4 i386 and x86_64 guests, as well as F-9 guests.

Avi,
You were probably traveling while I sent this, so ping?

Chris Lalancette