aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorGleb Natapov <gleb@redhat.com>2013-06-28 06:17:18 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-07-13 14:42:27 -0400
commit096bff23937209645162a7fc5e70246cb5c60336 (patch)
tree1c189e4d521275757a77112945e950b5a7f7e18c /arch/x86
parentc334daca734bbb11f79742ec699b1cf9d2112117 (diff)
KVM: VMX: mark unusable segment as nonpresent
commit 03617c188f41eeeb4223c919ee7e66e5a114f2c6 upstream. Some userspaces do not preserve unusable property. Since usable segment has to be present according to VMX spec we can use present property to amend userspace bug by making unusable segment always nonpresent. vmx_segment_access_rights() already marks nonpresent segment as unusable. Reported-by: Stefan Pietsch <stefan.pietsch@lsexperts.de> Tested-by: Stefan Pietsch <stefan.pietsch@lsexperts.de> Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/kvm/vmx.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 260a91939555..5402c94ab768 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -3399,15 +3399,22 @@ static void vmx_get_segment(struct kvm_vcpu *vcpu,
3399 var->limit = vmx_read_guest_seg_limit(vmx, seg); 3399 var->limit = vmx_read_guest_seg_limit(vmx, seg);
3400 var->selector = vmx_read_guest_seg_selector(vmx, seg); 3400 var->selector = vmx_read_guest_seg_selector(vmx, seg);
3401 ar = vmx_read_guest_seg_ar(vmx, seg); 3401 ar = vmx_read_guest_seg_ar(vmx, seg);
3402 var->unusable = (ar >> 16) & 1;
3402 var->type = ar & 15; 3403 var->type = ar & 15;
3403 var->s = (ar >> 4) & 1; 3404 var->s = (ar >> 4) & 1;
3404 var->dpl = (ar >> 5) & 3; 3405 var->dpl = (ar >> 5) & 3;
3405 var->present = (ar >> 7) & 1; 3406 /*
3407 * Some userspaces do not preserve unusable property. Since usable
3408 * segment has to be present according to VMX spec we can use present
3409 * property to amend userspace bug by making unusable segment always
3410 * nonpresent. vmx_segment_access_rights() already marks nonpresent
3411 * segment as unusable.
3412 */
3413 var->present = !var->unusable;
3406 var->avl = (ar >> 12) & 1; 3414 var->avl = (ar >> 12) & 1;
3407 var->l = (ar >> 13) & 1; 3415 var->l = (ar >> 13) & 1;
3408 var->db = (ar >> 14) & 1; 3416 var->db = (ar >> 14) & 1;
3409 var->g = (ar >> 15) & 1; 3417 var->g = (ar >> 15) & 1;
3410 var->unusable = (ar >> 16) & 1;
3411} 3418}
3412 3419
3413static u64 vmx_get_segment_base(struct kvm_vcpu *vcpu, int seg) 3420static u64 vmx_get_segment_base(struct kvm_vcpu *vcpu, int seg)