aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/svm.c
diff options
context:
space:
mode:
authorChris Lalancette <clalance@redhat.com>2008-05-05 13:05:16 -0400
committerAvi Kivity <avi@qumranet.com>2008-07-20 05:40:49 -0400
commit14ae51b6c068ef7ab52dc2d53fe226e6189f2ab2 (patch)
tree1abe5475c427980663865a0231198c7a20afe1dc /arch/x86/kvm/svm.c
parentf697554515b06e8d7264f316b25e6da943407142 (diff)
KVM: SVM: Fake MSR_K7 performance counters
Attached is a patch that fixes a guest crash when booting older Linux kernels. The problem stems from the fact that we are currently emulating MSR_K7_EVNTSEL[0-3], but not emulating MSR_K7_PERFCTR[0-3]. Because of this, setup_k7_watchdog() in the Linux kernel receives a GPF when it attempts to write into MSR_K7_PERFCTR, which causes an OOPs. The patch fixes it by just "fake" emulating the appropriate MSRs, throwing away the data in the process. This causes the NMI watchdog to not actually work, but it's not such a big deal in a virtualized environment. When we get a write to one of these counters, we printk_ratelimit() a warning. I decided to print it out for all writes, even if the data is 0; it doesn't seem to make sense to me to special case when data == 0. Tested by myself on a RHEL-4 guest, and Joerg Roedel on a Windows XP 64-bit guest. Signed-off-by: Chris Lalancette <clalance@redhat.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'arch/x86/kvm/svm.c')
-rw-r--r--arch/x86/kvm/svm.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 218949cce1a0..992ab7115871 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -1312,16 +1312,19 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, unsigned ecx, u64 data)
1312 case MSR_K7_EVNTSEL1: 1312 case MSR_K7_EVNTSEL1:
1313 case MSR_K7_EVNTSEL2: 1313 case MSR_K7_EVNTSEL2:
1314 case MSR_K7_EVNTSEL3: 1314 case MSR_K7_EVNTSEL3:
1315 case MSR_K7_PERFCTR0:
1316 case MSR_K7_PERFCTR1:
1317 case MSR_K7_PERFCTR2:
1318 case MSR_K7_PERFCTR3:
1315 /* 1319 /*
1316 * only support writing 0 to the performance counters for now 1320 * Just discard all writes to the performance counters; this
1317 * to make Windows happy. Should be replaced by a real 1321 * should keep both older linux and windows 64-bit guests
1318 * performance counter emulation later. 1322 * happy
1319 */ 1323 */
1320 if (data != 0) 1324 pr_unimpl(vcpu, "unimplemented perfctr wrmsr: 0x%x data 0x%llx\n", ecx, data);
1321 goto unhandled; 1325
1322 break; 1326 break;
1323 default: 1327 default:
1324 unhandled:
1325 return kvm_set_msr_common(vcpu, ecx, data); 1328 return kvm_set_msr_common(vcpu, ecx, data);
1326 } 1329 }
1327 return 0; 1330 return 0;