[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] x86/monitor: Notify monitor if an emulation fails.



On Mon, Jul 10, 2017 at 11:07 AM, Petre Pircalabu
<ppircalabu@xxxxxxxxxxxxxxx> wrote:
> If case of a vm_event with the emulate_flags set, if the instruction
> cannot be emulated, the monitor should be notified instead of directly
> injecting a hw exception.
> This behavior can be used to re-execute an instruction not supported by
> the emulator using the real processor (e.g. altp2m) instead of just
> crashing.
>
> Signed-off-by: Petre Pircalabu <ppircalabu@xxxxxxxxxxxxxxx>
> ---
>  tools/libxc/include/xenctrl.h     |  2 ++
>  tools/libxc/xc_monitor.c          | 14 ++++++++++++++
>  xen/arch/x86/hvm/emulate.c        |  5 ++++-
>  xen/arch/x86/hvm/monitor.c        | 19 +++++++++++++++++++
>  xen/arch/x86/monitor.c            | 12 ++++++++++++
>  xen/include/asm-x86/domain.h      |  1 +
>  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 ++
>  10 files changed, 58 insertions(+), 2 deletions(-)
>
> diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
> index c51bb3b..8deb5ac 100644
> --- a/tools/libxc/include/xenctrl.h
> +++ b/tools/libxc/include/xenctrl.h
> @@ -2029,6 +2029,8 @@ int xc_monitor_debug_exceptions(xc_interface *xch, 
> domid_t domain_id,
>  int xc_monitor_cpuid(xc_interface *xch, domid_t domain_id, bool enable);
>  int xc_monitor_privileged_call(xc_interface *xch, domid_t domain_id,
>                                 bool enable);
> +int xc_monitor_emul_unhandleable(xc_interface *xch, domid_t domain_id,
> +                                 bool enable);
>  /**
>   * This function enables / disables emulation for each REP for a
>   * REP-compatible instruction.
> diff --git a/tools/libxc/xc_monitor.c b/tools/libxc/xc_monitor.c
> index b44ce93..8e72c6c 100644
> --- a/tools/libxc/xc_monitor.c
> +++ b/tools/libxc/xc_monitor.c
> @@ -216,6 +216,20 @@ int xc_monitor_privileged_call(xc_interface *xch, 
> domid_t domain_id,
>      return do_domctl(xch, &domctl);
>  }
>
> +int xc_monitor_emul_unhandleable(xc_interface *xch, domid_t domain_id,
> +                                 bool enable)
> +{
> +    DECLARE_DOMCTL;
> +
> +    domctl.cmd = XEN_DOMCTL_monitor_op;
> +    domctl.domain = domain_id;
> +    domctl.u.monitor_op.op = enable ? XEN_DOMCTL_MONITOR_OP_ENABLE
> +                                    : XEN_DOMCTL_MONITOR_OP_DISABLE;
> +    domctl.u.monitor_op.event = XEN_DOMCTL_MONITOR_EVENT_EMUL_UNHANDLEABLE;
> +
> +    return do_domctl(xch, &domctl);
> +}
> +
>  /*
>   * Local variables:
>   * mode: C
> diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c
> index e97aa69..083a38a 100644
> --- a/xen/arch/x86/hvm/emulate.c
> +++ b/xen/arch/x86/hvm/emulate.c
> @@ -14,12 +14,14 @@
>  #include <xen/sched.h>
>  #include <xen/paging.h>
>  #include <xen/trace.h>
> +#include <xen/vm_event.h>
>  #include <asm/event.h>
>  #include <asm/i387.h>
>  #include <asm/xstate.h>
>  #include <asm/hvm/emulate.h>
>  #include <asm/hvm/hvm.h>
>  #include <asm/hvm/ioreq.h>
> +#include <asm/hvm/monitor.h>
>  #include <asm/hvm/trace.h>
>  #include <asm/hvm/support.h>
>  #include <asm/hvm/svm/svm.h>
> @@ -2101,7 +2103,8 @@ void hvm_emulate_one_vm_event(enum emul_kind kind, 
> unsigned int trapnr,
>          return;
>      case X86EMUL_UNHANDLEABLE:
>          hvm_dump_emulation_state(XENLOG_G_DEBUG, "Mem event", &ctx);
> -        hvm_inject_hw_exception(trapnr, errcode);
> +        if ( (kind != EMUL_KIND_NORMAL) || !hvm_monitor_emul_unhandleable() )

Why is there this check for !EMUL_KIND_NORMAL?

Tamas

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

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.