| 674 | } |
| 675 | |
| 676 | void |
| 677 | kmem_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. |
no test coverage detected