From patchwork Thu Jan 6 17:56:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [09/35] kvm: x86: Fix DPL write back of segment registers Date: Thu, 06 Jan 2011 07:56:15 -0000 From: Marcelo Tosatti X-Patchwork-Id: 77755 Message-Id: <6d3896a6793615161dedaefd04e0b21cf71c86dd.1294336601.git.mtosatti@redhat.com> To: Anthony Liguori Cc: Jan Kiszka , qemu-devel@nongnu.org, kvm@vger.kernel.org, Avi Kivity From: Jan Kiszka 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 Signed-off-by: Avi Kivity --- target-i386/kvm.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 9a4bf98..ee7bdf8 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -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;