Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 340e01248478ba8b78a6d4d1809b1eff > files > 494

kvm-83-270.el5_11.src.rpm

From b7625f94914a42b8a840d7a9727b1aa0fe9473a7 Mon Sep 17 00:00:00 2001
From: Alex Williamson <alex.williamson@redhat.com>
Date: Thu, 7 Apr 2011 17:45:06 -0300
Subject: [PATCH 1/2] KVM: VMX: Save and restore tr selector across mode switches

RH-Author: Alex Williamson <alex.williamson@redhat.com>
Message-id: <20110407174448.8967.93438.stgit@localhost6.localdomain6>
Patchwork-id: 21653
O-Subject: [RHEL5.7 kmod-kvm PATCH 1/2] KVM: VMX: Save and restore tr selector
	across mode switches
Bugzilla: 693918
RH-Acked-by: Avi Kivity <avi@redhat.com>
RH-Acked-by: Gleb Natapov <gleb@redhat.com>
RH-Acked-by: Don Dutile <ddutile@redhat.com>
RH-Acked-by: Glauber Costa <glommer@redhat.com>

From: Avi Kivity <avi@redhat.com>

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=693918
Brew build: https://brewweb.devel.redhat.com/taskinfo?taskID=3240237
Upstream commit: d0ba64f9b4b3e41e7b91681fe04a334bc8bfc8f5

When emulating real mode we play with tr hidden state, but leave
tr.selector alone.  That works well, except for save/restore, since
loading TR writes it to the hidden state in vmx->rmode.

Fix by also saving and restoring the tr selector; this makes things
more consistent and allows migration to work during the early
boot stages of Windows XP.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
---

 arch/x86/kvm/vmx.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 arch/x86/kvm/vmx.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 1c67e4f..660f42e 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -1362,6 +1362,7 @@ static void enter_pmode(struct kvm_vcpu *vcpu)
 	vmx->emulation_required = 1;
 	vcpu->arch.rmode.active = 0;
 
+	vmcs_write16(GUEST_TR_SELECTOR, vcpu->arch.rmode.tr.selector);
 	vmcs_writel(GUEST_TR_BASE, vcpu->arch.rmode.tr.base);
 	vmcs_write32(GUEST_TR_LIMIT, vcpu->arch.rmode.tr.limit);
 	vmcs_write32(GUEST_TR_AR_BYTES, vcpu->arch.rmode.tr.ar);
@@ -1424,6 +1425,7 @@ static void enter_rmode(struct kvm_vcpu *vcpu)
 	vmx->emulation_required = 1;
 	vcpu->arch.rmode.active = 1;
 
+	vcpu->arch.rmode.tr.selector = vmcs_read16(GUEST_TR_SELECTOR);
 	vcpu->arch.rmode.tr.base = vmcs_readl(GUEST_TR_BASE);
 	vmcs_writel(GUEST_TR_BASE, rmode_tss_base(vcpu->kvm));
 
-- 
1.7.3.2