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

Re: [Xen-devel] xen and cr0,cr3,cr4



> All accesses to control registers, whether read or write, are
> disallowed outside ring 0. There is no way to allow such accesses so,
> yes, they would hve to indirect thru Xen.
>
> You should know the value in %cr3 anyway. Why do you need to read %cr0
> and %cr4?

well, it just a module I have which examines the current page tables,
settings and prints out physical and virutal memory maps.

It currently works under plain linux and from inside of xen. Now that I
have basic 4kb pages working (on pentium 3, with PSE enabled) it would be
nice to have it working from inside of xenolinux too, so that I can iron
out remaining issues with 4kb pages.

you are right that cr0 and cr4 are not strictly necessary but nice to
have, just to verify that things are what they appear to be.

as for cr3, I suppose I know what it was in xen, but I just hoped not to
assume anything. Either way can I rely on xen_start_info.pt_base ?

=================================================================
unsigned long my_show_regs(void)
{
    unsigned long cr0 = 0L, cr3 = 0L, cr4 = 0L;
    int i;

    // is Paging enabled ?? -> CR0
    __asm__("movl %%cr0, %0": "=r" (cr0));
    printk("CR4            : 0x%08lX = ", cr0);
    print_binary(cr0);
    printk(" : \'%s\'", cr0 & (1<<31) ? "PG" : "NO-PG" );
    nl;

    // is Page Size Extensions Enabled ?? -> CR4
    __asm__("movl %%cr4, %0": "=r" (cr4));
    printk("CR0            : 0x%08lX = ", cr4);
    print_binary(cr4);
    printk(" : \'%s\'", cr4 & (0x10) ? "PSE" : "NO-PSE" );
    nl;

    // What is the Page Directory Base ?? -> CR3
    __asm__("movl %%cr3, %0": "=r" (cr3));
    printk("CR3            : 0x%08lX = ", cr3);
    print_binary(cr3);
    nl;

    return cr3;
}
=================================================================




-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/xen-devel


 


Rackspace

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