blob: 2d21db4de969489be4c7b6809c5b3483cc96bdd9 [file] [log] [blame]
From mtosatti@redhat.com Tue Apr 28 21:36:19 2009
From: Marcelo Tosatti <mtosatti@redhat.com>
Date: Mon, 23 Mar 2009 17:51:22 -0300
Subject: KVM: SVM: Set the 'g' bit of the cs selector for cross-vendor migration
To: stable@kernel.org
Cc: Amit Shah <amit.shah@redhat.com>, mtosatti@redhat.com, avi@redhat.com
Message-ID: <1237841498-14100-6-git-send-email-mtosatti@redhat.com>
From: Amit Shah <amit.shah@redhat.com>
(cherry picked from 25022acc3dd5f0b54071c7ba7c371860f2971b52)
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>
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
arch/x86/kvm/svm.c | 9 +++++++++
1 file changed, 9 insertions(+)
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -772,6 +772,15 @@ static void svm_get_segment(struct kvm_v
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;
}