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 <[email protected]>
---
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"; "
 
 /* After executing instruction: write-back necessary bits in EFLAGS. */
 #define _POST_EFLAGS(_sav, _msk, _tmp)          \



x86emul: make _PRE_EFLAGS() tolerate first argument being 32-bit

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 <[email protected]>
---
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"; "
 
 /* After executing instruction: write-back necessary bits in EFLAGS. */
 #define _POST_EFLAGS(_sav, _msk, _tmp)          \
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

Reply via email to