On 5/28/14, Greg KH <greg@xxxxxxxxx> wrote: > On Wed, May 28, 2014 at 06:47:24PM +0530, Pranay Srivastava wrote: >> Hi >> >> I need to capture all writes on page which is memory mapped by the >> user program. > > For what and what are you going to do with them once you "capture" them? > This is just as an exercise nothing in specific. Currently what I've is a misc_device having a page of memory. I've made it available through mmap to user space programs(again this is just an exercise). > Are you trying to capture them in the kernel or in userspace? So after a user space program has done mmap of this page to its address space, I wanted the writes to be captured. Now if i don't set the VM_WRITE in vm_flags then __do_fault sends sends the SEGV and if I do set it then I'm able to get the first fault (read or write access). > >> I've tried setting the vm_page_prot by disabling the >> VM_WRITE flag but even then the page fault occurs only once during the >> first write. VM_SHARED is set to stop COW in the __do_fault. >> >> I was also trying to set_memory_ro(this may not be available for all >> archs?) however I can't do that while handling the fault since the >> page table entries are created later after the >> vm_operations_struct->fault has installed the page for the fault. >> >> I'm not having any clues on how to do this. Any help would be really >> helpful on this. > > I don't think this is going to be possible, sorry, please go revisit > the reason you think you want to do this. > > greg k-h > Actually trying to do something like if there's a write being done on the page by a task currently then other tasks should wait( was hoping that the fault handler code would be called for write but doesn't happen that way). Yes through write operation I can do with mutex but I was wondering what if this has to be done through mmap of my misc_device then no read/write calls involved so just wanted to see how would I stop multiple writes to my misc_device. Perhaps there are other methods as to how device memory can be mapped to user space? or they aren't at all? Not really sure just reading and trying. -- ---P.K.S _______________________________________________ Kernelnewbies mailing list Kernelnewbies@xxxxxxxxxxxxxxxxx http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies