| 2520 | } |
| 2521 | |
| 2522 | static vm_page_t |
| 2523 | pmap_allocpte2(pmap_t pmap, vm_offset_t va, u_int flags) |
| 2524 | { |
| 2525 | u_int pte1_idx; |
| 2526 | pt1_entry_t *pte1p, pte1; |
| 2527 | vm_page_t m; |
| 2528 | |
| 2529 | pte1_idx = pte1_index(va); |
| 2530 | retry: |
| 2531 | pte1p = pmap->pm_pt1 + pte1_idx; |
| 2532 | pte1 = pte1_load(pte1p); |
| 2533 | |
| 2534 | /* |
| 2535 | * This supports switching from a 1MB page to a |
| 2536 | * normal 4K page. |
| 2537 | */ |
| 2538 | if (pte1_is_section(pte1)) { |
| 2539 | (void)pmap_demote_pte1(pmap, pte1p, va); |
| 2540 | /* |
| 2541 | * Reload pte1 after demotion. |
| 2542 | * |
| 2543 | * Note: Demotion can even fail as either PT2 is not find for |
| 2544 | * the virtual address or PT2PG can not be allocated. |
| 2545 | */ |
| 2546 | pte1 = pte1_load(pte1p); |
| 2547 | } |
| 2548 | |
| 2549 | /* |
| 2550 | * If the L2 page table page is mapped, we just increment the |
| 2551 | * hold count, and activate it. |
| 2552 | */ |
| 2553 | if (pte1_is_link(pte1)) { |
| 2554 | m = PHYS_TO_VM_PAGE(pte1_link_pa(pte1)); |
| 2555 | pt2_wirecount_inc(m, pte1_idx); |
| 2556 | } else { |
| 2557 | /* |
| 2558 | * Here if the PT2 isn't mapped, or if it has |
| 2559 | * been deallocated. |
| 2560 | */ |
| 2561 | m = _pmap_allocpte2(pmap, va, flags); |
| 2562 | if (m == NULL && (flags & PMAP_ENTER_NOSLEEP) == 0) |
| 2563 | goto retry; |
| 2564 | } |
| 2565 | |
| 2566 | return (m); |
| 2567 | } |
| 2568 | |
| 2569 | /* |
| 2570 | * Schedule the specified unused L2 page table page to be freed. Specifically, |
no test coverage detected