From nobody Thu Sep 08 05:03:29 2022 X-Original-To: dev-commits-src-all@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 4MNRpn3tzfz4c6w8; Thu, 8 Sep 2022 05:03:29 +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 4MNRpn33Q0z3LDQ; Thu, 8 Sep 2022 05:03:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1662613409; 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=z9jB5mz6FQyZI2COD9xGMBdWB7GH4qC3jwGtbd5l+OM=; b=resJasfKS7iYLhGlJDacFSDB78T8lHY+8DxnvwemonzOm10KqPI/lvi3z5RJ04m/c1jCYp sr36MYw+tOd1uQCZ3nyNmfNA0Xn2D7ARJPJ7wB8Talw3emLvcGJEHqUfEk1pZEwQzGh5K7 A3X4S7qT2UEGOkKCiIF6gV6obKk7oiP7uFnfi4oKyp4FmQRTpT15tUnmLlfgzLxAINGrz7 yctwoajumwHLXeDe90kQTMmISCcB0B2KVyvYGEfFaMeFilnk745i2I3mEZVEHO+RtLOpsq gGUG0gDI8WWDAptHDZjc3+paPrVrtIRNqSrwf16e8aOBBA6pmpMVCpaqhD6PBg== 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 4MNRpn25pvzmKk; Thu, 8 Sep 2022 05:03:29 +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 28853Txw040011; Thu, 8 Sep 2022 05:03:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 28853TUZ040010; Thu, 8 Sep 2022 05:03:29 GMT (envelope-from git) Date: Thu, 8 Sep 2022 05:03:29 GMT Message-Id: <202209080503.28853TUZ040010@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kyle Evans Subject: git: bab32a8029c3 - main - arm64, riscv: size boot stacks appropriately List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/main X-Git-Reftype: branch X-Git-Commit: bab32a8029c3f9339acbd786ffe8f27ad9cfd288 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1662613409; 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=z9jB5mz6FQyZI2COD9xGMBdWB7GH4qC3jwGtbd5l+OM=; b=Rix+plhKes4QZcH6d8dJaeLDWeEitJ3KUkKSnAp95Amfdff8zq4L5Eo17HMBT5i034pgve A+Twkxc/eDKDpR/mbWPgJ5OlwCqK/QDQ6/T5rqWLdlEaig5GsyL52MvyIoKFzCaLZTK5k8 mL6Ay7OeWWe2EV2FSp+DiJmEO2vH7gUGxcjHdV0UIxhY2HtZ5k/S0/eAoXySoh9PoCl+V6 NJzOBmsnqT16blzktvOsyR9fepkl+nuPloUmIOkJJ40lqtgQFIrZvl1r9cmpMKt6Z9HCuE YwqwzNWI0IM3qLHmvXToveoqipJcXwI6vVfPZqfV9aroW1IQXR6hka5slu5tdg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1662613409; a=rsa-sha256; cv=none; b=uGXevjEDwpndF6imGEq6srymJCPOKetS0miX9gz1sY8vhCa9wALUFIjX3JdENUODUN3SIY YRu2Vy1GvMsiHg1Bn5dfq4Wmeujcz6dv93p4YZtsOCM4JB3MrF6SikH2yG+7sf/oj160uH 2vU6afiGgyE7Keg/qINODOVYMpx3sc/2A8evv8mHKMxRSX359BCT+mDs/wSkO0/Mphv8Yo iJjR6Nrfczx/l1PC+pfPQcRcvZkPXe/FvltOgzCta/mJd4o+wy6BE5+uPvwJUQE37x3fWT nRxyeO+vmKDVwgDC9m1/tt7rTrUQGIiVt7ud+v2k1KBpGUZCvXQAPFbDvP9DQQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=bab32a8029c3f9339acbd786ffe8f27ad9cfd288 commit bab32a8029c3f9339acbd786ffe8f27ad9cfd288 Author: Kyle Evans AuthorDate: 2022-09-07 02:11:30 +0000 Commit: Kyle Evans CommitDate: 2022-09-08 05:03:05 +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. Differential Revision: https://reviews.freebsd.org/D36475 --- 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 d1fbb4c079d2..ee512ce4e256 100644 --- a/sys/arm64/arm64/mp_machdep.c +++ b/sys/arm64/arm64/mp_machdep.c @@ -82,6 +82,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; @@ -317,7 +319,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, @@ -524,10 +527,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); @@ -545,7 +548,7 @@ start_cpu(u_int cpuid, uint64_t target_cpu, int domain) pcpu_destroy(pcpup); dpcpu[cpuid - 1] = NULL; - kmem_free((vm_offset_t)bootstacks[cpuid], PAGE_SIZE); + kmem_free((vm_offset_t)bootstacks[cpuid], MP_BOOTSTACK_SIZE); kmem_free(pcpu_mem, size); bootstacks[cpuid] = NULL; mp_ncpus--; diff --git a/sys/riscv/riscv/mp_machdep.c b/sys/riscv/riscv/mp_machdep.c index f0048284a0c7..2b441d49877b 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]; @@ -311,7 +313,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, @@ -475,10 +478,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);