LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Modifying pagetable entries (https://www.linuxquestions.org/questions/programming-9/modifying-pagetable-entries-520453/)

Kumar 01-18-2007 05:46 AM

Modifying pagetable entries
 
Hi,
I am developing a chardriver which implements mmap using nopage method where I handle the pagefaults in that range. The problem is that the pagefault handler runs only once for any access in that page. My requirement is that, everytime the page is written, the handler should be invoked. So, I tried marking the page as read-only. But it's still not working. Following is the code snippet. Can anyone please tell me where am I going wrong? I am using kernel 2.6.19-1, gcc 3.4.6 on x86_64 architecture.

Code:

mmap_vma_nopage (struct vm_area_struct *vma, unsigned long address,
                  int write)
{
  ...

  pgd_t * pgd;
  pud_t * pud;
  pmd_t * pmd;
  pte_t * pte;

  pgd=pgd_offset(vma->vm_mm,address);
  pud=pud_offset(pgd,address);
  pmd=pmd_offset(pud,address);
  pte=pte_offset_map(pmd,address&PAGE_MASK);




  set_pte(pte,pte_wrprotect(*pte));
  set_pte(pte,pte_rdprotect(*pte));
  pte_unmap(pte);
  global_flush_tlb();

  ...

}



Thanks,


All times are GMT -5. The time now is 09:36 PM.