WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

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

To: Keir Fraser <Keir.Fraser@xxxxxxxxxxxx>
Subject: Re: [Xen-devel] xen and cr0,cr3,cr4
From: Adam Sulmicki <adam@xxxxxxxxxxxx>
Date: Sun, 28 Nov 2004 17:54:33 -0500 (EST)
Cc: xen-devel@xxxxxxxxxxxxxxxxxxxxx
Delivery-date: Sun, 28 Nov 2004 22:41:38 +0000
Envelope-to: xen+James.Bulpin@xxxxxxxxxxxx
In-reply-to: <E1CYVWY-0004lw-00@xxxxxxxxxxxxxxxxx>
List-archive: <http://sourceforge.net/mailarchive/forum.php?forum=xen-devel>
List-help: <mailto:xen-devel-request@lists.sourceforge.net?subject=help>
List-id: List for Xen developers <xen-devel.lists.sourceforge.net>
List-post: <mailto:xen-devel@lists.sourceforge.net>
List-subscribe: <https://lists.sourceforge.net/lists/listinfo/xen-devel>, <mailto:xen-devel-request@lists.sourceforge.net?subject=subscribe>
List-unsubscribe: <https://lists.sourceforge.net/lists/listinfo/xen-devel>, <mailto:xen-devel-request@lists.sourceforge.net?subject=unsubscribe>
Sender: xen-devel-admin@xxxxxxxxxxxxxxxxxxxxx
> 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