From: "Jan Beulich" Subject: [PATCH v2 1/2] x86emul: make _PRE_EFLAGS() tolerate first argument being 32-bit Date: Wed, 04 Jan 2017 03:22:36 -0700 Message-ID: <586CDAFC020000780012CE87@prv-mh.provo.novell.com> References: <586CDA52020000780012CE74@prv-mh.provo.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part6C5555FC.1__=" Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cOiiT-0008W9-PE for xen-devel@lists.xenproject.org; Wed, 04 Jan 2017 10:22:45 +0000 In-Reply-To: <586CDA52020000780012CE74@prv-mh.provo.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" To: xen-devel Cc: Andrew Cooper List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part6C5555FC.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline While this may appear to introduce a truncation issue, the high 32 bits get zapped already anyway (early in _PRE_EFLAGS() as well as in _POST_EFLAGS()). Once a subsequent patch switches to use proper 32-bit EFLAGS operands, we'll in fact end up with more correct code, as that zeroing of the upper halves will then go away. Signed-off-by: Jan Beulich --- As this adds an instruction, the question is whether it would be worth forking _PRE_EFLAGS() into two flavors: One dealing with _sav in a register (allowing several instructions to be dropped) and another dealing with it being on the stack (in which case the logic needs to remain as is, since between the first PUSH and the last POP we mustn't access variables possibly living on the stack). --- a/xen/arch/x86/x86_emulate/x86_emulate.c +++ b/xen/arch/x86/x86_emulate/x86_emulate.c @@ -530,7 +530,8 @@ typedef union { "pop %"_tmp"; " \ "orl %"_LO32 _tmp",("_STK"); " \ "popf; " \ -"pop %"_sav"; " +"pop %"_tmp"; " \ +"movl %"_LO32 _tmp",%"_LO32 _sav"; " =20 /* After executing instruction: write-back necessary bits in EFLAGS. */ #define _POST_EFLAGS(_sav, _msk, _tmp) \ --=__Part6C5555FC.1__= Content-Type: text/plain; name="x86emul-pre-eflags.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86emul-pre-eflags.patch" x86emul: make _PRE_EFLAGS() tolerate first argument being 32-bit=0A=0AWhile= this may appear to introduce a truncation issue, the high 32 bits=0Aget = zapped already anyway (early in _PRE_EFLAGS() as well as in=0A_POST_EFLAGS(= )). Once a subsequent patch switches to use proper 32-bit=0AEFLAGS = operands, we'll in fact end up with more correct code, as that=0Azeroing = of the upper halves will then go away.=0A=0ASigned-off-by: Jan Beulich = =0A---=0AAs this adds an instruction, the question is = whether it would be worth=0Aforking _PRE_EFLAGS() into two flavors: One = dealing with _sav in a=0Aregister (allowing several instructions to be = dropped) and another=0Adealing with it being on the stack (in which case = the logic needs to=0Aremain as is, since between the first PUSH and the = last POP we mustn't=0Aaccess variables possibly living on the stack).=0A=0A= --- a/xen/arch/x86/x86_emulate/x86_emulate.c=0A+++ b/xen/arch/x86/x86_emula= te/x86_emulate.c=0A@@ -530,7 +530,8 @@ typedef union {=0A "pop %"_tmp"; " = \=0A "orl %"_LO32 = _tmp",("_STK"); " \=0A "popf; " = \=0A-"pop %"_sav"; "=0A+"pop = %"_tmp"; " \=0A+"movl = %"_LO32 _tmp",%"_LO32 _sav"; "=0A =0A /* After executing instruction: = write-back necessary bits in EFLAGS. */=0A #define _POST_EFLAGS(_sav, = _msk, _tmp) \=0A --=__Part6C5555FC.1__= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KWGVuLWRldmVs IG1haWxpbmcgbGlzdApYZW4tZGV2ZWxAbGlzdHMueGVuLm9yZwpodHRwczovL2xpc3RzLnhlbi5v cmcveGVuLWRldmVsCg== --=__Part6C5555FC.1__=--