linux - How can I use the vm_operations struct to intercept page faults to a particular set of pages? -
i create kernel module when given id of process can lookup task struct , memory map. when finds should attach function serve page faults particular set of pages (namely heap pages). set vma->vm_ops->fault of needed vma. can easier, if hack heap allocator , replace mmap s mmap_anonymous mmap of special device. code related: http://lxr.free-electrons.com/source/mm/memory.c?v=3.12#l3676 3689 static int handle_pte_fault(struct mm_struct *mm, 3690 struct vm_area_struct *vma, unsigned long address, 3691 pte_t *pte, pmd_t *pmd, unsigned int flags) 3692 { 3693 pte_t entry; 3694 spinlock_t *ptl; 3695 3696 entry = *pte; 3697 if (!pte_present(entry)) { 3698 if (pte_none(entry)) { 3699 if (vma->vm_ops) { 3700 if (likely(vma->vm_ops->fault)) /* here */ 3701 return do_linear_fault(...