From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EE576CA5FA6 for ; Mon, 28 Sep 2026 20:37:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=4tAW3SlP431F7bjWdI4ygJqmG7YuYjWhSnR8WVAPb5Q=; b=lTp9/BeOBaSLzKUJPZdDxTjt4v Qd0Di+CMXygG+UOTX2UpftM9r4Je6uWRsk3wPISBXKgecSABLQ9I+YSdAihVwW6cQztj+gbMiwO7e 7l0onXrS/PxRM+767r674WuvJqbEPKPCrPIAkhey2Q1SK8y2kDBgpNde+lCoDdlHXy29s2KEOYwnH m5JjHaB09t0m04DqBUSEHMTcigpMsy8TPZ0O/YCLjWIoWLhEMRr0Udbbca70N+06VTpR9sh+pgVMC Q4hhfqGFdIHoY017sMM0NFv7h1j8j2an5jumRagvQZsPqicF2RBzNQzEQywAttMzqODGZO4MT3CQ/ qrEYGlRA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1xBI6W-00000001aNb-3Lp8; Mon, 28 Sep 2026 20:37:40 +0000 Received: from [50.53.43.113] (helo=[192.168.254.34]) by bombadil.infradead.org with esmtpsa (Exim 4.99.1 #2 (Red Hat Linux)) id 1xBI6U-00000001aN3-2nto; Mon, 28 Sep 2026 20:37:38 +0000 Message-ID: <5c6edcfe-8332-4db6-b0fa-ca5d137a2075@infradead.org> Date: Mon, 28 Sep 2026 13:37:37 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH 12/15] sched/task_stack: Introduce ARCH_HAS_VARIABLE_STACK_SIZE To: Mostafa Saleh , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-hardening@vger.kernel.org, linux-rt-devel@lists.linux.dev Cc: corbet@lwn.net, skhan@linuxfoundation.org, catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, akpm@linux-foundation.org, urezki@gmail.com, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, vschneid@redhat.com, kprateek.nayak@amd.com, kees@kernel.org, david@kernel.org, ljs@kernel.org, liam@infradead.org, vbabka@kernel.org, rppt@kernel.org, surenb@google.com, mhocko@suse.com, gustavoars@kernel.org, bigeasy@linutronix.de, clrkwllms@kernel.org References: <20260928174122.3380703-1-smostafa@google.com> <20260928174122.3380703-13-smostafa@google.com> Content-Language: en-US From: Randy Dunlap In-Reply-To: <20260928174122.3380703-13-smostafa@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 9/28/26 10:41 AM, Mostafa Saleh wrote: > When CONFIG_ARCH_HAS_VARIABLE_STACK_SIZE is enabled, the kernel stack > may not be fully populated with the THREAD_SIZE virtual area. > > Teach task_stack_size() to return the size of the vm area and not a > fixed size. > > This propagates to end_of_stack() which makes functions like > stack_not_used() and set_task_stack_end_magic() to use the lowest > valid stack address instead of THREAD_SIZE which would cause data > aborts. > > Signed-off-by: Mostafa Saleh > --- > arch/Kconfig | 10 ++++++++++ > include/linux/sched/task_stack.h | 5 +++++ > 2 files changed, 15 insertions(+) > > diff --git a/arch/Kconfig b/arch/Kconfig > index 45c657772362..d6fa2ccb0599 100644 > --- a/arch/Kconfig > +++ b/arch/Kconfig > @@ -431,6 +431,16 @@ config HAVE_ASM_MODVERSIONS > to support the module versioning for symbols > exported from assembly code. > > +config ARCH_HAS_VARIABLE_STACK_SIZE > + bool > + depends on VMAP_STACK > + depends on !STACK_GROWSUP > + depends on THREAD_INFO_IN_TASK > + help > + An arch should select this if it supports dynamically configuring the > + kernel stack size. > + For example the kernel stack size can be from the command line. can be set from the command line. ? > + > config HAVE_REGS_AND_STACK_ACCESS_API > bool > help > diff --git a/include/linux/sched/task_stack.h b/include/linux/sched/task_stack.h > index 4a808f9c4631..07d73adaecd1 100644 > --- a/include/linux/sched/task_stack.h > +++ b/include/linux/sched/task_stack.h > @@ -10,6 +10,7 @@ > #include > #include > #include > +#include > > #ifdef CONFIG_THREAD_INFO_IN_TASK > > @@ -96,6 +97,10 @@ static inline unsigned long *end_of_stack(const struct task_struct *p) > */ > static __always_inline unsigned long task_stack_size(const struct task_struct *task) > { > +#ifdef CONFIG_ARCH_HAS_VARIABLE_STACK_SIZE > + if (task->stack_vm_area) > + return task->stack_vm_area->nr_pages * PAGE_SIZE; > +#endif > return THREAD_SIZE; > } > -- ~Randy