- volatile x86_pte_t* pte = &PTE_MOUNTED(PD_REFERENCED, ptr >> 12);
- if (PG_PRESENTED(*pte)) {
+ volatile x86_pte_t* pte = &PTE_MOUNTED(VMS_SELF, ptr >> 12);
+ if (PG_IS_PRESENT(*pte)) {
if ((hit_region->attr & COW_MASK) == COW_MASK) {
// normal page fault, do COW
cpu_invplg(pte);
uintptr_t pa =
(uintptr_t)vmm_dup_page(__current->pid, PG_ENTRY_ADDR(*pte));
pmm_free_page(__current->pid, *pte & ~0xFFF);
if ((hit_region->attr & COW_MASK) == COW_MASK) {
// normal page fault, do COW
cpu_invplg(pte);
uintptr_t pa =
(uintptr_t)vmm_dup_page(__current->pid, PG_ENTRY_ADDR(*pte));
pmm_free_page(__current->pid, *pte & ~0xFFF);
// an anonymous page and not present
// -> a new page need to be alloc
if ((hit_region->attr & REGION_ANON)) {
// an anonymous page and not present
// -> a new page need to be alloc
if ((hit_region->attr & REGION_ANON)) {
struct v_file* file = hit_region->mfile;
u32_t offset =
(ptr - hit_region->start) & (PG_SIZE - 1) + hit_region->offset;
struct v_file* file = hit_region->mfile;
u32_t offset =
(ptr - hit_region->start) & (PG_SIZE - 1) + hit_region->offset;
- int errno = file->ops->read_page(file->inode, ptr, PG_SIZE, offset);
+ int errno = 0;
+ if (hit_region->init_page) {
+ errno = hit_region->init_page(hit_region, ptr, offset);
+ } else {
+ errno = file->ops->read_page(file->inode, ptr, PG_SIZE, offset);
+ }
+