From nobody Sun Sep 18 06:27:09 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MVdBj5N7Wz4c3BF; Sun, 18 Sep 2022 06:27:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MVdBj4WsNz3YYc; Sun, 18 Sep 2022 06:27:09 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1663482429; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=NTIcw0N4q7GheYHRv7P7KPeDYDZU0GVdVM9OC+JsRhw=; b=GpXJ0vaJW+Wue9Fb4jjzJMaDGBf0loQlSt+iChWxpMnbeCNxbdzGc5YxrxqRZ1yBLmpbnc /rL01ddDWJ1MftDciAmI48p6SCd8f8p4HYesKrqSH+7cK0pZdQ59AAYsKVaq7XpEf6Dy9u WGU9SxdNrrIw7eV3/CRCbxT+HpLBHgWBYDIJy5vYZYWaZG55dh7Dg0OkdbyjAXtXXBmmpE k4Lzw+xIHNHK2F7SG3jBC80y3i5SJA/BAi5ePHS23xROzgr54OY02jjHWSFkFKXfF09A0v 0rh5/mCNxW76OkqhWGDIC1FMxJvSIejK0S30svLOLq4B8vOAyh8q1PZ0rtx/DQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MVdBj3f2kzxTF; Sun, 18 Sep 2022 06:27:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 28I6R9hZ067902; Sun, 18 Sep 2022 06:27:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 28I6R9QF067900; Sun, 18 Sep 2022 06:27:09 GMT (envelope-from git) Date: Sun, 18 Sep 2022 06:27:09 GMT Message-Id: <202209180627.28I6R9QF067900@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kyle Evans Subject: git: 9a45e76cfd25 - stable/13 - arm64, riscv: size boot stacks appropriately List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 9a45e76cfd25c3a01ef44350ddbda603bb07e408 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1663482429; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=NTIcw0N4q7GheYHRv7P7KPeDYDZU0GVdVM9OC+JsRhw=; b=fl5I16L5/AsDt8/hJsK5YfONVhI8e7HSNz6w4x/LU8Wyk6ZGXi9yHJ/0u8QORaWhjFqBnc x8SNiqzs0SOXIeCMjqsT55adzNoRoM4kq2eVQcpEWGOkFVxmUmFT/bMiST1gjAJusd9aqq cmdQZhDmRZNpLfjKiIf731cDRyAQbwnuPDzZJkFN9sLuQ74sv1bB/4sQYkIKbehrBGFber WPxYGuyixiPd9P/4552p/xEVYxabb+K2HnDi3dWUWmGV5YIxQfPOg/2lM+WuwIn6NGhZgh NCcW+9g+Zb8zhTQBUlQCwt2Z6q7ZTWsZZWrTcwR5FrRvNwpLkdBCpu3/FfPS/A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1663482429; a=rsa-sha256; cv=none; b=hY8PjLNaBgwhXBYYZNR7zaiBGAqGbXqRLrG9352joaA7sDmws1lKUVYrkpQf0KaMPsJRBf loqKIIKMWrw1h1pEl6PDqI5UT1rKN1i6NWaTa3w8ACDUmjnSO7OvT7LBrIyJUGFsa8G1vj MyH0N4iqsq4ZOT4vyHGgCkX92bNYaZQB1GZGwFSxf9WjaTzGBJWgGM7rSRWSHOgCmZthMX PA3E1MDm62Te96dfkUj2Gj7DzlZKAFZ03iRkV3owpL/mspKFOWSn/ps1LgxWMrykfFD5M0 5ApC2KJeq1MgQRHwcQTwzZnX6IVySTZYiwY0uwOnW32tv7Yy1OymfhjWP+gm8g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=9a45e76cfd25c3a01ef44350ddbda603bb07e408 commit 9a45e76cfd25c3a01ef44350ddbda603bb07e408 Author: Kyle Evans AuthorDate: 2022-09-07 02:11:30 +0000 Commit: Kyle Evans CommitDate: 2022-09-18 06:26:39 +0000 arm64, riscv: size boot stacks appropriately In 8db2e8fd16c4 ("Remove the secondary_stacks array in arm64 [...]"), bootstacks was setup to be allocated dynamically. While this is generally how x86 does it, it inadvertently shrunk each boot stack from KSTACK_PAGES pages to a single page. Resize these back up to the expected size using the kstack_pages tunable, as we'll need larger stacks with upcoming sanitizer work. Reviewed by: andrew, imp, markj Fixes: 8db2e8fd16c4 ("Remove the secondary_stacks array [...]") Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. (cherry picked from commit bab32a8029c3f9339acbd786ffe8f27ad9cfd288) --- sys/arm64/arm64/mp_machdep.c | 11 +++++++---- sys/riscv/riscv/mp_machdep.c | 10 +++++++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/sys/arm64/arm64/mp_machdep.c b/sys/arm64/arm64/mp_machdep.c index 3e47c60088a8..d2f81d9a950f 100644 --- a/sys/arm64/arm64/mp_machdep.c +++ b/sys/arm64/arm64/mp_machdep.c @@ -81,6 +81,8 @@ __FBSDID("$FreeBSD$"); #include "pic_if.h" +#define MP_BOOTSTACK_SIZE (kstack_pages * PAGE_SIZE) + #define MP_QUIRK_CPULIST 0x01 /* The list of cpus may be wrong, */ /* don't panic if one fails to start */ static uint32_t mp_quirks; @@ -314,7 +316,8 @@ smp_after_idle_runnable(void *arg __unused) for (cpu = 1; cpu < mp_ncpus; cpu++) { if (bootstacks[cpu] != NULL) - kmem_free((vm_offset_t)bootstacks[cpu], PAGE_SIZE); + kmem_free((vm_offset_t)bootstacks[cpu], + MP_BOOTSTACK_SIZE); } } SYSINIT(smp_after_idle_runnable, SI_SUB_SMP, SI_ORDER_ANY, @@ -515,10 +518,10 @@ start_cpu(u_int cpuid, uint64_t target_cpu, int domain) dpcpu_init(dpcpu[cpuid - 1], cpuid); bootstacks[cpuid] = (void *)kmem_malloc_domainset( - DOMAINSET_PREF(domain), PAGE_SIZE, M_WAITOK | M_ZERO); + DOMAINSET_PREF(domain), MP_BOOTSTACK_SIZE, M_WAITOK | M_ZERO); naps = atomic_load_int(&aps_started); - bootstack = (char *)bootstacks[cpuid] + PAGE_SIZE; + bootstack = (char *)bootstacks[cpuid] + MP_BOOTSTACK_SIZE; printf("Starting CPU %u (%lx)\n", cpuid, target_cpu); pa = pmap_extract(kernel_pmap, (vm_offset_t)mpentry); @@ -537,7 +540,7 @@ start_cpu(u_int cpuid, uint64_t target_cpu, int domain) pcpu_destroy(pcpup); kmem_free((vm_offset_t)dpcpu[cpuid - 1], DPCPU_SIZE); dpcpu[cpuid - 1] = NULL; - kmem_free((vm_offset_t)bootstacks[cpuid], PAGE_SIZE); + kmem_free((vm_offset_t)bootstacks[cpuid], MP_BOOTSTACK_SIZE); bootstacks[cpuid] = NULL; mp_ncpus--; return (false); diff --git a/sys/riscv/riscv/mp_machdep.c b/sys/riscv/riscv/mp_machdep.c index e038b65d9aba..e4fb7e98badb 100644 --- a/sys/riscv/riscv/mp_machdep.c +++ b/sys/riscv/riscv/mp_machdep.c @@ -71,6 +71,8 @@ __FBSDID("$FreeBSD$"); #include #endif +#define MP_BOOTSTACK_SIZE (kstack_pages * PAGE_SIZE) + boolean_t ofw_cpu_reg(phandle_t node, u_int, cell_t *); uint32_t __riscv_boot_ap[MAXCPU]; @@ -312,7 +314,8 @@ smp_after_idle_runnable(void *arg __unused) for (cpu = 1; cpu <= mp_maxid; cpu++) { if (bootstacks[cpu] != NULL) - kmem_free((vm_offset_t)bootstacks[cpu], PAGE_SIZE); + kmem_free((vm_offset_t)bootstacks[cpu], + MP_BOOTSTACK_SIZE); } } SYSINIT(smp_after_idle_runnable, SI_SUB_SMP, SI_ORDER_ANY, @@ -476,10 +479,11 @@ cpu_init_fdt(u_int id, phandle_t node, u_int addr_size, pcell_t *reg) dpcpu[cpuid - 1] = (void *)kmem_malloc(DPCPU_SIZE, M_WAITOK | M_ZERO); dpcpu_init(dpcpu[cpuid - 1], cpuid); - bootstacks[cpuid] = (void *)kmem_malloc(PAGE_SIZE, M_WAITOK | M_ZERO); + bootstacks[cpuid] = (void *)kmem_malloc(MP_BOOTSTACK_SIZE, + M_WAITOK | M_ZERO); naps = atomic_load_int(&aps_started); - bootstack = (char *)bootstacks[cpuid] + PAGE_SIZE; + bootstack = (char *)bootstacks[cpuid] + MP_BOOTSTACK_SIZE; printf("Starting CPU %u (hart %lx)\n", cpuid, hart); atomic_store_32(&__riscv_boot_ap[hart], 1);