MCPcopy Create free account
hub / github.com/F-Stack/f-stack / pmap_enter

Function pmap_enter

freebsd/arm64/arm64/pmap.c:3881–4200  ·  view source on GitHub ↗

* 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

Source from the content-addressed store, hash-verified

3879 * insert this page into the given map NOW.
3880 */
3881int
3882pmap_enter(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot,
3883 u_int flags, int8_t psind)
3884{
3885 struct rwlock *lock;
3886 pd_entry_t *pde;
3887 pt_entry_t new_l3, orig_l3;
3888 pt_entry_t *l2, *l3;
3889 pv_entry_t pv;
3890 vm_paddr_t opa, pa;
3891 vm_page_t mpte, om;
3892 boolean_t nosleep;
3893 int lvl, rv;
3894
3895 va = trunc_page(va);
3896 if ((m->oflags & VPO_UNMANAGED) == 0)
3897 VM_PAGE_OBJECT_BUSY_ASSERT(m);
3898 pa = VM_PAGE_TO_PHYS(m);
3899 new_l3 = (pt_entry_t)(pa | ATTR_DEFAULT | L3_PAGE);
3900 new_l3 |= pmap_pte_memattr(pmap, m->md.pv_memattr);
3901 new_l3 |= pmap_pte_prot(pmap, prot);
3902
3903 if ((flags & PMAP_ENTER_WIRED) != 0)
3904 new_l3 |= ATTR_SW_WIRED;
3905 if (pmap->pm_stage == PM_STAGE1) {
3906 if (va < VM_MAXUSER_ADDRESS)
3907 new_l3 |= ATTR_S1_AP(ATTR_S1_AP_USER) | ATTR_S1_PXN;
3908 else
3909 new_l3 |= ATTR_S1_UXN;
3910 if (pmap != kernel_pmap)
3911 new_l3 |= ATTR_S1_nG;
3912 } else {
3913 /*
3914 * Clear the access flag on executable mappings, this will be
3915 * set later when the page is accessed. The fault handler is
3916 * required to invalidate the I-cache.
3917 *
3918 * TODO: Switch to the valid flag to allow hardware management
3919 * of the access flag. Much of the pmap code assumes the
3920 * valid flag is set and fails to destroy the old page tables
3921 * correctly if it is clear.
3922 */
3923 if (prot & VM_PROT_EXECUTE)
3924 new_l3 &= ~ATTR_AF;
3925 }
3926 if ((m->oflags & VPO_UNMANAGED) == 0) {
3927 new_l3 |= ATTR_SW_MANAGED;
3928 if ((prot & VM_PROT_WRITE) != 0) {
3929 new_l3 |= ATTR_SW_DBM;
3930 if ((flags & VM_PROT_WRITE) == 0) {
3931 if (pmap->pm_stage == PM_STAGE1)
3932 new_l3 |= ATTR_S1_AP(ATTR_S1_AP_RO);
3933 else
3934 new_l3 &=
3935 ~ATTR_S2_S2AP(ATTR_S2_S2AP_WRITE);
3936 }
3937 }
3938 }

Callers

nothing calls this directly

Calls 15

pmap_pte_memattrFunction · 0.85
pmap_pte_protFunction · 0.85
pmap_enter_l2Function · 0.85
pmap_l2_to_l3Function · 0.85
PHYS_TO_VM_PAGEFunction · 0.85
pmap_l1_to_l2Function · 0.85
pmap_demote_l2_lockedFunction · 0.85
_pmap_alloc_l3Function · 0.85
pmap_l3_validFunction · 0.85
vm_page_aflag_setFunction · 0.85
pmap_pte_dirtyFunction · 0.85
vm_page_dirtyFunction · 0.85

Tested by

no test coverage detected