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

Function sysctl_kmaps

freebsd/amd64/amd64/pmap.c:11281–11418  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11279}
11280
11281static int
11282sysctl_kmaps(SYSCTL_HANDLER_ARGS)
11283{
11284 struct pmap_kernel_map_range range;
11285 struct sbuf sbuf, *sb;
11286 pml4_entry_t pml4e;
11287 pdp_entry_t *pdp, pdpe;
11288 pd_entry_t *pd, pde;
11289 pt_entry_t *pt, pte;
11290 vm_offset_t sva;
11291 vm_paddr_t pa;
11292 int error, i, j, k, l;
11293
11294 error = sysctl_wire_old_buffer(req, 0);
11295 if (error != 0)
11296 return (error);
11297 sb = &sbuf;
11298 sbuf_new_for_sysctl(sb, NULL, PAGE_SIZE, req);
11299
11300 /* Sentinel value. */
11301 range.sva = la57 ? KV5ADDR(NPML5EPG - 1, NPML4EPG - 1, NPDPEPG - 1,
11302 NPDEPG - 1, NPTEPG - 1) : KV4ADDR(NPML4EPG - 1, NPDPEPG - 1,
11303 NPDEPG - 1, NPTEPG - 1);
11304
11305 /*
11306 * Iterate over the kernel page tables without holding the kernel pmap
11307 * lock. Outside of the large map, kernel page table pages are never
11308 * freed, so at worst we will observe inconsistencies in the output.
11309 * Within the large map, ensure that PDP and PD page addresses are
11310 * valid before descending.
11311 */
11312 for (sva = 0, i = pmap_pml4e_index(sva); i < NPML4EPG; i++) {
11313 switch (i) {
11314 case PML4PML4I:
11315 sbuf_printf(sb, "\nRecursive map:\n");
11316 break;
11317 case DMPML4I:
11318 sbuf_printf(sb, "\nDirect map:\n");
11319 break;
11320 case KPML4BASE:
11321 sbuf_printf(sb, "\nKernel map:\n");
11322 break;
11323 case LMSPML4I:
11324 sbuf_printf(sb, "\nLarge map:\n");
11325 break;
11326 }
11327
11328 /* Convert to canonical form. */
11329 if (sva == 1ul << 47)
11330 sva |= -1ul << 48;
11331
11332restart:
11333 pml4e = kernel_pml4[i];
11334 if ((pml4e & X86_PG_V) == 0) {
11335 sva = rounddown2(sva, NBPML4);
11336 sysctl_kmaps_dump(sb, &range, sva);
11337 sva += NBPML4;
11338 continue;

Callers

nothing calls this directly

Calls 12

sysctl_wire_old_bufferFunction · 0.85
sbuf_new_for_sysctlFunction · 0.85
pmap_pml4e_indexFunction · 0.85
sbuf_printfFunction · 0.85
pmap_pdpe_indexFunction · 0.85
vm_phys_paddr_to_vm_pageFunction · 0.85
pmap_pde_indexFunction · 0.85
pmap_pte_indexFunction · 0.85
sbuf_finishFunction · 0.85
sbuf_deleteFunction · 0.85
sysctl_kmaps_dumpFunction · 0.70
sysctl_kmaps_checkFunction · 0.70

Tested by

no test coverage detected