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@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
/* 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:
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) )
{