hello, As I understand _writing_ cr{0,3,4} would be privileged operationg. However, I would tend to think that _reading_ them should be not. It seems like I''m getting ooops when I''m trying to read CRx under linux in dom0 under xen. Is that indeed case? If yes, I suppose I can somehow get around this using hypercalls from inside of xenolinux dom0. =============================================================================Entering PAGE module -- init_module():start $Id: page-init.c,v 1.4 2004/11/27 21:36:11 sulmicki Exp sulmicki $ Entering memory_map(). PAGE OFFSET : 0xC0000000 = 3GiB CPUID(EAX=1)EDX: 0x0383FBFF = 0000 0011 1000 0011 1111 1011 1111 1111 : ''PSE'' About to read CR0 general protection fault: 0000 [#2] PREEMPT Modules linked in: pagemap_2 pagemap_1 ds yenta_socket pcmcia_core e100 CPU: 0 EIP: 0061:[<c4850142>] Not tainted EFLAGS: 00013297 (2.6.8.1-xen0) EIP is at my_show_regs+0x2f/0x101 [pagemap_2] eax: ffffff82 ebx: c0336778 ecx: 0007a11f edx: ffffff82 esi: c4851000 edi: c2e36000 ebp: 00000000 esp: c2e37f30 ds: 0069 es: 0069 ss: 0069 Process insmod (pid: 9356, threadinfo=c2e36000 task=c13ee6b0) Stack: c4850a04 c0336778 c0336778 c4850258 00000001 c0000000 00000003 c2e37f58 c02ee921 00000000 ffffffba c011d8b0 00000000 000018c8 c03ac103 00000000 00000043 c0336760 c011d6f4 0000000a 00000400 c4850864 c0336778 c4851000 Call Trace: [<c4850258>] memory_map+0x44/0x620 [pagemap_2] [<c02ee921>] preempt_schedule+0x29/0x42 [<c011d8b0>] release_console_sem+0x113/0x12d [<c011d6f4>] printk+0x148/0x1ad [<c4850027>] init_module+0x27/0x39 [pagemap_2] [<c0133b40>] sys_init_module+0x115/0x25e [<c010d52b>] syscall_call+0x7/0xc Code: 0f 20 c3 89 d0 e6 80 e6 80 83 e9 01 79 f5 c7 04 24 17 0a 85 ============================================================================= printk("About to read CR0\n"); for (i=0;i<500000;i++) outb_p(0x82,0x80); __asm__("movl %%cr0, %0": "=r" (cr0)); for (i=0;i<500000;i++) outb_p(0x82,0x80); printk("Just read CR0\n"); =============================================================================Linux redbull 2.6.8.1-xen0 #9 Sun Oct 31 11:05:07 MST 2004 i686 i686 i386 GNU/Linux ============================================================================= ------------------------------------------------------- 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@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/xen-devel
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? -- Keir> > hello, > As I understand _writing_ cr{0,3,4} would be privileged > operationg. However, I would tend to think that _reading_ them > should be not. > > It seems like I''m getting ooops when I''m trying to read CRx > under linux in dom0 under xen. > > Is that indeed case? > > If yes, I suppose I can somehow get around this using hypercalls > from inside of xenolinux dom0. > > =============================================================================> Entering PAGE module -- init_module():start > $Id: page-init.c,v 1.4 2004/11/27 21:36:11 sulmicki Exp sulmicki $ > Entering memory_map(). > PAGE OFFSET : 0xC0000000 = 3GiB > CPUID(EAX=1)EDX: 0x0383FBFF = 0000 0011 1000 0011 1111 1011 1111 1111 : ''PSE'' > About to read CR0 > general protection fault: 0000 [#2] > PREEMPT > Modules linked in: pagemap_2 pagemap_1 ds yenta_socket pcmcia_core e100 > CPU: 0 > EIP: 0061:[<c4850142>] Not tainted > EFLAGS: 00013297 (2.6.8.1-xen0) > EIP is at my_show_regs+0x2f/0x101 [pagemap_2] > eax: ffffff82 ebx: c0336778 ecx: 0007a11f edx: ffffff82 > esi: c4851000 edi: c2e36000 ebp: 00000000 esp: c2e37f30 > ds: 0069 es: 0069 ss: 0069 > Process insmod (pid: 9356, threadinfo=c2e36000 task=c13ee6b0) > Stack: c4850a04 c0336778 c0336778 c4850258 00000001 c0000000 00000003 c2e37f58 > c02ee921 00000000 ffffffba c011d8b0 00000000 000018c8 c03ac103 00000000 > 00000043 c0336760 c011d6f4 0000000a 00000400 c4850864 c0336778 > c4851000 > Call Trace: > [<c4850258>] memory_map+0x44/0x620 [pagemap_2] > [<c02ee921>] preempt_schedule+0x29/0x42 > [<c011d8b0>] release_console_sem+0x113/0x12d > [<c011d6f4>] printk+0x148/0x1ad > [<c4850027>] init_module+0x27/0x39 [pagemap_2] > [<c0133b40>] sys_init_module+0x115/0x25e > [<c010d52b>] syscall_call+0x7/0xc > > Code: 0f 20 c3 89 d0 e6 80 e6 80 83 e9 01 79 f5 c7 04 24 17 0a 85 > =============================================================================> printk("About to read CR0\n"); > for (i=0;i<500000;i++) outb_p(0x82,0x80); > __asm__("movl %%cr0, %0": "=r" (cr0)); > for (i=0;i<500000;i++) outb_p(0x82,0x80); > printk("Just read CR0\n"); > =============================================================================> Linux redbull 2.6.8.1-xen0 #9 Sun Oct 31 11:05:07 MST 2004 i686 i686 i386 GNU/Linux > =============================================================================> > > > > ------------------------------------------------------- > 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@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/xen-devel------------------------------------------------------- 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@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/xen-devel
> 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@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/xen-devel
> > 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 ?Nope, that''s the initial page table when the machine boots. Even if it were possible from ring 1, reading cr3 directly wouldn''t necessary give you want you want e.g. if you ''re in one of the shadow page table modes. The easiest way to get the base within Linux is current->mm->pgd (modulo lazy switching). Ian ------------------------------------------------------- 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@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/xen-devel
On Sun, 28 Nov 2004, Ian Pratt wrote:> Nope, that''s the initial page table when the machine boots. > > Even if it were possible from ring 1, reading cr3 directly > wouldn''t necessary give you want you want e.g. if you ''re in one > of the shadow page table modes. > > The easiest way to get the base within Linux is current->mm->pgd > (modulo lazy switching).I must be missing something obvious. Using 4MB pages, under xenolinux, when I try to print the Page Directory I Get output like this. PD 0x020-0x020[0x04965067]V:0128M-0132M-1>P:++++M-++++M-1 S:0004MB F:PK PD 0x100-0x100[0x04191067]V:1024M-1028M-1>P:++++M-++++M-1 S:0004MB F:PK PD 0x2FF-0x2FF[0x04b54067]V:3068M-3072M-1>P:++++M-++++M-1 S:0004MB F:PK PD 0x300-0x30F[0x02c0f067]V:3072M-3136M-1>P:++++M-++++M-1 S:0064MB F:PK PD 0x312-0x312[0x06b00067]V:3144M-3148M-1>P:++++M-++++M-1 S:0004MB F:PK PD 0x3EF-0x3EF[0x02c10067]V:4028M-4032M-1>P:++++M-++++M-1 S:0004MB F:PK PD 0x3F0-0x3F0[0x00c001e1]V:4032M-4036M-1>P:0012M-0016M-1 S:0004MB F:PM PD 0x3F1-0x3FA[0x024001e3]V:4036M-4076M-1>P:0000M-0040M-1 S:0040MB F:PM PD 0x3FB-0x3FB[0x040cf063]V:4076M-4080M-1>P:++++M-++++M-1 S:0004MB F:PK PD 0x3FD-0x3FD[0x001ef063]V:4084M-4088M-1>P:++++M-++++M-1 S:0004MB F:PK PD 0x3FE-0x3FF[0x0017d063]V:4088M-4096M-1>P:++++M-++++M-1 S:0008MB F:PK This _seems_ mostly correct since those 4032M-4036 and 4036M-4076 (repeated below) seem to match original setup from x86_32.S PD 0x3F0-0x3F0[0x00c001e1]V:4032M-4036M-1>P:0012M-0016M-1 S:0004MB F:PM PD 0x3F1-0x3FA[0x024001e3]V:4036M-4076M-1>P:0000M-0040M-1 S:0040MB F:PM I can also repeat the said output using 4kb pages setup. PD 0x020-0x020[0x03a12067]V:0128M-0132M-1>P:++++M-++++M-1 S:0004MB F:PK PD 0x100-0x100[0x03a13067]V:1024M-1028M-1>P:++++M-++++M-1 S:0004MB F:PK PD 0x2FF-0x2FF[0x03a11067]V:3068M-3072M-1>P:++++M-++++M-1 S:0004MB F:PK PD 0x300-0x30F[0x02c0f067]V:3072M-3136M-1>P:++++M-++++M-1 S:0064MB F:PK PD 0x312-0x312[0x03cfc067]V:3144M-3148M-1>P:++++M-++++M-1 S:0004MB F:PK PD 0x3EF-0x3EF[0x02c10067]V:4028M-4032M-1>P:++++M-++++M-1 S:0004MB F:PK PD 0x3F0-0x3F0[0x004f9021]V:4032M-4036M-1>P:++++M-++++M-1 S:0004MB F:PK PD 0x3F1-0x3FA[0x004ff023]V:4036M-4076M-1>P:++++M-++++M-1 S:0040MB F:PK PD 0x3FB-0x3FB[0x05540063]V:4076M-4080M-1>P:++++M-++++M-1 S:0004MB F:PK PD 0x3FD-0x3FD[0x005ed063]V:4084M-4088M-1>P:++++M-++++M-1 S:0004MB F:PK PD 0x3FE-0x3FF[0x0057f063]V:4088M-4096M-1>P:++++M-++++M-1 S:0008MB F:PK once again I get 4032M-4036 and 4036M-4076, and the "PK" instead of "PM" indicates that it is using 4kb pages instead of 4mb pages. PD 0x3F0-0x3F0[0x004f9021]V:4032M-4036M-1>P:++++M-++++M-1 S:0004MB F:PK PD 0x3F1-0x3FA[0x004ff023]V:4036M-4076M-1>P:++++M-++++M-1 S:0040MB F:PK All dandy and nice. now the weird part is that if I try to list Page Table entries referenced by by Page Directory in either setup I get an ooops saying that the referneced Page Table is not in memory. No such problems in linux classic... weird. ------------------------------------------------------- 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@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/xen-devel
> All dandy and nice. now the weird part is that if I try to list Page Table > entries referenced by by Page Directory in either setup I get an ooops > saying that the referneced Page Table is not in memory. > > No such problems in linux classic... weird.How are you converting the address in the PDE into something you can dereference? You should be using machine_to_virt() (*not* phys_to_virt()). -- Keir ------------------------------------------------------- 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@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/xen-devel
> > All dandy and nice. now the weird part is that if I try to list Page Table > > entries referenced by by Page Directory in either setup I get an ooops > > saying that the referneced Page Table is not in memory. > > > > No such problems in linux classic... weird. > > How are you converting the address in the PDE into something you can > dereference? You should be using machine_to_virt() (*not* > phys_to_virt()).yeah, that definitely helps, in so far that I was able to list low memory, ie 0-(4gb-64), but it still seems to get confused once it gets into xen space... PD 0x313-0x3EE[0x00000000]V:3148M-4028M-1>P:????M-????M-1 S:0880MB F:__ PD 0x3EF-0x3EF[0x02c10067]V:4028M-4032M-1>P:++++M-++++M-1 S:0004MB F:PK Printing Page Table (0x3EF) PT Base Address (physical): 0x02C10000 PT Base Address (virtual) : 0xC0010000 PT 000-2FA V:4028M.0000K-4030M.1004K-1>P:!!!!!!!!!!K-!!!!!!!!!!K-1 S:3052K F:_ PT 2FB-3FA V:4030M.1004K-4031M.1004K-1>P:0000M.0000K-0001M.0000K-1 S:1024K F:P PT 3FB-3FB V:4031M.1004K-4031M.1008K-1>P:!!!!!!!!!!K-!!!!!!!!!!K-1 S:0004K F:_ PT 3FC-3FC V:4031M.1008K-4031M.1012K-1>P:0005M.0952K-0005M.0956K-1 S:0004K F:P PT 3FD-3FD V:4031M.1012K-4031M.1016K-1>P:0060M.0840K-0060M.0844K-1 S:0004K F:P PT 3FE-3FF V:4031M.1016K-4032M.0000K-1>P:!!!!!!!!!!K-!!!!!!!!!!K-1 S:0008K F:_ PD 0x3F0-0x3F0[0x004f9021]V:4032M-4036M-1>P:++++M-++++M-1 S:0004MB F:PK Printing Page Table (0x3F0) PT Base Address (physical): 0x004F9000 PT Base Address (virtual) : 0x15555000 Unable to handle kernel paging request at virtual address 15555000 ------------------------------------------------------- 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@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/xen-devel
> > > > All dandy and nice. now the weird part is that if I try to list Page Table > > > entries referenced by by Page Directory in either setup I get an ooops > > > saying that the referneced Page Table is not in memory. > > > > > > No such problems in linux classic... weird. > > > > How are you converting the address in the PDE into something you can > > dereference? You should be using machine_to_virt() (*not* > > phys_to_virt()). > > yeah, that definitely helps, in so far that I was able to list low > memory, ie 0-(4gb-64), but it still seems to get confused once it gets > into xen space...Your Linux instance has no valid virtual address for the Xen-private page tables (machine_to_virt() is only usable for pages of memory that are permanently mapped into Linux''s address space). In fact, Xen won''t allow any domain to map any of it''s private memory, so there is no way for you to print the PT contents from Linux, unless you hack the mapping-checking code in Xen. -- Keir ------------------------------------------------------- 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@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/xen-devel