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

Function pmap_page_set_memattr

freebsd/arm/arm/pmap-v6.c:5742–5788  ·  view source on GitHub ↗

* Sets the memory attribute for the specified page. */

Source from the content-addressed store, hash-verified

5740 * Sets the memory attribute for the specified page.
5741 */
5742void
5743pmap_page_set_memattr(vm_page_t m, vm_memattr_t ma)
5744{
5745 pt2_entry_t *cmap2_pte2p;
5746 vm_memattr_t oma;
5747 vm_paddr_t pa;
5748 struct pcpu *pc;
5749
5750 oma = m->md.pat_mode;
5751 m->md.pat_mode = ma;
5752
5753 CTR5(KTR_PMAP, "%s: page %p - 0x%08X oma: %d, ma: %d", __func__, m,
5754 VM_PAGE_TO_PHYS(m), oma, ma);
5755 if ((m->flags & PG_FICTITIOUS) != 0)
5756 return;
5757#if 0
5758 /*
5759 * If "m" is a normal page, flush it from the cache.
5760 *
5761 * First, try to find an existing mapping of the page by sf
5762 * buffer. sf_buf_invalidate_cache() modifies mapping and
5763 * flushes the cache.
5764 */
5765 if (sf_buf_invalidate_cache(m, oma))
5766 return;
5767#endif
5768 /*
5769 * If page is not mapped by sf buffer, map the page
5770 * transient and do invalidation.
5771 */
5772 if (ma != oma) {
5773 pa = VM_PAGE_TO_PHYS(m);
5774 sched_pin();
5775 pc = get_pcpu();
5776 cmap2_pte2p = pc->pc_cmap2_pte2p;
5777 mtx_lock(&pc->pc_cmap_lock);
5778 if (pte2_load(cmap2_pte2p) != 0)
5779 panic("%s: CMAP2 busy", __func__);
5780 pte2_store(cmap2_pte2p, PTE2_KERN_NG(pa, PTE2_AP_KRW,
5781 vm_memattr_to_pte2(ma)));
5782 dcache_wbinv_poc((vm_offset_t)pc->pc_cmap2_addr, pa, PAGE_SIZE);
5783 pte2_clear(cmap2_pte2p);
5784 tlb_flush((vm_offset_t)pc->pc_cmap2_addr);
5785 sched_unpin();
5786 mtx_unlock(&pc->pc_cmap_lock);
5787 }
5788}
5789
5790/*
5791 * Miscellaneous support routines follow

Callers 1

pmap_pt2pg_initFunction · 0.70

Calls 13

sf_buf_invalidate_cacheFunction · 0.85
sched_pinFunction · 0.85
get_pcpuFunction · 0.85
pte2_loadFunction · 0.85
pte2_storeFunction · 0.85
vm_memattr_to_pte2Function · 0.85
dcache_wbinv_pocFunction · 0.85
pte2_clearFunction · 0.85
tlb_flushFunction · 0.85
sched_unpinFunction · 0.85
mtx_lockFunction · 0.50
panicFunction · 0.50

Tested by

no test coverage detected