[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] Re: how to transfer virtual address into pyhsical address
I use get_free_pages to get a contiguous virtual space, then get physical address for DMA with virt_to_bus. Regards Yong. > Related to this, can you tell me whether the memory allocated to a domain is > contiguous in machine RAM (given the calls to xen_create_contiguous, seems > like it is not)? > > Thanks, > Himanshu > > On Wed, Feb 15, 2006 at 02:13:52PM +0100, Mathieu Ropert wrote: > > Yong LIU wrote: > > >I write a very simple module to test memory address translation. > > >When I install the module under xen 3.0, kernel panic. But when > > >I install it under xen3.0 & kernel 2.6.16-rc2, it can work well. > > > > > >My question is: Is there a different way to translate virtual address > > >into physical address under Xen 3.0? > > >thanks for help. > > > > > >dmesg information. > > >-------------------------------------------------------- > > >hello: module license 'unspecified' taints kernel. > > >Unable to handle kernel paging request at virtual address 3e0c5b0c > > > printing eip: > > >f483c023 > > >*pde = ma 00000000 pa 55555000 > > >Oops: 0000 [#1] > > >SMP > > >Modules linked in: hello iptable_filter ip_tables video thermal > > >processor fan button battery ac > > >CPU: 1 > > >EIP: 0061:[<f483c023>] Tainted: P VLI > > >EFLAGS: 00010206 (2.6.12.6-xen0-smp) > > >EIP is at kvirt_to_pa+0x23/0x3c [hello] > > >eax: 7e0c5000 ebx: f22c3000 ecx: 00000b0c edx: 000003c8 > > >esi: f2026000 edi: c0000000 ebp: f2026000 esp: f2027f90 > > >ds: 007b es: 007b ss: 0069 > > >Process insmod (pid: 4710, threadinfo=f2026000 task=f27c4520) > > >Stack: f483e01a f22c3000 f483c380 c013a1f8 c05a10a8 00000001 f483c380 > > >0804a060 > > > b7fb3ff4 b7fb5538 c0109021 0804a060 00000dda 0804a050 b7fb3ff4 > > >b7fb5538 > > > bffd6558 00000080 0000007b c010007b 00000080 b7f5667e 00000073 > > >00010246 > > >Call Trace: > > > [<f483e01a>] hello_init_module+0x1a/0x2d [hello] > > > [<c013a1f8>] sys_init_module+0x145/0x1e1 > > > [<c0109021>] syscall_call+0x7/0xb > > >Code: Bad EIP value. > > >------------------------------------------------------- > > >here is the code. > > >#include <linux/init.h> > > >#include <linux/kernel.h> > > >#include <linux/module.h> > > > > > >#include <asm/pgtable.h> > > >#include <asm/page.h> > > > > > >static void kvirt_to_pa(void *vaddr) > > >{ > > > unsigned long addr=(unsigned long) vaddr; > > > unsigned long pte_value; > > > pgd_t *pgd=NULL; > > > pmd_t *pmd=NULL; > > > pte_t *pte=NULL; > > > > > > pgd=pgd_offset_k(addr); > > > if(pgd_none(*pgd)) > > > goto hello_failed; > > > pmd=pmd_offset(pgd, addr); > > > if(pmd_none(*pmd)) > > > goto hello_failed; > > > pte=pte_offset_kernel(pmd, addr); > > > if(!pte_present(*pte)) > > > goto hello_failed; > > > > > > pte_value= pte_val(*pte) & PAGE_MASK | (addr & (PAGE_SIZE - 1)); > > > return; > > > > > >hello_failed: > > > printk(" failed\n"); > > > return; > > >} > > >static int __init hello_init_module(void) > > >{ > > > void * page=NULL; > > > page=__get_free_pages(GFP_KERNEL, 0); > > > kvirt_to_pa(page); > > > free_page(page); > > > return 1; > > >} > > > > > > > > >static void __exit hello_exit_module(void) > > >{ > > > printk(" say bye\n"); > > > return; > > >} > > >module_init(hello_init_module); > > >module_exit(hello_exit_module); > > > > __alloc_pages() returns a pointer to a page struct, not the virtual > > address of the allocated page. You can't use it directly like you do. > > If you want the virtual address, either use page_address(page) or try > > some get_*_page function directly instead of alloc_pages(). > > > > Regards, > > Mathieu _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |