static void vm_pagemem_init() { npg_pdpe_t *pdp = info->vm.cpu.pg[0].pdp[0]; npg_init(); npg_set_entry(&info->vm.cpu.pg[0].pml4[0], npg_dft_attr, page_nr(pdp)); }
static void __npg_map_1G_nolarge(npg_pdpe_t *pdpe, offset_t addr, uint64_t attr) { npg_pde64_t *pd; uint32_t i; pd = __npg_new_pd(); debug(PG_MAP, "map 2M for each pde\n"); for(i=0 ; i<PDE64_PER_PD ; i++) { __npg_map_2M(&pd[i], addr, attr); addr += PG_2M_SIZE; } /* upper-level entry has full pvl */ npg_set_entry(pdpe, attr|npg_dft_pvl, page_nr(pd)); debug(PG_MAP, "mapped 1G until 0x%X 0x%X\n", addr, attr); }
/* ** Low level services */ static void __npg_map_2M_nolarge(npg_pde64_t *pde, offset_t addr, uint64_t attr) { npg_pte64_t *pt; offset_t pfn; uint32_t i; pt = __npg_new_pt(); debug(PG_MAP, "new pt\n"); pfn = pg_4K_nr(addr); debug(PG_MAP, "mapping 4K for each pte\n"); for(i=0 ; i<PTE64_PER_PT ; i++, pfn++) npg_set_page_entry(&pt[i], attr, pfn); /* upper-level entry has full pvl */ npg_set_entry(pde, attr|npg_dft_pvl, page_nr(pt)); debug(PG_MAP, "mapped 2M 0x%X 0x%X\n", addr, attr); }
/* ** resolve pte (allocate pt if needed for non-large pde ** return 0 if large page */ static inline npg_pte64_t* __npg_resolve_pte(npg_pde64_t *pde, offset_t addr, uint64_t attr) { npg_pte64_t *pt; if(!npg_present(pde)) { pt = __npg_new_pt(); /* upper-level entry has full pvl */ npg_set_entry(pde, attr|npg_dft_pvl, page_nr(pt)); } else if(npg_large(pde)) return 0; else pt = (npg_pte64_t*)page_addr(pde->addr); return &pt[pt64_idx(addr)]; }
/* ** resolve pde (allocate pd if needed) for non-large pdpe ** return 0 if large page */ static inline npg_pde64_t* __npg_resolve_pde(npg_pdpe_t *pdpe, offset_t addr, uint64_t attr) { npg_pde64_t *pd; if(!npg_present(pdpe)) { pd = __npg_new_pd(); /* upper-level entry has full pvl */ npg_set_entry(pdpe, attr|npg_dft_pvl, page_nr(pd)); } else if(npg_large(pdpe)) return 0; else pd = (npg_pde64_t*)page_addr(pdpe->addr); return &pd[pd64_idx(addr)]; }
/* ** resolve pdpe (allocate pdp if needed) */ static inline npg_pdpe_t* __npg_resolve_pdpe(offset_t addr, uint64_t attr) { vm_pgmem_t *pg = npg_get_active_paging(); npg_pml4e_t *pml4e; npg_pdpe_t *pdp; pml4e = &pg->pml4[pml4_idx(addr)]; if(!npg_present(pml4e)) { pdp = __npg_new_pdp(); /* upper-level entry has full pvl */ npg_set_entry(pml4e, attr|npg_dft_pvl, page_nr(pdp)); } else pdp = (npg_pdpe_t*)page_addr(pml4e->addr); return &pdp[pdp_idx(addr)]; }