* Initialize the pmap module. * Called by vm_init, to initialize any structures that the pmap * system needs to map virtual memory. */
| 2301 | * system needs to map virtual memory. |
| 2302 | */ |
| 2303 | void |
| 2304 | pmap_init(void) |
| 2305 | { |
| 2306 | struct pmap_preinit_mapping *ppim; |
| 2307 | vm_page_t m, mpte; |
| 2308 | int error, i, ret, skz63; |
| 2309 | |
| 2310 | /* L1TF, reserve page @0 unconditionally */ |
| 2311 | vm_page_blacklist_add(0, bootverbose); |
| 2312 | |
| 2313 | /* Detect bare-metal Skylake Server and Skylake-X. */ |
| 2314 | if (vm_guest == VM_GUEST_NO && cpu_vendor_id == CPU_VENDOR_INTEL && |
| 2315 | CPUID_TO_FAMILY(cpu_id) == 0x6 && CPUID_TO_MODEL(cpu_id) == 0x55) { |
| 2316 | /* |
| 2317 | * Skylake-X errata SKZ63. Processor May Hang When |
| 2318 | * Executing Code In an HLE Transaction Region between |
| 2319 | * 40000000H and 403FFFFFH. |
| 2320 | * |
| 2321 | * Mark the pages in the range as preallocated. It |
| 2322 | * seems to be impossible to distinguish between |
| 2323 | * Skylake Server and Skylake X. |
| 2324 | */ |
| 2325 | skz63 = 1; |
| 2326 | TUNABLE_INT_FETCH("hw.skz63_enable", &skz63); |
| 2327 | if (skz63 != 0) { |
| 2328 | if (bootverbose) |
| 2329 | printf("SKZ63: skipping 4M RAM starting " |
| 2330 | "at physical 1G\n"); |
| 2331 | for (i = 0; i < atop(0x400000); i++) { |
| 2332 | ret = vm_page_blacklist_add(0x40000000 + |
| 2333 | ptoa(i), FALSE); |
| 2334 | if (!ret && bootverbose) |
| 2335 | printf("page at %#lx already used\n", |
| 2336 | 0x40000000 + ptoa(i)); |
| 2337 | } |
| 2338 | } |
| 2339 | } |
| 2340 | |
| 2341 | /* IFU */ |
| 2342 | pmap_allow_2m_x_ept_recalculate(); |
| 2343 | |
| 2344 | /* |
| 2345 | * Initialize the vm page array entries for the kernel pmap's |
| 2346 | * page table pages. |
| 2347 | */ |
| 2348 | PMAP_LOCK(kernel_pmap); |
| 2349 | for (i = 0; i < nkpt; i++) { |
| 2350 | mpte = PHYS_TO_VM_PAGE(KPTphys + (i << PAGE_SHIFT)); |
| 2351 | KASSERT(mpte >= vm_page_array && |
| 2352 | mpte < &vm_page_array[vm_page_array_size], |
| 2353 | ("pmap_init: page table page is out of range")); |
| 2354 | mpte->pindex = pmap_pde_pindex(KERNBASE) + i; |
| 2355 | mpte->phys_addr = KPTphys + (i << PAGE_SHIFT); |
| 2356 | mpte->ref_count = 1; |
| 2357 | |
| 2358 | /* |
| 2359 | * Collect the page table pages that were replaced by a 2MB |
| 2360 | * page in create_pagetables(). They are zero filled. |
nothing calls this directly
no test coverage detected