From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from canpmsgout04.his.huawei.com (canpmsgout04.his.huawei.com [113.46.200.219]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5DD523368A4; Thu, 9 Jul 2026 02:49:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.219 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783565399; cv=none; b=QDh5VFEtlOEkhoWqadjdj8hChyqsLtPrw5onzWXTWlBUy1VPJK7oG8lUduQEWXudxKJcnZ4x1ceuL8r9uEaFSsNr8lexqPAlJcfsc4iXe+HLZUKrMX3Rcqnr8gEFvj7tVU3eY8SbcBmMGyt53Lb4Fx1+cCHHP6nJwKuMgy7aZQc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783565399; c=relaxed/simple; bh=OefyM4WQMu/ogVIwyC5PDancgubTT/iz6Z3KxdeO+m8=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=uovjREklefjCQEsHtfvUYQfN9ixXeykEBIRD7yC3/RZk1JW4wHmO1OFmNAmEAtoTuVMrGnlcYqq0rl79kgoUC6Y9YJA3UFtxVApFrx28pTCjTcX3XfKfJfRGHIiO8oBGqmpOUz/B2I6q32ZNhOvAzDTBG4gw2SCEVLbIg8QptAo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=WYcDhBCe; arc=none smtp.client-ip=113.46.200.219 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="WYcDhBCe" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=gRLMujcKtEgBMihCnDtsclQWX/qVGk38Az9O1hBwWug=; b=WYcDhBCejjUxivBdzvnifl21YIETXwgIZsYeyUTc0ZIYBryBI97TILWYu1HMwm1YE2vINjF8I OY7T5SdLEAUXkBIElWz6F8N6Xg7mqLSSxrH7zxy/wVvAH3ebyG2mR9Ll4pd5U3Gp45fz1ez8gyF mf0A0We+FczmLc/+QgvFnwM= Received: from mail.maildlp.com (unknown [172.19.163.104]) by canpmsgout04.his.huawei.com (SkyGuard) with ESMTPS id 4gwfMn1Jqnz1prKM; Thu, 9 Jul 2026 10:40:37 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id A0C9E4058C; Thu, 9 Jul 2026 10:49:53 +0800 (CST) Received: from [10.67.109.254] (10.67.109.254) by dggpemf500011.china.huawei.com (7.185.36.131) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 9 Jul 2026 10:49:50 +0800 Message-ID: <954e9fdb-0940-4f6f-a5b4-3fe6faf0eedb@huawei.com> Date: Thu, 9 Jul 2026 10:49:49 +0800 Precedence: bulk X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [patch 09/18] entry: Remove syscall_enter_from_user_mode() To: Thomas Gleixner , LKML CC: Peter Zijlstra , Michael Ellerman , Shrikanth Hegde , , Kees Cook , Huacai Chen , , Paul Walmsley , Palmer Dabbelt , , Sven Schnelle , , , Mark Rutland , Andy Lutomirski , Oleg Nesterov , Richard Henderson , Russell King , Catalin Marinas , Guo Ren , Geert Uytterhoeven , Thomas Bogendoerfer , Helge Deller , Yoshinori Sato , Richard Weinberger , Chris Zankel , , , , , , , , , Arnd Bergmann , Vineet Gupta , Will Deacon , Brian Cain , Michal Simek , Dinh Nguyen , "David S. Miller" , Andreas Larsson , , , , , , =?UTF-8?Q?Michal_Such=C3=A1nek?= , Jonathan Corbet , References: <20260707181957.433213175@kernel.org> <20260707190254.132654198@kernel.org> From: Jinjie Ruan In-Reply-To: <20260707190254.132654198@kernel.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: kwepems500002.china.huawei.com (7.221.188.17) To dggpemf500011.china.huawei.com (7.185.36.131) On 7/8/2026 3:06 AM, Thomas Gleixner wrote: > All architecture use either: > > nr = enter_from_user_mode_randomize_stack(regs, nr); > > or > > enter_from_user_mode_randomize_stack(regs); > nr = syscall_enter_from_user_mode_work(regs, nr); > > Remove the now unused function. > > Signed-off-by: Thomas Gleixner > --- > Documentation/core-api/entry.rst | 17 +++++++++------- > include/linux/entry-common.h | 40 +++------------------------------------ > include/linux/irq-entry-common.h | 6 ++--- > 3 files changed, 17 insertions(+), 46 deletions(-) > > --- a/Documentation/core-api/entry.rst > +++ b/Documentation/core-api/entry.rst > @@ -68,7 +68,7 @@ low-level C code must not be instrumente > noinstr void syscall(struct pt_regs *regs, int nr) > { > arch_syscall_enter(regs); > - nr = syscall_enter_from_user_mode(regs, nr); > + nr = syscall_enter_from_user_mode_randomize_stack(regs, nr); > > instrumentation_begin(); > if (!invoke_syscall(regs, nr) && nr != -1) > @@ -78,12 +78,14 @@ low-level C code must not be instrumente > syscall_exit_to_user_mode(regs); > } > > -syscall_enter_from_user_mode() first invokes enter_from_user_mode() which > -establishes state in the following order: > +syscall_enter_from_user_mode_randomize_stack() first invokes > +enter_from_user_mode_randomize_stack() which establishes state in the > +following order: > > * Lockdep > * RCU / Context tracking > * Tracing > + * Apply stack randomization > > and then invokes the various entry work functions like ptrace, seccomp, audit, > syscall tracing, etc. After all that is done, the instrumentable invoke_syscall > @@ -99,10 +101,11 @@ that it invokes exit_to_user_mode() whic > * RCU / Context tracking > * Lockdep > > -syscall_enter_from_user_mode() and syscall_exit_to_user_mode() are also > -available as fine grained subfunctions in cases where the architecture code > -has to do extra work between the various steps. In such cases it has to > -ensure that enter_from_user_mode() is called first on entry and > +syscall_enter_from_user_mode_randomize_stack() and > +syscall_exit_to_user_mode() are also available as fine grained subfunctions > +in cases where the architecture code has to do extra work between the > +various steps. In such cases it has to ensure that > +enter_from_user_mode_randomize_stack() is called first on entry and > exit_to_user_mode() is called last on exit. > > Do not nest syscalls. Nested syscalls will cause RCU and/or context tracking > --- a/include/linux/entry-common.h > +++ b/include/linux/entry-common.h > @@ -19,7 +19,7 @@ > #endif > > /* > - * SYSCALL_WORK flags handled in syscall_enter_from_user_mode() > + * SYSCALL_WORK flags handled in syscall_enter_from_user_mode_work() > */ > #define SYSCALL_WORK_ENTER (SYSCALL_WORK_SECCOMP | \ > SYSCALL_WORK_SYSCALL_TRACEPOINT | \ > @@ -205,42 +205,10 @@ do { \ > _ret; \ > }) > > -/** > - * syscall_enter_from_user_mode - Establish state and check and handle work > - * before invoking a syscall > - * @regs: Pointer to currents pt_regs > - * @syscall: The syscall number > - * > - * Invoked from architecture specific syscall entry code with interrupts > - * disabled. The calling code has to be non-instrumentable. When the > - * function returns all state is correct, interrupts are enabled and the > - * subsequent functions can be instrumented. > - * > - * This is the combination of enter_from_user_mode() and > - * syscall_enter_from_user_mode_work() to be used when there is no > - * architecture specific work to be done between the two. > - * > - * Returns: The original or a modified syscall number. See > - * syscall_enter_from_user_mode_work() for further explanation. > - */ > -static __always_inline long syscall_enter_from_user_mode(struct pt_regs *regs, long syscall) > -{ > - long ret; > - > - enter_from_user_mode(regs); > - > - instrumentation_begin(); > - local_irq_enable(); > - ret = syscall_enter_from_user_mode_work(regs, syscall); > - instrumentation_end(); > - > - return ret; > -} > - > /* > - * If SYSCALL_EMU is set, then the only reason to report is when > - * SINGLESTEP is set (i.e. PTRACE_SYSEMU_SINGLESTEP). This syscall > - * instruction has been already reported in syscall_enter_from_user_mode(). > + * If SYSCALL_EMU is set, then the only reason to report is when SINGLESTEP is > + * set (i.e. PTRACE_SYSEMU_SINGLESTEP). This syscall instruction has been > + * already reported in syscall_enter_from_user_mode_work(). > */ > static __always_inline bool report_single_step(unsigned long work) > { > --- a/include/linux/irq-entry-common.h > +++ b/include/linux/irq-entry-common.h > @@ -49,9 +49,9 @@ > * Defaults to an empty implementation. Can be replaced by architecture > * specific code. > * > - * Invoked from syscall_enter_from_user_mode() in the non-instrumentable > - * section. Use __always_inline so the compiler cannot push it out of line > - * and make it instrumentable. > + * Invoked from enter_from_user_mode_syscall_and_randomize_stack() in the > + * non-instrumentable section. Use __always_inline so the compiler cannot push > + * it out of line and make it instrumentable. Reviewed-by: Jinjie Ruan > */ > static __always_inline void arch_enter_from_user_mode(struct pt_regs *regs); > >