|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen staging] x86/emul: Make POPF emulation easier to follow
commit 7b6e05c50fc39466fcc685fb6d4216f99af58743
Author: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Mon Dec 3 18:11:40 2018 +0000
Commit: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Mon Dec 31 12:09:46 2018 +0000
x86/emul: Make POPF emulation easier to follow
Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
xen/arch/x86/x86_emulate/x86_emulate.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c
b/xen/arch/x86/x86_emulate/x86_emulate.c
index 03540b648f..717e02fe67 100644
--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -4198,6 +4198,10 @@ x86_emulate(
goto push;
case 0x9d: /* popf */ {
+ /*
+ * Bits which may not be modified by this instruction. RF is handled
+ * uniformly during instruction retirement.
+ */
uint32_t mask = X86_EFLAGS_VIP | X86_EFLAGS_VIF | X86_EFLAGS_VM;
cr4 = 0;
@@ -4211,15 +4215,20 @@ x86_emulate(
if ( rc != X86EMUL_OKAY )
goto done;
}
+ /* All IOPL != 3 POPFs fail, except in vm86 mode. */
generate_exception_if(!(cr4 & X86_CR4_VME) &&
MASK_EXTR(_regs.eflags, X86_EFLAGS_IOPL)
!= 3,
EXC_GP, 0);
}
+ /*
+ * IOPL cannot be modified outside of CPL 0. IF cannot be
+ * modified if IOPL < CPL.
+ */
mask |= X86_EFLAGS_IOPL;
if ( !mode_iopl() )
mask |= X86_EFLAGS_IF;
}
- /* 64-bit mode: POP defaults to a 64-bit operand. */
+ /* 64-bit mode: POPF defaults to a 64-bit operand. */
if ( mode_64bit() && (op_bytes == 4) )
op_bytes = 8;
if ( (rc = read_ulong(x86_seg_ss, sp_post_inc(op_bytes),
@@ -4227,7 +4236,9 @@ x86_emulate(
goto done;
if ( op_bytes == 2 )
{
+ /* 16-bit POPF preserves the upper 16 bits of EFLAGS. */
dst.val = (uint16_t)dst.val | (_regs.eflags & 0xffff0000u);
+ /* VME processing only applies at IOPL != 3. */
if ( (cr4 & X86_CR4_VME) &&
MASK_EXTR(_regs.eflags, X86_EFLAGS_IOPL) != 3 )
{
--
generated by git-patchbot for /home/xen/git/xen.git#staging
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |