[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 10/17] PVH xen: introduce vmx_pvh.c and pvh.c



>>> On 10.05.13 at 03:51, Mukesh Rathor <mukesh.rathor@xxxxxxxxxx> wrote:
> On Wed, 01 May 2013 14:52:27 +0100
> "Jan Beulich" <jbeulich@xxxxxxxx> wrote:
> 
>> >> > +static int vmxit_io_instr(struct cpu_user_regs *regs)
>> >> > +{
>> >> > +    int curr_lvl;
>> >> > +    int requested = (regs->rflags >> 12) & 3;
>> >> > +
>> >> > +    read_vmcs_selectors(regs);
>> >> > +    curr_lvl = regs->cs & 3;
>> >> 
>> >> Shouldn't you look at SS'es DPL instead?
>> >
>> >Ok. It looks like CPL is stored in both CS and SS, so either
>> >should be ok. But I changed it to ss. 
>> 
>> Your response reads as if you're still looking at the low two bits of
>> the selector, whereas me using DPL was intended to hint at you
>> needing to look at the "hidden" portion of the register.
> 
> Hmm... sorry, still don't understand why I need to use DPL here. Ref'ing
> the SDM again: Vol1 Basic architecture on IO says:
> 
> The following instructions can be executed only if the current privilege 
> level (CPL) of the program or task currently executing is less than or 
> equal to the IOPL: IN, INS, OUT, OUTS, CLI ..........
> 
> It says in Vol 3A in chapter on Protection, that CPL comes
> from bit 0 and 1 of the CS seg register. Since the RPL relfects the CPL
> when the program is executing, it seems the above code is correct. Moreover,
> I don't understand how the desc priv level of stack segement relates 
> to the IO instructions.

This is of specific relevance when including real and VM86 modes in
the picture: The section "Guest Register State" says "The value of
the DPL field for SS is always equal to the logical processorâs current
privilege level (CPL)", with the respective footnote "In protected mode,
CPL is also associated with the RPL field in the CS selector. However,
the RPL fields are not meaningful in real-address mode or in virtual-
8086 mode".

While I didn't want to spend even more time finding the respective
sections in the documentation, I'm certain this is being documented
this way also in areas not concerned with VMX (because I've been
knowing of this rule for far longer than VMX exists).

Also, if you look through the code, I'm sure you will find other places
where SS is being used in favor of CS (albeit in the PV cases obviously
we have to [and can safely] use RPL, as we can't see the hidden parts
of the registers, but there's also no real mode involved). get_cpl() in
the instruction emulator is a good example.

Jan

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.