Messages in this thread | | | From | Vinesh Christopher <> | Subject | Memory corruption in mmap whe accessing more than 4K (Page Size) | Date | Thu, 19 Jun 2003 16:57:32 -0400 |
| |
I am having a driver which allocates 2MB of contiguous physical memory using get_free_pages(). A user-mode program has to access this memory using mmap(). The user mode repeatedly opens the driver, mmap the memory access the memory for some time , then munmaps the memory and closes the memory. After some period of time, the kernel / process crashes and panics
If I use only 4K (Page Size) of memory, then it does not happen. Is there any restriction or any other way to access them?
struct page * sample_vma_nopage(struct vm_area_struct *vma,unsigned long address, int write) { unsigned long offset; unsigned long physaddr; struct page *page = NOPAGE_SIGBUS;
/* Compute the offset */ offset = (address - vma->vm_start) + VMA_OFFSET(vma);
/* Get the page in the 2MB buffer where the offset begins */ physaddr = MyBuffer +offset; page = virt_to_page(__va(physaddr));
/* Increment the count */ get_page(page);
return page; }
struct vm_operations_struct sample_vm_ops = { open : sample_vma_open, close : sample_vma_close, nopage : sample_vma_nopage, };
int videocap_mmap(struct file *filp, struct vm_area_struct *vma) {
/* Check if the offsets are aligned */ if (VMA_OFFSET(vma) & (PAGE_SIZE-1)) { TRACE_ERROR("mmap() received unaligned offsets. Cannot map \n"); return -ENXIO; }
vma->vm_flags |= VM_RESERVED; vma->vm_private_data = NULL; vma->vm_ops = &sample_vm_ops; sample_vma_open(vma); return 0; }
Any help will be appreciated
Regards Samvinesh Christopher
P.S: Iam not in the mailing list. So please CC to me @ vineshc@ami.com - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |