aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm/kvm_main.c
diff options
context:
space:
mode:
authorAvi Kivity <avi@qumranet.com>2007-09-12 06:21:09 -0400
committerAvi Kivity <avi@qumranet.com>2007-10-13 04:18:28 -0400
commit054b1369679fb97582fc77f25a700d4290ff3e89 (patch)
treefc06afd41830c263f6c068d1bd743ef7fcf9637d /drivers/kvm/kvm_main.c
parentfd2a76086527cbe074b08a8820253228cd919ece (diff)
KVM: Improve emulation failure reporting
Report failed opcodes from all locations. Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm/kvm_main.c')
-rw-r--r--drivers/kvm/kvm_main.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index e17b433152cb..3b046507ebc6 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -1240,25 +1240,25 @@ int emulator_set_dr(struct x86_emulate_ctxt *ctxt, int dr, unsigned long value)
1240 return X86EMUL_CONTINUE; 1240 return X86EMUL_CONTINUE;
1241} 1241}
1242 1242
1243static void report_emulation_failure(struct x86_emulate_ctxt *ctxt) 1243void kvm_report_emulation_failure(struct kvm_vcpu *vcpu, const char *context)
1244{ 1244{
1245 static int reported; 1245 static int reported;
1246 u8 opcodes[4]; 1246 u8 opcodes[4];
1247 unsigned long rip = ctxt->vcpu->rip; 1247 unsigned long rip = vcpu->rip;
1248 unsigned long rip_linear; 1248 unsigned long rip_linear;
1249 1249
1250 rip_linear = rip + get_segment_base(ctxt->vcpu, VCPU_SREG_CS); 1250 rip_linear = rip + get_segment_base(vcpu, VCPU_SREG_CS);
1251 1251
1252 if (reported) 1252 if (reported)
1253 return; 1253 return;
1254 1254
1255 emulator_read_std(rip_linear, (void *)opcodes, 4, ctxt->vcpu); 1255 emulator_read_std(rip_linear, (void *)opcodes, 4, vcpu);
1256 1256
1257 printk(KERN_ERR "emulation failed but !mmio_needed?" 1257 printk(KERN_ERR "emulation failed (%s) rip %lx %02x %02x %02x %02x\n",
1258 " rip %lx %02x %02x %02x %02x\n", 1258 context, rip, opcodes[0], opcodes[1], opcodes[2], opcodes[3]);
1259 rip, opcodes[0], opcodes[1], opcodes[2], opcodes[3]);
1260 reported = 1; 1259 reported = 1;
1261} 1260}
1261EXPORT_SYMBOL_GPL(kvm_report_emulation_failure);
1262 1262
1263struct x86_emulate_ops emulate_ops = { 1263struct x86_emulate_ops emulate_ops = {
1264 .read_std = emulator_read_std, 1264 .read_std = emulator_read_std,
@@ -1323,7 +1323,7 @@ int emulate_instruction(struct kvm_vcpu *vcpu,
1323 if (kvm_mmu_unprotect_page_virt(vcpu, cr2)) 1323 if (kvm_mmu_unprotect_page_virt(vcpu, cr2))
1324 return EMULATE_DONE; 1324 return EMULATE_DONE;
1325 if (!vcpu->mmio_needed) { 1325 if (!vcpu->mmio_needed) {
1326 report_emulation_failure(&emulate_ctxt); 1326 kvm_report_emulation_failure(vcpu, "mmio");
1327 return EMULATE_FAIL; 1327 return EMULATE_FAIL;
1328 } 1328 }
1329 return EMULATE_DO_MMIO; 1329 return EMULATE_DO_MMIO;