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

Function sysctl_kmaps

freebsd/arm64/arm64/pmap.c:7118–7216  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7116}
7117
7118static int
7119sysctl_kmaps(SYSCTL_HANDLER_ARGS)
7120{
7121 struct pmap_kernel_map_range range;
7122 struct sbuf sbuf, *sb;
7123 pd_entry_t l0e, *l1, l1e, *l2, l2e;
7124 pt_entry_t *l3, l3e;
7125 vm_offset_t sva;
7126 vm_paddr_t pa;
7127 int error, i, j, k, l;
7128
7129 error = sysctl_wire_old_buffer(req, 0);
7130 if (error != 0)
7131 return (error);
7132 sb = &sbuf;
7133 sbuf_new_for_sysctl(sb, NULL, PAGE_SIZE, req);
7134
7135 /* Sentinel value. */
7136 range.sva = 0xfffffffffffffffful;
7137
7138 /*
7139 * Iterate over the kernel page tables without holding the kernel pmap
7140 * lock. Kernel page table pages are never freed, so at worst we will
7141 * observe inconsistencies in the output.
7142 */
7143 for (sva = 0xffff000000000000ul, i = pmap_l0_index(sva); i < Ln_ENTRIES;
7144 i++) {
7145 if (i == pmap_l0_index(DMAP_MIN_ADDRESS))
7146 sbuf_printf(sb, "\nDirect map:\n");
7147 else if (i == pmap_l0_index(VM_MIN_KERNEL_ADDRESS))
7148 sbuf_printf(sb, "\nKernel map:\n");
7149
7150 l0e = kernel_pmap->pm_l0[i];
7151 if ((l0e & ATTR_DESCR_VALID) == 0) {
7152 sysctl_kmaps_dump(sb, &range, sva);
7153 sva += L0_SIZE;
7154 continue;
7155 }
7156 pa = l0e & ~ATTR_MASK;
7157 l1 = (pd_entry_t *)PHYS_TO_DMAP(pa);
7158
7159 for (j = pmap_l1_index(sva); j < Ln_ENTRIES; j++) {
7160 l1e = l1[j];
7161 if ((l1e & ATTR_DESCR_VALID) == 0) {
7162 sysctl_kmaps_dump(sb, &range, sva);
7163 sva += L1_SIZE;
7164 continue;
7165 }
7166 if ((l1e & ATTR_DESCR_MASK) == L1_BLOCK) {
7167 sysctl_kmaps_check(sb, &range, sva, l0e, l1e,
7168 0, 0);
7169 range.l1blocks++;
7170 sva += L1_SIZE;
7171 continue;
7172 }
7173 pa = l1e & ~ATTR_MASK;
7174 l2 = (pd_entry_t *)PHYS_TO_DMAP(pa);
7175

Callers

nothing calls this directly

Calls 7

sysctl_wire_old_bufferFunction · 0.85
sbuf_new_for_sysctlFunction · 0.85
sbuf_printfFunction · 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