Changeset View
Changeset View
Standalone View
Standalone View
sys/amd64/amd64/pmap.c
Show First 20 Lines • Show All 3,088 Lines • ▼ Show 20 Lines | pmap_growkernel(vm_offset_t addr) | ||||
* than the kernel. Thus, there is no immediate need to allocate | * than the kernel. Thus, there is no immediate need to allocate | ||||
* any new kernel page table pages between "kernel_vm_end" and | * any new kernel page table pages between "kernel_vm_end" and | ||||
* "KERNBASE". | * "KERNBASE". | ||||
*/ | */ | ||||
if (KERNBASE < addr && addr <= KERNBASE + nkpt * NBPDR) | if (KERNBASE < addr && addr <= KERNBASE + nkpt * NBPDR) | ||||
return; | return; | ||||
addr = roundup2(addr, NBPDR); | addr = roundup2(addr, NBPDR); | ||||
if (addr - 1 >= kernel_map->max_offset) | if (addr - 1 >= vm_map_max(kernel_map)) | ||||
addr = kernel_map->max_offset; | addr = vm_map_max(kernel_map); | ||||
while (kernel_vm_end < addr) { | while (kernel_vm_end < addr) { | ||||
pdpe = pmap_pdpe(kernel_pmap, kernel_vm_end); | pdpe = pmap_pdpe(kernel_pmap, kernel_vm_end); | ||||
if ((*pdpe & X86_PG_V) == 0) { | if ((*pdpe & X86_PG_V) == 0) { | ||||
/* We need a new PDP entry */ | /* We need a new PDP entry */ | ||||
nkpg = vm_page_alloc(NULL, kernel_vm_end >> PDPSHIFT, | nkpg = vm_page_alloc(NULL, kernel_vm_end >> PDPSHIFT, | ||||
VM_ALLOC_INTERRUPT | VM_ALLOC_NOOBJ | | VM_ALLOC_INTERRUPT | VM_ALLOC_NOOBJ | | ||||
VM_ALLOC_WIRED | VM_ALLOC_ZERO); | VM_ALLOC_WIRED | VM_ALLOC_ZERO); | ||||
if (nkpg == NULL) | if (nkpg == NULL) | ||||
panic("pmap_growkernel: no memory to grow kernel"); | panic("pmap_growkernel: no memory to grow kernel"); | ||||
if ((nkpg->flags & PG_ZERO) == 0) | if ((nkpg->flags & PG_ZERO) == 0) | ||||
pmap_zero_page(nkpg); | pmap_zero_page(nkpg); | ||||
paddr = VM_PAGE_TO_PHYS(nkpg); | paddr = VM_PAGE_TO_PHYS(nkpg); | ||||
*pdpe = (pdp_entry_t)(paddr | X86_PG_V | X86_PG_RW | | *pdpe = (pdp_entry_t)(paddr | X86_PG_V | X86_PG_RW | | ||||
X86_PG_A | X86_PG_M); | X86_PG_A | X86_PG_M); | ||||
continue; /* try again */ | continue; /* try again */ | ||||
} | } | ||||
pde = pmap_pdpe_to_pde(pdpe, kernel_vm_end); | pde = pmap_pdpe_to_pde(pdpe, kernel_vm_end); | ||||
if ((*pde & X86_PG_V) != 0) { | if ((*pde & X86_PG_V) != 0) { | ||||
kernel_vm_end = (kernel_vm_end + NBPDR) & ~PDRMASK; | kernel_vm_end = (kernel_vm_end + NBPDR) & ~PDRMASK; | ||||
if (kernel_vm_end - 1 >= kernel_map->max_offset) { | if (kernel_vm_end - 1 >= vm_map_max(kernel_map)) { | ||||
kernel_vm_end = kernel_map->max_offset; | kernel_vm_end = vm_map_max(kernel_map); | ||||
break; | break; | ||||
} | } | ||||
continue; | continue; | ||||
} | } | ||||
nkpg = vm_page_alloc(NULL, pmap_pde_pindex(kernel_vm_end), | nkpg = vm_page_alloc(NULL, pmap_pde_pindex(kernel_vm_end), | ||||
VM_ALLOC_INTERRUPT | VM_ALLOC_NOOBJ | VM_ALLOC_WIRED | | VM_ALLOC_INTERRUPT | VM_ALLOC_NOOBJ | VM_ALLOC_WIRED | | ||||
VM_ALLOC_ZERO); | VM_ALLOC_ZERO); | ||||
if (nkpg == NULL) | if (nkpg == NULL) | ||||
panic("pmap_growkernel: no memory to grow kernel"); | panic("pmap_growkernel: no memory to grow kernel"); | ||||
if ((nkpg->flags & PG_ZERO) == 0) | if ((nkpg->flags & PG_ZERO) == 0) | ||||
pmap_zero_page(nkpg); | pmap_zero_page(nkpg); | ||||
paddr = VM_PAGE_TO_PHYS(nkpg); | paddr = VM_PAGE_TO_PHYS(nkpg); | ||||
newpdir = paddr | X86_PG_V | X86_PG_RW | X86_PG_A | X86_PG_M; | newpdir = paddr | X86_PG_V | X86_PG_RW | X86_PG_A | X86_PG_M; | ||||
pde_store(pde, newpdir); | pde_store(pde, newpdir); | ||||
kernel_vm_end = (kernel_vm_end + NBPDR) & ~PDRMASK; | kernel_vm_end = (kernel_vm_end + NBPDR) & ~PDRMASK; | ||||
if (kernel_vm_end - 1 >= kernel_map->max_offset) { | if (kernel_vm_end - 1 >= vm_map_max(kernel_map)) { | ||||
kernel_vm_end = kernel_map->max_offset; | kernel_vm_end = vm_map_max(kernel_map); | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
/*************************************************** | /*************************************************** | ||||
* page management routines. | * page management routines. | ||||
▲ Show 20 Lines • Show All 5,097 Lines • Show Last 20 Lines |