Fix the non-conforming type check and use the consistent method to fetch the cpl value as function get_cpl(). Signed-off-by: Xu, Dongxiao diff -r e64c3a8c60e1 xen/arch/x86/x86_emulate/x86_emulate.c --- a/xen/arch/x86/x86_emulate/x86_emulate.c Wed May 21 16:55:11 2008 +0100 +++ b/xen/arch/x86/x86_emulate/x86_emulate.c Mon Jun 16 14:55:43 2008 +0800 @@ -903,7 +903,7 @@ protmode_load_seg( struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops) { - struct segment_register desctab, cs, segr; + struct segment_register desctab, ss, segr; struct { uint32_t a, b; } desc; unsigned long val; uint8_t dpl, rpl, cpl; @@ -923,7 +923,7 @@ protmode_load_seg( if ( (seg == x86_seg_ldtr) && (sel & 4) ) goto raise_exn; - if ( (rc = ops->read_segment(x86_seg_cs, &cs, ctxt)) || + if ( (rc = ops->read_segment(x86_seg_ss, &ss, ctxt)) || (rc = ops->read_segment((sel & 4) ? x86_seg_ldtr : x86_seg_gdtr, &desctab, ctxt)) ) return rc; @@ -955,7 +955,7 @@ protmode_load_seg( dpl = (desc.b >> 13) & 3; rpl = sel & 3; - cpl = cs.sel & 3; + cpl = ss.attr.fields.dpl; switch ( seg ) { @@ -964,7 +964,7 @@ protmode_load_seg( if ( !(desc.b & (1u<<11)) ) goto raise_exn; /* Non-conforming segment: check DPL against RPL. */ - if ( ((desc.b & (6u<<9)) != 6) && (dpl != rpl) ) + if ( ((desc.b & (6u<<9)) != (6u<<9)) && (dpl != rpl) ) goto raise_exn; break; case x86_seg_ss: @@ -984,7 +984,7 @@ protmode_load_seg( if ( (desc.b & (5u<<9)) == (4u<<9) ) goto raise_exn; /* Non-conforming segment: check DPL against RPL and CPL. */ - if ( ((desc.b & (6u<<9)) != 6) && ((dpl < cpl) || (dpl < rpl)) ) + if ( ((desc.b & (6u<<9)) != (6u<<9)) && ((dpl < cpl) || (dpl < rpl)) ) goto raise_exn; break; }