As I know, when program try to access virtual address that the corresponding PTE is NO present , kernel will trigger page fault and page fault handler will handle it. In handler, if fault is caused by no physical mapping to the PTE, kernel should allocate free physical page and write physical address to PTE. I found many functions like