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

Avi Kivity
2010-05-25T11:22:17Z

On 05/25/2010 01:36 PM, Mohammed Gamal wrote:
>
>> 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.
>>
>>
> Intel 64 and IA-32 Architectures Software Developer’s Manual Volume
> 3B, System Programming Guide, Part 2, Chapter 22, Section 22.3.1.2:
> Checks on Guest Segment Registers.
> You'll note that DS, ES, FS, GS checks are done when the segment is
> usable. SS checks are not necessarily checked only when the segment is
> usable.
>

Strange, but consistent with

> If the unusable bit is 1, the base address, the segment limit, and the
> remainder of the access rights are undefined after VM entry. The only
> exceptions are the following:
> — Bits 3:0 of the base address for SS are cleared to 0.
> — SS.DPL: always loaded from the SS access-rights field. This will be
> the current privilege level (CPL) after the VM entry completes.
> — SS.B: set to 1.
> — The base addresses for FS and GS: always loaded. On processors
> that support Intel 64 architecture, the values loaded for base
> addresses for FS and GS are also manifest in the FS.base and
> GS.base MSRs.
> — The base address for LDTR on processors that support Intel 64 archi-
> tecture: set to an undefined but canonical value.
> — Bits 63:32 of the base addresses for SS, DS, and ES on processors
> that support Intel 64 architecture: cleared to 0.

So you are right.

Seems to me we can simplify vmx_get_cpl() on this basis to look at ss.dpl.

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