diff mbox

[2/4] KVM: Rework VCPU state writeback API

Message ID 20100303022910.GA21054@amt.cnet (mailing list archive)
State New, archived
Headers show

Commit Message

Marcelo Tosatti March 3, 2010, 2:29 a.m. UTC
None
diff mbox

Patch

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 14873b9..898173a 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -1822,13 +1822,23 @@  static u64 vmx_get_segment_base(struct kvm_vcpu *vcpu, int seg)
 static void vmx_get_segment(struct kvm_vcpu *vcpu,
 			    struct kvm_segment *var, int seg)
 {
+	struct vcpu_vmx *vmx = to_vmx(vcpu);
 	struct kvm_vmx_segment_field *sf = &kvm_vmx_segment_fields[seg];
 	u32 ar;
 
+	if (vmx->rmode.vm86_active && seg == VCPU_SREG_TR) {
+		var->base = vmx->rmode.tr.base;
+		var->limit = vmx->rmode.tr.limit;
+		var->selector = vmx->rmode.tr.selector;
+		ar = vmx->rmode.tr.ar;
+		goto ar;
+	}
+
 	var->base = vmcs_readl(sf->base);
 	var->limit = vmcs_read32(sf->limit);
 	var->selector = vmcs_read16(sf->selector);
 	ar = vmcs_read32(sf->ar_bytes);
+ar:
 	if ((ar & AR_UNUSABLE_MASK) && !emulate_invalid_guest_state)
 		ar = 0;
 	var->type = ar & 15;