Commit 096bff23 authored by Gleb Natapov's avatar Gleb Natapov Committed by Greg Kroah-Hartman

KVM: VMX: mark unusable segment as nonpresent

commit 03617c18 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: default avatarStefan Pietsch <stefan.pietsch@lsexperts.de>
Tested-by: default avatarStefan Pietsch <stefan.pietsch@lsexperts.de>
Signed-off-by: default avatarGleb Natapov <gleb@redhat.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c334daca
...@@ -3399,15 +3399,22 @@ static void vmx_get_segment(struct kvm_vcpu *vcpu, ...@@ -3399,15 +3399,22 @@ static void vmx_get_segment(struct kvm_vcpu *vcpu,
var->limit = vmx_read_guest_seg_limit(vmx, seg); var->limit = vmx_read_guest_seg_limit(vmx, seg);
var->selector = vmx_read_guest_seg_selector(vmx, seg); var->selector = vmx_read_guest_seg_selector(vmx, seg);
ar = vmx_read_guest_seg_ar(vmx, seg); ar = vmx_read_guest_seg_ar(vmx, seg);
var->unusable = (ar >> 16) & 1;
var->type = ar & 15; var->type = ar & 15;
var->s = (ar >> 4) & 1; var->s = (ar >> 4) & 1;
var->dpl = (ar >> 5) & 3; var->dpl = (ar >> 5) & 3;
var->present = (ar >> 7) & 1; /*
* 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.
*/
var->present = !var->unusable;
var->avl = (ar >> 12) & 1; var->avl = (ar >> 12) & 1;
var->l = (ar >> 13) & 1; var->l = (ar >> 13) & 1;
var->db = (ar >> 14) & 1; var->db = (ar >> 14) & 1;
var->g = (ar >> 15) & 1; var->g = (ar >> 15) & 1;
var->unusable = (ar >> 16) & 1;
} }
static u64 vmx_get_segment_base(struct kvm_vcpu *vcpu, int seg) static u64 vmx_get_segment_base(struct kvm_vcpu *vcpu, int seg)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment