KVM: VMX: Preserve segment limit and access rights in real mode
authorAvi Kivity <avi@redhat.com>
Tue, 21 Aug 2012 14:07:08 +0000 (17:07 +0300)
committerMarcelo Tosatti <mtosatti@redhat.com>
Mon, 27 Aug 2012 23:02:21 +0000 (20:02 -0300)
While this is undocumented, real processors do not reload the segment
limit and access rights when loading a segment register in real mode.
Real programs rely on it so we need to comply with this behaviour.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
arch/x86/kvm/vmx.c

index 0d6872621ab5b487f934d4fb50090e9ddd1ac5cf..6e6421aeca03cd76c66172eb279b1ac1969fbc18 100644 (file)
@@ -3113,6 +3113,9 @@ static void vmx_get_segment(struct kvm_vcpu *vcpu,
                if (seg == VCPU_SREG_TR
                    || var->selector == vmx_read_guest_seg_selector(vmx, seg))
                        return;
+               var->base = vmx_read_guest_seg_base(vmx, seg);
+               var->selector = vmx_read_guest_seg_selector(vmx, seg);
+               return;
        }
        var->base = vmx_read_guest_seg_base(vmx, seg);
        var->limit = vmx_read_guest_seg_limit(vmx, seg);