FreeBSD/sys/arm/arm/pmap-v6.c
/*
 *  Abuse the pte2 nodes for unmapped kva to thread a kva freelist through.
 *  Requirements:
 *   - Must deal with pages in order to ensure that none of the PTE2_* bits
 *     are ever set, PTE2_V in particular.
 *   - Assumes we can write to pte2s without pte2_store() atomic ops.
 *   - Assumes nothing will ever test these addresses for 0 to indicate
 *     no mapping instead of correctly checking PTE2_V.
 *   - Assumes a vm_offset_t will fit in a pte2 (true for arm).
 *  Because PTE2_V is never set, there can be no mappings to invalidate.
 */
Abuse the pte2 nodes for unmapped kva to thread a kva freelist through.
Requirements:
- Must deal with pages in order to ensure that none of the PTE2_* bits
are ever set, PTE2_V in particular.
- Assumes we can write to pte2s without pte2_store() atomic ops.
- Assumes nothing will ever test these addresses for 0 to indicate
no mapping instead of correctly checking PTE2_V.
- Assumes a vm_offset_t will fit in a pte2 (true for arm).
Because PTE2_V is never set, there can be no mappings to invalidate.
Abuse the pte2 nodes for unmapped kva to thread a kva freelist through . Requirements : - Must deal with pages in order to ensure that none of the PTE2_ * bits are ever set PTE2_V in particular . - Assumes we can write to pte2s without pte2_store () atomic ops . - Assumes nothing will ever test these addresses for 0 to indicate no mapping instead of correctly checking PTE2_V . - Assumes a vm_offset_t will fit in a pte2 ( true for arm ) . Because PTE2_V is never set there can be no mappings to invalidate .
static vm_offset_t
pmap_pte2list_alloc(vm_offset_t *head)
{
	pt2_entry_t *pte2p;
	vm_offset_t va;
	va = *head;
	if (va == 0)
		panic("pmap_ptelist_alloc: exhausted ptelist KVA");
	pte2p = pt2map_entry(va);
	*head = *pte2p;
	if (*head & PTE2_V)
		panic("%s: va with PTE2_V set!", __func__);
	*pte2p = 0;
	return (va);
}
static vm_offset_t pmap_pte2list_alloc ( vm_offset_t * head ) { pt2_entry_t * pte2p ; vm_offset_t va ; va = * head ; if ( va == 0 ) panic ( " " ) ; pte2p = pt2map_entry ( va ) ; * head = * pte2p ; if ( * head & PTE2_V ) panic ( " " , __func__ ) ; * pte2p = 0 ; return ( va ) ; }
Abuse the pte2 nodes for unmapped kva to thread a kva freelist through.
Abuse the pte2 nodes for unmapped kva to thread a kva freelist through .