diff options
| author | Dag-Erling Smørgrav <des@FreeBSD.org> | 2025-12-11 09:01:47 +0000 |
|---|---|---|
| committer | Dag-Erling Smørgrav <des@FreeBSD.org> | 2025-12-11 09:02:07 +0000 |
| commit | a35545ee02680cee04c354b50182dd94d4489666 (patch) | |
| tree | ba5fc3f3894a841e6963292e929983c3a6f29c59 | |
| parent | e3fa0a22dd371727712764e3d07891b05980cd61 (diff) | |
vm: Fix kstack alignment assertion
The expectation that the allocation will be aligned to the kstack size
only applies when allocating from a kstack arena, not when allocating a
non-standard size from the kernel arena.
MFC after: 1 week
Sponsored by: Klara, Inc.
Sponsored by: NetApp, Inc.
Fixes: 7a79d0669761 ("vm: improve kstack_object pindex calculation to avoid pindex holes")
Reviewed by: bnovkov, siderop1_netapp.com
Differential Revision: https://reviews.freebsd.org/D54171
| -rw-r--r-- | sys/vm/vm_glue.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/sys/vm/vm_glue.c b/sys/vm/vm_glue.c index 18d789c59281..925bb92cdd75 100644 --- a/sys/vm/vm_glue.c +++ b/sys/vm/vm_glue.c @@ -321,10 +321,12 @@ vm_thread_alloc_kstack_kva(vm_size_t size, int domain) rv = vmem_alloc(arena, size, M_BESTFIT | M_NOWAIT, &addr); if (rv == ENOMEM) return (0); - KASSERT(atop(addr - VM_MIN_KERNEL_ADDRESS) % - (kstack_pages + KSTACK_GUARD_PAGES) == 0, - ("%s: allocated kstack KVA not aligned to multiple of kstack size", - __func__)); + if (size == ptoa(kstack_pages + KSTACK_GUARD_PAGES)) { + /* This expectation only applies to kstack arenas */ + KASSERT((addr - VM_MIN_KERNEL_ADDRESS) % size == 0, + ("%s: allocated kstack KVA not aligned to multiple of kstack size", + __func__)); + } return (addr); #else |
