From: Petre Ovidiu PIRCALABU <ppircalabu@bitdefender.com>
To: "tamas@tklengyel.com" <tamas@tklengyel.com>
Cc: "wei.liu2@citrix.com" <wei.liu2@citrix.com>,
"ian.jackson@eu.citrix.com" <ian.jackson@eu.citrix.com>,
"rcojocaru@bitdefender.com" <rcojocaru@bitdefender.com>,
"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Subject: Re: [PATCH] x86/monitor: Notify monitor if an emulation fails.
Date: Tue, 11 Jul 2017 14:47:31 +0000 [thread overview]
Message-ID: <1499784451.7000.1.camel@bitdefender.com> (raw)
In-Reply-To: <CABfawhnFFyb2+Q3ckwC+gbnHSiWN_KnKVNS6AFVLH0Nz-1s=gw@mail.gmail.com>
On Lu, 2017-07-10 at 12:30 -0600, Tamas K Lengyel wrote:
> On Mon, Jul 10, 2017 at 11:07 AM, Petre Pircalabu
> <ppircalabu@bitdefender.com> 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@bitdefender.com>
> > ---
> > 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
>
> ________________________
> This email was scanned by Bitdefender
Hi Tamas,
I have checked with Razvan and this condition is no longer necessary.
I will remove it and send a v2.
Many thanks,
Petre
________________________
This email was scanned by Bitdefender
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
prev parent reply other threads:[~2017-07-11 14:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-10 17:07 [PATCH] x86/monitor: Notify monitor if an emulation fails Petre Pircalabu
2017-07-10 18:30 ` Tamas K Lengyel
2017-07-11 14:47 ` Petre Ovidiu PIRCALABU [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1499784451.7000.1.camel@bitdefender.com \
--to=ppircalabu@bitdefender.com \
--cc=ian.jackson@eu.citrix.com \
--cc=rcojocaru@bitdefender.com \
--cc=tamas@tklengyel.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.