All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v12 0/4] Notify monitor when emulating an unimplemented instruction
@ 2017-09-21  5:12 Petre Pircalabu
  2017-09-21  5:12 ` [PATCH v12 1/4] x86emul: New return code for " Petre Pircalabu
                   ` (3 more replies)
  0 siblings, 4 replies; 15+ messages in thread
From: Petre Pircalabu @ 2017-09-21  5:12 UTC (permalink / raw)
  To: xen-devel
  Cc: Petre Pircalabu, kevin.tian, sstabellini, wei.liu2, jun.nakajima,
	rcojocaru, George.Dunlap, andrew.cooper3, ian.jackson, tim,
	paul.durrant, tamas, jbeulich

This patchset implements a mechanism which allows XEN to send first an event
if the emulator encountered an unsupported instruction.
The monitor application can choose to mitigate the error, for example to singlestep
the instruction using the real processor and then resume execution of the normal
instruction flow.

This feature was tested using a modified version of XTF:
https://github.com/petrepircalabu/xen-test-framework/tree/emul_unimpl

---
Changed since v1:
  * Removed the emulation kind check when calling hvm_inject_hw_exception

Changed since v2:
  * Removed a file added by mistake

Changed since v3:
  * Removed extra stray line
  * Added the _enabled suffix to the emul_unhandleable monitor option

Changed since v4
  * Fixed return expression of hvm_monitor_emul_unhandleable handle
  monitor_traps failures.
  * Removed stray parantheses.

Changed since v5:
  * Removed unnecessary "else" when calling hvm_monitor_emul_unhandleable.
  * Added extra line in arch_monitor_domctl_event.

Changed since v6:
  * add the distinction between unimplemented instructions and emulation failures.
  * changed "emul_unhandleable" event name to "emul_unimplemented"

Changed since v7:
  * Add "fall-through" comments to the switch statements (coverity)
  * Added X86EMUL_UNIMPLEMENTED to X86EMUL_UNHANDLEABLE checks the in functions
  referencing x86_emulate.
  * Improved comment describing X86EMUL_UNIMPLEMENTED.

Changed since v8:
  * Removed unnecessary "fall-through" comments.
  * Added check for X86EMUL_UNIMPLEMENTED in hvm_ud_intercept.
  * add a new label 'unimplemented_insn' to accomodate the existing jumps to
  'cannot_emulate' (e.g. invoke_stub)

Changed since v9:
  * Added detailed description in the patch comment regarding the usage (and lack of it) 
  of the new X86EMUL_UNIMPLEMENTED return code.
  * removed 'cannot_emulate' label.
  * added local vimrc files to the gitignore list.

Changed since v10:
  * Added asserts to make sure the return code cannot be X86EMUL_UNIMPLEMENTED.
  * Added new return code (X86EMUL_UNRECOGNIZED) to be used when trying
  to emulate an instruction with an invalid opcode.
  * Added emulation return code information to error messages.
  * Raise #UD when emulating an unimplemented instruction instead of just crash the domain

Changed since v11:
    * Fixed double negative comment.
    * Move assertion into the switch and use ASSERT_UNREACHABLE() when
    applicable.
    * Changed the description of X86EMUL_UNIMPLEMENTED / X86EMUL_UNRECOGNIZED
    to reflect the differences between those 2 return codes.
    * Changed the returned value to X86EMUL_UNRECOGNIZED in some cases (a detailed list is
    provided in the patch description)
    * Removed "rc=" from the error message.
    * Check for X86EMUL_UNRECOGNIZED instead of X86EMUL_UNIMPLEMENTED when generating an
    Invalid Opcode trap


Petre Pircalabu (4):
  x86emul: New return code for unimplemented instruction
  x86emul: Add return code information to error messages
  x86/monitor: Notify monitor if an emulation fails.
  x86emul: Raise #UD when emulating an unrecognized instruction.

 tools/libxc/include/xenctrl.h          |  2 ++
 tools/libxc/xc_monitor.c               | 14 +++++++++
 xen/arch/x86/hvm/emulate.c             | 30 ++++++++++++++++----
 xen/arch/x86/hvm/hvm.c                 |  1 +
 xen/arch/x86/hvm/io.c                  |  7 ++++-
 xen/arch/x86/hvm/monitor.c             | 17 +++++++++++
 xen/arch/x86/hvm/vmx/realmode.c        | 11 ++++++-
 xen/arch/x86/mm/shadow/multi.c         |  6 ++--
 xen/arch/x86/monitor.c                 | 13 +++++++++
 xen/arch/x86/x86_emulate/x86_emulate.c | 52 ++++++++++++++++++++--------------
 xen/arch/x86/x86_emulate/x86_emulate.h | 13 +++++++++
 xen/include/asm-x86/domain.h           |  1 +
 xen/include/asm-x86/hvm/emulate.h      |  2 +-
 xen/include/asm-x86/hvm/monitor.h      |  1 +
 xen/include/asm-x86/monitor.h          |  3 +-
 xen/include/public/domctl.h            |  1 +
 xen/include/public/vm_event.h          |  2 ++
 17 files changed, 142 insertions(+), 34 deletions(-)

-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2017-09-25 10:36 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-21  5:12 [PATCH v12 0/4] Notify monitor when emulating an unimplemented instruction Petre Pircalabu
2017-09-21  5:12 ` [PATCH v12 1/4] x86emul: New return code for " Petre Pircalabu
2017-09-21  8:53   ` Paul Durrant
2017-09-23 18:56     ` Petre Ovidiu PIRCALABU
2017-09-25  7:54       ` Paul Durrant
2017-09-21 12:42   ` Jan Beulich
2017-09-25  9:16     ` Petre Ovidiu PIRCALABU
2017-09-25 10:36       ` Jan Beulich
2017-09-22  9:10   ` Jan Beulich
2017-09-21  5:12 ` [PATCH v12 2/4] x86emul: Add return code information to error messages Petre Pircalabu
2017-09-21  5:12 ` [PATCH v12 3/4] x86/monitor: Notify monitor if an emulation fails Petre Pircalabu
2017-09-21  5:12 ` [PATCH v12 4/4] x86emul: Raise #UD when emulating an unrecognized instruction Petre Pircalabu
2017-09-21  8:57   ` Paul Durrant
2017-09-21 12:44     ` Jan Beulich
2017-09-25  6:22       ` Petre Ovidiu PIRCALABU

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.