Skip to contentSkip to conversation

x86/pv: Check that emulate_privileged_op() don't change any unexpected flags

PATCH In review Andrew Cooper 2 participants 2 messages Jan 16, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/pv: Check that emulate_privileged_op() don't change any unexpected flags

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.

---
CC: Jan Beulich <[email protected]>

v2:
* Extend to all unexpected bits.

---
 xen/arch/x86/traps.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
xen/arch/x86/traps.c +4 -2
index 4f29c3a..ea0ce52 100644
@@ -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;
 
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 16.01.17 at 14:03, <[email protected]> wrote:

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.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel