From e0df13ab4aecd9303eb4e1c949a8f017757b9995 Mon Sep 17 00:00:00 2001 From: Nick Hudson Date: Sun, 24 May 2026 16:06:34 +0100 Subject: [PATCH 1/2] mi pmap: pmap_clear_attribute should check cached value of the attribute The pmap_clear_attribute implementation used by the MI pmap should check the cached valued of the attribute as well as any value held in the PTE. Some emulation implementations require this as some operations, e.g changing page mappings to RO, can lose PTE attribute information. --- sys/uvm/pmap/pmap.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sys/uvm/pmap/pmap.c b/sys/uvm/pmap/pmap.c index 548896ee0bb4..c74e2cef0585 100644 --- a/sys/uvm/pmap/pmap.c +++ b/sys/uvm/pmap/pmap.c @@ -1925,7 +1925,6 @@ pmap_clear_attribute(struct vm_page *pg, return rv; } - bool changed = false; kpreempt_disable(); VM_PAGEMD_PVLIST_READLOCK(mdpg); pmap_pvlist_check(mdpg); @@ -1947,7 +1946,7 @@ pmap_clear_attribute(struct vm_page *pg, if (npte == opte) { continue; } - changed = true; + rv = true; KASSERT(pte_valid_p(npte)); const uintptr_t gen = VM_PAGEMD_PVLIST_UNLOCK(mdpg); pmap_tlb_miss_lock_enter(); @@ -1967,10 +1966,13 @@ pmap_clear_attribute(struct vm_page *pg, VM_PAGEMD_PVLIST_UNLOCK(mdpg); kpreempt_enable(); - UVMHIST_LOG(pmaphist, " <-- %jx (and mappings changed)", - ops->pcao_attribute, changed, 0, 0); + UVMHIST_LOG(pmaphist, " <-- %jx (ref=%jd mod=%jd)", + rv, + ops->pcao_attribute == VM_PAGEMD_REFERENCED, + ops->pcao_attribute == VM_PAGEMD_MODIFIED, + 0); - return changed; + return rv; } struct pmap_is_attribute_ops { -- 2.50.1 (Apple Git-155)