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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (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 2AA76C43458 for ; Mon, 29 Jun 2026 13:08:20 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4gpmly6bc6z2ydn; Mon, 29 Jun 2026 23:07:42 +1000 (AEST) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=113.46.200.224 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1782738462; cv=none; b=YGpiTE+omqhezDnJIsHZsZXfUhVKrKbRU0s6SvPYcAXQdsvlVj/g6oDgANfap7VylFhl1mkqckDq3PPKHuf4Swvi7qBH30icFM4CFVPPP/mmWhmjxDbVaLm2K+rOAydxQ0KqJhlom20jNHLkl54EVcS7YUShZw8uO1c+aEL0SNYAOIzKn0VmkdFxPh4KQvo8HI9viDtQtC90XwvRrcJPRU7lob55gX33SK4Z/ZCLPcxKzT3RDRAK6MLjBRPPwQvy2MNn70B4GXhTeoE7fCBKo+q2cnO5uv4DG1Mc677Tbkwgt6hqO6YLKQFTFSM7pQvpEepYIgmvzlCRrAM8k3a5ug== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1782738462; c=relaxed/relaxed; bh=2sNn+EhmZkPBnxB5RQNDtHQcKZyPX1Y9+NQI7nSKf14=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Q0N7sAnKq49Piol1a/jYuC4bt76N1qMYVUg2IVdb+gKhWVEfjbA712lHv7FzczDVu91GGVa+vBKbhtoCQy1sgT2PahhxAWqo4/7UIpw5H50Hjxw3mfeE9WaT2K7sQsHuPA3hwmqu3/ZFvxtGyzyTN7RKuvFEDPqxAV4tNq0h5nf3MpC0Qe0MLchoAkwvKQs3YrU79JtF6cQ2fCCNb9GdvkD3J0GvAhW4WESTxV2pKhWkCIxvO0rqi/B6lu/YO39l0lCUaNICAoUi2MPKIp8+/TYUUM0T/WnFe8APYa/AVKdRi+zEgpjNLvG4a6q7W1iuBEBioM8SCFWkpqPBrVFRQg== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; dkim=pass (1024-bit key; unprotected) header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256 header.s=dkim header.b=WOSDlhXC; dkim-atps=neutral; spf=pass (client-ip=113.46.200.224; helo=canpmsgout09.his.huawei.com; envelope-from=ruanjinjie@huawei.com; receiver=lists.ozlabs.org) smtp.mailfrom=huawei.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256 header.s=dkim header.b=WOSDlhXC; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=huawei.com (client-ip=113.46.200.224; helo=canpmsgout09.his.huawei.com; envelope-from=ruanjinjie@huawei.com; receiver=lists.ozlabs.org) Received: from canpmsgout09.his.huawei.com (canpmsgout09.his.huawei.com [113.46.200.224]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4gpmlx71jFz302K for ; Mon, 29 Jun 2026 23:07:41 +1000 (AEST) dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=2sNn+EhmZkPBnxB5RQNDtHQcKZyPX1Y9+NQI7nSKf14=; b=WOSDlhXCtKSH9DuQjQF7cN7xo24WszR3BWM9oku/cs7+saNJ+E9vPIIg/8CLYSaNprTRXxF7A hEdudLHYk8HD7RmzXNu55qhb9nXz/Ltq92CIWHTtxa3KkGjW/uQOvRjsjjeEpCF/QRk1Rs1R7/e KTNbN8PrEwYPo0zlJjtVoUU= Received: from mail.maildlp.com (unknown [172.19.163.15]) by canpmsgout09.his.huawei.com (SkyGuard) with ESMTPS id 4gpmY93S2gz1cyT2; Mon, 29 Jun 2026 20:58:21 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id 8E40040586; Mon, 29 Jun 2026 21:07:28 +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; Mon, 29 Jun 2026 21:07:24 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v16 12/18] arm64: syscall: Use exit-specific flags check in el0_svc_common() Date: Mon, 29 Jun 2026 21:06:10 +0800 Message-ID: <20260629130616.642022-13-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260629130616.642022-1-ruanjinjie@huawei.com> References: <20260629130616.642022-1-ruanjinjie@huawei.com> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: kwepems500001.china.huawei.com (7.221.188.70) To dggpemf500011.china.huawei.com (7.185.36.131) Use exit-specific _TIF_SYSCALL_EXIT_WORK mask to filter out entry-only flags during the system call exit path checks. This aligns arm64 with the generic entry framework's SYSCALL_WORK_EXIT semantics. [Rationale] The current syscall exit path re-evaluates the thread flags using the global _TIF_SYSCALL_WORK mask. However, _TIF_SYSCALL_WORK includes flags that are strictly relevant to system call entry processing: 1. _TIF_SECCOMP: Seccomp filtering (__secure_computing()) only runs on entry. There is no seccomp callback for syscall exit. 2. _TIF_SYSCALL_EMU: In PTRACE_SYSEMU mode, the syscall is intercepted and skipped on entry. Since the syscall is never fully executed, reporting a separate syscall exit stop is unnecessary. [Changes] - _TIF_SYSCALL_EXIT_WORK: A new mask containing only flags requiring exit-time processing: _TIF_SYSCALL_TRACE, _TIF_SYSCALL_AUDIT, and _TIF_SYSCALL_TRACEPOINT. - Optimize re-evaluation check: Use _TIF_SYSCALL_EXIT_WORK inside the el0_svc_common() fast-path block to prevent redundant exit work execution when entry-only flags fluctuate or are synchronously modified under the hood. The outermost gating maintains _TIF_SYSCALL_WORK to preserve architectural entry-exit symmetry for tracers. - Cleanup: Remove the has_syscall_work() helper as it is no longer needed, supporting direct flag comparison to clearly distinguish between entry and exit mandates. [Impact] Unnecessary exit tracing and auditing processing are safely bypassed when entry-specific flags fluctuate during the fast-path re-check block. This safely streamlines the syscall exit sequence to mirror the generic entry loop behaviors without breaking debugger expectations. No functional changes intended Cc: Mark Rutland Cc: Will Deacon Cc: Catalin Marinas Cc: Ada Couprie Diaz Reviewed-by: Ada Couprie Diaz Reviewed-by: Linus Walleij Reviewed-by: Yeoreum Yun Signed-off-by: Jinjie Ruan --- arch/arm64/kernel/syscall.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/arch/arm64/kernel/syscall.c b/arch/arm64/kernel/syscall.c index 6de1fe281d61..5dd94bece929 100644 --- a/arch/arm64/kernel/syscall.c +++ b/arch/arm64/kernel/syscall.c @@ -54,11 +54,6 @@ static void invoke_syscall(struct pt_regs *regs, unsigned int scno, syscall_set_return_value(current, regs, 0, ret); } -static inline bool has_syscall_work(unsigned long flags) -{ - return unlikely(flags & _TIF_SYSCALL_WORK); -} - static void el0_svc_common(struct pt_regs *regs, int scno, int sc_nr, const syscall_fn_t syscall_table[]) { @@ -95,7 +90,7 @@ static void el0_svc_common(struct pt_regs *regs, int scno, int sc_nr, return; } - if (has_syscall_work(flags)) { + if (unlikely(flags & _TIF_SYSCALL_WORK)) { /* * The de-facto standard way to skip a system call using ptrace * is to set the system call to -1 (NO_SYSCALL) and set x0 to a @@ -125,9 +120,9 @@ static void el0_svc_common(struct pt_regs *regs, int scno, int sc_nr, * check again. However, if we were tracing entry, then we always trace * exit regardless, as the old entry assembly did. */ - if (!has_syscall_work(flags) && !IS_ENABLED(CONFIG_DEBUG_RSEQ)) { + if (!(unlikely(flags & _TIF_SYSCALL_WORK)) && !IS_ENABLED(CONFIG_DEBUG_RSEQ)) { flags = read_thread_flags(); - if (has_syscall_work(flags) || flags & _TIF_SINGLESTEP) + if (unlikely(flags & _TIF_SYSCALL_EXIT_WORK) || flags & _TIF_SINGLESTEP) syscall_exit_to_user_mode_work(regs); return; } -- 2.34.1