* Insert the given physical page (p) at * the specified virtual address (v) in the * target physical map with the protection requested. * * If specified, the page will be wired down, meaning * that the related pte can not be reclaimed. * * NB: This is the only routine which MAY NOT lazy-evaluate * or lose information. That is, this routine must actually * insert this page into the given
| 3857 | * insert this page into the given map NOW. |
| 3858 | */ |
| 3859 | int |
| 3860 | pmap_enter(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot, |
| 3861 | u_int flags, int8_t psind) |
| 3862 | { |
| 3863 | pt1_entry_t *pte1p; |
| 3864 | pt2_entry_t *pte2p; |
| 3865 | pt2_entry_t npte2, opte2; |
| 3866 | pv_entry_t pv; |
| 3867 | vm_paddr_t opa, pa; |
| 3868 | vm_page_t mpte2, om; |
| 3869 | int rv; |
| 3870 | |
| 3871 | va = trunc_page(va); |
| 3872 | KASSERT(va <= vm_max_kernel_address, ("%s: toobig", __func__)); |
| 3873 | KASSERT(va < UPT2V_MIN_ADDRESS || va >= UPT2V_MAX_ADDRESS, |
| 3874 | ("%s: invalid to pmap_enter page table pages (va: 0x%x)", __func__, |
| 3875 | va)); |
| 3876 | KASSERT((m->oflags & VPO_UNMANAGED) != 0 || va < kmi.clean_sva || |
| 3877 | va >= kmi.clean_eva, |
| 3878 | ("%s: managed mapping within the clean submap", __func__)); |
| 3879 | if ((m->oflags & VPO_UNMANAGED) == 0) |
| 3880 | VM_PAGE_OBJECT_BUSY_ASSERT(m); |
| 3881 | KASSERT((flags & PMAP_ENTER_RESERVED) == 0, |
| 3882 | ("%s: flags %u has reserved bits set", __func__, flags)); |
| 3883 | pa = VM_PAGE_TO_PHYS(m); |
| 3884 | npte2 = PTE2(pa, PTE2_A, vm_page_pte2_attr(m)); |
| 3885 | if ((flags & VM_PROT_WRITE) == 0) |
| 3886 | npte2 |= PTE2_NM; |
| 3887 | if ((prot & VM_PROT_WRITE) == 0) |
| 3888 | npte2 |= PTE2_RO; |
| 3889 | KASSERT((npte2 & (PTE2_NM | PTE2_RO)) != PTE2_RO, |
| 3890 | ("%s: flags includes VM_PROT_WRITE but prot doesn't", __func__)); |
| 3891 | if ((prot & VM_PROT_EXECUTE) == 0) |
| 3892 | npte2 |= PTE2_NX; |
| 3893 | if ((flags & PMAP_ENTER_WIRED) != 0) |
| 3894 | npte2 |= PTE2_W; |
| 3895 | if (va < VM_MAXUSER_ADDRESS) |
| 3896 | npte2 |= PTE2_U; |
| 3897 | if (pmap != kernel_pmap) |
| 3898 | npte2 |= PTE2_NG; |
| 3899 | |
| 3900 | rw_wlock(&pvh_global_lock); |
| 3901 | PMAP_LOCK(pmap); |
| 3902 | sched_pin(); |
| 3903 | if (psind == 1) { |
| 3904 | /* Assert the required virtual and physical alignment. */ |
| 3905 | KASSERT((va & PTE1_OFFSET) == 0, |
| 3906 | ("%s: va unaligned", __func__)); |
| 3907 | KASSERT(m->psind > 0, ("%s: m->psind < psind", __func__)); |
| 3908 | rv = pmap_enter_pte1(pmap, va, PTE1_PA(pa) | ATTR_TO_L1(npte2) | |
| 3909 | PTE1_V, flags, m); |
| 3910 | goto out; |
| 3911 | } |
| 3912 | |
| 3913 | /* |
| 3914 | * In the case that a page table page is not |
| 3915 | * resident, we are creating it here. |
| 3916 | */ |
nothing calls this directly
no test coverage detected