Skip to contentSkip to conversation

Fix cross vendor migration issue with unusable bit

PATCH Applied Andre Przywara 2 participants 2 messages Apr 28, 2009 – May 4, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Fix cross vendor migration issue with unusable bit

AMDs VMCB does not have an explicit unusable segment descriptor field, so we emulate it by using "not present". This has to be setup before the fixups, because this field is used there.

---
 arch/x86/kvm/svm.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

Avi, pleasy push this patch also to 2.6.30, since it fixes a bug introduced in 2.6.30-rc1.

Thanks,
Andre.

arch/x86/kvm/svm.c +5 -2
index 1821c20..1580464 100644
@@ -796,6 +796,11 @@ static void svm_get_segment(struct kvm_vcpu *vcpu,
 	var->db = (s->attrib >> SVM_SELECTOR_DB_SHIFT) & 1;
 	var->g = (s->attrib >> SVM_SELECTOR_G_SHIFT) & 1;
 
+	/* AMD's VMCB does not have an explicit unusable field, so emulate it
+	 * for cross vendor migration purposes by "not present"
+	 */
+	var->unusable = !var->present || (var->type == 0);
+	
 	switch (seg) {
 	case VCPU_SREG_CS:
 		/*
@@ -827,8 +832,6 @@ static void svm_get_segment(struct kvm_vcpu *vcpu,
 			var->type |= 0x1;
 		break;
 	}
-
-	var->unusable = !var->present;
 }
 
 static int svm_get_cpl(struct kvm_vcpu *vcpu)
Signature · 1 line
1.6.1.3
Applied
#1 lore raw
Quoted 5 lines · Andre Przywara

AMDs VMCB does not have an explicit unusable segment descriptor field, so we emulate it by using "not present". This has to be setup before the fixups, because this field is used there.

Applied both, thanks.

Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.