From nobody Mon Feb 9 05:42:35 2026 Received: from canpmsgout02.his.huawei.com (canpmsgout02.his.huawei.com [113.46.200.217]) (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 3B5C331328E; Mon, 22 Dec 2025 11:48:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.217 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766404103; cv=none; b=cXy5fNdGX6Xt0gygmpNJfIyhpJwrTvZcNKrBy+VdANblFxO48A/vMFo08JGU+/fEgHuDLx+SCm1DajrqDvK6awi2rrylMjn67ULLOvyl+8IOvO9euAF+3inZDxdvdgme3Q32IPH1vs4ZLuyRAkUZ1cia/+uB1iJ1EGeD/GzrJG0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766404103; c=relaxed/simple; bh=wOu7iNm4bCW7xNFMm07kSxf+6rNlcg1bw+tJUrdXxjg=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YRbW9fb/lT/N6iZ/CeSdCbHPj24lsaBun2q/52uPnPljl6UskYAPZ1/o8KkA4dpCHSfDh4e+wD1cpZQN8+jKiCPmLXxtvNhzQygnUgGEJNzGtni+tF13f/A5f4xcg9+gEttlIQBOVlkmLPaTdAkqCePAGlPDDFGbyeoE6H1iEF4= 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=gk87i4gg; arc=none smtp.client-ip=113.46.200.217 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="gk87i4gg" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=2pfG2FGkeqdKtN9RNd7Vzxcgb13kzm9Ua4HpZFnxrFA=; b=gk87i4ggW79ZggPR8oBheys6SvdF7hYLha1MT6VPKCAPQJ+TRHjXBDLKaAIZXxgVtSlejhfSU R6ETfk4CROePgxZT3vmKHzg5eEqPEYIblrxgLmvfIhtM/OV7CDzs1cREKjzkP2Fo1oHHKJaNQKa a0KIQkMCcY6SDj/sd3BxOik= Received: from mail.maildlp.com (unknown [172.19.162.140]) by canpmsgout02.his.huawei.com (SkyGuard) with ESMTPS id 4dZbsy2C2mzcZxm; Mon, 22 Dec 2025 19:45:10 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id 15A5F201E8; Mon, 22 Dec 2025 19:48:13 +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, 22 Dec 2025 19:48:11 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v10 01/16] arm64: Remove unused _TIF_WORK_MASK Date: Mon, 22 Dec 2025 19:47:22 +0800 Message-ID: <20251222114737.1334364-2-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251222114737.1334364-1-ruanjinjie@huawei.com> References: <20251222114737.1334364-1-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100001.china.huawei.com (7.221.188.238) To dggpemf500011.china.huawei.com (7.185.36.131) Content-Type: text/plain; charset="utf-8" Since commit b3cf07851b6c ("arm64: entry: Switch to generic IRQ entry"), _TIF_WORK_MASK is never used, so remove it. Reviewed-by: Anshuman Khandual Reviewed-by: Kevin Brodsky Signed-off-by: Jinjie Ruan --- arch/arm64/include/asm/thread_info.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/= thread_info.h index a803b887b0b4..24fcd6adaa33 100644 --- a/arch/arm64/include/asm/thread_info.h +++ b/arch/arm64/include/asm/thread_info.h @@ -106,12 +106,6 @@ void arch_setup_new_exec(void); #define _TIF_NOTIFY_SIGNAL (1 << TIF_NOTIFY_SIGNAL) #define _TIF_TSC_SIGSEGV (1 << TIF_TSC_SIGSEGV) =20 -#define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_NEED_RESCHED_LAZY | \ - _TIF_NOTIFY_RESUME | _TIF_FOREIGN_FPSTATE | \ - _TIF_UPROBE | _TIF_MTE_ASYNC_FAULT | \ - _TIF_NOTIFY_SIGNAL | _TIF_SIGPENDING | \ - _TIF_PATCH_PENDING) - #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \ _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | \ _TIF_SYSCALL_EMU) --=20 2.34.1 From nobody Mon Feb 9 05:42:35 2026 Received: from canpmsgout07.his.huawei.com (canpmsgout07.his.huawei.com [113.46.200.222]) (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 0906231BC8D; Mon, 22 Dec 2025 11:48:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.222 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766404105; cv=none; b=HZS93rn6QvjyvOBX3Z70bI1nIyElpIF+6Yr5z7oy9EuTpx1XtnkXev+mKz/2GBjsVLKLUIzxVBtamdo8Ku23GbQG7t5Cl6TLUSl1a7o04882CATe8Kk0RFwgs7+bpkJITSUWFumh/rNvnWNbeyrvSBjfH2MsvIC21tdzoViJa9U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766404105; c=relaxed/simple; bh=5Gst5SGXok/LST2YUfZIoAf1TaixhCb8CPojSfHFHE8=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UucCNX6f2WcqHGcFL6xXyCJw8iEnGNIrx/6q3HlVHC+w6hoyPZFCWhH1p+EaugWnmb9/pD+dYzynpX6klQE+vdnNh4QPen3fkteYCgwEa7dPH2m7HdE1WjFOEdu1QguJ1bckZL2EL5CB3G+RxR/A9Ug30qt+DUtn3hQP5WMHg9o= 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=HZ4lPPx/; arc=none smtp.client-ip=113.46.200.222 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="HZ4lPPx/" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=pxgQLkj0Z7hHoCYhNOLJqMr8LObp/tqs2Sovd+PzMtM=; b=HZ4lPPx/CfznsSIiZbI4KOTlDMzG0Ifg+iz13CW2kG+nAG431Zbip88e1rRIb+2HC8IjU50G3 X1jg48Xhr/ISGsb362U31wZE90tnAehSfEXzVRUxoRBTazwy7jL065zbHffkTLPZ5+l8g570ZYO 6RARnmpAdtWv/7sJLSZrpXE= Received: from mail.maildlp.com (unknown [172.19.162.92]) by canpmsgout07.his.huawei.com (SkyGuard) with ESMTPS id 4dZbsx3jRnzLlTC; Mon, 22 Dec 2025 19:45:09 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id 9DF7A40565; Mon, 22 Dec 2025 19:48:14 +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, 22 Dec 2025 19:48:13 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v10 02/16] arm64/ptrace: Split report_syscall() Date: Mon, 22 Dec 2025 19:47:23 +0800 Message-ID: <20251222114737.1334364-3-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251222114737.1334364-1-ruanjinjie@huawei.com> References: <20251222114737.1334364-1-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100001.china.huawei.com (7.221.188.238) To dggpemf500011.china.huawei.com (7.185.36.131) Content-Type: text/plain; charset="utf-8" The generic syscall entry code has the form: | syscall_trace_enter() | { | ptrace_report_syscall_entry() | } | | syscall_exit_work() | { | ptrace_report_syscall_exit() | } In preparation for moving arm64 over to the generic entry code, split report_syscall() to two separate enter and exit functions to align the structure of the arm64 code with syscall_trace_enter() and syscall_exit_work() from the generic entry code. No functional changes. Reviewed-by: Anshuman Khandual Reviewed-by: Kevin Brodsky Suggested-by: Mark Rutland Signed-off-by: Jinjie Ruan --- v8: - report_syscall_enter() -> report_syscall_entry(). - Add ptrace_save_reg() helper. --- arch/arm64/kernel/ptrace.c | 41 +++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index b9bdd83fbbca..03fe2f8a4d54 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -2343,9 +2343,10 @@ enum ptrace_syscall_dir { PTRACE_SYSCALL_EXIT, }; =20 -static void report_syscall(struct pt_regs *regs, enum ptrace_syscall_dir d= ir) +static __always_inline unsigned long ptrace_save_reg(struct pt_regs *regs, + enum ptrace_syscall_dir dir, + int *regno) { - int regno; unsigned long saved_reg; =20 /* @@ -2364,15 +2365,31 @@ static void report_syscall(struct pt_regs *regs, en= um ptrace_syscall_dir dir) * - Syscall stops behave differently to seccomp and pseudo-step traps * (the latter do not nobble any registers). */ - regno =3D (is_compat_task() ? 12 : 7); - saved_reg =3D regs->regs[regno]; - regs->regs[regno] =3D dir; + *regno =3D (is_compat_task() ? 12 : 7); + saved_reg =3D regs->regs[*regno]; + regs->regs[*regno] =3D dir; =20 - if (dir =3D=3D PTRACE_SYSCALL_ENTER) { - if (ptrace_report_syscall_entry(regs)) - forget_syscall(regs); - regs->regs[regno] =3D saved_reg; - } else if (!test_thread_flag(TIF_SINGLESTEP)) { + return saved_reg; +} + +static void report_syscall_entry(struct pt_regs *regs) +{ + unsigned long saved_reg; + int regno; + + saved_reg =3D ptrace_save_reg(regs, PTRACE_SYSCALL_ENTER, ®no); + if (ptrace_report_syscall_entry(regs)) + forget_syscall(regs); + regs->regs[regno] =3D saved_reg; +} + +static void report_syscall_exit(struct pt_regs *regs) +{ + unsigned long saved_reg; + int regno; + + saved_reg =3D ptrace_save_reg(regs, PTRACE_SYSCALL_EXIT, ®no); + if (!test_thread_flag(TIF_SINGLESTEP)) { ptrace_report_syscall_exit(regs, 0); regs->regs[regno] =3D saved_reg; } else { @@ -2392,7 +2409,7 @@ int syscall_trace_enter(struct pt_regs *regs) unsigned long flags =3D read_thread_flags(); =20 if (flags & (_TIF_SYSCALL_EMU | _TIF_SYSCALL_TRACE)) { - report_syscall(regs, PTRACE_SYSCALL_ENTER); + report_syscall_entry(regs); if (flags & _TIF_SYSCALL_EMU) return NO_SYSCALL; } @@ -2420,7 +2437,7 @@ void syscall_trace_exit(struct pt_regs *regs) trace_sys_exit(regs, syscall_get_return_value(current, regs)); =20 if (flags & (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP)) - report_syscall(regs, PTRACE_SYSCALL_EXIT); + report_syscall_exit(regs); =20 rseq_syscall(regs); } --=20 2.34.1 From nobody Mon Feb 9 05:42:35 2026 Received: from canpmsgout01.his.huawei.com (canpmsgout01.his.huawei.com [113.46.200.216]) (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 E835C30F552; Mon, 22 Dec 2025 11:48:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.216 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766404100; cv=none; b=O1chpMkz3M5xbzwuFS3PRHcp1ph2E9uaogBSRvZK8qAt+jVSNgXnHh6RglL8QJAbyZr0TMurKDfvj+SWKD453FDqXmVNJFusDguCfvyVr3KtZPONoXQEeVl2SmPn+kCoj7lrc3xVAsjs9gFrAgvtaEaadOl236j49OSmPk+Z6Wo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766404100; c=relaxed/simple; bh=e2WbpbCMzHLqBkoEtGaFBePKKKYbMo6SyDuqYb8qkLc=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=eKGmZUPR6KUq5UIKJ/6UJS6bzGkzZpQGCb9H3kcTFiSB779F6P/bEeWiYaDuZ9SFiaYzJKLV3olvzTjmrCFlD4pfASRNqlJ3wOF8tViRyolhSqgyx7TDjEi87nI28pUrJz1eBnc4fPwF9oYj7vNvs0Vf1ZViyBvRhrH6925zPOc= 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=H07+Cca2; arc=none smtp.client-ip=113.46.200.216 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="H07+Cca2" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=eA9FmNXHGiOZZGgTL6Sla6Y2umwnwt6FXz/Hs6qRHm4=; b=H07+Cca2xuxeNQpzvbRVmh8CyvEBwrt6UIo902ma750PFu24SIMd5UR52h0063FIyECjxm0Qt 6O0Y7f3whHfpdAAHfOC/G8ZJ9d2sd3Tnz199rOns6TCik7R/Ojo+FTGTmx8iDnF/17f8pkZgbRe mlSK4OHEbDVRcQm2aRzBTgw= Received: from mail.maildlp.com (unknown [172.19.162.223]) by canpmsgout01.his.huawei.com (SkyGuard) with ESMTPS id 4dZbtr6fL6z1T4GL; Mon, 22 Dec 2025 19:45:56 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id 3E50240562; Mon, 22 Dec 2025 19:48:16 +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, 22 Dec 2025 19:48:14 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v10 03/16] arm64/ptrace: Return early for ptrace_report_syscall_entry() error Date: Mon, 22 Dec 2025 19:47:24 +0800 Message-ID: <20251222114737.1334364-4-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251222114737.1334364-1-ruanjinjie@huawei.com> References: <20251222114737.1334364-1-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100001.china.huawei.com (7.221.188.238) To dggpemf500011.china.huawei.com (7.185.36.131) Content-Type: text/plain; charset="utf-8" The generic entry abort the syscall_trace_enter() sequence if ptrace_report_syscall_entry() errors out, but arm64 not. When ptrace requests interception, it should prevent all subsequent system-call processing, including audit and seccomp. In preparation for moving arm64 over to the generic entry code, return early if ptrace_report_syscall_entry() encounters an error. Reviewed-by: Kevin Brodsky Signed-off-by: Jinjie Ruan --- arch/arm64/kernel/ptrace.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index 03fe2f8a4d54..f333791ffba6 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -2372,15 +2372,18 @@ static __always_inline unsigned long ptrace_save_re= g(struct pt_regs *regs, return saved_reg; } =20 -static void report_syscall_entry(struct pt_regs *regs) +static int report_syscall_entry(struct pt_regs *regs) { unsigned long saved_reg; - int regno; + int regno, ret; =20 saved_reg =3D ptrace_save_reg(regs, PTRACE_SYSCALL_ENTER, ®no); - if (ptrace_report_syscall_entry(regs)) + ret =3D ptrace_report_syscall_entry(regs); + if (ret) forget_syscall(regs); regs->regs[regno] =3D saved_reg; + + return ret; } =20 static void report_syscall_exit(struct pt_regs *regs) @@ -2407,10 +2410,11 @@ static void report_syscall_exit(struct pt_regs *reg= s) int syscall_trace_enter(struct pt_regs *regs) { unsigned long flags =3D read_thread_flags(); + int ret; =20 if (flags & (_TIF_SYSCALL_EMU | _TIF_SYSCALL_TRACE)) { - report_syscall_entry(regs); - if (flags & _TIF_SYSCALL_EMU) + ret =3D report_syscall_entry(regs); + if (ret || (flags & _TIF_SYSCALL_EMU)) return NO_SYSCALL; } =20 --=20 2.34.1 From nobody Mon Feb 9 05:42:35 2026 Received: from canpmsgout12.his.huawei.com (canpmsgout12.his.huawei.com [113.46.200.227]) (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 B2A0731A7F6; Mon, 22 Dec 2025 11:48:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.227 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766404109; cv=none; b=LTTgeBNnqskBAYZSo69amMla5pMLQiIZYu29WcJamDBhDAaSINm3Kfyvk4TSEE0OsKaxpP7gu792qePxdj5BSKhcqQqHg0WxGvl/b21mgnpfKWBUqKVpMKyr1YwWCaB2LvKmvw5AgorE0V+AwWgVUbIyX2KOIj5aXVygXfVBzDw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766404109; c=relaxed/simple; bh=yyJkFJ2sDuTsUNZSyJQ41SUicwzLPd0PSXjtq8OOeLU=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JhSI0Ms5A8ajDu7fA+5X6a1gxjBHSaSsMmbPkpv84MigwtH4aHAVCM4PttZcWhhpTqg2e+WA1BI07QbOobVKH6mpXhGjHvJJEVxbrd6jn2RxIseHWjW5qA472KFrIsWU7PRr1ku9Plc00Bxy7uhvuHml2PFuO/pf2qx+jLgwFNw= 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=dLGwzFCd; arc=none smtp.client-ip=113.46.200.227 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="dLGwzFCd" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=wHDagg1ohFtchyB4EBBYwxbzjJmO+PZ5X8hQ84MABgU=; b=dLGwzFCdUCQaApzc+qqtqPlQVo6yWcqlis93fFSA0hY2qAMv1THHn9H+udvDz1xW5hH01Rp90 wfuqnqPcpLZm537V1MkV7SI3DJrBaAOCuIEaDSQ8vaTtQY1H2H+4WuBUJnzYay3O3Z3oElRQ9ga WVVDnzHHofVjoZrQjvrK33w= Received: from mail.maildlp.com (unknown [172.19.163.15]) by canpmsgout12.his.huawei.com (SkyGuard) with ESMTPS id 4dZbv32B92znTXp; Mon, 22 Dec 2025 19:46:07 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id CBD2540539; Mon, 22 Dec 2025 19:48:17 +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, 22 Dec 2025 19:48:16 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v10 04/16] arm64/ptrace: Refactor syscall_trace_enter/exit() Date: Mon, 22 Dec 2025 19:47:25 +0800 Message-ID: <20251222114737.1334364-5-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251222114737.1334364-1-ruanjinjie@huawei.com> References: <20251222114737.1334364-1-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100001.china.huawei.com (7.221.188.238) To dggpemf500011.china.huawei.com (7.185.36.131) Content-Type: text/plain; charset="utf-8" The generic syscall entry code has the following form, which use the input syscall work flag and syscall number: | syscall_trace_enter(struct pt_regs *regs, long syscall, | unsigned long work) | | syscall_exit_work(struct pt_regs *regs, unsigned long work) In preparation for moving arm64 over to the generic entry code, refactor syscall_trace_enter/exit() to also pass thread flags, and get syscall number by syscall_get_nr() helper. No functional changes. Reviewed-by: Kevin Brodsky Signed-off-by: Jinjie Ruan --- arch/arm64/include/asm/syscall.h | 4 ++-- arch/arm64/kernel/ptrace.c | 25 ++++++++++++++++--------- arch/arm64/kernel/syscall.c | 5 +++-- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/arch/arm64/include/asm/syscall.h b/arch/arm64/include/asm/sysc= all.h index 5e4c7fc44f73..cef1d9ce6e1b 100644 --- a/arch/arm64/include/asm/syscall.h +++ b/arch/arm64/include/asm/syscall.h @@ -120,7 +120,7 @@ static inline int syscall_get_arch(struct task_struct *= task) return AUDIT_ARCH_AARCH64; } =20 -int syscall_trace_enter(struct pt_regs *regs); -void syscall_trace_exit(struct pt_regs *regs); +int syscall_trace_enter(struct pt_regs *regs, long syscall, unsigned long = flags); +void syscall_trace_exit(struct pt_regs *regs, unsigned long flags); =20 #endif /* __ASM_SYSCALL_H */ diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index f333791ffba6..79762ff33945 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -2407,9 +2407,8 @@ static void report_syscall_exit(struct pt_regs *regs) } } =20 -int syscall_trace_enter(struct pt_regs *regs) +int syscall_trace_enter(struct pt_regs *regs, long syscall, unsigned long = flags) { - unsigned long flags =3D read_thread_flags(); int ret; =20 if (flags & (_TIF_SYSCALL_EMU | _TIF_SYSCALL_TRACE)) { @@ -2422,19 +2421,27 @@ int syscall_trace_enter(struct pt_regs *regs) if (secure_computing() =3D=3D -1) return NO_SYSCALL; =20 - if (test_thread_flag(TIF_SYSCALL_TRACEPOINT)) - trace_sys_enter(regs, regs->syscallno); + /* Either of the above might have changed the syscall number */ + syscall =3D syscall_get_nr(current, regs); =20 - audit_syscall_entry(regs->syscallno, regs->orig_x0, regs->regs[1], + if (test_thread_flag(TIF_SYSCALL_TRACEPOINT)) { + trace_sys_enter(regs, syscall); + + /* + * Probes or BPF hooks in the tracepoint may have changed the + * system call number as well. + */ + syscall =3D syscall_get_nr(current, regs); + } + + audit_syscall_entry(syscall, regs->orig_x0, regs->regs[1], regs->regs[2], regs->regs[3]); =20 - return regs->syscallno; + return syscall; } =20 -void syscall_trace_exit(struct pt_regs *regs) +void syscall_trace_exit(struct pt_regs *regs, unsigned long flags) { - unsigned long flags =3D read_thread_flags(); - audit_syscall_exit(regs); =20 if (flags & _TIF_SYSCALL_TRACEPOINT) diff --git a/arch/arm64/kernel/syscall.c b/arch/arm64/kernel/syscall.c index c062badd1a56..5a103873de12 100644 --- a/arch/arm64/kernel/syscall.c +++ b/arch/arm64/kernel/syscall.c @@ -124,7 +124,7 @@ static void el0_svc_common(struct pt_regs *regs, int sc= no, int sc_nr, */ if (scno =3D=3D NO_SYSCALL) syscall_set_return_value(current, regs, -ENOSYS, 0); - scno =3D syscall_trace_enter(regs); + scno =3D syscall_trace_enter(regs, scno, flags); if (scno =3D=3D NO_SYSCALL) goto trace_exit; } @@ -143,7 +143,8 @@ static void el0_svc_common(struct pt_regs *regs, int sc= no, int sc_nr, } =20 trace_exit: - syscall_trace_exit(regs); + flags =3D read_thread_flags(); + syscall_trace_exit(regs, flags); } =20 void do_el0_svc(struct pt_regs *regs) --=20 2.34.1 From nobody Mon Feb 9 05:42:35 2026 Received: from canpmsgout02.his.huawei.com (canpmsgout02.his.huawei.com [113.46.200.217]) (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 1E1DD31B810; Mon, 22 Dec 2025 11:48:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.217 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766404104; cv=none; b=Rw1oBsrZWdH40r9Eh4Gg2gQG1VmaeZbMvHLgk3Lead9ZuMYazriL5hEWfASHhx6rIQNBqksWpXlHv/Q/CJ3iZA6bYiiF03hC4HgXinA3imwcNv7/HxgESoA2lU5Hn6LAJPU+gAmG2oe/sF1iVvFPWe8rrxrAnn9i9H+2Qd8qj9k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766404104; c=relaxed/simple; bh=86vqIlnDGE9SXsgx6ZmdyIIE3hDpkjKJzPCz+NCmIOI=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fVHnhXbRr2E3R43v+c6OxOHlIEc6FhqWpRk494GEVU/gmnGwo7Lm+7KognqpS5z/xqwBqANQJjsCCZL5h2xNljI5CEdGVvDLIfXHaU3WjGq1d4CN361VyO+ot/68LJAOpW2N8c5xACNcDprkfJ+5FwUUiocWV3TtscdAp/58bic= 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=y2uAVP5/; arc=none smtp.client-ip=113.46.200.217 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="y2uAVP5/" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=KhO8fxda2eoaFX00guyo2P+RdkMem4jclOb0Q5+D1Vs=; b=y2uAVP5/oePyH6XgV5Su2hxNDS3b7tssANwdFF6VrWKLUJqyslgK3bXBVaI5+55TVqlCQW0ZK Y+15Mmi0VwJwHv1HNPJnnVabXjxSjHbc+nnFG52CET6G6CkC6qtDUPFWbxy4ua4B1409ScktHk+ astDwjPWM0qo1RqDatU+f5Q= Received: from mail.maildlp.com (unknown [172.19.162.223]) by canpmsgout02.his.huawei.com (SkyGuard) with ESMTPS id 4dZbt44PS3zcb1P; Mon, 22 Dec 2025 19:45:16 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id 630FC40562; Mon, 22 Dec 2025 19:48:19 +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, 22 Dec 2025 19:48:17 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v10 05/16] arm64: ptrace: Move rseq_syscall() before audit_syscall_exit() Date: Mon, 22 Dec 2025 19:47:26 +0800 Message-ID: <20251222114737.1334364-6-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251222114737.1334364-1-ruanjinjie@huawei.com> References: <20251222114737.1334364-1-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100001.china.huawei.com (7.221.188.238) To dggpemf500011.china.huawei.com (7.185.36.131) Content-Type: text/plain; charset="utf-8" commit a9f3a74a29af ("entry: Provide generic syscall exit function") introduce generic syscall exit function and call rseq_syscall() before audit_syscall_exit() and arch_syscall_exit_tracehook(). And commit b74406f37737 ("arm: Add syscall detection for restartable sequences") add rseq support for arm32, which also call rseq_syscall() before audit_syscall_exit() and tracehook_report_syscall(). However, commit 409d5db49867c ("arm64: rseq: Implement backend rseq calls and select HAVE_RSEQ") implement arm64 rseq and call rseq_syscall() after audit_syscall_exit() and tracehook_report_syscall(). So compared to the generic entry and arm32 code, arm64 terminates the process a bit later if the syscall is issued within a restartable sequence. But as commit b74406f37737 ("arm: Add syscall detection for restartable sequences") said, syscalls are not allowed inside restartable sequences, so should call rseq_syscall() at the very beginning of system call exiting path for CONFIG_DEBUG_RSEQ=3Dy kernel. This could help us to detect whether there is a syscall issued inside restartable sequences. It makes sense to raise SIGSEGV via rseq_syscall() before auditing and ptrace syscall exit, because this guarantees that the process is already in an error state with SIGSEGV pending when those later steps run. Although it makes no practical difference to signal delivery (signals are processed at the very end in arm64_exit_to_user_mode()), the ordering is more logical: detect and flag the error first, then proceed with the remaining work. To make it more reasonable and in preparation for moving arm64 over to the generic entry code, move rseq_syscall() ahead before audit_syscall_exit(). Reviewed-by: Kevin Brodsky Signed-off-by: Jinjie Ruan --- arch/arm64/kernel/ptrace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index 79762ff33945..983d8d1104df 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -2442,6 +2442,8 @@ int syscall_trace_enter(struct pt_regs *regs, long sy= scall, unsigned long flags) =20 void syscall_trace_exit(struct pt_regs *regs, unsigned long flags) { + rseq_syscall(regs); + audit_syscall_exit(regs); =20 if (flags & _TIF_SYSCALL_TRACEPOINT) @@ -2449,8 +2451,6 @@ void syscall_trace_exit(struct pt_regs *regs, unsigne= d long flags) =20 if (flags & (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP)) report_syscall_exit(regs); - - rseq_syscall(regs); } =20 /* --=20 2.34.1 From nobody Mon Feb 9 05:42:35 2026 Received: from canpmsgout01.his.huawei.com (canpmsgout01.his.huawei.com [113.46.200.216]) (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 2CC2E31DDB8; Mon, 22 Dec 2025 11:48:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.216 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766404106; cv=none; b=ePoaiFbKwhz75PxWlkZfN5RmffP3PiCtib8uxQxAfzPiWUs5/fDKEErcVA9SAAZWylZYtezD+bwDQM3QJGOyqp8N85Jz0DB9mL//2B3lYYIr6YbzhErJW/nQp1HeReDpV3tjDK5YrIbTXvheNIXMWlcBvqen+a83kD2kZyAZ+4U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766404106; c=relaxed/simple; bh=CE7FuD67smcsVzI6kj7ta/ufDUvAJF8k098OQyTc5Zc=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EQij5PeaQWMBWV0qA3Q1jb3ikkw6XZn9Zc1Hgg3eizVOdCNKIK96S2GFw8l78VjJjyaM/8lWz2Kg9XlVgg+wWjgq8pmdef8YHgQf+9LNHewgDBqutHbcxOPKC91K+AZbkDys2ecx9jVmPADhpR2v8YWFTnQCS06cRmV4ZH6Vo2k= 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=a2dmece0; arc=none smtp.client-ip=113.46.200.216 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="a2dmece0" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=GokUrbOFG3JToI5q551JTBNOthHknUqU2MHY3KDyCDU=; b=a2dmece0JA1WqaMMuIhDcayjG5Cay8HS6SoFb/ZT4LMUVHowNpK4PaU10Y0QN/+SwsVMF6yRO oBGGxcbZRYUG3WXc+At7oy23GRZ+FD8JDZycdXY2t4QSX76fztNLog2cwVWSyzfpeNDvp31WkkI qIke3FimparZiiR67IDLH8E= Received: from mail.maildlp.com (unknown [172.19.163.104]) by canpmsgout01.his.huawei.com (SkyGuard) with ESMTPS id 4dZbtx4sfQz1T4JS; Mon, 22 Dec 2025 19:46:01 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id 022AD40363; Mon, 22 Dec 2025 19:48:21 +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, 22 Dec 2025 19:48:19 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v10 06/16] arm64: syscall: Rework el0_svc_common() Date: Mon, 22 Dec 2025 19:47:27 +0800 Message-ID: <20251222114737.1334364-7-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251222114737.1334364-1-ruanjinjie@huawei.com> References: <20251222114737.1334364-1-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100001.china.huawei.com (7.221.188.238) To dggpemf500011.china.huawei.com (7.185.36.131) Content-Type: text/plain; charset="utf-8" The generic syscall syscall_exit_work() has the following content: | audit_syscall_exit(regs) | trace_sys_exit(regs, ...) | ptrace_report_syscall_exit(regs, step) The generic syscall syscall_exit_to_user_mode_work() has the following form: | unsigned long work =3D READ_ONCE(current_thread_info()->syscall_work) | rseq_syscall() | if (unlikely(work & SYSCALL_WORK_EXIT)) | syscall_exit_work(regs, work) In preparation for moving arm64 over to the generic entry code, rework el0_svc_common() as below: - Rename syscall_trace_exit() to syscall_exit_work(). - Add syscall_exit_to_user_mode_work_prepare() function to replace the combination of read_thread_flags() and syscall_exit_work(), also move the syscall exit check logic into it. Move has_syscall_work() helper into asm/syscall.h for reuse. - As currently rseq_syscall() is always called and itself is controlled by the CONFIG_DEBUG_RSEQ macro, so the CONFIG_DEBUG_RSEQ check is removed. Reviewed-by: Kevin Brodsky Signed-off-by: Jinjie Ruan --- arch/arm64/include/asm/syscall.h | 7 ++++++- arch/arm64/kernel/ptrace.c | 14 +++++++++++--- arch/arm64/kernel/syscall.c | 20 +------------------- 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/arch/arm64/include/asm/syscall.h b/arch/arm64/include/asm/sysc= all.h index cef1d9ce6e1b..b86b2ffa16ef 100644 --- a/arch/arm64/include/asm/syscall.h +++ b/arch/arm64/include/asm/syscall.h @@ -120,7 +120,12 @@ static inline int syscall_get_arch(struct task_struct = *task) return AUDIT_ARCH_AARCH64; } =20 +static inline bool has_syscall_work(unsigned long flags) +{ + return unlikely(flags & _TIF_SYSCALL_WORK); +} + int syscall_trace_enter(struct pt_regs *regs, long syscall, unsigned long = flags); -void syscall_trace_exit(struct pt_regs *regs, unsigned long flags); +void syscall_exit_to_user_mode_work_prepare(struct pt_regs *regs); =20 #endif /* __ASM_SYSCALL_H */ diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index 983d8d1104df..95f8ea21680a 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -2440,10 +2440,8 @@ int syscall_trace_enter(struct pt_regs *regs, long s= yscall, unsigned long flags) return syscall; } =20 -void syscall_trace_exit(struct pt_regs *regs, unsigned long flags) +static void syscall_exit_work(struct pt_regs *regs, unsigned long flags) { - rseq_syscall(regs); - audit_syscall_exit(regs); =20 if (flags & _TIF_SYSCALL_TRACEPOINT) @@ -2453,6 +2451,16 @@ void syscall_trace_exit(struct pt_regs *regs, unsign= ed long flags) report_syscall_exit(regs); } =20 +void syscall_exit_to_user_mode_work_prepare(struct pt_regs *regs) +{ + unsigned long flags =3D read_thread_flags(); + + rseq_syscall(regs); + + if (has_syscall_work(flags) || flags & _TIF_SINGLESTEP) + syscall_exit_work(regs, flags); +} + /* * SPSR_ELx bits which are always architecturally RES0 per ARM DDI 0487D.a. * We permit userspace to set SSBS (AArch64 bit 12, AArch32 bit 23) which = is diff --git a/arch/arm64/kernel/syscall.c b/arch/arm64/kernel/syscall.c index 5a103873de12..76c9c6fc1b30 100644 --- a/arch/arm64/kernel/syscall.c +++ b/arch/arm64/kernel/syscall.c @@ -65,11 +65,6 @@ static void invoke_syscall(struct pt_regs *regs, unsigne= d int scno, choose_random_kstack_offset(get_random_u16()); } =20 -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[]) { @@ -130,21 +125,8 @@ static void el0_svc_common(struct pt_regs *regs, int s= cno, int sc_nr, } =20 invoke_syscall(regs, scno, sc_nr, syscall_table); - - /* - * The tracing status may have changed under our feet, so we have to - * 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)) { - flags =3D read_thread_flags(); - if (!has_syscall_work(flags) && !(flags & _TIF_SINGLESTEP)) - return; - } - trace_exit: - flags =3D read_thread_flags(); - syscall_trace_exit(regs, flags); + syscall_exit_to_user_mode_work_prepare(regs); } =20 void do_el0_svc(struct pt_regs *regs) --=20 2.34.1 From nobody Mon Feb 9 05:42:35 2026 Received: from canpmsgout07.his.huawei.com (canpmsgout07.his.huawei.com [113.46.200.222]) (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 84FA431AF17; Mon, 22 Dec 2025 11:48:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.222 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766404108; cv=none; b=Alq0eFkaxk8n7Y5EKM97QRmwuvETRcgTMcdhWh/m19JLsWmWTihW0nbjbjCt0TJfG8GNHbOT9/WhnOEm+cBiMZmRfO6+P72ABtbDOqGPpGCZJ3AuPBZTfBBrTVA/HI8u/Pl1fB4BbUBZh8HYThVNV6ayICcaqPZO0piED5Xp+P0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766404108; c=relaxed/simple; bh=ikKEgf5l1fQxPecfEd4XmqwnzRjIDi4kFxbRx1Dwt84=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=g5z/HKLbLOgi1bsxVJcMACqV5/CjuIM2A9FicIR+vt7+S/Hfwf7H7m7sEW3Rvy92XVQKEut9a3TNWMK94gk2P7W1EVlmZ+crMjeemVNgHv1ur7wNTbR31HK04wY8+81A+0L2X7tY0GTxM/+QOeHxGqxVp6uGKJs7/Xo6hRn2ymE= 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=yjfyGkZ0; arc=none smtp.client-ip=113.46.200.222 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="yjfyGkZ0" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=VXr45dLUL9DojJRqNoV5nQwL2Eqlt0ZVl3qP2rursdY=; b=yjfyGkZ0PgYc6WeTZsKoieRFT9/F7PYzR28A0F2Vx+J9BbRvdKqbUcxNyRqQLYHdn++gFxfe8 loOXZO2YsIOwk5mm4pMSH/QsTtgf4JH7LbVLc3+/WhHKCsX33miBS+6RAEs7YaXuo3G7G16a13N 8NuR92acyxyfNtzhh6a/96c= Received: from mail.maildlp.com (unknown [172.19.163.127]) by canpmsgout07.his.huawei.com (SkyGuard) with ESMTPS id 4dZbt53DBjzLlVp; Mon, 22 Dec 2025 19:45:17 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id 8D7FC40363; Mon, 22 Dec 2025 19:48:22 +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, 22 Dec 2025 19:48:20 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v10 07/16] arm64/ptrace: Not check _TIF_SECCOMP/SYSCALL_EMU for syscall_exit_work() Date: Mon, 22 Dec 2025 19:47:28 +0800 Message-ID: <20251222114737.1334364-8-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251222114737.1334364-1-ruanjinjie@huawei.com> References: <20251222114737.1334364-1-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100001.china.huawei.com (7.221.188.238) To dggpemf500011.china.huawei.com (7.185.36.131) As syscall_exit_work() do not handle seccomp, so not check _TIF_SECCOMP for syscall_exit_work(). And as the man manual of PTRACE_SYSEMU and PTRACE_SYSEMU_SINGLESTEP said, "For PTRACE_SYSEMU, continue and stop on entry to the next system call, which will not be executed. For PTRACE_SYSEMU_SINGLESTEP, do the same but also singlestep if not a system call.". So only the syscall entry need to be reported for SYSCALL_EMU, so not check _TIF_SYSCALL_EMU for syscall_exit_work(). After this, audit_syscall_exit() and report_syscall_exit() will no longer be called if only SECCOMP and/or SYSCALL_EMU is set. And remove has_syscall_work() by the way as currently it is only used in el0_svc_common(). This is another preparation for moving arm64 over to the generic entry code. Link=EF=BC=9Ahttps://man7.org/linux/man-pages/man2/ptrace.2.html Signed-off-by: Jinjie Ruan --- arch/arm64/include/asm/syscall.h | 5 ----- arch/arm64/include/asm/thread_info.h | 3 +++ arch/arm64/kernel/ptrace.c | 2 +- arch/arm64/kernel/syscall.c | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/arch/arm64/include/asm/syscall.h b/arch/arm64/include/asm/sysc= all.h index b86b2ffa16ef..7746c8f0e045 100644 --- a/arch/arm64/include/asm/syscall.h +++ b/arch/arm64/include/asm/syscall.h @@ -120,11 +120,6 @@ static inline int syscall_get_arch(struct task_struct = *task) return AUDIT_ARCH_AARCH64; } =20 -static inline bool has_syscall_work(unsigned long flags) -{ - return unlikely(flags & _TIF_SYSCALL_WORK); -} - int syscall_trace_enter(struct pt_regs *regs, long syscall, unsigned long = flags); void syscall_exit_to_user_mode_work_prepare(struct pt_regs *regs); =20 diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/= thread_info.h index 24fcd6adaa33..ef1462b9b00b 100644 --- a/arch/arm64/include/asm/thread_info.h +++ b/arch/arm64/include/asm/thread_info.h @@ -110,6 +110,9 @@ void arch_setup_new_exec(void); _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | \ _TIF_SYSCALL_EMU) =20 +#define _TIF_SYSCALL_EXIT_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \ + _TIF_SYSCALL_TRACEPOINT) + #ifdef CONFIG_SHADOW_CALL_STACK #define INIT_SCS \ .scs_base =3D init_shadow_call_stack, \ diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index 95f8ea21680a..ec818940114e 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -2457,7 +2457,7 @@ void syscall_exit_to_user_mode_work_prepare(struct pt= _regs *regs) =20 rseq_syscall(regs); =20 - if (has_syscall_work(flags) || flags & _TIF_SINGLESTEP) + if (unlikely(flags & _TIF_SYSCALL_EXIT_WORK) || flags & _TIF_SINGLESTEP) syscall_exit_work(regs, flags); } =20 diff --git a/arch/arm64/kernel/syscall.c b/arch/arm64/kernel/syscall.c index 76c9c6fc1b30..80b7fd67492e 100644 --- a/arch/arm64/kernel/syscall.c +++ b/arch/arm64/kernel/syscall.c @@ -101,7 +101,7 @@ static void el0_svc_common(struct pt_regs *regs, int sc= no, int sc_nr, return; } =20 - 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 --=20 2.34.1 From nobody Mon Feb 9 05:42:35 2026 Received: from canpmsgout03.his.huawei.com (canpmsgout03.his.huawei.com [113.46.200.218]) (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 D640231B825; Mon, 22 Dec 2025 11:48:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766404109; cv=none; b=sZuA3ol2naJsjoh50va01m/3Bu+2sUBHRzE6upEMkcfj1Aoz+wUAqe84yFsqJ0kTmSVZXaw1IqsAMkC+wwSHOJhG26BNCjKpDaO+915gAEd8n9r2q/DDFM09zGor27M9uhsF+h3eXSFp9J49Q79SBOk28S58a2ZH0sSAjbYGug4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766404109; c=relaxed/simple; bh=QQADJFmFOX9MtKDPKvXM3/ttyGNVAvUDDH/vWBbWWRo=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QERFCzmanHuLLBrebqT6eJXLnojfKnDcEFMPQmg5MIAvmJtLjvitG0s8KGFRG+UJjiEtH9wG6SUXV9fHbuMjymw2ovZCV/YRIIYkw7hcr66yP0iR315gGInJvmRoUN2IFeH073agJmZ3MZ+92LXH4FAiIRB0qQWr9oQxn406oWk= 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=ohiUYkxj; arc=none smtp.client-ip=113.46.200.218 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="ohiUYkxj" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=fjWdd/vlyHsbupVpqCXHo9EJOCq1gDlA2o9eaOcad8M=; b=ohiUYkxj+fovHWNdtPWOEROwwhddUQ9Q3g/4mvPLFXxUKLRfUXWlJMmKCUK6gZgJp64AhCpsP D2EeaKA3QqEvHHecOq8Nrob5M5ME1yWlmzp2fAwOANjIpbYZ1GfbZ9QykzuvOeRptEkR+YJqU/J BYjihdrQYKphUheWy3/qVY8= Received: from mail.maildlp.com (unknown [172.19.162.223]) by canpmsgout03.his.huawei.com (SkyGuard) with ESMTPS id 4dZbtM0N04zpSvn; Mon, 22 Dec 2025 19:45:31 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id 35AC540562; Mon, 22 Dec 2025 19:48:24 +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, 22 Dec 2025 19:48:22 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v10 08/16] arm64/ptrace: Do not report_syscall_exit() for PTRACE_SYSEMU_SINGLESTEP Date: Mon, 22 Dec 2025 19:47:29 +0800 Message-ID: <20251222114737.1334364-9-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251222114737.1334364-1-ruanjinjie@huawei.com> References: <20251222114737.1334364-1-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100001.china.huawei.com (7.221.188.238) To dggpemf500011.china.huawei.com (7.185.36.131) Content-Type: text/plain; charset="utf-8" The generic report_single_step() always returns false if SYSCALL_EMU is set, but arm64 only checks _TIF_SINGLESTEP and does not check _TIF_SYSCALL_EMU, which means that if both _TIF_SINGLESTEP and _TIF_SYSCALL_EMU are set, the generic entry will not report a single-step, whereas arm64 will do it. As the man manual of PTRACE_SYSEMU and PTRACE_SYSEMU_SINGLESTEP said, "For PTRACE_SYSEMU, continue and stop on entry to the next system call, which will not be executed. For PTRACE_SYSEMU_SINGLESTEP, do the same but also singlestep if not a system call.". And as the generic entry report_single_step() comment said, If SYSCALL_EMU is set, then the only reason to report is when SINGLESTEP is set (i.e. PTRACE_SYSEMU_SINGLESTEP). Because this syscall instruction has been already reported in syscall_trace_enter(), there is no need to report the syscall again in syscall_exit_work(). In preparation for moving arm64 over to the generic entry code, - Add report_single_step() helper for arm64 to make it clear. - Do not report_syscall_exit() if both _TIF_SYSCALL_EMU and _TIF_SINGLESTEP set. Signed-off-by: Jinjie Ruan --- arch/arm64/kernel/ptrace.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index ec818940114e..558d5553fd6b 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -2440,14 +2440,25 @@ int syscall_trace_enter(struct pt_regs *regs, long = syscall, unsigned long flags) return syscall; } =20 +static inline bool report_single_step(unsigned long flags) +{ + if (flags & _TIF_SYSCALL_EMU) + return false; + + return flags & _TIF_SINGLESTEP; +} + static void syscall_exit_work(struct pt_regs *regs, unsigned long flags) { + bool step; + audit_syscall_exit(regs); =20 if (flags & _TIF_SYSCALL_TRACEPOINT) trace_sys_exit(regs, syscall_get_return_value(current, regs)); =20 - if (flags & (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP)) + step =3D report_single_step(flags); + if (step || flags & _TIF_SYSCALL_TRACE) report_syscall_exit(regs); } =20 --=20 2.34.1 From nobody Mon Feb 9 05:42:35 2026 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 E2769327BE4; Mon, 22 Dec 2025 11:48:28 +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=1766404111; cv=none; b=HR2m9MA/PkHmjFv3TgL+JZbYtiqafW8TbGLSRsJPIY4Wj9JQr4hfnieoA/RkHOWA9Gb7kWzTNKE1jlVgaP3UHxJqybais8sdOmoEWT7mb8wan49fQg4D7vd4h9Ifh/BHdGAIxR66AWwVj0GrI6947jmYen+Mn1w3vHkVz0fe73I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766404111; c=relaxed/simple; bh=1uIykU9r2fskMeJKXwCSG4StHhzWzl81M6MMS4AzZX0=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JuE5bSYkzdRX17NM4MBQARyOXZLedGRfPMFTrCp9Fw5OVuUS3Xn3dK+MUYAfWTc2TIaAg7Jy9DcIIxWC0+Rz5VIp8FRWzz+FgtXLeQ272ma5e0fYnoy3itkH1GMzP678EyoX/HS7bI+2hAKVKUMO0oAz4Un0+YR/NQe6ayK4wqo= 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=Q9Q2GMi3; 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="Q9Q2GMi3" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=iXHtd/oRJPuc/FpfHkoWFgTNZ+mBvJ/hdvChQnBvkN4=; b=Q9Q2GMi3ghaCtAtJPr7sFhx7TXo6us/eyjxGxztr8InTqGIDfmcwXBKMGkxfF5vuEzXs0y2Xz d+Sh6m6bzedmSN4+WeNsks5qM1j6R55pfrpzt73s86/rjKdHiGeayggIFeOBT+Rxl97q4nHCBc6 27nEIydbWKZOITE9Tv8CtIg= Received: from mail.maildlp.com (unknown [172.19.162.223]) by canpmsgout04.his.huawei.com (SkyGuard) with ESMTPS id 4dZbt56ZDNz1prKB; Mon, 22 Dec 2025 19:45:17 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id BE0B140562; Mon, 22 Dec 2025 19:48:25 +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, 22 Dec 2025 19:48:24 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v10 09/16] arm64/ptrace: Expand secure_computing() in place Date: Mon, 22 Dec 2025 19:47:30 +0800 Message-ID: <20251222114737.1334364-10-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251222114737.1334364-1-ruanjinjie@huawei.com> References: <20251222114737.1334364-1-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100001.china.huawei.com (7.221.188.238) To dggpemf500011.china.huawei.com (7.185.36.131) Content-Type: text/plain; charset="utf-8" The generic entry expand secure_computing() in place and call __secure_computing() directly. In order to switch to the generic entry for arm64, refactor secure_computing() for syscall_trace_enter(). No functional changes. Reviewed-by: Kevin Brodsky Signed-off-by: Jinjie Ruan --- arch/arm64/kernel/ptrace.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index 558d5553fd6b..a1922e4a6437 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -2418,8 +2418,11 @@ int syscall_trace_enter(struct pt_regs *regs, long s= yscall, unsigned long flags) } =20 /* Do the secure computing after ptrace; failures should be fast. */ - if (secure_computing() =3D=3D -1) - return NO_SYSCALL; + if (flags & _TIF_SECCOMP) { + ret =3D __secure_computing(); + if (ret =3D=3D -1) + return NO_SYSCALL; + } =20 /* Either of the above might have changed the syscall number */ syscall =3D syscall_get_nr(current, regs); @@ -2437,7 +2440,7 @@ int syscall_trace_enter(struct pt_regs *regs, long sy= scall, unsigned long flags) audit_syscall_entry(syscall, regs->orig_x0, regs->regs[1], regs->regs[2], regs->regs[3]); =20 - return syscall; + return ret ? : syscall; } =20 static inline bool report_single_step(unsigned long flags) --=20 2.34.1 From nobody Mon Feb 9 05:42:35 2026 Received: from canpmsgout08.his.huawei.com (canpmsgout08.his.huawei.com [113.46.200.223]) (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 C6EE731E0F2; Mon, 22 Dec 2025 11:48:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.223 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766404116; cv=none; b=SBh+vQhMiSfADEPtZNWMXZgXCn2mk/gs1943eRPoqjr+6jDluGNq9IjSeZLXwPR4I6hm0E6GFl469EE1LzriDqfPM2d3bx3SSnzJuS0UtH9qLfvJd1cc3Vxd+401XUMfRZYGC3Aqfv8wLHoHTQV1zrwYKbFeI8AEss4YVslJX30= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766404116; c=relaxed/simple; bh=XIa4OdxYwiMnsFqS6guEHGiJWxCxujFLYiqMPPn3iX0=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=j7YQE19r8sG9y+HTsRMwEJdqLBs7AHfkhMgvTC+9JjPy7l2UAtR+oDkyO+BUD0YkzIryJd/hqsaoDGv27E+NRujzWThaIGswC1Fudv4k7IJ66LwBZSHYrhp4SzZYGK00V0AJEFLWlQ5QUl4RKswLAx2EVoIrMQiMKWsAWtTneYk= 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=yuCEvVky; arc=none smtp.client-ip=113.46.200.223 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="yuCEvVky" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=8fKGogfif+HoCc3kIHvnvF0L83fYROr/QiADL9niEfU=; b=yuCEvVkyfc05tkT4jKX7cVdfIsnF2cOHQsg2SnhRSGWdEk+Ht4711wBNARx7ofXrYY5PajHwc mdilYBz98ektLNmkeD2/cPrkKDS6Q3/ANBbxt5e5f1KHYkuZRSSQkPIvHNq/jUdHaYrCeW+SzID if3uDh86yDbFcaEmaZGeXJs= Received: from mail.maildlp.com (unknown [172.19.163.163]) by canpmsgout08.his.huawei.com (SkyGuard) with ESMTPS id 4dZbt86Y6jzmV6t; Mon, 22 Dec 2025 19:45:20 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id 5280D4056B; Mon, 22 Dec 2025 19:48:27 +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, 22 Dec 2025 19:48:25 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v10 10/16] arm64/ptrace: Use syscall_get_arguments() helper Date: Mon, 22 Dec 2025 19:47:31 +0800 Message-ID: <20251222114737.1334364-11-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251222114737.1334364-1-ruanjinjie@huawei.com> References: <20251222114737.1334364-1-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100001.china.huawei.com (7.221.188.238) To dggpemf500011.china.huawei.com (7.185.36.131) Content-Type: text/plain; charset="utf-8" The generic entry check audit context first and use syscall_get_arguments() helper. In order to switch to the generic entry for arm64, - Also use syscall_get_arguments() to get audit_syscall_entry()'s last four parameters. - Extract the syscall_enter_audit() helper to make it clear. - Check audit context first, which saves an unnecessary memcpy when current process's audit_context is NULL. Overall these changes make syscall_enter_audit() exactly equivalent to the generic one. No functional changes. Reviewed-by: Kevin Brodsky Signed-off-by: Jinjie Ruan --- arch/arm64/kernel/ptrace.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index a1922e4a6437..2645ddf77369 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -2407,6 +2407,16 @@ static void report_syscall_exit(struct pt_regs *regs) } } =20 +static inline void syscall_enter_audit(struct pt_regs *regs, long syscall) +{ + if (unlikely(audit_context())) { + unsigned long args[6]; + + syscall_get_arguments(current, regs, args); + audit_syscall_entry(syscall, args[0], args[1], args[2], args[3]); + } +} + int syscall_trace_enter(struct pt_regs *regs, long syscall, unsigned long = flags) { int ret; @@ -2437,8 +2447,7 @@ int syscall_trace_enter(struct pt_regs *regs, long sy= scall, unsigned long flags) syscall =3D syscall_get_nr(current, regs); } =20 - audit_syscall_entry(syscall, regs->orig_x0, regs->regs[1], - regs->regs[2], regs->regs[3]); + syscall_enter_audit(regs, syscall); =20 return ret ? : syscall; } --=20 2.34.1 From nobody Mon Feb 9 05:42:35 2026 Received: from canpmsgout03.his.huawei.com (canpmsgout03.his.huawei.com [113.46.200.218]) (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 CDF2031B107; Mon, 22 Dec 2025 11:48:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766404113; cv=none; b=iITUN70Ais2QSLBZ1NPsCJl1FWysmu0hhKL3WwkY89pqQBii65JWqW0iO2XPkY+0NbFlURvI8nZtphh28S0yLFjTs9SQci+r9Zk2CmBkNCic18o4i9Wv9cJTLojhzQfb5oG+4bsKhNhstxZFWjJTb5zsSo3g5HuTStqezH0qH+w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766404113; c=relaxed/simple; bh=UePzw26qataYVvLMTJVkXv3NkgN0Y1bkDcjs9OZBItU=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HUzILbCmK6tiEqu6+8tmxjSiMDxmlU5+BIUi1rjYydWVNxg9WWdLiLSeK5N6JxIBfBsa7RV+PXKSxyDkh8Bt13f4pipU2nwhVMFL4FYftNIH9EOhg3vOIobV9zdkGvf1O3JPo1HWCAQ/7wAXLEivWxmzUKDN4wpdOMj5DpUdb3o= 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=xPs06yj3; arc=none smtp.client-ip=113.46.200.218 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="xPs06yj3" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=sde7CMqad4MudR5Jd+IXLkECaEABP+JRMCA+DT9KOB4=; b=xPs06yj3mTcRkpRgDd4jfclYERlGEN3F/fY0JBYc3/FMKcu+f2TeRWGEqH0q0671TTazyV1r7 IPLOb/3Y84yNtv9mujOunZJlLkKoovplXrrC0iiesidcfjqpgBO0+5Savo4Ob+0118AnXeF2K3x D6ewwjWohJ/p12Kd6cx23jc= Received: from mail.maildlp.com (unknown [172.19.162.197]) by canpmsgout03.his.huawei.com (SkyGuard) with ESMTPS id 4dZbtR5M9SzpSy3; Mon, 22 Dec 2025 19:45:35 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id DF0D940363; Mon, 22 Dec 2025 19:48: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, 22 Dec 2025 19:48:27 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v10 11/16] entry: Split syscall_exit_to_user_mode_work() for arch reuse Date: Mon, 22 Dec 2025 19:47:32 +0800 Message-ID: <20251222114737.1334364-12-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251222114737.1334364-1-ruanjinjie@huawei.com> References: <20251222114737.1334364-1-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100001.china.huawei.com (7.221.188.238) To dggpemf500011.china.huawei.com (7.185.36.131) Content-Type: text/plain; charset="utf-8" In the generic entry code, the beginning of syscall_exit_to_user_mode_work() can be reused on arm64 so it makes sense to split it. In preparation for moving arm64 over to the generic entry code, split out syscall_exit_to_user_mode_work_prepare() helper from syscall_exit_to_user_mode_work(). No functional changes. Reviewed-by: Kevin Brodsky Reviewed-by: Thomas Gleixner Signed-off-by: Jinjie Ruan --- include/linux/entry-common.h | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/include/linux/entry-common.h b/include/linux/entry-common.h index 87efb38b7081..0de0e60630e1 100644 --- a/include/linux/entry-common.h +++ b/include/linux/entry-common.h @@ -121,20 +121,11 @@ static __always_inline long syscall_enter_from_user_m= ode(struct pt_regs *regs, l */ void syscall_exit_work(struct pt_regs *regs, unsigned long work); =20 -/** - * syscall_exit_to_user_mode_work - Handle work before returning to user m= ode - * @regs: Pointer to currents pt_regs - * - * Same as step 1 and 2 of syscall_exit_to_user_mode() but without calling - * exit_to_user_mode() to perform the final transition to user mode. - * - * Calling convention is the same as for syscall_exit_to_user_mode() and it - * returns with all work handled and interrupts disabled. The caller must - * invoke exit_to_user_mode() before actually switching to user mode to - * make the final state transitions. Interrupts must stay disabled between - * return from this function and the invocation of exit_to_user_mode(). +/* + * Syscall specific exit to user mode preparation. Runs with interrupts + * enabled. */ -static __always_inline void syscall_exit_to_user_mode_work(struct pt_regs = *regs) +static __always_inline void syscall_exit_to_user_mode_work_prepare(struct = pt_regs *regs) { unsigned long work =3D READ_ONCE(current_thread_info()->syscall_work); unsigned long nr =3D syscall_get_nr(current, regs); @@ -155,6 +146,24 @@ static __always_inline void syscall_exit_to_user_mode_= work(struct pt_regs *regs) */ if (unlikely(work & SYSCALL_WORK_EXIT)) syscall_exit_work(regs, work); +} + +/** + * syscall_exit_to_user_mode_work - Handle work before returning to user m= ode + * @regs: Pointer to currents pt_regs + * + * Same as step 1 and 2 of syscall_exit_to_user_mode() but without calling + * exit_to_user_mode() to perform the final transition to user mode. + * + * Calling convention is the same as for syscall_exit_to_user_mode() and it + * returns with all work handled and interrupts disabled. The caller must + * invoke exit_to_user_mode() before actually switching to user mode to + * make the final state transitions. Interrupts must stay disabled between + * return from this function and the invocation of exit_to_user_mode(). + */ +static __always_inline void syscall_exit_to_user_mode_work(struct pt_regs = *regs) +{ + syscall_exit_to_user_mode_work_prepare(regs); local_irq_disable_exit_to_user(); syscall_exit_to_user_mode_prepare(regs); } --=20 2.34.1 From nobody Mon Feb 9 05:42:35 2026 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 3D37A329C41; Mon, 22 Dec 2025 11:48:33 +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=1766404115; cv=none; b=RJaS85/fWerVV2bKes3UiRot48zt2ETwOjmEpdRa60aDHcB/X6TBfaw5NW/3lH9n9EgRKtWDfxa10+5wbhvi3S+uQ++DLctWtXqx4lHT4q9xqxgKTk10vOEhefVZUmcGirUgN8lZlyrzHftJWL1k2L0f8JHIvJLh38p8xuQbE3w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766404115; c=relaxed/simple; bh=lefHAzKDKk5qEfqBW32KoQp/TdE0goG7qq83kn2U5bk=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YHIDM5qwRzlyQSkELUF9bZxFzK5ZP63AZm3o/dtlD9wJ34UrwefdDXhEn4LksVOvo6ZPEPztrpNATuOtS1Sy95B47ZDuEU7OebkffV13ziQ1ZZVb4dHQ8V0Z03symbuhxhIBSTYTh03ROCR1pQN+ViXrb093ugTh4BeAqWatCzY= 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=UONZScV/; 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="UONZScV/" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=MorARlqx1l48FFO5oJ77A55XAj+4n5dHHdsXuHM6xN8=; b=UONZScV/ePtCxaIDIy35CLn5B4653E8MxmSuL1RtbMG6Clq73beIwnhhOz22EOidPtMS/SL+E 6j3d9QWzoSvq/lugQ6Eiij3Z6Bl3Z+Pjyjf5jy3dlBjLh1DEUlQACHPeExlrwM55Z268VeYKU01 wqX6joJS1BZBLSnQnBD9TrA= Received: from mail.maildlp.com (unknown [172.19.162.140]) by canpmsgout04.his.huawei.com (SkyGuard) with ESMTPS id 4dZbtB4dVnz1prN7; Mon, 22 Dec 2025 19:45:22 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id 77417201E8; Mon, 22 Dec 2025 19:48:30 +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, 22 Dec 2025 19:48:28 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v10 12/16] entry: Add arch_ptrace_report_syscall_entry/exit() Date: Mon, 22 Dec 2025 19:47:33 +0800 Message-ID: <20251222114737.1334364-13-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251222114737.1334364-1-ruanjinjie@huawei.com> References: <20251222114737.1334364-1-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100001.china.huawei.com (7.221.188.238) To dggpemf500011.china.huawei.com (7.185.36.131) Content-Type: text/plain; charset="utf-8" Differ from generic entry, due to historical reasons, ARM64 need to save/restore during syscall entry/exit because ARM64 use a scratch register (ip(r12) on AArch32, x7 on AArch64) to denote syscall entry/exit. In preparation for moving arm64 over to the generic entry code, add arch_ptrace_report_syscall_entry/exit() as the default ptrace_report_syscall_entry/exit() implementation. This allows arm64 to implement the architecture specific version. This allows arm64 to implement the architecture specific version. Reviewed-by: Kevin Brodsky Suggested-by: Mark Rutland Suggested-by: Thomas Gleixner Signed-off-by: Jinjie Ruan --- include/linux/entry-common.h | 39 +++++++++++++++++++++++++++++++++++ kernel/entry/syscall-common.c | 4 ++-- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/include/linux/entry-common.h b/include/linux/entry-common.h index 0de0e60630e1..17171e8873fc 100644 --- a/include/linux/entry-common.h +++ b/include/linux/entry-common.h @@ -45,6 +45,25 @@ SYSCALL_WORK_SYSCALL_EXIT_TRAP | \ ARCH_SYSCALL_WORK_EXIT) =20 +/** + * arch_ptrace_report_syscall_entry - Architecture specific + * ptrace_report_syscall_entry(). + * + * Invoked from syscall_trace_enter() to wrap ptrace_report_syscall_entry(= ). + * Defaults to ptrace_report_syscall_entry. + * + * The main purpose is to support arch-specific ptrace_report_syscall_entr= y() + * implementation. + */ +static __always_inline int arch_ptrace_report_syscall_entry(struct pt_regs= *regs); + +#ifndef arch_ptrace_report_syscall_entry +static __always_inline int arch_ptrace_report_syscall_entry(struct pt_regs= *regs) +{ + return ptrace_report_syscall_entry(regs); +} +#endif + long syscall_trace_enter(struct pt_regs *regs, long syscall, unsigned long= work); =20 /** @@ -112,6 +131,26 @@ static __always_inline long syscall_enter_from_user_mo= de(struct pt_regs *regs, l return ret; } =20 +/** + * arch_ptrace_report_syscall_exit - Architecture specific + * ptrace_report_syscall_exit. + * + * Invoked from syscall_exit_work() to wrap ptrace_report_syscall_exit(). + * + * The main purpose is to support arch-specific ptrace_report_syscall_exit + * implementation. + */ +static __always_inline void arch_ptrace_report_syscall_exit(struct pt_regs= *regs, + int step); + +#ifndef arch_ptrace_report_syscall_exit +static __always_inline void arch_ptrace_report_syscall_exit(struct pt_regs= *regs, + int step) +{ + ptrace_report_syscall_exit(regs, step); +} +#endif + /** * syscall_exit_work - Handle work before returning to user mode * @regs: Pointer to current pt_regs diff --git a/kernel/entry/syscall-common.c b/kernel/entry/syscall-common.c index 940a597ded40..fe38f84dfff3 100644 --- a/kernel/entry/syscall-common.c +++ b/kernel/entry/syscall-common.c @@ -34,7 +34,7 @@ long syscall_trace_enter(struct pt_regs *regs, long sysca= ll, =20 /* Handle ptrace */ if (work & (SYSCALL_WORK_SYSCALL_TRACE | SYSCALL_WORK_SYSCALL_EMU)) { - ret =3D ptrace_report_syscall_entry(regs); + ret =3D arch_ptrace_report_syscall_entry(regs); if (ret || (work & SYSCALL_WORK_SYSCALL_EMU)) return -1L; } @@ -100,5 +100,5 @@ void syscall_exit_work(struct pt_regs *regs, unsigned l= ong work) =20 step =3D report_single_step(work); if (step || work & SYSCALL_WORK_SYSCALL_TRACE) - ptrace_report_syscall_exit(regs, step); + arch_ptrace_report_syscall_exit(regs, step); } --=20 2.34.1 From nobody Mon Feb 9 05:42:35 2026 Received: from canpmsgout02.his.huawei.com (canpmsgout02.his.huawei.com [113.46.200.217]) (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 1223A329C73; Mon, 22 Dec 2025 11:48:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.217 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766404117; cv=none; b=JxhvwBjF+TZpF+QJ0gNnV9X+ackl5Rjznu5peceErc1wyYVDgt6TwxDubYoA4nqxguA6Mpt8M8c/gZU4iZq5rJXuuBkx/fG5q3RahaVJp7cevZsIijMgZvdlwwufK21Fxrh/q9QWHtxgbss73S2HdzvrP2y5zZY5DjESGOgvH7k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766404117; c=relaxed/simple; bh=w+cUrSnTFPj7qB1ZhE5wRIgVWI719XIZTH8tY8rpieI=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EWr4lWtpwWzInlP5Ecb200lUdsXIN1DPVtfLN/Worlo5zLOC6g9Knz/xWSIFauCDyZ+TqWpxaiPAOkdH+ioOplFzmPg6iN3/cGEP8z652y7QP+kGK+yPkcKzML/hS5Oipopir3chokkksuTbyUFFSyBdYVAW9O/k8cp+W7foQ4s= 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=Nmtk4AEv; arc=none smtp.client-ip=113.46.200.217 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="Nmtk4AEv" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=S3hbrlvj9nTle8zD5nundzj0J9i0Kdczvuf9BWM9sBA=; b=Nmtk4AEvwXQmD/Kyr7Q6sF5YiVxvdJ4yKktNjmWsoTNDFUOX90ZXuaQHq68uB3JIwjBRvKiNj hM5LXkZn3vf7Rv21+HsbhvpjBNL+U2tIS/S8HufXp0m9Urd/gr7wvUAlUk6Z5KE/k61cQpXTNgf npauqpC+TR/O3miBueiw71I= Received: from mail.maildlp.com (unknown [172.19.162.144]) by canpmsgout02.his.huawei.com (SkyGuard) with ESMTPS id 4dZbtK2QM1zcZxm; Mon, 22 Dec 2025 19:45:29 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id 1B24140538; Mon, 22 Dec 2025 19:48:32 +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, 22 Dec 2025 19:48:30 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v10 13/16] arm64: entry: Convert to generic entry Date: Mon, 22 Dec 2025 19:47:34 +0800 Message-ID: <20251222114737.1334364-14-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251222114737.1334364-1-ruanjinjie@huawei.com> References: <20251222114737.1334364-1-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100001.china.huawei.com (7.221.188.238) To dggpemf500011.china.huawei.com (7.185.36.131) Content-Type: text/plain; charset="utf-8" Currently, x86, Riscv, Loongarch use the generic entry which makes maintainers' work easier and codes more elegant. arm64 has already switched to the generic IRQ entry, so completely convert arm64 to use the generic entry infrastructure from kernel/entry/*. The changes are below: - Remove TIF_SYSCALL_* flag. - Remove _TIF_SYSCALL_WORK/EXIT_WORK as they are equal with SYSCALL_WORK_ENTER/EXIT. - Implement arch_ptrace_report_syscall_entry/exit() with report_syscall_entry/exit() to do arm64-specific save/restore during syscall entry/exit. - Remove arm64 syscall_trace_enter() and related sub-functions including syscall_enter_audit(), by calling generic entry's functions with similar functionality. - Set/clear SYSCALL_EXIT_TRAP flag when enable/disable single_step, So _TIF_SINGLESTEP can be replaced with generic SYSCALL_EXIT_TRAP, _TIF_SYSCALL_EXIT_WORK and _TIF_SINGLESTEP can be replaced with generic SYSCALL_WORK_EXIT, arm64's report_single_step() can be replaced with generic version. - Remove arm64's syscall_exit_to_user_mode_work_prepare() and syscall_exit_work() etc. by using generic entry's similar same name functions. - Implement arch_syscall_is_vdso_sigreturn() to support "Syscall User Dispatch". Reviewed-by: Kevin Brodsky Suggested-by: Kevin Brodsky Suggested-by: Mark Rutland Signed-off-by: Jinjie Ruan --- arch/arm64/Kconfig | 2 +- arch/arm64/include/asm/entry-common.h | 76 +++++++++++++ arch/arm64/include/asm/syscall.h | 19 +++- arch/arm64/include/asm/thread_info.h | 19 +--- arch/arm64/kernel/debug-monitors.c | 7 ++ arch/arm64/kernel/ptrace.c | 153 -------------------------- arch/arm64/kernel/signal.c | 2 +- arch/arm64/kernel/syscall.c | 6 +- 8 files changed, 107 insertions(+), 177 deletions(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 93173f0a09c7..f50b49ce8b65 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -153,9 +153,9 @@ config ARM64 select GENERIC_CPU_DEVICES select GENERIC_CPU_VULNERABILITIES select GENERIC_EARLY_IOREMAP + select GENERIC_ENTRY select GENERIC_IDLE_POLL_SETUP select GENERIC_IOREMAP - select GENERIC_IRQ_ENTRY select GENERIC_IRQ_IPI select GENERIC_IRQ_KEXEC_CLEAR_VM_FORWARD select GENERIC_IRQ_PROBE diff --git a/arch/arm64/include/asm/entry-common.h b/arch/arm64/include/asm= /entry-common.h index cab8cd78f693..d8bf4bf342e8 100644 --- a/arch/arm64/include/asm/entry-common.h +++ b/arch/arm64/include/asm/entry-common.h @@ -3,14 +3,21 @@ #ifndef _ASM_ARM64_ENTRY_COMMON_H #define _ASM_ARM64_ENTRY_COMMON_H =20 +#include #include =20 +#include #include #include #include #include #include =20 +enum ptrace_syscall_dir { + PTRACE_SYSCALL_ENTER =3D 0, + PTRACE_SYSCALL_EXIT, +}; + #define ARCH_EXIT_TO_USER_MODE_WORK (_TIF_MTE_ASYNC_FAULT | _TIF_FOREIGN_F= PSTATE) =20 static __always_inline void arch_exit_to_user_mode_work(struct pt_regs *re= gs, @@ -54,4 +61,73 @@ static inline bool arch_irqentry_exit_need_resched(void) =20 #define arch_irqentry_exit_need_resched arch_irqentry_exit_need_resched =20 +static __always_inline unsigned long ptrace_save_reg(struct pt_regs *regs, + enum ptrace_syscall_dir dir, + int *regno) +{ + unsigned long saved_reg; + + /* + * We have some ABI weirdness here in the way that we handle syscall + * exit stops because we indicate whether or not the stop has been + * signalled from syscall entry or syscall exit by clobbering a general + * purpose register (ip/r12 for AArch32, x7 for AArch64) in the tracee + * and restoring its old value after the stop. This means that: + * + * - Any writes by the tracer to this register during the stop are + * ignored/discarded. + * + * - The actual value of the register is not available during the stop, + * so the tracer cannot save it and restore it later. + * + * - Syscall stops behave differently to seccomp and pseudo-step traps + * (the latter do not nobble any registers). + */ + *regno =3D (is_compat_task() ? 12 : 7); + saved_reg =3D regs->regs[*regno]; + regs->regs[*regno] =3D dir; + + return saved_reg; +} + +static __always_inline int arch_ptrace_report_syscall_entry(struct pt_regs= *regs) +{ + unsigned long saved_reg; + int regno, ret; + + saved_reg =3D ptrace_save_reg(regs, PTRACE_SYSCALL_ENTER, ®no); + ret =3D ptrace_report_syscall_entry(regs); + if (ret) + forget_syscall(regs); + regs->regs[regno] =3D saved_reg; + + return ret; +} + +#define arch_ptrace_report_syscall_entry arch_ptrace_report_syscall_entry + +static __always_inline void arch_ptrace_report_syscall_exit(struct pt_regs= *regs, + int step) +{ + unsigned long saved_reg; + int regno; + + saved_reg =3D ptrace_save_reg(regs, PTRACE_SYSCALL_EXIT, ®no); + if (!step) { + ptrace_report_syscall_exit(regs, 0); + regs->regs[regno] =3D saved_reg; + } else { + regs->regs[regno] =3D saved_reg; + + /* + * Signal a pseudo-step exception since we are stepping but + * tracer modifications to the registers may have rewound the + * state machine. + */ + ptrace_report_syscall_exit(regs, 1); + } +} + +#define arch_ptrace_report_syscall_exit arch_ptrace_report_syscall_exit + #endif /* _ASM_ARM64_ENTRY_COMMON_H */ diff --git a/arch/arm64/include/asm/syscall.h b/arch/arm64/include/asm/sysc= all.h index 7746c8f0e045..240d45735cc5 100644 --- a/arch/arm64/include/asm/syscall.h +++ b/arch/arm64/include/asm/syscall.h @@ -9,6 +9,9 @@ #include #include =20 +#include +#include + typedef long (*syscall_fn_t)(const struct pt_regs *regs); =20 extern const syscall_fn_t sys_call_table[]; @@ -120,7 +123,19 @@ static inline int syscall_get_arch(struct task_struct = *task) return AUDIT_ARCH_AARCH64; } =20 -int syscall_trace_enter(struct pt_regs *regs, long syscall, unsigned long = flags); -void syscall_exit_to_user_mode_work_prepare(struct pt_regs *regs); +static inline bool arch_syscall_is_vdso_sigreturn(struct pt_regs *regs) +{ + unsigned long sigtramp; + +#ifdef CONFIG_COMPAT + if (is_compat_task()) { + unsigned long sigpage =3D (unsigned long)current->mm->context.sigpage; + + return regs->pc >=3D sigpage && regs->pc < (sigpage + PAGE_SIZE); + } +#endif + sigtramp =3D (unsigned long)VDSO_SYMBOL(current->mm->context.vdso, sigtra= mp); + return regs->pc =3D=3D (sigtramp + 8); +} =20 #endif /* __ASM_SYSCALL_H */ diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/= thread_info.h index ef1462b9b00b..90be0c590b86 100644 --- a/arch/arm64/include/asm/thread_info.h +++ b/arch/arm64/include/asm/thread_info.h @@ -43,6 +43,7 @@ struct thread_info { void *scs_sp; #endif u32 cpu; + unsigned long syscall_work; /* SYSCALL_WORK_ flags */ }; =20 #define thread_saved_pc(tsk) \ @@ -65,11 +66,6 @@ void arch_setup_new_exec(void); #define TIF_UPROBE 5 /* uprobe breakpoint or singlestep */ #define TIF_MTE_ASYNC_FAULT 6 /* MTE Asynchronous Tag Check Fault */ #define TIF_NOTIFY_SIGNAL 7 /* signal notifications exist */ -#define TIF_SYSCALL_TRACE 8 /* syscall trace active */ -#define TIF_SYSCALL_AUDIT 9 /* syscall auditing */ -#define TIF_SYSCALL_TRACEPOINT 10 /* syscall tracepoint for ftrace */ -#define TIF_SECCOMP 11 /* syscall secure computing */ -#define TIF_SYSCALL_EMU 12 /* syscall emulation active */ #define TIF_PATCH_PENDING 13 /* pending live patching update */ #define TIF_MEMDIE 18 /* is terminating due to OOM killer */ #define TIF_FREEZE 19 @@ -92,27 +88,14 @@ void arch_setup_new_exec(void); #define _TIF_NEED_RESCHED_LAZY (1 << TIF_NEED_RESCHED_LAZY) #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) #define _TIF_FOREIGN_FPSTATE (1 << TIF_FOREIGN_FPSTATE) -#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) -#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) -#define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT) -#define _TIF_SECCOMP (1 << TIF_SECCOMP) -#define _TIF_SYSCALL_EMU (1 << TIF_SYSCALL_EMU) #define _TIF_PATCH_PENDING (1 << TIF_PATCH_PENDING) #define _TIF_UPROBE (1 << TIF_UPROBE) -#define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP) #define _TIF_32BIT (1 << TIF_32BIT) #define _TIF_SVE (1 << TIF_SVE) #define _TIF_MTE_ASYNC_FAULT (1 << TIF_MTE_ASYNC_FAULT) #define _TIF_NOTIFY_SIGNAL (1 << TIF_NOTIFY_SIGNAL) #define _TIF_TSC_SIGSEGV (1 << TIF_TSC_SIGSEGV) =20 -#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \ - _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 =3D init_shadow_call_stack, \ diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-m= onitors.c index 29307642f4c9..e67643a70405 100644 --- a/arch/arm64/kernel/debug-monitors.c +++ b/arch/arm64/kernel/debug-monitors.c @@ -385,11 +385,18 @@ void user_enable_single_step(struct task_struct *task) =20 if (!test_and_set_ti_thread_flag(ti, TIF_SINGLESTEP)) set_regs_spsr_ss(task_pt_regs(task)); + + /* + * Ensure that a trap is triggered once stepping out of a system + * call prior to executing any user instruction. + */ + set_task_syscall_work(task, SYSCALL_EXIT_TRAP); } NOKPROBE_SYMBOL(user_enable_single_step); =20 void user_disable_single_step(struct task_struct *task) { clear_ti_thread_flag(task_thread_info(task), TIF_SINGLESTEP); + clear_task_syscall_work(task, SYSCALL_EXIT_TRAP); } NOKPROBE_SYMBOL(user_disable_single_step); diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index 2645ddf77369..f575b30b2dc4 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -8,7 +8,6 @@ * Copyright (C) 2012 ARM Ltd. */ =20 -#include #include #include #include @@ -18,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -28,7 +26,6 @@ #include #include #include -#include =20 #include #include @@ -38,13 +35,9 @@ #include #include #include -#include #include #include =20 -#define CREATE_TRACE_POINTS -#include - struct pt_regs_offset { const char *name; int offset; @@ -2338,152 +2331,6 @@ long arch_ptrace(struct task_struct *child, long re= quest, return ptrace_request(child, request, addr, data); } =20 -enum ptrace_syscall_dir { - PTRACE_SYSCALL_ENTER =3D 0, - PTRACE_SYSCALL_EXIT, -}; - -static __always_inline unsigned long ptrace_save_reg(struct pt_regs *regs, - enum ptrace_syscall_dir dir, - int *regno) -{ - unsigned long saved_reg; - - /* - * We have some ABI weirdness here in the way that we handle syscall - * exit stops because we indicate whether or not the stop has been - * signalled from syscall entry or syscall exit by clobbering a general - * purpose register (ip/r12 for AArch32, x7 for AArch64) in the tracee - * and restoring its old value after the stop. This means that: - * - * - Any writes by the tracer to this register during the stop are - * ignored/discarded. - * - * - The actual value of the register is not available during the stop, - * so the tracer cannot save it and restore it later. - * - * - Syscall stops behave differently to seccomp and pseudo-step traps - * (the latter do not nobble any registers). - */ - *regno =3D (is_compat_task() ? 12 : 7); - saved_reg =3D regs->regs[*regno]; - regs->regs[*regno] =3D dir; - - return saved_reg; -} - -static int report_syscall_entry(struct pt_regs *regs) -{ - unsigned long saved_reg; - int regno, ret; - - saved_reg =3D ptrace_save_reg(regs, PTRACE_SYSCALL_ENTER, ®no); - ret =3D ptrace_report_syscall_entry(regs); - if (ret) - forget_syscall(regs); - regs->regs[regno] =3D saved_reg; - - return ret; -} - -static void report_syscall_exit(struct pt_regs *regs) -{ - unsigned long saved_reg; - int regno; - - saved_reg =3D ptrace_save_reg(regs, PTRACE_SYSCALL_EXIT, ®no); - if (!test_thread_flag(TIF_SINGLESTEP)) { - ptrace_report_syscall_exit(regs, 0); - regs->regs[regno] =3D saved_reg; - } else { - regs->regs[regno] =3D saved_reg; - - /* - * Signal a pseudo-step exception since we are stepping but - * tracer modifications to the registers may have rewound the - * state machine. - */ - ptrace_report_syscall_exit(regs, 1); - } -} - -static inline void syscall_enter_audit(struct pt_regs *regs, long syscall) -{ - if (unlikely(audit_context())) { - unsigned long args[6]; - - syscall_get_arguments(current, regs, args); - audit_syscall_entry(syscall, args[0], args[1], args[2], args[3]); - } -} - -int syscall_trace_enter(struct pt_regs *regs, long syscall, unsigned long = flags) -{ - int ret; - - if (flags & (_TIF_SYSCALL_EMU | _TIF_SYSCALL_TRACE)) { - ret =3D report_syscall_entry(regs); - if (ret || (flags & _TIF_SYSCALL_EMU)) - return NO_SYSCALL; - } - - /* Do the secure computing after ptrace; failures should be fast. */ - if (flags & _TIF_SECCOMP) { - ret =3D __secure_computing(); - if (ret =3D=3D -1) - return NO_SYSCALL; - } - - /* Either of the above might have changed the syscall number */ - syscall =3D syscall_get_nr(current, regs); - - if (test_thread_flag(TIF_SYSCALL_TRACEPOINT)) { - trace_sys_enter(regs, syscall); - - /* - * Probes or BPF hooks in the tracepoint may have changed the - * system call number as well. - */ - syscall =3D syscall_get_nr(current, regs); - } - - syscall_enter_audit(regs, syscall); - - return ret ? : syscall; -} - -static inline bool report_single_step(unsigned long flags) -{ - if (flags & _TIF_SYSCALL_EMU) - return false; - - return flags & _TIF_SINGLESTEP; -} - -static void syscall_exit_work(struct pt_regs *regs, unsigned long flags) -{ - bool step; - - audit_syscall_exit(regs); - - if (flags & _TIF_SYSCALL_TRACEPOINT) - trace_sys_exit(regs, syscall_get_return_value(current, regs)); - - step =3D report_single_step(flags); - if (step || flags & _TIF_SYSCALL_TRACE) - report_syscall_exit(regs); -} - -void syscall_exit_to_user_mode_work_prepare(struct pt_regs *regs) -{ - unsigned long flags =3D read_thread_flags(); - - rseq_syscall(regs); - - if (unlikely(flags & _TIF_SYSCALL_EXIT_WORK) || flags & _TIF_SINGLESTEP) - syscall_exit_work(regs, flags); -} - /* * SPSR_ELx bits which are always architecturally RES0 per ARM DDI 0487D.a. * We permit userspace to set SSBS (AArch64 bit 12, AArch32 bit 23) which = is diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c index 1110eeb21f57..d3ec1892b3c7 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -8,8 +8,8 @@ =20 #include #include +#include #include -#include #include #include #include diff --git a/arch/arm64/kernel/syscall.c b/arch/arm64/kernel/syscall.c index 80b7fd67492e..c440ccb2af62 100644 --- a/arch/arm64/kernel/syscall.c +++ b/arch/arm64/kernel/syscall.c @@ -2,6 +2,7 @@ =20 #include #include +#include #include #include #include @@ -68,6 +69,7 @@ static void invoke_syscall(struct pt_regs *regs, unsigned= int scno, static void el0_svc_common(struct pt_regs *regs, int scno, int sc_nr, const syscall_fn_t syscall_table[]) { + unsigned long work =3D READ_ONCE(current_thread_info()->syscall_work); unsigned long flags =3D read_thread_flags(); =20 regs->orig_x0 =3D regs->regs[0]; @@ -101,7 +103,7 @@ static void el0_svc_common(struct pt_regs *regs, int sc= no, int sc_nr, return; } =20 - if (unlikely(flags & _TIF_SYSCALL_WORK)) { + if (unlikely(work & SYSCALL_WORK_ENTER)) { /* * 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 @@ -119,7 +121,7 @@ static void el0_svc_common(struct pt_regs *regs, int sc= no, int sc_nr, */ if (scno =3D=3D NO_SYSCALL) syscall_set_return_value(current, regs, -ENOSYS, 0); - scno =3D syscall_trace_enter(regs, scno, flags); + scno =3D syscall_trace_enter(regs, scno, work); if (scno =3D=3D NO_SYSCALL) goto trace_exit; } --=20 2.34.1 From nobody Mon Feb 9 05:42:35 2026 Received: from canpmsgout12.his.huawei.com (canpmsgout12.his.huawei.com [113.46.200.227]) (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 96326329E46; Mon, 22 Dec 2025 11:48:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.227 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766404118; cv=none; b=sNdFTq2pO650mHdXr7bmPI0tFubpKy0jFoIYytLiJ8Co7UNUPHMfH0Ewjg0dLLSn6XF7qxPLpNLodxDkueNaXuUkOc8qctIvpcdo7lOMbyDurWBfTMYEBOQsKQkpmbOM305ZdTZhURV243vB9pKKabCWh1KFTtpB1712Qt9nKNI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766404118; c=relaxed/simple; bh=DlAuNfHcDAnBWNTtcVAuSZqlrfIHDJ1ArnJPjTEYxx8=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HDIw3bhsGM8oXJzHcf76+bRQ2R0oEx5rK04ttk0j1ofv6OnYIc0LPZ60YPnhvubzYVWoMsEsyuf7/SQlW3UWGrV2R94DUI6mufQzthpSo88biqwgZ5zDSKRmhP3e7HSL4iQCLf+yxfGXyNarr3P5rScSJbIaNC24jpDWRe8+Bw0= 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=kxKN7EC2; arc=none smtp.client-ip=113.46.200.227 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="kxKN7EC2" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=BvR7YcTvE00lWHQbU4IS+hM0Xz5YMD3BeY0bCI8PRBw=; b=kxKN7EC2DVzEPw6j55Rh10QT6j69Hd+KHvk8DXRJAuGwYp0b+8ClSH2oAP/Qu/qMpM8Tn1l8W CEPoWjk1yUtmwZtnxxYxyGvrPraeB7X3bc1iHrdOeiL7L3Wl06JrHGqHy3X6aGlVpa6E7RIrKBe ZWKypiYoDri0zz2+a/HxdoA= Received: from mail.maildlp.com (unknown [172.19.163.15]) by canpmsgout12.his.huawei.com (SkyGuard) with ESMTPS id 4dZbvM0vmmznTXZ; Mon, 22 Dec 2025 19:46:23 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id A385640539; Mon, 22 Dec 2025 19:48:33 +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, 22 Dec 2025 19:48:32 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v10 14/16] arm64: Inline el0_svc_common() Date: Mon, 22 Dec 2025 19:47:35 +0800 Message-ID: <20251222114737.1334364-15-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251222114737.1334364-1-ruanjinjie@huawei.com> References: <20251222114737.1334364-1-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100001.china.huawei.com (7.221.188.238) To dggpemf500011.china.huawei.com (7.185.36.131) After switch arm64 to Generic Entry, the compiler no longer inlines el0_svc_common() into do_el0_svc(). So inline el0_svc_common() and it has 1% performance uplift on perf bench basic syscall on kunpeng920 as below. | Metric | W/O this patch | With this patch | Change | | ---------- | -------------- | --------------- | --------- | | Total time | 2.195 [sec] | 2.171 [sec] | =E2=86=931.1% | | usecs/op | 0.219575 | 0.217192 | =E2=86=931.1% | | ops/sec | 4,554,260 | 4,604,225 | =E2=86=911.1% | Reviewed-by: Kevin Brodsky Signed-off-by: Jinjie Ruan --- arch/arm64/kernel/syscall.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/syscall.c b/arch/arm64/kernel/syscall.c index c440ccb2af62..45ceb8c4316a 100644 --- a/arch/arm64/kernel/syscall.c +++ b/arch/arm64/kernel/syscall.c @@ -66,8 +66,8 @@ static void invoke_syscall(struct pt_regs *regs, unsigned= int scno, choose_random_kstack_offset(get_random_u16()); } =20 -static void el0_svc_common(struct pt_regs *regs, int scno, int sc_nr, - const syscall_fn_t syscall_table[]) +static __always_inline void el0_svc_common(struct pt_regs *regs, int scno,= int sc_nr, + const syscall_fn_t syscall_table[]) { unsigned long work =3D READ_ONCE(current_thread_info()->syscall_work); unsigned long flags =3D read_thread_flags(); --=20 2.34.1 From nobody Mon Feb 9 05:42:35 2026 Received: from canpmsgout06.his.huawei.com (canpmsgout06.his.huawei.com [113.46.200.221]) (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 1D10D32B9AC; Mon, 22 Dec 2025 11:48:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.221 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766404126; cv=none; b=PN/oYfMn+d/swxW7W3MfEhgfHJzjGAaInoqF9K2fxE2Bu5ZwqvMbt8UL8rrxN+xV8TkDQj+Xe8NR2q0fL2yDxQ632/YXXDMx4N3V7wWX0P9oN5v8h90/QRSRTKjrYisb5pRlB1Uq9fwngFymdZ6A/ro2pJn/PavoiWyzccTb1dw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766404126; c=relaxed/simple; bh=Uwx4KJhyIRX+0FKJqrEw/iuBXDmfw0YMxs+D9x/Ewbk=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OPyTJ3sIqB4N1qe7yFCJyQtBL0j9Dc0Ugpm17ZwEufrW10l6CS0vKiL4pgc2nmTcUm/heupi5spVbsRqOzK7AuYrUVpDZoX4TXD7h+IYn1ynwqdOi7OrpSR8i3wPI+jLxPcU9V2UIemFxu5AEyqeP74JylMVxxQO7vjiXmgppTA= 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=oEp9Ug2a; arc=none smtp.client-ip=113.46.200.221 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="oEp9Ug2a" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=aJTiI4bA0T86T+t5tkcGj308AfemJUXr12sJGCUKjxE=; b=oEp9Ug2akzL8mvTBxZckK/2AGC0mDTS0+1Yg50bxXbJZZwf0Kofh8opHytIvDbFFE0fTZ+mKg 91HGNx00zKxlBUuyoTwgobQs1gtHw90gQ6xi/9B+Xo0yzM6Q7KVc1VBm39OwekhahuHXm0g22Vv pnooENZI9QBWUtKykiVbRXQ= Received: from mail.maildlp.com (unknown [172.19.163.0]) by canpmsgout06.his.huawei.com (SkyGuard) with ESMTPS id 4dZbtK16znzRhWS; Mon, 22 Dec 2025 19:45:29 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id 4BC574036C; Mon, 22 Dec 2025 19:48:35 +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, 22 Dec 2025 19:48:33 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v10 15/16] entry: Inline syscall_exit_work() and syscall_trace_enter() Date: Mon, 22 Dec 2025 19:47:36 +0800 Message-ID: <20251222114737.1334364-16-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251222114737.1334364-1-ruanjinjie@huawei.com> References: <20251222114737.1334364-1-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100001.china.huawei.com (7.221.188.238) To dggpemf500011.china.huawei.com (7.185.36.131) After switch arm64 to Generic Entry, a new hotspot syscall_exit_work() appeared because syscall_exit_work() is not inlined, so inline syscall_exit_work(). Also inline syscall_trace_enter() to align with syscall_exit_work(). On v6.19-rc1 with audit on, inline both syscall_trace_enter() and syscall_exit_work() has 4% performance uplift on perf bench basic syscall on kunpeng920 as below: | Metric | W/O this patch | With this patch | Change | | ---------- | -------------- | --------------- | ------ | | Total time | 2.353 [sec] | 2.264 [sec] | =E2=86=933.8% | | usecs/op | 0.235374 | 0.226472 | =E2=86=933.8% | | ops/sec | 4,248,588 | 4,415,554 | =E2=86=913.9% | Signed-off-by: Jinjie Ruan --- include/linux/entry-common.h | 102 ++++++++++++++++++++++++++- kernel/entry/common.h | 7 -- kernel/entry/syscall-common.c | 96 ++----------------------- kernel/entry/syscall_user_dispatch.c | 4 +- 4 files changed, 106 insertions(+), 103 deletions(-) delete mode 100644 kernel/entry/common.h diff --git a/include/linux/entry-common.h b/include/linux/entry-common.h index 17171e8873fc..ad61a13bf24f 100644 --- a/include/linux/entry-common.h +++ b/include/linux/entry-common.h @@ -2,6 +2,7 @@ #ifndef __LINUX_ENTRYCOMMON_H #define __LINUX_ENTRYCOMMON_H =20 +#include #include #include #include @@ -64,7 +65,64 @@ static __always_inline int arch_ptrace_report_syscall_en= try(struct pt_regs *regs } #endif =20 -long syscall_trace_enter(struct pt_regs *regs, long syscall, unsigned long= work); +static inline void syscall_enter_audit(struct pt_regs *regs, long syscall) +{ + if (unlikely(audit_context())) { + unsigned long args[6]; + + syscall_get_arguments(current, regs, args); + audit_syscall_entry(syscall, args[0], args[1], args[2], args[3]); + } +} + +void __trace_sys_enter(struct pt_regs *regs, long syscall); +bool syscall_user_dispatch(struct pt_regs *regs); + +static __always_inline long syscall_trace_enter(struct pt_regs *regs, long= syscall, + unsigned long work) +{ + long ret =3D 0; + + /* + * Handle Syscall User Dispatch. This must comes first, since + * the ABI here can be something that doesn't make sense for + * other syscall_work features. + */ + if (work & SYSCALL_WORK_SYSCALL_USER_DISPATCH) { + if (syscall_user_dispatch(regs)) + return -1L; + } + + /* Handle ptrace */ + if (work & (SYSCALL_WORK_SYSCALL_TRACE | SYSCALL_WORK_SYSCALL_EMU)) { + ret =3D arch_ptrace_report_syscall_entry(regs); + if (ret || (work & SYSCALL_WORK_SYSCALL_EMU)) + return -1L; + } + + /* Do seccomp after ptrace, to catch any tracer changes. */ + if (work & SYSCALL_WORK_SECCOMP) { + ret =3D __secure_computing(); + if (ret =3D=3D -1L) + return ret; + } + + /* Either of the above might have changed the syscall number */ + syscall =3D syscall_get_nr(current, regs); + + if (unlikely(work & SYSCALL_WORK_SYSCALL_TRACEPOINT)) { + __trace_sys_enter(regs, syscall); + /* + * Probes or BPF hooks in the tracepoint may have changed the + * system call number as well. + */ + syscall =3D syscall_get_nr(current, regs); + } + + syscall_enter_audit(regs, syscall); + + return ret ? : syscall; +} =20 /** * syscall_enter_from_user_mode_work - Check and handle work before invoki= ng @@ -131,6 +189,19 @@ static __always_inline long syscall_enter_from_user_mo= de(struct pt_regs *regs, l return ret; } =20 +/* + * 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(). + */ +static __always_inline bool report_single_step(unsigned long work) +{ + if (work & SYSCALL_WORK_SYSCALL_EMU) + return false; + + return work & SYSCALL_WORK_SYSCALL_EXIT_TRAP; +} + /** * arch_ptrace_report_syscall_exit - Architecture specific * ptrace_report_syscall_exit. @@ -151,6 +222,8 @@ static __always_inline void arch_ptrace_report_syscall_= exit(struct pt_regs *regs } #endif =20 +void __trace_sys_exit(struct pt_regs *regs, long ret); + /** * syscall_exit_work - Handle work before returning to user mode * @regs: Pointer to current pt_regs @@ -158,7 +231,32 @@ static __always_inline void arch_ptrace_report_syscall= _exit(struct pt_regs *regs * * Do one-time syscall specific work. */ -void syscall_exit_work(struct pt_regs *regs, unsigned long work); +static __always_inline void syscall_exit_work(struct pt_regs *regs, unsign= ed long work) +{ + bool step; + + /* + * If the syscall was rolled back due to syscall user dispatching, + * then the tracers below are not invoked for the same reason as + * the entry side was not invoked in syscall_trace_enter(): The ABI + * of these syscalls is unknown. + */ + if (work & SYSCALL_WORK_SYSCALL_USER_DISPATCH) { + if (unlikely(current->syscall_dispatch.on_dispatch)) { + current->syscall_dispatch.on_dispatch =3D false; + return; + } + } + + audit_syscall_exit(regs); + + if (work & SYSCALL_WORK_SYSCALL_TRACEPOINT) + __trace_sys_exit(regs, syscall_get_return_value(current, regs)); + + step =3D report_single_step(work); + if (step || work & SYSCALL_WORK_SYSCALL_TRACE) + arch_ptrace_report_syscall_exit(regs, step); +} =20 /* * Syscall specific exit to user mode preparation. Runs with interrupts diff --git a/kernel/entry/common.h b/kernel/entry/common.h deleted file mode 100644 index f6e6d02f07fe..000000000000 --- a/kernel/entry/common.h +++ /dev/null @@ -1,7 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _COMMON_H -#define _COMMON_H - -bool syscall_user_dispatch(struct pt_regs *regs); - -#endif diff --git a/kernel/entry/syscall-common.c b/kernel/entry/syscall-common.c index fe38f84dfff3..10231d30405e 100644 --- a/kernel/entry/syscall-common.c +++ b/kernel/entry/syscall-common.c @@ -1,104 +1,16 @@ // SPDX-License-Identifier: GPL-2.0 =20 -#include #include -#include "common.h" =20 #define CREATE_TRACE_POINTS #include =20 -static inline void syscall_enter_audit(struct pt_regs *regs, long syscall) +void __trace_sys_enter(struct pt_regs *regs, long syscall) { - if (unlikely(audit_context())) { - unsigned long args[6]; - - syscall_get_arguments(current, regs, args); - audit_syscall_entry(syscall, args[0], args[1], args[2], args[3]); - } + trace_sys_enter(regs, syscall); } =20 -long syscall_trace_enter(struct pt_regs *regs, long syscall, - unsigned long work) +void __trace_sys_exit(struct pt_regs *regs, long ret) { - long ret =3D 0; - - /* - * Handle Syscall User Dispatch. This must comes first, since - * the ABI here can be something that doesn't make sense for - * other syscall_work features. - */ - if (work & SYSCALL_WORK_SYSCALL_USER_DISPATCH) { - if (syscall_user_dispatch(regs)) - return -1L; - } - - /* Handle ptrace */ - if (work & (SYSCALL_WORK_SYSCALL_TRACE | SYSCALL_WORK_SYSCALL_EMU)) { - ret =3D arch_ptrace_report_syscall_entry(regs); - if (ret || (work & SYSCALL_WORK_SYSCALL_EMU)) - return -1L; - } - - /* Do seccomp after ptrace, to catch any tracer changes. */ - if (work & SYSCALL_WORK_SECCOMP) { - ret =3D __secure_computing(); - if (ret =3D=3D -1L) - return ret; - } - - /* Either of the above might have changed the syscall number */ - syscall =3D syscall_get_nr(current, regs); - - if (unlikely(work & SYSCALL_WORK_SYSCALL_TRACEPOINT)) { - trace_sys_enter(regs, syscall); - /* - * Probes or BPF hooks in the tracepoint may have changed the - * system call number as well. - */ - syscall =3D syscall_get_nr(current, regs); - } - - syscall_enter_audit(regs, syscall); - - return ret ? : syscall; -} - -/* - * 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(). - */ -static inline bool report_single_step(unsigned long work) -{ - if (work & SYSCALL_WORK_SYSCALL_EMU) - return false; - - return work & SYSCALL_WORK_SYSCALL_EXIT_TRAP; -} - -void syscall_exit_work(struct pt_regs *regs, unsigned long work) -{ - bool step; - - /* - * If the syscall was rolled back due to syscall user dispatching, - * then the tracers below are not invoked for the same reason as - * the entry side was not invoked in syscall_trace_enter(): The ABI - * of these syscalls is unknown. - */ - if (work & SYSCALL_WORK_SYSCALL_USER_DISPATCH) { - if (unlikely(current->syscall_dispatch.on_dispatch)) { - current->syscall_dispatch.on_dispatch =3D false; - return; - } - } - - audit_syscall_exit(regs); - - if (work & SYSCALL_WORK_SYSCALL_TRACEPOINT) - trace_sys_exit(regs, syscall_get_return_value(current, regs)); - - step =3D report_single_step(work); - if (step || work & SYSCALL_WORK_SYSCALL_TRACE) - arch_ptrace_report_syscall_exit(regs, step); + trace_sys_exit(regs, ret); } diff --git a/kernel/entry/syscall_user_dispatch.c b/kernel/entry/syscall_us= er_dispatch.c index a9055eccb27e..d89dffcc2d64 100644 --- a/kernel/entry/syscall_user_dispatch.c +++ b/kernel/entry/syscall_user_dispatch.c @@ -2,6 +2,8 @@ /* * Copyright (C) 2020 Collabora Ltd. */ + +#include #include #include #include @@ -15,8 +17,6 @@ =20 #include =20 -#include "common.h" - static void trigger_sigsys(struct pt_regs *regs) { struct kernel_siginfo info; --=20 2.34.1 From nobody Mon Feb 9 05:42:35 2026 Received: from canpmsgout10.his.huawei.com (canpmsgout10.his.huawei.com [113.46.200.225]) (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 D726632AAB4; Mon, 22 Dec 2025 11:48:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.225 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766404122; cv=none; b=GXPE0odtq0131s5yf0vO0hm5NHrWs4Ez6baTUBlCRS8TLTTyYWjnALPpQHPV+HyiYl4v9U2f0crbXv14qlJQNvnXCC8kV6LWqPWMVSRXAuhiJFRRzFAmv2/Q/SlOBKyRuFar2hEBfSoklz4VsO4yYxb4BheY8SX6AxsEkpfSU4w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766404122; c=relaxed/simple; bh=pasMR4Ygz9qFZaIQ1r+gvgo/O4vK/SWhOSegJiBFM+s=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=W7IhU+kF/vxEC9Ek+JnxfI7phEAJrtwhO5+BGO1t1jh00pXWZTdpLmeU+0IpVPiwigpe82m+VnG3rNRY5E7Ah9G3hVb/yL8YRLAkhL9IJIybEKdz6WjXp6+0FBCZquqlKiqRRvgezXDWabAiH+9m94BkC6TcOcf1dyIpPuZoInY= 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=pzn12l3+; arc=none smtp.client-ip=113.46.200.225 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="pzn12l3+" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=OD26JToyDDl5Sgwi12v/k4z4U3Ry0aaK+EFkcVoSzl0=; b=pzn12l3+8i2u0VdW8ObsjpHBUYiRi5QgiY9/e9Ff2NU9gMiDOJb6ykZehU1P2/eldejwciE1Q 4ilwISyzTFydBUQAtNmC1IpmPAkEpUypzMGzoAp5lBtKuPSrq/kNRlK1uAA2mrgvhVgZ0SfvnwL nEkQP9EhdJ/amGMMMnpDTGI= Received: from mail.maildlp.com (unknown [172.19.163.15]) by canpmsgout10.his.huawei.com (SkyGuard) with ESMTPS id 4dZbtP0pmXz1K96V; Mon, 22 Dec 2025 19:45:33 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id D16E740539; Mon, 22 Dec 2025 19:48:36 +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, 22 Dec 2025 19:48:35 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v10 16/16] selftests: sud_test: Support aarch64 Date: Mon, 22 Dec 2025 19:47:37 +0800 Message-ID: <20251222114737.1334364-17-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251222114737.1334364-1-ruanjinjie@huawei.com> References: <20251222114737.1334364-1-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100001.china.huawei.com (7.221.188.238) To dggpemf500011.china.huawei.com (7.185.36.131) Content-Type: text/plain; charset="utf-8" From: kemal Support aarch64 to test "Syscall User Dispatch" with sud_test selftest testcase. Signed-off-by: kemal --- tools/testing/selftests/syscall_user_dispatch/sud_benchmark.c | 2 +- tools/testing/selftests/syscall_user_dispatch/sud_test.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/syscall_user_dispatch/sud_benchmark.c = b/tools/testing/selftests/syscall_user_dispatch/sud_benchmark.c index 073a03702ff5..6059abe75cb3 100644 --- a/tools/testing/selftests/syscall_user_dispatch/sud_benchmark.c +++ b/tools/testing/selftests/syscall_user_dispatch/sud_benchmark.c @@ -41,7 +41,7 @@ * out of the box, but don't enable them until they support syscall user * dispatch. */ -#if defined(__x86_64__) || defined(__i386__) +#if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__) #define TEST_BLOCKED_RETURN #endif =20 diff --git a/tools/testing/selftests/syscall_user_dispatch/sud_test.c b/too= ls/testing/selftests/syscall_user_dispatch/sud_test.c index b855c6000287..3ffea2f4a66d 100644 --- a/tools/testing/selftests/syscall_user_dispatch/sud_test.c +++ b/tools/testing/selftests/syscall_user_dispatch/sud_test.c @@ -192,6 +192,10 @@ static void handle_sigsys(int sig, siginfo_t *info, vo= id *ucontext) ((ucontext_t *)ucontext)->uc_mcontext.__gregs[REG_A0] =3D ((ucontext_t *)ucontext)->uc_mcontext.__gregs[REG_A7]; #endif +#ifdef __aarch64__ + ((ucontext_t *)ucontext)->uc_mcontext.regs[0] =3D (unsigned int) + ((ucontext_t *)ucontext)->uc_mcontext.regs[8]; +#endif } =20 int setup_sigsys_handler(void) --=20 2.34.1