]> xenbits.xensource.com Git - qemu-upstream-4.5-testing.git/commitdiff
kvm: x86: Fix DPL write back of segment registers
authorJan Kiszka <jan.kiszka@siemens.com>
Mon, 27 Dec 2010 14:56:44 +0000 (15:56 +0100)
committerMarcelo Tosatti <mtosatti@redhat.com>
Fri, 21 Jan 2011 16:05:22 +0000 (14:05 -0200)
The DPL is stored in the flags and not in the selector. In fact, the RPL
may differ from the DPL at some point in time, and so we were corrupting
the guest state so far.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
target-i386/kvm.c

index 9a4bf9883146ac73ce8895de966a7fb89d91a428..ee7bdf801234b14834f563f9e25bc5573e800811 100644 (file)
@@ -602,7 +602,7 @@ static void set_seg(struct kvm_segment *lhs, const SegmentCache *rhs)
     lhs->limit = rhs->limit;
     lhs->type = (flags >> DESC_TYPE_SHIFT) & 15;
     lhs->present = (flags & DESC_P_MASK) != 0;
-    lhs->dpl = rhs->selector & 3;
+    lhs->dpl = (flags >> DESC_DPL_SHIFT) & 3;
     lhs->db = (flags >> DESC_B_SHIFT) & 1;
     lhs->s = (flags & DESC_S_MASK) != 0;
     lhs->l = (flags >> DESC_L_SHIFT) & 1;