MCPcopy Create free account
hub / github.com/F-Stack/f-stack / pmap_allocpte

Function pmap_allocpte

freebsd/amd64/amd64/pmap.c:4583–4633  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4581}
4582
4583static vm_page_t
4584pmap_allocpte(pmap_t pmap, vm_offset_t va, struct rwlock **lockp)
4585{
4586 vm_pindex_t ptepindex;
4587 pd_entry_t *pd, PG_V;
4588 vm_page_t m;
4589
4590 PG_V = pmap_valid_bit(pmap);
4591
4592 /*
4593 * Calculate pagetable page index
4594 */
4595 ptepindex = pmap_pde_pindex(va);
4596retry:
4597 /*
4598 * Get the page directory entry
4599 */
4600 pd = pmap_pde(pmap, va);
4601
4602 /*
4603 * This supports switching from a 2MB page to a
4604 * normal 4K page.
4605 */
4606 if (pd != NULL && (*pd & (PG_PS | PG_V)) == (PG_PS | PG_V)) {
4607 if (!pmap_demote_pde_locked(pmap, pd, va, lockp)) {
4608 /*
4609 * Invalidation of the 2MB page mapping may have caused
4610 * the deallocation of the underlying PD page.
4611 */
4612 pd = NULL;
4613 }
4614 }
4615
4616 /*
4617 * If the page table page is mapped, we just increment the
4618 * hold count, and activate it.
4619 */
4620 if (pd != NULL && (*pd & PG_V) != 0) {
4621 m = PHYS_TO_VM_PAGE(*pd & PG_FRAME);
4622 m->ref_count++;
4623 } else {
4624 /*
4625 * Here if the pte page isn't mapped, or if it has been
4626 * deallocated.
4627 */
4628 m = pmap_allocpte_alloc(pmap, ptepindex, lockp, va);
4629 if (m == NULL && lockp != NULL)
4630 goto retry;
4631 }
4632 return (m);
4633}
4634
4635/***************************************************
4636 * Pmap allocation/deallocation routines.

Callers 1

pmap_copyFunction · 0.70

Calls 6

pmap_valid_bitFunction · 0.85
pmap_pde_pindexFunction · 0.85
pmap_demote_pde_lockedFunction · 0.85
PHYS_TO_VM_PAGEFunction · 0.85
pmap_allocpte_allocFunction · 0.85
pmap_pdeFunction · 0.70

Tested by

no test coverage detected