x86/pv: Check that emulate_privileged_op() don't change any unexpected flags
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 6 Jan 2017 20:05:36 +0000 (20:05 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 16 Jan 2017 17:37:26 +0000 (17:37 +0000)
No bits, other than arithmetic ones and the resume flag (which will most
likely change from 1 to 0), can be changed by the instructions we permit.
Extend the check to cover other flags.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/traps.c

index 4f29c3af93491475bceea567edb39fdcc1f1a0d9..ea0ce528f345c9e0852fe5f6fce603c444eb2a7f 100644 (file)
@@ -3012,9 +3012,11 @@ static int emulate_privileged_op(struct cpu_user_regs *regs)
 
     /*
      * Un-mirror virtualized state from EFLAGS.
-     * Nothing we allow to be emulated can change TF, IF, or IOPL.
+     * Nothing we allow to be emulated can change anything other than the
+     * arithmetic bits, and the resume flag.
      */
-    ASSERT(!((regs->_eflags ^ eflags) & (X86_EFLAGS_IF | X86_EFLAGS_IOPL)));
+    ASSERT(!((regs->_eflags ^ eflags) &
+             ~(X86_EFLAGS_RF | X86_EFLAGS_ARITH_MASK)));
     regs->_eflags |= X86_EFLAGS_IF;
     regs->_eflags &= ~X86_EFLAGS_IOPL;