Re: [PATCH] VMX: Fix and improve guest state validity checks

Avi Kivity
2010-05-25T09:37:43Z

On 05/13/2010 11:15 PM, Mohammed Gamal wrote:
> On Thu, May 13, 2010 at 9:24 AM, Avi Kivity<avi@redhat.com> wrote:
>
>> On 05/11/2010 07:52 PM, Mohammed Gamal wrote:
>>
>>> - Add 's' and 'g' field checks on segment registers
>>> - Correct SS checks for request and descriptor privilege levels
>>>
>>> Signed-off-by: Mohammed Gamal<m.gamal005@gmail.com>
>>> ---
>>> arch/x86/kvm/vmx.c | 73
>>> +++++++++++++++++++++++++++++++++++++++++++++++----
>>> 1 files changed, 67 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
>>> index 777e00d..9805c2a 100644
>>> --- a/arch/x86/kvm/vmx.c
>>> +++ b/arch/x86/kvm/vmx.c
>>> @@ -2121,16 +2121,30 @@ static bool stack_segment_valid(struct kvm_vcpu
>>> *vcpu)
>>> vmx_get_segment(vcpu,&ss, VCPU_SREG_SS);
>>> ss_rpl = ss.selector& SELECTOR_RPL_MASK;
>>>
>>> - if (ss.unusable)
>>> + if (ss.dpl != ss_rpl) /* DPL != RPL */
>>> + return false;
>>> +
>>> + if (ss.unusable) /* Short-circuit */
>>> return true;
>>>
>>>
>> If ss.unusable, do the dpl and rpl have any meaning?
>>
> The idea is that dpl and rpl are checked on vmentry regardless of
> whether ss is usable or not. While the other checks are performed only
> if ss is usable.
>

Any reference to back this up? I think rpl is valid regardless of
ss.unusable (i.e. loading selector 0003 results in an unusable segment
with rpl=3), but I don't see how dpl can be valid in an unusable segment.

--
error compiling committee.c: too many arguments to function