remap_pfn_range : Cant access mapped memory!

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

 



Hi all,
I have been trying to map memory to user space, but i get a strange problem.
Heres a kmsg dump
<1>Hello
<1>Success!
<1>Alloc memory now
<1>Virtual address of region alloced using kmalloc : d79ec000
<1>I'm ok!
<1>Virtual address of region alloced using kmalloc : d79ec000
<1>Physical address of region alloced using kmalloc : 179ec000
<1>VMA start for process : b7f22000
<1>VMA end for process : b7f23000
<1>Bye

and heres the code for allocating the memory area
base=kmalloc(PAGE_SIZE,GFP_KERNEL);
*base='a';
printk ("<1>%x",base);
mem_map_reserve(virt_to_page(base));

Heres the mmap code..It succeeds the dump doesnt say failed

unsigned long page,pos,basepos;
pos=(unsigned long) base;
printk ("<1>%x",pos);
page = virt_to_phys((void *)pos);
printk ("<1>%x",page);
printk ("<1>%x",vma->vm_start);
printk ("<1>%x",vma->vm_end);
if (remap_pfn_range(vma,vma->vm_start, page >> PAGE_SHIFT,
vma->vm_end-vma->vm_start, vma->vm_page_prot))
{
       printk ("<1>failed");
       return -EAGAIN;
}
return 0;

Heres a gdb dump for the process

Breakpoint 1, main () at userapp.c:21
(gdb) print p
$1 = 0xb7f22000 <Address 0xb7f22000 out of bounds>
(gdb) quit

This is btw a character device..
i do
int fd=open("....",O_RDONLY);
char *p = ( char *) mmap(NULL, 1024, PROT_READ,MAP_SHARED,fd,0);

All the calculations seem right...and remap was called with 0xb7f22000 as
the base to mmap..But the app complains that the page tables arent right!
I did a pagetable walk for vma->vm_start in current->mm and the
physical address was right! What could be the problem?

Thanks,
Sudharsan

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux