git: da507ac5503d - main - pmap: Fix some bugs around accounting of wired mappings
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 11 Nov 2026 16:49:53 UTC
The branch main has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=da507ac5503d9af35f5aff4a7a773f6a92746e4a
commit da507ac5503d9af35f5aff4a7a773f6a92746e4a
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2026-11-11 14:15:35 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-11-11 16:49:42 +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
---
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 12c17a8ced64..d6c2636d5844 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 c65de8094dcc..c7fa75d1f25f 100644
--- a/sys/arm64/arm64/pmap.c
+++ b/sys/arm64/arm64/pmap.c
@@ -4598,6 +4598,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, TLBI_TTL_L1);
pmap_resident_count_dec(pmap, L1_SIZE / PAGE_SIZE);
diff --git a/sys/riscv/riscv/pmap.c b/sys/riscv/riscv/pmap.c
index 66dd65747f13..097d16590268 100644
--- a/sys/riscv/riscv/pmap.c
+++ b/sys/riscv/riscv/pmap.c
@@ -4069,6 +4069,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) {