From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Lively Subject: [PATCH] x86_emulate fix Date: Fri, 19 Oct 2007 11:43:38 -0400 Message-ID: <4718D0AA.7010201@virtualiron.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------070402020507060403030006" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --------------070402020507060403030006 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit The x86_emulate code uses the _PRE_EFLAGS macro to setup eflags immediately before executing (an emulated version of) the instruction. But _PRE_EFLAGS ends in a "andl" instruction, which clobbers the real eflags we've just carefully set up. This fix simply leaves the new eflags value on the stack until the final "popf" into eflags. Signed-off-by: David Lively --------------070402020507060403030006 Content-Type: text/x-patch; name="xen-emulate-eflags-clobber-fix.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="xen-emulate-eflags-clobber-fix.patch" diff -r 85791ff698bd xen/arch/x86/x86_emulate.c --- a/xen/arch/x86/x86_emulate.c Fri Oct 19 11:31:38 2007 -0400 +++ b/xen/arch/x86/x86_emulate.c Fri Oct 19 11:31:38 2007 -0400 @@ -300,7 +300,7 @@ struct operand { /* Before executing instruction: restore necessary bits in EFLAGS. */ #define _PRE_EFLAGS(_sav, _msk, _tmp) \ -/* EFLAGS = (_sav & _msk) | (EFLAGS & ~_msk); */\ +/* push (_sav & _msk) | (EFLAGS & ~_msk); */\ "push %"_sav"; " \ "movl %"_msk",%"_LO32 _tmp"; " \ "andl %"_LO32 _tmp",("_STK"); " \ @@ -309,11 +309,12 @@ struct operand { "andl %"_LO32 _tmp",("_STK"); " \ "pop %"_tmp"; " \ "orl %"_LO32 _tmp",("_STK"); " \ -"popf; " \ /* _sav &= ~msk; */ \ "movl %"_msk",%"_LO32 _tmp"; " \ "notl %"_LO32 _tmp"; " \ -"andl %"_LO32 _tmp",%"_sav"; " +"andl %"_LO32 _tmp",%"_sav"; " \ +/* pop EFLAGS */ \ +"popf; " /* After executing instruction: write-back necessary bits in EFLAGS. */ #define _POST_EFLAGS(_sav, _msk, _tmp) \ --------------070402020507060403030006 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --------------070402020507060403030006--