]> Pileus Git - ~andy/linux/commitdiff
KVM: x86 emulator: allow loading null SS in long mode
authorAvi Kivity <avi@redhat.com>
Thu, 7 Jun 2012 14:03:42 +0000 (17:03 +0300)
committerAvi Kivity <avi@redhat.com>
Mon, 9 Jul 2012 11:19:01 +0000 (14:19 +0300)
Null SS is valid in long mode; allow loading it.

Signed-off-by: Avi Kivity <avi@redhat.com>
arch/x86/kvm/emulate.c

index db95a55d59369e9e2bb2acab64f8c14213597d1e..fe4340f621371ded86a56c534cb507975577aaa3 100644 (file)
@@ -1324,8 +1324,14 @@ static int load_segment_descriptor(struct x86_emulate_ctxt *ctxt,
                goto load;
        }
 
-       /* NULL selector is not valid for TR, CS and SS */
-       if ((seg == VCPU_SREG_CS || seg == VCPU_SREG_SS || seg == VCPU_SREG_TR)
+       rpl = selector & 3;
+       cpl = ctxt->ops->cpl(ctxt);
+
+       /* NULL selector is not valid for TR, CS and SS (except for long mode) */
+       if ((seg == VCPU_SREG_CS
+            || (seg == VCPU_SREG_SS
+                && (ctxt->mode != X86EMUL_MODE_PROT64 || rpl != cpl))
+            || seg == VCPU_SREG_TR)
            && null_selector)
                goto exception;
 
@@ -1352,9 +1358,7 @@ static int load_segment_descriptor(struct x86_emulate_ctxt *ctxt,
                goto exception;
        }
 
-       rpl = selector & 3;
        dpl = seg_desc.dpl;
-       cpl = ctxt->ops->cpl(ctxt);
 
        switch (seg) {
        case VCPU_SREG_SS: