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

Function kmem_init_zero_region

freebsd/vm/vm_kern.c:676–697  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

674}
675
676void
677kmem_init_zero_region(void)
678{
679 vm_offset_t addr, i;
680 vm_page_t m;
681
682 /*
683 * Map a single physical page of zeros to a larger virtual range.
684 * This requires less looping in places that want large amounts of
685 * zeros, while not using much more physical resources.
686 */
687 addr = kva_alloc(ZERO_REGION_SIZE);
688 m = vm_page_alloc(NULL, 0, VM_ALLOC_NORMAL |
689 VM_ALLOC_NOOBJ | VM_ALLOC_WIRED | VM_ALLOC_ZERO);
690 if ((m->flags & PG_ZERO) == 0)
691 pmap_zero_page(m);
692 for (i = 0; i < ZERO_REGION_SIZE; i += PAGE_SIZE)
693 pmap_qenter(addr + i, &m, 1);
694 pmap_protect(kernel_pmap, addr, addr + ZERO_REGION_SIZE, VM_PROT_READ);
695
696 zero_region = (const void *)addr;
697}
698
699/*
700 * Import KVA from the kernel map into the kernel arena.

Callers 1

vm_mem_initFunction · 0.85

Calls 5

kva_allocFunction · 0.85
vm_page_allocFunction · 0.85
pmap_zero_pageFunction · 0.50
pmap_qenterFunction · 0.50
pmap_protectFunction · 0.50

Tested by

no test coverage detected