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

Re: [Xen-devel] [RFC XTF PATCH] Pagetable Emulation testing



>>> On 13.03.17 at 18:48, <andrew.cooper3@xxxxxxxxxx> wrote:
> On 13/03/17 15:45, Jan Beulich wrote:
>>>>> On 06.03.17 at 17:42, <andrew.cooper3@xxxxxxxxxx> wrote:
>>> +    /* Put FEP immediately before va, and a ret instruction at va. */
>>> +    memcpy(m->va - 5, "\x0f\x0bxen\xc3", 6);
>>> +    barrier();
>>> +
>>> +    /* Read them back, to confirm that RAM is properly in place. */
>>> +    if ( memcmp(m->va - 5, "\x0f\x0bxen\xc3", 6) )
>>> +        panic("Bad phys or virtual setup\n");
>>> +
>>> +    /* Construct the LDT at va. */
>>> +    user_desc *ldt = m->va;
>>> +
>>> +    ldt[LDT_SEL >> 3] = (typeof(*ldt))INIT_GDTE_SYM(0, 0xfffff, COMMON, 
>>> DATA, DPL3, B, W);
>> This dual use of m->va clearly needs a comment, perhaps next to
>> the definition of LDT_SEL (which can't be freely set to whatever one
>> may like - it namely can't be using LDT slot 0).
> 
> va is just the virtual address under test.
> 
> It gets read/write testing normally, exec testing by calling at it, and
> implicit access testing by layering an LDT over the top and loading a
> selector.
> 
> The choice of LDT selector to use only matters if it fits within the
> mapping, is otherwise valid, and is already accessed.  In particular,
> the test logic doesn't cope with hardware setting the accessed bit over
> a read-only mapping, because it can't distinguish the two different
> memory accesses.

But that's my point - one can't use any LDT selector one might like,
yet what restrictions there are can only be understood by detailed
reading of the code. A comment clarifying that the chosen LDT slot
must not be slot 0 and has to be within the first page would help.

>>> +    gdt[GDTE_AVAIL0]  = (typeof(*gdt))INIT_GDTE((unsigned long)m->va, 
>>> PAGE_SIZE, 0x82);
>>> +#if __x86_64__
>> #ifdef ?
> 
> Yes, although this variant definitely works.

Some compilers warn about such constructs when the symbol is
undefined (there'll never be the case of the symbol being defined,
but evaluating to zero).

Jan


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

 


Rackspace

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