git: bc405804570e - stable/15 - pmap: Fix some bugs around accounting of wired mappings
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 26 Nov 2026 14:20:23 UTC
The branch stable/15 has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=bc405804570e339f474cb76cd98d165f0148b9dd
commit bc405804570e339f474cb76cd98d165f0148b9dd
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2026-11-11 14:15:35 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-11-26 14:20:03 +0000
pmap: Fix some bugs around accounting of wired mappings
The amd64 and arm64 pmaps failed to decrement the count when tearing
down a 1GB largepage mapping. The riscv pmap failed to decrement the
count when unwiring a superpage mapping.
Reported by: alc
Reviewed by: bnovkov, alc, kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D61414
(cherry picked from commit da507ac5503d9af35f5aff4a7a773f6a92746e4a)
---
sys/amd64/amd64/pmap.c | 2 ++
sys/arm64/arm64/pmap.c | 3 +++
sys/riscv/riscv/pmap.c | 2 ++
3 files changed, 7 insertions(+)
diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c
index 64419f9b9007..524db24ddde7 100644
--- a/sys/amd64/amd64/pmap.c
+++ b/sys/amd64/amd64/pmap.c
@@ -6394,6 +6394,8 @@ pmap_remove1(pmap_t pmap, vm_offset_t sva, vm_offset_t eva, bool map_delete)
MPASS(pmap != kernel_pmap); /* XXXKIB */
MPASS((*pdpe & (PG_MANAGED | PG_G)) == 0);
anyvalid = 1;
+ if ((*pdpe & PG_W) != 0)
+ pmap->pm_stats.wired_count -= NBPDP / PAGE_SIZE;
*pdpe = 0;
pmap_resident_count_adj(pmap, -NBPDP / PAGE_SIZE);
mt = PHYS_TO_VM_PAGE(*pmap_pml4e(pmap, sva) & PG_FRAME);
diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c
index a8ab4423d0a8..8ec81e09fc32 100644
--- a/sys/arm64/arm64/pmap.c
+++ b/sys/arm64/arm64/pmap.c
@@ -4353,6 +4353,9 @@ pmap_remove1(pmap_t pmap, vm_offset_t sva, vm_offset_t eva, bool map_delete)
pmap_load(l1), sva, eva, va_next));
MPASS(pmap != kernel_pmap);
MPASS((pmap_load(l1) & ATTR_SW_MANAGED) == 0);
+ if ((pmap_load(l1) & ATTR_SW_WIRED) != 0)
+ pmap->pm_stats.wired_count -=
+ L1_SIZE / PAGE_SIZE;
pmap_clear(l1);
pmap_s1_invalidate_page(pmap, sva, true);
pmap_resident_count_dec(pmap, L1_SIZE / PAGE_SIZE);
diff --git a/sys/riscv/riscv/pmap.c b/sys/riscv/riscv/pmap.c
index e9f88f5d653e..9c52bd77aa00 100644
--- a/sys/riscv/riscv/pmap.c
+++ b/sys/riscv/riscv/pmap.c
@@ -3969,6 +3969,8 @@ retry:
panic("pmap_unwire: l2 %#jx is missing "
"PTE_SW_WIRED", (uintmax_t)l2e);
pmap_clear_bits(l2, PTE_SW_WIRED);
+ pmap->pm_stats.wired_count -= L2_SIZE /
+ PAGE_SIZE;
continue;
} else {
if (!pv_lists_locked) {