Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 11 Dec 2025 09:02:10 +0000
From:      Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav <des@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: a35545ee0268 - main - vm: Fix kstack alignment assertion
Message-ID:  <693a8892.31030.200d994c@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help

The branch main has been updated by des:

URL: https://cgit.FreeBSD.org/src/commit/?id=a35545ee02680cee04c354b50182dd94d4489666

commit a35545ee02680cee04c354b50182dd94d4489666
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2025-12-11 09:01:47 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2025-12-11 09:02:07 +0000

    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
---
 sys/vm/vm_glue.c | 10 ++++++----
 1 file 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?693a8892.31030.200d994c>