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

[Xen-changelog] [xen master] x86/hvm: Correct the position of the %cs L/D checks



commit 13b9f31751a55a96e86bd7e64b433a62a4a5b71e
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Thu Oct 13 11:27:28 2016 +0100
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Fri Oct 14 12:43:17 2016 +0100

    x86/hvm: Correct the position of the %cs L/D checks
    
    Contrary to the description in the software manuals, in Long Mode, attempts 
to
    load %cs check that D is not set in combination with L before the present 
flag
    is checked.
    
    This can be observed because the L/D check fails with #GP before the 
presence
    check failes with #NP.
    
    This change partially reverts c/s 78ff18c90 "x86: defer not-present segment
    checks", taking it back to how it was in the v1 submission.
    
    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, 8 insertions(+), 5 deletions(-)

diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c 
b/xen/arch/x86/x86_emulate/x86_emulate.c
index 793ce30..b23cd99 100644
--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -1405,6 +1405,14 @@ protmode_load_seg(
                /* Non-conforming segment: check RPL and DPL against CPL. */
                : rpl > cpl || dpl != cpl )
             goto raise_exn;
+        /*
+         * 64-bit code segments (L bit set) must have D bit clear.
+         * Experimentally in long mode, the L and D bits are checked before
+         * the Present bit.
+         */
+        if ( in_longmode(ctxt, ops) &&
+             (desc.b & (1 << 21)) && (desc.b & (1 << 22)) )
+            goto raise_exn;
         sel = (sel ^ rpl) | cpl;
         break;
     case x86_seg_ss:
@@ -1444,11 +1452,6 @@ protmode_load_seg(
         goto raise_exn;
     }
 
-    /* 64-bit code segments (L bit set) must have D bit clear. */
-    if ( seg == x86_seg_cs && in_longmode(ctxt, ops) &&
-         (desc.b & (1 << 21)) && (desc.b & (1 << 22)) )
-        goto raise_exn;
-
     /* Ensure Accessed flag is set. */
     if ( a_flag && !(desc.b & a_flag) )
     {
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
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®.