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 A1722C624D5 for ; Wed, 2 Sep 2026 09:55:27 +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-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=j48ygBxQtnVqga/KxGE2hJAND8SrQruXUFpMvk/8YUA=; b=rR64QAer13AXNLjs/JGNKUJ/IB mNEE6ZihiOrwYLHmKBXYM37NQQHdg5KVAnILeGFGG23X3AuWTrpqDPb/Hv+4Gn9QzlpPXCer1vzJ+ SCUursFJOY1zXkT5iXLF+UDstE+ud0ggN7dnrmskzjkseSU1aA7E3HYLG1Yfl+xMJ5Q+gHOTl/ksf 88txAkxgFOUZ7Le9WRJBH0BtO8CO5UsnWqrbPztkw1fq8oXegVcHgM9p6pkzTJrufZuqLkqBYVd0P 1RNYzXgsBdJ+z+I1OHEqvSHSjS8SXisRYs+IL87NOB11Hpk3jMCx1ONAuRDWRoC8tZwm07lYnjbgz YJI7mhGg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1x1hga-0000000EHHp-0Uki; Wed, 02 Sep 2026 09:55:16 +0000 Received: from canpmsgout06.his.huawei.com ([113.46.200.221]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1x1hgS-0000000EH8g-3JAR for linux-arm-kernel@lists.infradead.org; Wed, 02 Sep 2026 09:55:11 +0000 dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=j48ygBxQtnVqga/KxGE2hJAND8SrQruXUFpMvk/8YUA=; b=mMXdNRXJcknTqC2OMuM4HkW+/8U/XW8nLiCaEMtw8CMqowE/l0OuILklBw5XNaARIJJjlp4f8 xqfy1JB/QPeZiNlwrNJeLvUTRT9J194Qg1yiEWL64oxWiIBr0Yxeu80las99ylSYKtT1GyEckdg IG2ilEkW3rXQx9m/NizCuEQ= Received: from mail.maildlp.com (unknown [172.19.162.197]) by canpmsgout06.his.huawei.com (SkyGuard) with ESMTPS id 4hZd9G75PTzRhWY; Wed, 2 Sep 2026 17:44:18 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id DF4E14057D; Wed, 2 Sep 2026 17:55:06 +0800 (CST) Received: from huawei.com (10.90.53.73) 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; Wed, 2 Sep 2026 17:55:05 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , CC: Subject: [PATCH v18 09/14] arm64: ptrace: Align syscall exit work semantics with generic entry Date: Wed, 2 Sep 2026 17:55:32 +0800 Message-ID: <20260902095537.602517-10-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260902095537.602517-1-ruanjinjie@huawei.com> References: <20260902095537.602517-1-ruanjinjie@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: kwepems100002.china.huawei.com (7.221.188.206) To dggpemf500011.china.huawei.com (7.185.36.131) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260902_025509_250658_3915C9AC X-CRM114-Status: GOOD ( 13.75 ) 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 Refactor the syscall exit path to better match the generic entry framework. Specifically: - Introduce `_TIF_SYSCALL_EXIT_WORK` to aggregate exit-time thread flags (trace, audit, tracepoint). - Rename `syscall_trace_exit()` to `arm64_syscall_exit_work()` to better reflect its role. - Move `rseq_syscall()` out of `arm64_syscall_exit_work()` and into `arm64_syscall_exit_to_user_mode_work()` so that it runs unconditionally on all exits, consistent with generic entry. - Gate `arm64_syscall_exit_work()` behind the new flag check, mirroring the generic entry exit's pattern. Gating audit on `_TIF_SYSCALL_AUDIT` is equivalent to the previous `audit_context()` check: the audit context and flag are statically allocated at fork and freed at exit, remaining stable throughout syscall execution. No functional changes intended. Cc: Mark Rutland Cc: Will Deacon Cc: Catalin Marinas Cc: Ada Couprie Diaz Reviewed-by: Linus Walleij Signed-off-by: Jinjie Ruan --- arch/arm64/include/asm/syscall.h | 8 ++++++-- arch/arm64/include/asm/thread_info.h | 3 +++ arch/arm64/kernel/ptrace.c | 5 +---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/arch/arm64/include/asm/syscall.h b/arch/arm64/include/asm/syscall.h index 3e4672ab4a4f..7cc872fde019 100644 --- a/arch/arm64/include/asm/syscall.h +++ b/arch/arm64/include/asm/syscall.h @@ -8,6 +8,7 @@ #include #include #include +#include typedef long (*syscall_fn_t)(const struct pt_regs *regs); @@ -121,13 +122,16 @@ static inline int syscall_get_arch(struct task_struct *task) } int arm64_syscall_trace_enter(struct pt_regs *regs, unsigned long flags); -void syscall_trace_exit(struct pt_regs *regs, unsigned long flags); +void arm64_syscall_exit_work(struct pt_regs *regs, unsigned long flags); static __always_inline void arm64_syscall_exit_to_user_mode_work(struct pt_regs *regs) { unsigned long flags = read_thread_flags(); - syscall_trace_exit(regs, flags); + rseq_syscall(regs); + + if (unlikely(flags & _TIF_SYSCALL_EXIT_WORK) || flags & _TIF_SINGLESTEP) + arm64_syscall_exit_work(regs, flags); } #endif /* __ASM_SYSCALL_H */ diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/thread_info.h index 5d7fe3e153c8..56a2c9426a32 100644 --- a/arch/arm64/include/asm/thread_info.h +++ b/arch/arm64/include/asm/thread_info.h @@ -112,6 +112,9 @@ void arch_setup_new_exec(void); _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | \ _TIF_SYSCALL_EMU) +#define _TIF_SYSCALL_EXIT_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \ + _TIF_SYSCALL_TRACEPOINT) + #ifdef CONFIG_SHADOW_CALL_STACK #define INIT_SCS \ .scs_base = init_shadow_call_stack, \ diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index ed970576d9a7..08d2c39ae2ba 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include @@ -2505,12 +2504,10 @@ static inline bool report_single_step(unsigned long flags) return flags & _TIF_SINGLESTEP; } -void syscall_trace_exit(struct pt_regs *regs, unsigned long flags) +void arm64_syscall_exit_work(struct pt_regs *regs, unsigned long flags) { bool step; - rseq_syscall(regs); - audit_syscall_exit(regs); if (flags & _TIF_SYSCALL_TRACEPOINT) -- 2.34.1