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

Function pmap_page_array_startup

freebsd/amd64/amd64/pmap.c:4714–4750  ·  view source on GitHub ↗

* Allocate physical memory for the vm_page array and map it into KVA, * attempting to back the vm_pages with domain-local memory. */

Source from the content-addressed store, hash-verified

4712 * attempting to back the vm_pages with domain-local memory.
4713 */
4714void
4715pmap_page_array_startup(long pages)
4716{
4717 pdp_entry_t *pdpe;
4718 pd_entry_t *pde, newpdir;
4719 vm_offset_t va, start, end;
4720 vm_paddr_t pa;
4721 long pfn;
4722 int domain, i;
4723
4724 vm_page_array_size = pages;
4725
4726 start = VM_MIN_KERNEL_ADDRESS;
4727 end = start + pages * sizeof(struct vm_page);
4728 for (va = start; va < end; va += NBPDR) {
4729 pfn = first_page + (va - start) / sizeof(struct vm_page);
4730 domain = vm_phys_domain(ptoa(pfn));
4731 pdpe = pmap_pdpe(kernel_pmap, va);
4732 if ((*pdpe & X86_PG_V) == 0) {
4733 pa = vm_phys_early_alloc(domain, PAGE_SIZE);
4734 dump_add_page(pa);
4735 pagezero((void *)PHYS_TO_DMAP(pa));
4736 *pdpe = (pdp_entry_t)(pa | X86_PG_V | X86_PG_RW |
4737 X86_PG_A | X86_PG_M);
4738 }
4739 pde = pmap_pdpe_to_pde(pdpe, va);
4740 if ((*pde & X86_PG_V) != 0)
4741 panic("Unexpected pde");
4742 pa = vm_phys_early_alloc(domain, NBPDR);
4743 for (i = 0; i < NPDEPG; i++)
4744 dump_add_page(pa + i * PAGE_SIZE);
4745 newpdir = (pd_entry_t)(pa | X86_PG_V | X86_PG_RW | X86_PG_A |
4746 X86_PG_M | PG_PS | pg_g | pg_nx);
4747 pde_store(pde, newpdir);
4748 }
4749 vm_page_array = (vm_page_t)start;
4750}
4751
4752/*
4753 * grow the number of kernel page table entries, if needed

Callers 1

vm_page_startupFunction · 0.85

Calls 7

vm_phys_domainFunction · 0.85
pmap_pdpeFunction · 0.85
vm_phys_early_allocFunction · 0.85
dump_add_pageFunction · 0.85
pmap_pdpe_to_pdeFunction · 0.70
pagezeroFunction · 0.50
panicFunction · 0.50

Tested by

no test coverage detected