From: David Lively <dlively@virtualiron.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH] x86_emulate fix
Date: Fri, 19 Oct 2007 11:43:38 -0400 [thread overview]
Message-ID: <4718D0AA.7010201@virtualiron.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 391 bytes --]
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 <dlively@virtualiron.com>
[-- Attachment #2: xen-emulate-eflags-clobber-fix.patch --]
[-- Type: text/x-patch, Size: 1218 bytes --]
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) \
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
next reply other threads:[~2007-10-19 15:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-19 15:43 David Lively [this message]
2007-10-19 16:07 ` [PATCH] x86_emulate fix Keir Fraser
2007-10-19 16:59 ` Dave Lively
2007-10-19 17:10 ` Keir Fraser
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=4718D0AA.7010201@virtualiron.com \
--to=dlively@virtualiron.com \
--cc=xen-devel@lists.xensource.com \
/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.