[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen stable-4.8] x86emul: correct PUSHF/POPF



commit 3e902dd55eba8f2668502b88f1220c25dcc5fb40
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Wed Jan 18 09:43:00 2017 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Wed Jan 18 09:43:00 2017 +0100

    x86emul: correct PUSHF/POPF
    
    Both need to raise #GP(0) when in VM86 mode with IOPL < 3.
    
    Additionally PUSHF is documented to clear VM and RF from the value
    placed onto the stack.
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    master commit: e5c1b8145bccb7fc587ee5b0c95ace6c5e0c7ffd
    master date: 2016-12-07 13:55:42 +0100
---
 xen/arch/x86/x86_emulate/x86_emulate.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c 
b/xen/arch/x86/x86_emulate/x86_emulate.c
index ff952a9..9ccfbf0 100644
--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -3085,13 +3085,20 @@ x86_emulate(
     }
 
     case 0x9c: /* pushf */
-        src.val = _regs.eflags;
+        generate_exception_if((_regs.eflags & EFLG_VM) &&
+                              MASK_EXTR(_regs.eflags, EFLG_IOPL) != 3,
+                              EXC_GP, 0);
+        src.val = _regs.eflags & ~(EFLG_VM | EFLG_RF);
         goto push;
 
     case 0x9d: /* popf */ {
         uint32_t mask = EFLG_VIP | EFLG_VIF | EFLG_VM;
+
         if ( !mode_ring0() )
         {
+            generate_exception_if((_regs.eflags & EFLG_VM) &&
+                                  MASK_EXTR(_regs.eflags, EFLG_IOPL) != 3,
+                                  EXC_GP, 0);
             mask |= EFLG_IOPL;
             if ( !mode_iopl() )
                 mask |= EFLG_IF;
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.8

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.