x86emul: Add return code information to error messages

- print the return code of the last failed emulator operation
in hvm_dump_emulation_state.
- print the return code in sh_page_fault (SHADOW_PRINTK) to make the
distiction between X86EMUL_UNHANDLEABLE and X86EMUL_UNIMPLEMENTED.

Signed-off-by: Petre Pircalabu <ppircalabu@bitdefender.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
This commit is contained in:
Petre Pircalabu authored and George Dunlap committed 2017-10-02 16:04:55 +01:00
1 parent 63e49e966f
commit 1c1c39e210
5 files changed
+13 -12

No files matched your search

+7 -6
View File
@@ -2056,7 +2056,7 @@ int hvm_emulate_one_mmio(unsigned long mfn, unsigned long gla)
{
case X86EMUL_UNHANDLEABLE:
case X86EMUL_UNIMPLEMENTED:
hvm_dump_emulation_state(XENLOG_G_WARNING, "MMCFG", &ctxt);
hvm_dump_emulation_state(XENLOG_G_WARNING, "MMCFG", &ctxt, rc);
break;
case X86EMUL_EXCEPTION:
hvm_inject_event(&ctxt.ctxt.event);
@@ -2115,7 +2115,7 @@ void hvm_emulate_one_vm_event(enum emul_kind kind, unsigned int trapnr,
return;
case X86EMUL_UNIMPLEMENTED:
case X86EMUL_UNHANDLEABLE:
hvm_dump_emulation_state(XENLOG_G_DEBUG, "Mem event", &ctx);
hvm_dump_emulation_state(XENLOG_G_DEBUG, "Mem event", &ctx, rc);
hvm_inject_hw_exception(trapnr, errcode);
break;
case X86EMUL_EXCEPTION:
@@ -2243,16 +2243,17 @@ static const char *guest_x86_mode_to_str(int mode)
}
void hvm_dump_emulation_state(const char *loglvl, const char *prefix,
struct hvm_emulate_ctxt *hvmemul_ctxt)
struct hvm_emulate_ctxt *hvmemul_ctxt, int rc)
{
struct vcpu *curr = current;
const char *mode_str = guest_x86_mode_to_str(hvm_guest_x86_mode(curr));
const struct segment_register *cs =
hvmemul_get_seg_reg(x86_seg_cs, hvmemul_ctxt);
printk("%s%s emulation failed: %pv %s @ %04x:%08lx -> %*ph\n",
loglvl, prefix, curr, mode_str, cs->sel, hvmemul_ctxt->insn_buf_eip,
hvmemul_ctxt->insn_buf_bytes, hvmemul_ctxt->insn_buf);
printk("%s%s emulation failed (%d): %pv %s @ %04x:%08lx -> %*ph\n",
loglvl, prefix, rc, curr, mode_str, cs->sel,
hvmemul_ctxt->insn_buf_eip, hvmemul_ctxt->insn_buf_bytes,
hvmemul_ctxt->insn_buf);
}
/*
+2 -2
View File
@@ -96,11 +96,11 @@ bool hvm_emulate_one_insn(hvm_emulate_validate_t *validate, const char *descr)
switch ( rc )
{
case X86EMUL_UNHANDLEABLE:
hvm_dump_emulation_state(XENLOG_G_WARNING, descr, &ctxt);
hvm_dump_emulation_state(XENLOG_G_WARNING, descr, &ctxt, rc);
return false;
case X86EMUL_UNRECOGNIZED:
hvm_dump_emulation_state(XENLOG_G_WARNING, descr, &ctxt);
hvm_dump_emulation_state(XENLOG_G_WARNING, descr, &ctxt, rc);
hvm_inject_hw_exception(TRAP_invalid_op, X86_EVENT_NO_EC);
break;
+1 -1
View File
@@ -147,7 +147,7 @@ void vmx_realmode_emulate_one(struct hvm_emulate_ctxt *hvmemul_ctxt)
return;
fail:
hvm_dump_emulation_state(XENLOG_G_ERR, "Real-mode", hvmemul_ctxt);
hvm_dump_emulation_state(XENLOG_G_ERR, "Real-mode", hvmemul_ctxt, rc);
domain_crash(curr->domain);
}
+2 -2
View File
@@ -3498,8 +3498,8 @@ static int sh_page_fault(struct vcpu *v,
v->arch.paging.last_write_emul_ok = 0;
}
#endif
SHADOW_PRINTK("emulator failure, unshadowing mfn %#lx\n",
mfn_x(gmfn));
SHADOW_PRINTK("emulator failure (rc=%d), unshadowing mfn %#lx\n",
r, mfn_x(gmfn));
/* If this is actually a page table, then we have a bug, and need
* to support more operations in the emulator. More likely,
* though, this is a hint that this page should not be shadowed. */
+1 -1
View File
@@ -92,7 +92,7 @@ int hvmemul_do_pio_buffer(uint16_t port,
void *buffer);
void hvm_dump_emulation_state(const char *loglvl, const char *prefix,
struct hvm_emulate_ctxt *hvmemul_ctxt);
struct hvm_emulate_ctxt *hvmemul_ctxt, int rc);
#endif /* __ASM_X86_HVM_EMULATE_H__ */
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.