* Tries to create a read- and/or execute-only 2MB page mapping. Returns true * if successful. Returns false if (1) a page table page cannot be allocated * without sleeping, (2) a mapping already exists at the specified virtual * address, or (3) a PV entry cannot be allocated without reclaiming another * PV entry. */
| 4207 | * PV entry. |
| 4208 | */ |
| 4209 | static bool |
| 4210 | pmap_enter_2mpage(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot, |
| 4211 | struct rwlock **lockp) |
| 4212 | { |
| 4213 | pd_entry_t new_l2; |
| 4214 | |
| 4215 | PMAP_LOCK_ASSERT(pmap, MA_OWNED); |
| 4216 | PMAP_ASSERT_STAGE1(pmap); |
| 4217 | |
| 4218 | new_l2 = (pd_entry_t)(VM_PAGE_TO_PHYS(m) | ATTR_DEFAULT | |
| 4219 | ATTR_S1_IDX(m->md.pv_memattr) | ATTR_S1_AP(ATTR_S1_AP_RO) | |
| 4220 | L2_BLOCK); |
| 4221 | if ((m->oflags & VPO_UNMANAGED) == 0) { |
| 4222 | new_l2 |= ATTR_SW_MANAGED; |
| 4223 | new_l2 &= ~ATTR_AF; |
| 4224 | } |
| 4225 | if ((prot & VM_PROT_EXECUTE) == 0 || |
| 4226 | m->md.pv_memattr == VM_MEMATTR_DEVICE) |
| 4227 | new_l2 |= ATTR_S1_XN; |
| 4228 | if (va < VM_MAXUSER_ADDRESS) |
| 4229 | new_l2 |= ATTR_S1_AP(ATTR_S1_AP_USER) | ATTR_S1_PXN; |
| 4230 | else |
| 4231 | new_l2 |= ATTR_S1_UXN; |
| 4232 | if (pmap != kernel_pmap) |
| 4233 | new_l2 |= ATTR_S1_nG; |
| 4234 | return (pmap_enter_l2(pmap, va, new_l2, PMAP_ENTER_NOSLEEP | |
| 4235 | PMAP_ENTER_NOREPLACE | PMAP_ENTER_NORECLAIM, NULL, lockp) == |
| 4236 | KERN_SUCCESS); |
| 4237 | } |
| 4238 | |
| 4239 | /* |
| 4240 | * Returns true if every page table entry in the specified page table is |
no test coverage detected