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

Function pmap_pinit

freebsd/arm/arm/pmap-v6.c:2184–2298  ·  view source on GitHub ↗

* Initialize a preallocated and zeroed pmap structure, * such as one in a vmspace structure. */

Source from the content-addressed store, hash-verified

2182 * such as one in a vmspace structure.
2183 */
2184int
2185pmap_pinit(pmap_t pmap)
2186{
2187 pt1_entry_t *pte1p;
2188 pt2_entry_t *pte2p;
2189 vm_paddr_t pa, pt2tab_pa;
2190 u_int i;
2191
2192 PDEBUG(6, printf("%s: pmap = %p, pm_pt1 = %p\n", __func__, pmap,
2193 pmap->pm_pt1));
2194
2195 /*
2196 * No need to allocate L2 page table space yet but we do need
2197 * a valid L1 page table and PT2TAB table.
2198 *
2199 * Install shared kernel mappings to these tables. It's a little
2200 * tricky as some parts of KVA are reserved for vectors, devices,
2201 * and whatever else. These parts are supposed to be above
2202 * vm_max_kernel_address. Thus two regions should be installed:
2203 *
2204 * (1) <KERNBASE, kernel_vm_end),
2205 * (2) <vm_max_kernel_address, 0xFFFFFFFF>.
2206 *
2207 * QQQ: The second region should be stable enough to be installed
2208 * only once in time when the tables are allocated.
2209 * QQQ: Maybe copy of both regions at once could be faster ...
2210 * QQQ: Maybe the other TTBR is an option.
2211 *
2212 * Finally, install own PT2TAB table to these tables.
2213 */
2214
2215 if (pmap->pm_pt1 == NULL) {
2216 pmap->pm_pt1 = (pt1_entry_t *)kmem_alloc_contig(NB_IN_PT1,
2217 M_NOWAIT | M_ZERO, 0, -1UL, NB_IN_PT1, 0, pt_memattr);
2218 if (pmap->pm_pt1 == NULL)
2219 return (0);
2220 }
2221 if (pmap->pm_pt2tab == NULL) {
2222 /*
2223 * QQQ: (1) PT2TAB must be contiguous. If PT2TAB is one page
2224 * only, what should be the only size for 32 bit systems,
2225 * then we could allocate it with vm_page_alloc() and all
2226 * the stuff needed as other L2 page table pages.
2227 * (2) Note that a process PT2TAB is special L2 page table
2228 * page. Its mapping in kernel_arena is permanent and can
2229 * be used no matter which process is current. Its mapping
2230 * in PT2MAP can be used only for current process.
2231 */
2232 pmap->pm_pt2tab = (pt2_entry_t *)kmem_alloc_attr(NB_IN_PT2TAB,
2233 M_NOWAIT | M_ZERO, 0, -1UL, pt_memattr);
2234 if (pmap->pm_pt2tab == NULL) {
2235 /*
2236 * QQQ: As struct pmap is allocated from UMA with
2237 * UMA_ZONE_NOFREE flag, it's important to leave
2238 * no allocation in pmap if initialization failed.
2239 */
2240 kmem_free((vm_offset_t)pmap->pm_pt1, NB_IN_PT1);
2241 pmap->pm_pt1 = NULL;

Callers

nothing calls this directly

Calls 13

kmem_alloc_attrFunction · 0.85
pte1_copy_nosyncFunction · 0.85
pt2tab_copy_nosyncFunction · 0.85
pmap_pt2tab_entryFunction · 0.85
pt2tab_storeFunction · 0.85
pmap_pte1Function · 0.85
pte1_storeFunction · 0.85
pte1_sync_rangeFunction · 0.85
pte2_sync_rangeFunction · 0.85
bzeroFunction · 0.85
printfFunction · 0.50
kmem_alloc_contigFunction · 0.50

Tested by

no test coverage detected