* Sets the memory attribute for the specified page. */
| 5740 | * Sets the memory attribute for the specified page. |
| 5741 | */ |
| 5742 | void |
| 5743 | pmap_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 |
no test coverage detected