Hi, I am trying to write a module that allocates memory in kernel ( kmalloc ) and maps it to the user space using do_mmap_pgoff. I have attached the code for the same. When I load the module and run ioctl from the user program it is giving error "Unable to handle kernel pageing request". Any help is appreciated. static int cosy_mmap_handler( struct file *file, struct vm_area_struct *vma ) { unsigned long physical; physical = vma->vm_pgoff << PAGE_SHIFT; physical = __pa(physical); if (remap_page_range(vma->vm_start, physical, vma->vm_end - vma->vm_s return -1; vma->vm_file = NULL; return 0; } int io_ioctl (struct inode *inode, struct file *file, unsigned int cmd, unsigned long user_ptr) { int i; unsigned long pAddr,uAddr = 0; struct file_operations fops; struct file pseudofile; unsigned long bsize = 4096; int *tmp; pAddr = (unsigned long) kmalloc( bsize + 2*PAGE_SIZE, GFP_KERNEL ); printk("\nThe kmallocked address = %ld",pAddr); pAddr = (unsigned long)(((unsigned long)pAddr + PAGE_SIZE -1) & PAGE_MASK); printk("\nPage aligned address = %ld",pAddr); for (uAddr = pAddr; uAddr<pAddr+bsize; uAddr += PAGE_SIZE) { mem_map_reserve(virt_to_page(uAddr)); } tmp = (int *)pAddr; for(i=0; i<bsize/(sizeof(int)); i++) tmp[i] = i; fops.mmap = cosy_mmap_handler; pseudofile.f_op = &fops; pseudofile.f_mode = 0x3; uAddr = do_mmap_pgoff( &pseudofile, 0, bsize, PROT_READ | PROT_WRITE, MAP_PRIVATE, pAddr); printk("\n do_mmaped address is = %ld",uAddr); tmp = (int *)pAddr; for(i=0; i<bsize/(sizeof(int)); i++) tmp[i] = 9; return uAddr; } --Amit - Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ IRC Channel: irc.openprojects.net / #kernelnewbies Web Page: http://www.kernelnewbies.org/