All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petre Ovidiu PIRCALABU <ppircalabu@bitdefender.com>
To: "JBeulich@suse.com" <JBeulich@suse.com>
Cc: "tim@xen.org" <tim@xen.org>,
	"kevin.tian@intel.com" <kevin.tian@intel.com>,
	"sstabellini@kernel.org" <sstabellini@kernel.org>,
	"wei.liu2@citrix.com" <wei.liu2@citrix.com>,
	"rcojocaru@bitdefender.com" <rcojocaru@bitdefender.com>,
	"George.Dunlap@eu.citrix.com" <George.Dunlap@eu.citrix.com>,
	"andrew.cooper3@citrix.com" <andrew.cooper3@citrix.com>,
	"ian.jackson@eu.citrix.com" <ian.jackson@eu.citrix.com>,
	"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>,
	"paul.durrant@citrix.com" <paul.durrant@citrix.com>,
	"tamas@tklengyel.com" <tamas@tklengyel.com>,
	"jun.nakajima@intel.com" <jun.nakajima@intel.com>
Subject: Re: [PATCH v12 1/4] x86emul: New return code for unimplemented instruction
Date: Mon, 25 Sep 2017 09:16:24 +0000	[thread overview]
Message-ID: <1506330984.2094.11.camel@bitdefender.com> (raw)
In-Reply-To: <59C3CFE0020000780017DF59@prv-mh.provo.novell.com>

On Jo, 2017-09-21 at 06:42 -0600, Jan Beulich wrote:
> > 
> > > 
> > > > 
> > > > On 21.09.17 at 07:12, <ppircalabu@bitdefender.com> wrote:
> > --- a/xen/arch/x86/x86_emulate/x86_emulate.c
> > +++ b/xen/arch/x86/x86_emulate/x86_emulate.c
> > @@ -6195,7 +6196,7 @@ x86_emulate(
> >                  /* vpsll{w,d} $imm8,{x,y}mm,{x,y}mm */
> >              break;
> >          default:
> > -            goto cannot_emulate;
> > +            goto unimplemented_insn;
> I would really appreciate if you were a little more patient and
> waited
> for replies to earlier review threads before sending a new version.
> As said on the v11 thread, this ought to be "unrecognized".
Thank-you very much for clearing this out. I will change the return
value to "unrecognized" in the next patchset iteration.

> 
> > 
> > @@ -6243,7 +6244,8 @@ x86_emulate(
> >          case 6: /* psllq $imm8,mm */
> >              goto simd_0f_shift_imm;
> >          }
> > -        goto cannot_emulate;
> > +        rc = X86EMUL_UNRECOGNIZED;
> > +        goto done;
> I think it would read better if we had an "unrecognized_insn"
> label just like now we gain an "unimplemented_insn" one. Whether
> the _insn suffixes are really useful is another question.

The best place to add this label is, in my opinion, at the end of the
"default" label of the "switch ( ctxt->opcode )" statement in
x86_emulate. This will make sure the current instruction flow will not
be altered.
e.g.:
     case X86EMUL_OPC_XOP(0a, 0x10): /* bextr imm,r/m,r */
     {
@@ -7750,6 +7742,9 @@ x86_emulate(
     unimplemented_insn:
         rc = X86EMUL_UNIMPLEMENTED;
         goto done;
+    unrecognized_insn:
+        rc = X86EMUL_UNRECOGNIZED;
+        goto done;
     }
Do you find this approach OK?
> 
> > 
> > --- a/xen/arch/x86/x86_emulate/x86_emulate.h
> > +++ b/xen/arch/x86/x86_emulate/x86_emulate.h
> > @@ -133,6 +133,19 @@ struct x86_emul_fpu_aux {
> >    * Undefined behavior when used anywhere else.
> >    */
> >  #define X86EMUL_DONE           4
> > + /*
> > +  * Current instruction is not implemented by the emulator.
> > +  * This value should only be returned by the core emulator when a
> > valid
> > +  * opcode is found but the execution logic for that instruction
> > is missing.
> > +  * It should NOT be returned by any of the x86_emulate_ops
> > callbacks.
> > +  */
> > +#define X86EMUL_UNIMPLEMENTED  5
> > + /*
> > +  * The current instruction's opcode is not valid.
> > +  * If this error code is returned by a function, an #UD trap
> > should be
> > +  * raised by the final consumer of it.
> > + */
> > +#define X86EMUL_UNRECOGNIZED   X86EMUL_UNIMPLEMENTED
> But with this aliasing of values the comment still is somewhat off.

Do you think adding a "TODO:" comment can make things more clear?
e.g.:
   * The current instruction's opcode is not valid.
   * If this error code is returned by a function, an #UD trap should e
   * raised by the final consumer of it.
+  *
+  * TODO: For the moment X86EMUL_UNRECOGNIZED and 86EMUL_UNIMPLEMENTED
+  * can be used interchangeably.
  */

Many thanks for your support,
//Petre
> 
> Jan
> 
> 
> ________________________
> This email was scanned by Bitdefender
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  reply	other threads:[~2017-09-25  9:16 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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=1506330984.2094.11.camel@bitdefender.com \
    --to=ppircalabu@bitdefender.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jun.nakajima@intel.com \
    --cc=kevin.tian@intel.com \
    --cc=paul.durrant@citrix.com \
    --cc=rcojocaru@bitdefender.com \
    --cc=sstabellini@kernel.org \
    --cc=tamas@tklengyel.com \
    --cc=tim@xen.org \
    --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.