git: e3e6f08472b7 - stable/13 - arm64: Fix thread0.td_kstack_pages init

From: Brooks Davis <brooks_at_FreeBSD.org>
Date: Tue, 24 Jan 2023 23:26:26 UTC
The branch stable/13 has been updated by brooks:

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

commit e3e6f08472b79f9c62fc3367a2c4adc5ccc3d94c
Author:     Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2023-01-17 16:35:08 +0000
Commit:     Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2023-01-24 22:45:35 +0000

    arm64: Fix thread0.td_kstack_pages init
    
    Commit 86a994d6537d7b5e1efb1019e466d86a688fd570 initialized
    thread0.td_kstack_pages to KSTACK_PAGES.  Due to the lack of an
    include of opt_kstack_pages.h it used the fallback value of 4 from
    machine/param.h.  This meant that increasing KSTACK_PAGES in the kernel
    config resulted in a panic in _epoch_enter_preempt as the following
    assertion was false during network stack setup:
    
            MPASS((vm_offset_t)et >= td->td_kstack &&
                (vm_offset_t)et + sizeof(struct epoch_tracker) <=
                td->td_kstack + td->td_kstack_pages * PAGE_SIZE);
    
    Switch to initializing with kstack_pages following other architectures.
    
    Reviewed by:    imp, markj
    Sponsored by:   DARPA, AFRL
    Differential Revision:  https://reviews.freebsd.org/D38048
    
    (cherry picked from commit e1b610f76caa09bbc3910477da878ea5078c6569)
---
 sys/arm64/arm64/machdep.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c
index 21c9ced1b0cc..6178221032eb 100644
--- a/sys/arm64/arm64/machdep.c
+++ b/sys/arm64/arm64/machdep.c
@@ -365,7 +365,7 @@ init_proc0(vm_offset_t kstack)
 
 	proc_linkup0(&proc0, &thread0);
 	thread0.td_kstack = kstack;
-	thread0.td_kstack_pages = KSTACK_PAGES;
+	thread0.td_kstack_pages = kstack_pages;
 #if defined(PERTHREAD_SSP)
 	thread0.td_md.md_canary = boot_canary;
 #endif