FreeBSD/sys/arm64/arm64/pmap.c
/*
 *	Routine:	pmap_extract_and_hold
 *	Function:
 *		Atomically extract and hold the physical page
 *		with the given pmap and virtual address pair
 *		if that mapping permits the given protection.
 */
pmap_extract_and_hold
Function:
Atomically extract and hold the physical page
with the given pmap and virtual address pair
if that mapping permits the given protection.
pmap_extract_and_hold Function : Atomically extract and hold the physical page with the given pmap and virtual address pair if that mapping permits the given protection .
vm_page_t
pmap_extract_and_hold(pmap_t pmap, vm_offset_t va, vm_prot_t prot)
{
	pt_entry_t *pte, tpte;
	vm_paddr_t pa;
	vm_page_t m;
	int lvl;
	pa = 0;
	m = NULL;
	PMAP_LOCK(pmap);
retry:
	pte = pmap_pte(pmap, va, &lvl);
	if (pte != NULL) {
		tpte = pmap_load(pte);
		KASSERT(lvl > 0 && lvl <= 3,
		    ("pmap_extract_and_hold: Invalid level %d", lvl));
		CTASSERT(L1_BLOCK == L2_BLOCK);
		KASSERT((lvl == 3 && (tpte & ATTR_DESCR_MASK) == L3_PAGE) ||
		    (lvl < 3 && (tpte & ATTR_DESCR_MASK) == L1_BLOCK),
		    ("pmap_extract_and_hold: Invalid pte at L%d: %lx", lvl,
		     tpte & ATTR_DESCR_MASK));
		if (((tpte & ATTR_AP_RW_BIT) == ATTR_AP(ATTR_AP_RW)) ||
		    ((prot & VM_PROT_WRITE) == 0)) {
			if (vm_page_pa_tryrelock(pmap, tpte & ~ATTR_MASK, &pa))
				goto retry;
			m = PHYS_TO_VM_PAGE(tpte & ~ATTR_MASK);
			vm_page_hold(m);
		}
	}
	PA_UNLOCK_COND(pa);
	PMAP_UNLOCK(pmap);
	return (m);
}
vm_page_t pmap_extract_and_hold ( pmap_t pmap , vm_offset_t va , vm_prot_t prot ) { pt_entry_t * pte , tpte ; vm_paddr_t pa ; vm_page_t m ; int lvl ; pa = 0 ; m = NULL ; PMAP_LOCK ( pmap ) ; retry : pte = pmap_pte ( pmap , va , & lvl ) ; if ( pte != NULL ) { tpte = pmap_load ( pte ) ; KASSERT ( lvl > 0 && lvl <= 3 , ( " " , lvl ) ) ; CTASSERT ( L1_BLOCK == L2_BLOCK ) ; KASSERT ( ( lvl == 3 && ( tpte & ATTR_DESCR_MASK ) == L3_PAGE ) || ( lvl < 3 && ( tpte & ATTR_DESCR_MASK ) == L1_BLOCK ) , ( " " , lvl , tpte & ATTR_DESCR_MASK ) ) ; if ( ( ( tpte & ATTR_AP_RW_BIT ) == ATTR_AP ( ATTR_AP_RW ) ) || ( ( prot & VM_PROT_WRITE ) == 0 ) ) { if ( vm_page_pa_tryrelock ( pmap , tpte & ~ ATTR_MASK , & pa ) ) goto retry ; m = PHYS_TO_VM_PAGE ( tpte & ~ ATTR_MASK ) ; vm_page_hold ( m ) ; } } PA_UNLOCK_COND ( pa ) ; PMAP_UNLOCK ( pmap ) ; return ( m ) ; }
Routine:        pmap_extract_and_hold
      Function:
              Atomically extract and hold the physical page
              with the given pmap and virtual address pair
              if that mapping permits the given protection.
Routine : pmap_extract_and_hold Function : Atomically extract and hold the physical page with the given pmap and virtual address pair if that mapping permits the given protection .