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

Function pmap_protect

freebsd/amd64/amd64/pmap.c:6312–6470  ·  view source on GitHub ↗

* Set the physical protection on the * specified range of this map as requested. */

Source from the content-addressed store, hash-verified

6310 * specified range of this map as requested.
6311 */
6312void
6313pmap_protect(pmap_t pmap, vm_offset_t sva, vm_offset_t eva, vm_prot_t prot)
6314{
6315 vm_page_t m;
6316 vm_offset_t va_next;
6317 pml4_entry_t *pml4e;
6318 pdp_entry_t *pdpe;
6319 pd_entry_t ptpaddr, *pde;
6320 pt_entry_t *pte, PG_G, PG_M, PG_RW, PG_V;
6321 pt_entry_t obits, pbits;
6322 boolean_t anychanged;
6323
6324 KASSERT((prot & ~VM_PROT_ALL) == 0, ("invalid prot %x", prot));
6325 if (prot == VM_PROT_NONE) {
6326 pmap_remove(pmap, sva, eva);
6327 return;
6328 }
6329
6330 if ((prot & (VM_PROT_WRITE|VM_PROT_EXECUTE)) ==
6331 (VM_PROT_WRITE|VM_PROT_EXECUTE))
6332 return;
6333
6334 PG_G = pmap_global_bit(pmap);
6335 PG_M = pmap_modified_bit(pmap);
6336 PG_V = pmap_valid_bit(pmap);
6337 PG_RW = pmap_rw_bit(pmap);
6338 anychanged = FALSE;
6339
6340 /*
6341 * Although this function delays and batches the invalidation
6342 * of stale TLB entries, it does not need to call
6343 * pmap_delayed_invl_start() and
6344 * pmap_delayed_invl_finish(), because it does not
6345 * ordinarily destroy mappings. Stale TLB entries from
6346 * protection-only changes need only be invalidated before the
6347 * pmap lock is released, because protection-only changes do
6348 * not destroy PV entries. Even operations that iterate over
6349 * a physical page's PV list of mappings, like
6350 * pmap_remove_write(), acquire the pmap lock for each
6351 * mapping. Consequently, for protection-only changes, the
6352 * pmap lock suffices to synchronize both page table and TLB
6353 * updates.
6354 *
6355 * This function only destroys a mapping if pmap_demote_pde()
6356 * fails. In that case, stale TLB entries are immediately
6357 * invalidated.
6358 */
6359
6360 PMAP_LOCK(pmap);
6361 for (; sva < eva; sva = va_next) {
6362 pml4e = pmap_pml4e(pmap, sva);
6363 if (pml4e == NULL || (*pml4e & PG_V) == 0) {
6364 va_next = (sva + NBPML4) & ~PML4MASK;
6365 if (va_next < sva)
6366 va_next = eva;
6367 continue;
6368 }
6369

Callers

nothing calls this directly

Calls 15

pmap_global_bitFunction · 0.85
pmap_modified_bitFunction · 0.85
pmap_valid_bitFunction · 0.85
pmap_rw_bitFunction · 0.85
pmap_pml4eFunction · 0.85
pmap_pml4e_to_pdpeFunction · 0.85
PHYS_TO_VM_PAGEFunction · 0.85
vm_page_dirtyFunction · 0.85
pmap_removeFunction · 0.70
pmap_pdpe_to_pdeFunction · 0.70
pmap_protect_pdeFunction · 0.70
pmap_demote_pdeFunction · 0.70

Tested by

no test coverage detected