kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Fix Linux guests migration from AMD to Intel hosts
@ 2008-10-27  9:04 Amit Shah
  2008-10-27  9:04 ` [PATCH 1/2] KVM: SVM: Set the 'g' bit of the cs selector for cross-vendor migration Amit Shah
  2008-10-27 10:15 ` Fix Linux guests migration from AMD to Intel hosts Avi Kivity
  0 siblings, 2 replies; 4+ messages in thread
From: Amit Shah @ 2008-10-27  9:04 UTC (permalink / raw)
  To: avi; +Cc: kvm, joerg.roedel


These two patches export some bits from SVM's VMCB to the state
that enable migration from AMD hosts to Intel hosts.

x86 Linux-32 bit and 64-bit guests successfully migrate after
applying these patches. Note: Intel->AMD migration of guests
already works.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] KVM: SVM: Set the 'g' bit of the cs selector for cross-vendor migration
  2008-10-27  9:04 Fix Linux guests migration from AMD to Intel hosts Amit Shah
@ 2008-10-27  9:04 ` Amit Shah
  2008-10-27  9:04   ` [PATCH 2/2] KVM: SVM: Set the 'busy' flag of the TR selector Amit Shah
  2008-10-27 10:15 ` Fix Linux guests migration from AMD to Intel hosts Avi Kivity
  1 sibling, 1 reply; 4+ messages in thread
From: Amit Shah @ 2008-10-27  9:04 UTC (permalink / raw)
  To: avi; +Cc: kvm, joerg.roedel, Amit Shah

The hardware does not set the 'g' bit of the cs selector and this breaks
migration from amd hosts to intel hosts. Set this bit if the segment
limit is beyond 1 MB.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 arch/x86/kvm/svm.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 05efc4e..665008d 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -772,6 +772,15 @@ static void svm_get_segment(struct kvm_vcpu *vcpu,
 	var->l = (s->attrib >> SVM_SELECTOR_L_SHIFT) & 1;
 	var->db = (s->attrib >> SVM_SELECTOR_DB_SHIFT) & 1;
 	var->g = (s->attrib >> SVM_SELECTOR_G_SHIFT) & 1;
+
+	/*
+	 * SVM always stores 0 for the 'G' bit in the CS selector in
+	 * the VMCB on a VMEXIT. This hurts cross-vendor migration:
+	 * Intel's VMENTRY has a check on the 'G' bit.
+	 */
+	if (seg == VCPU_SREG_CS)
+		var->g = s->limit > 0xfffff;
+
 	var->unusable = !var->present;
 }
 
-- 
1.5.4.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] KVM: SVM: Set the 'busy' flag of the TR selector
  2008-10-27  9:04 ` [PATCH 1/2] KVM: SVM: Set the 'g' bit of the cs selector for cross-vendor migration Amit Shah
@ 2008-10-27  9:04   ` Amit Shah
  0 siblings, 0 replies; 4+ messages in thread
From: Amit Shah @ 2008-10-27  9:04 UTC (permalink / raw)
  To: avi; +Cc: kvm, joerg.roedel, Amit Shah

The busy flag of the TR selector is not set by the hardware. This breaks
migration from amd hosts to intel hosts.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 arch/x86/kvm/svm.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 665008d..743aebd 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -781,6 +781,13 @@ static void svm_get_segment(struct kvm_vcpu *vcpu,
 	if (seg == VCPU_SREG_CS)
 		var->g = s->limit > 0xfffff;
 
+	/*
+	 * Work around a bug where the busy flag in the tr selector
+	 * isn't exposed
+	 */
+	if (seg == VCPU_SREG_TR)
+		var->type |= 0x2;
+
 	var->unusable = !var->present;
 }
 
-- 
1.5.4.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: Fix Linux guests migration from AMD to Intel hosts
  2008-10-27  9:04 Fix Linux guests migration from AMD to Intel hosts Amit Shah
  2008-10-27  9:04 ` [PATCH 1/2] KVM: SVM: Set the 'g' bit of the cs selector for cross-vendor migration Amit Shah
@ 2008-10-27 10:15 ` Avi Kivity
  1 sibling, 0 replies; 4+ messages in thread
From: Avi Kivity @ 2008-10-27 10:15 UTC (permalink / raw)
  To: Amit Shah; +Cc: kvm, joerg.roedel

Amit Shah wrote:
> These two patches export some bits from SVM's VMCB to the state
> that enable migration from AMD hosts to Intel hosts.
>
> x86 Linux-32 bit and 64-bit guests successfully migrate after
> applying these patches. Note: Intel->AMD migration of guests
> already works.
>   

Applied, thanks.

-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-10-27 10:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-27  9:04 Fix Linux guests migration from AMD to Intel hosts Amit Shah
2008-10-27  9:04 ` [PATCH 1/2] KVM: SVM: Set the 'g' bit of the cs selector for cross-vendor migration Amit Shah
2008-10-27  9:04   ` [PATCH 2/2] KVM: SVM: Set the 'busy' flag of the TR selector Amit Shah
2008-10-27 10:15 ` Fix Linux guests migration from AMD to Intel hosts Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).