From nobody Tue Dec 2 02:52:23 2025 Received: from canpmsgout05.his.huawei.com (canpmsgout05.his.huawei.com [113.46.200.220]) (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 0FAB2320CCF; Mon, 17 Nov 2025 13:31:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.220 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763386277; cv=none; b=WEEy/orqn0q4F/b0tzrMWxtX8JDPjWzMc2QzPwtONS75Xw+SGh7t14yAojHcipQOoyL3gXAieeQtG5rYwAtjwJb7KtNWxSD1m+qRA29+IRHyIonjLcYeDJoX9Ceq+FBW9rOVJyrbgFzhjvqLECBDazL7w6qlmsfamXjbM5jon6c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763386277; c=relaxed/simple; bh=VdHvdR9xYKjIdNBbC8/KNtwOCuoWMLN2B+4bji7I5b4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bS5Iwx6hHSyLZxIJbJk+f3mw7aC2Zxl6QwLltNG1Jal0PZPvrbt3eNeiw8NZHw/e6rUYce+J3xa3B1UrLvVZY1kDi8yixK9hLmASvVoYTpYU70dTkr73Oq1ISaC1ur7s1kzsc+5ifccc2rFCeP9502byALFUcaI0L9ANVBDIPGQ= 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=QJi33dP6; arc=none smtp.client-ip=113.46.200.220 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="QJi33dP6" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=TWXjlJ8Nf+o3OCawdZWYtmIL00hhY0BSagg28LmBWeY=; b=QJi33dP6IdSUigK10KKiBgdpbvdf1SKYXQuIPBmCCYEmiTxXcB5fSHcODD1YZgf+6UyICoqri nW0BJTJqctFPuR5QZpN02I7WG9GVzrAp1obQxhky2HCtnImh/jYM1ZfJHLB16YlwNr7kOAZhLjC KuPnJTZka72Fe5DjllMqeJc= Received: from mail.maildlp.com (unknown [172.19.162.254]) by canpmsgout05.his.huawei.com (SkyGuard) with ESMTPS id 4d97rf3TXXz12Lgl; Mon, 17 Nov 2025 21:29:38 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id 1BAC6180471; Mon, 17 Nov 2025 21:31:07 +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, 17 Nov 2025 21:31:05 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: Subject: [PATCH v7 01/11] arm64/ptrace: Split report_syscall() Date: Mon, 17 Nov 2025 21:30:38 +0800 Message-ID: <20251117133048.53182-2-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251117133048.53182-1-ruanjinjie@huawei.com> References: <20251117133048.53182-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: kwepems100002.china.huawei.com (7.221.188.206) 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. Suggested-by: Mark Rutland Signed-off-by: Jinjie Ruan --- arch/arm64/kernel/ptrace.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index 4b001121c72d..5534c175ceb7 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -2317,7 +2317,7 @@ enum ptrace_syscall_dir { PTRACE_SYSCALL_EXIT, }; =20 -static void report_syscall(struct pt_regs *regs, enum ptrace_syscall_dir d= ir) +static void report_syscall_enter(struct pt_regs *regs) { int regno; unsigned long saved_reg; @@ -2340,13 +2340,24 @@ static void report_syscall(struct pt_regs *regs, en= um ptrace_syscall_dir dir) */ regno =3D (is_compat_task() ? 12 : 7); saved_reg =3D regs->regs[regno]; - regs->regs[regno] =3D dir; + regs->regs[regno] =3D PTRACE_SYSCALL_ENTER; =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)) { + if (ptrace_report_syscall_entry(regs)) + forget_syscall(regs); + regs->regs[regno] =3D saved_reg; +} + +static void report_syscall_exit(struct pt_regs *regs) +{ + int regno; + unsigned long saved_reg; + + /* See comment for report_syscall_enter() above */ + regno =3D (is_compat_task() ? 12 : 7); + saved_reg =3D regs->regs[regno]; + regs->regs[regno] =3D PTRACE_SYSCALL_EXIT; + + if (!test_thread_flag(TIF_SINGLESTEP)) { ptrace_report_syscall_exit(regs, 0); regs->regs[regno] =3D saved_reg; } else { @@ -2366,7 +2377,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_enter(regs); if (flags & _TIF_SYSCALL_EMU) return NO_SYSCALL; } @@ -2394,7 +2405,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 Tue Dec 2 02:52:23 2025 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 CDC6A31B81D; Mon, 17 Nov 2025 13:31:16 +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=1763386279; cv=none; b=cx3V3TvxF9neCbe2AaoD6k/RkZ4vXG43Bfz9+/6XhMnu9y1XamI5KAfFQYK3RNd2XV9FokEWOBD0CkkrQhflWQumBGeTiQa3n7HacmnVlq+tJrS/MDF9KW832c68shw5XeHX6iJK9OVwTodFZlElZfY0MvtCxSLBjJOdUMeLls8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763386279; c=relaxed/simple; bh=rzcXOSEPfyqUemKA1OR69/JDsy29iHr/9zm+iqt5GGw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CnW5tI5l5l1VvyS5NheNFsY3lxtlfPsLxHArcxHwUfAtV8qlheetHSIM9KjQVpwL0n1Ua62qdQqRV6PcOWqX46IArqhCa7SJkuV4qCQSAJixhZtWFHQ53L1l1pl9p9ZLtPlfmInwN4ZYR8Kkeo5vC+IA3yUuy6vw1t8iq9xcilw= 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=IQFXTe/2; 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="IQFXTe/2" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=Po+J9ChiWqTu8ODR4zmOg9Leefa4MaCMclJAtu9oQJk=; b=IQFXTe/2IhYr6mwfB/HHz/SgGIcZ96Yh6HjGbc+AlSHb4a5exnH9p+vPR4QxGecINrFfDwA2h q7fBbN85IVMLd4lqYwXSxVb6ruoXeP3ytNdynNghbe9aeVgFZ0nx7viLqaTfhlra1qzFWzR/sBa J3jW8HZ2mI0FqSUvs9CN2Ew= Received: from mail.maildlp.com (unknown [172.19.163.17]) by canpmsgout10.his.huawei.com (SkyGuard) with ESMTPS id 4d97rR3W2Pz1K98x; Mon, 17 Nov 2025 21:29:27 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id 7BEB91A0188; Mon, 17 Nov 2025 21:31:08 +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, 17 Nov 2025 21:31:07 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: Subject: [PATCH v7 02/11] arm64/ptrace: Refactor syscall_trace_enter/exit() Date: Mon, 17 Nov 2025 21:30:39 +0800 Message-ID: <20251117133048.53182-3-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251117133048.53182-1-ruanjinjie@huawei.com> References: <20251117133048.53182-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: kwepems100002.china.huawei.com (7.221.188.206) 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. Signed-off-by: Jinjie Ruan --- arch/arm64/include/asm/syscall.h | 4 ++-- arch/arm64/kernel/ptrace.c | 24 +++++++++++++++--------- arch/arm64/kernel/syscall.c | 5 +++-- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/arch/arm64/include/asm/syscall.h b/arch/arm64/include/asm/sysc= all.h index 712daa90e643..d69f590a989b 100644 --- a/arch/arm64/include/asm/syscall.h +++ b/arch/arm64/include/asm/syscall.h @@ -114,7 +114,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 5534c175ceb7..bbb868f6b292 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -2372,10 +2372,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(); - if (flags & (_TIF_SYSCALL_EMU | _TIF_SYSCALL_TRACE)) { report_syscall_enter(regs); if (flags & _TIF_SYSCALL_EMU) @@ -2386,19 +2384,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); + + if (test_thread_flag(TIF_SYSCALL_TRACEPOINT)) { + trace_sys_enter(regs, syscall); =20 - audit_syscall_entry(regs->syscallno, regs->orig_x0, regs->regs[1], + /* + * 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; } =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 aba7ca6bca2d..6e3fe760e0bb 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, regs->syscallno, 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 Tue Dec 2 02:52:23 2025 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 F1664330B03; Mon, 17 Nov 2025 13:31:18 +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=1763386281; cv=none; b=Dw8jart/+Utp5rGDxnfMWprMHJgtiF0rc13riZg+9mohbs8y68DG6fSuRG35ii+uayfztWylHwujhmXNrnnmgQ5MBApM1NJA/MkWnrhrfbbMuSgplva2aVvOvIVGFrvz6+zDhx85BDYkTaGMiz/ER8onDfRfXsUZWB4r2+MSuIk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763386281; c=relaxed/simple; bh=qO5ZtWRyU93oWfWwgMQEyXOEIf2nN2ddEqJMkkjnPGk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cosBU6EHIDgcvahCeoIIbH2rjERkB+1Exhh1FF4M8toNf4/6Z9oYEs4PvPJbo7DtsP1Bf1zTd5oacPa9DyqAJbk9lV6sGxqV0G4apNWvROF4AAN3u3g+6ungi6/7nciHu0xntrrM5/DN4STthhRot2A0Olhhb783vt/UDszdzos= 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=q6Peldem; 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="q6Peldem" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=j4B/gAP/ehXLgCgUT9gdurkhU0EpobJjRCtEvQb5TWI=; b=q6Peldem+vwkoD+lMi5B9Gj4HhqVKk1YxlBmQDtEu0vgWc+O3fc1W8rK1dO/IV+Pjr5iKT3CD uinNAdXLP6p3Gypam6dCXjtA+TiZmb5RcKowm6WEKGuMZuyhyPwk2L7LKDq3uZ6cqdzjOV7vvhm hXv60Skoy6tiIyydIpJDDc4= Received: from mail.maildlp.com (unknown [172.19.88.194]) by canpmsgout02.his.huawei.com (SkyGuard) with ESMTPS id 4d97r704KMzcbNS; Mon, 17 Nov 2025 21:29:11 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id E3E3D140132; Mon, 17 Nov 2025 21:31:09 +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, 17 Nov 2025 21:31:08 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: Subject: [PATCH v7 03/11] arm64/ptrace: Refator el0_svc_common() Date: Mon, 17 Nov 2025 21:30:40 +0800 Message-ID: <20251117133048.53182-4-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251117133048.53182-1-ruanjinjie@huawei.com> References: <20251117133048.53182-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: kwepems100002.china.huawei.com (7.221.188.206) To dggpemf500011.china.huawei.com (7.185.36.131) Content-Type: text/plain; charset="utf-8" Compared to the generic entry code, arm64 terminate the process after report_syscall_exit() if the syscall is issued within a restartable sequence. In preparation for moving arm64 over to the generic entry code, refactor el0_svc_common() as below: - Extract syscall_exit_to_user_mode_prepare() to replace the the combination of read_thread_flags() and syscall_trace_exit(), also move the syscall exit check logic into it. - Move rseq_syscall() ahead, so the CONFIG_DEBUG_RSEQ check is not needed. - Move has_syscall_work() helper into asm/syscall.h, which will be reused by ptrace.c. Signed-off-by: Jinjie Ruan --- arch/arm64/include/asm/syscall.h | 7 ++++++- arch/arm64/kernel/ptrace.c | 10 +++++++++- arch/arm64/kernel/syscall.c | 26 +++++--------------------- 3 files changed, 20 insertions(+), 23 deletions(-) diff --git a/arch/arm64/include/asm/syscall.h b/arch/arm64/include/asm/sysc= all.h index d69f590a989b..6225981fbbdb 100644 --- a/arch/arm64/include/asm/syscall.h +++ b/arch/arm64/include/asm/syscall.h @@ -114,7 +114,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_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 bbb868f6b292..95984bbf53db 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -2403,7 +2403,7 @@ int syscall_trace_enter(struct pt_regs *regs, long sy= scall, unsigned long flags) return regs->syscallno; } =20 -void syscall_trace_exit(struct pt_regs *regs, unsigned long flags) +static void syscall_trace_exit(struct pt_regs *regs, unsigned long flags) { audit_syscall_exit(regs); =20 @@ -2412,8 +2412,16 @@ void syscall_trace_exit(struct pt_regs *regs, unsign= ed long flags) =20 if (flags & (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP)) report_syscall_exit(regs); +} + +void syscall_exit_to_user_mode_prepare(struct pt_regs *regs) +{ + unsigned long flags =3D read_thread_flags(); =20 rseq_syscall(regs); + + if (has_syscall_work(flags) || flags & _TIF_SINGLESTEP) + syscall_trace_exit(regs, flags); } =20 /* diff --git a/arch/arm64/kernel/syscall.c b/arch/arm64/kernel/syscall.c index 6e3fe760e0bb..9713b038d750 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[]) { @@ -125,26 +120,15 @@ static void el0_svc_common(struct pt_regs *regs, int = scno, int sc_nr, if (scno =3D=3D NO_SYSCALL) syscall_set_return_value(current, regs, -ENOSYS, 0); scno =3D syscall_trace_enter(regs, regs->syscallno, flags); - if (scno =3D=3D NO_SYSCALL) - goto trace_exit; + if (scno =3D=3D NO_SYSCALL) { + syscall_exit_to_user_mode_prepare(regs); + return; + } } =20 invoke_syscall(regs, scno, sc_nr, syscall_table); =20 - /* - * 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_prepare(regs); } =20 void do_el0_svc(struct pt_regs *regs) --=20 2.34.1 From nobody Tue Dec 2 02:52:23 2025 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 41613333427; Mon, 17 Nov 2025 13:31:18 +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=1763386281; cv=none; b=OxIykw3gZCGWl5aYLuB51EUtHmx9SL6MBr8qupX/1tQQTR2OZnn36f8opKWUwrkcqLLd2kXlXANpKVCNAdrJprswokbl7ZKhr+bjR5J0lMQ8toOVH/sg6suMHexOzGkoWhkXZ6XYGk2oVOAFAay7RocY8GqZh8YZiSDExXvM8RE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763386281; c=relaxed/simple; bh=JIaz9zgfcVFK3ca6qDzFvUQP6GbZmkf7k9Apn3brebY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pkpdx/ccZw1CqJ4/YiOAWsCQA+kTbnq9G73dlvkS9LZmevVFeO+Nm0I1zSScKSULqRGvS4MazFzwDc4sib7UR5Ul1NaW+RJL3lMrbdct0w4hAEM4SB3hcwzV7yft/ZOOPHJrxSUO3pUrDlfjASclU/k+LI/KUzMMU1D9eCgBx1I= 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=pnc6gW7e; 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="pnc6gW7e" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=L7VSQzrso9GSPLc8m0QenwYICMxW9oDwCZBjF11X5ag=; b=pnc6gW7eV6qXsHPrMzzc+1zBhX5PMceiCd1YbXc0Ij2ZQKwwNIXX6586xpe/44NNKqp92FxRe KLkIjSlAFHiXQAuzR4SzdX+F2b9s0CUzEP6/zCxmA5DEnM932nDKCe0RkHYm/wDubEkBmrqMWzs zYM4yx+QIx44xM7UxHf54S8= Received: from mail.maildlp.com (unknown [172.19.163.174]) by canpmsgout03.his.huawei.com (SkyGuard) with ESMTPS id 4d97rH2l06zpSyw; Mon, 17 Nov 2025 21:29:19 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id 480FC140202; Mon, 17 Nov 2025 21:31:11 +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, 17 Nov 2025 21:31:09 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: Subject: [PATCH v7 04/11] entry: Add syscall_exit_to_user_mode_prepare() helper Date: Mon, 17 Nov 2025 21:30:41 +0800 Message-ID: <20251117133048.53182-5-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251117133048.53182-1-ruanjinjie@huawei.com> References: <20251117133048.53182-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: kwepems100002.china.huawei.com (7.221.188.206) To dggpemf500011.china.huawei.com (7.185.36.131) Content-Type: text/plain; charset="utf-8" In the generic entry code, the part before syscall_exit_to_user_mode_work() calls syscall_exit_work(), which serves the same purpose as syscall_exit_to_user_mode_prepare() in arm64. In preparation for moving arm64 over to the generic entry code, extract syscall_exit_to_user_mode_prepare() helper from syscall_exit_to_user_mode_work(). No functional changes. Signed-off-by: Jinjie Ruan Reviewed-by: Kevin Brodsky Reviewed-by: Thomas Gleixner --- 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 7177436f0f9e..cd6dacb2d8bf 100644 --- a/include/linux/entry-common.h +++ b/include/linux/entry-common.h @@ -137,20 +137,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_prepare(struct pt_re= gs *regs) { unsigned long work =3D READ_ONCE(current_thread_info()->syscall_work); unsigned long nr =3D syscall_get_nr(current, regs); @@ -171,6 +162,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_prepare(regs); local_irq_disable_exit_to_user(); exit_to_user_mode_prepare(regs); } --=20 2.34.1 From nobody Tue Dec 2 02:52:23 2025 Received: from canpmsgout09.his.huawei.com (canpmsgout09.his.huawei.com [113.46.200.224]) (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 D21D933373D; Mon, 17 Nov 2025 13:31:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.224 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763386283; cv=none; b=pqyLXS6kMges9CZsAfTBhIhniN34IvsH7nL+9IZOxB/lFGhUr0xXoXftQ6oH43SfqtWT4CbTO513D59WYqSUwjG2qt/DL1CRKHAwOQxLOCGAzot+JS0eNdfgpoJU9rnuCgBQyki2jnDsSMvwk8TrDjJ4TK25XslCQfqokn8CaVs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763386283; c=relaxed/simple; bh=vR4ujFeL/c/rSyeE+Ew/QgmViHAeCETlnfNIV7PYf2Y=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DdZjyoAE2gBJ3HpbvCiEQigGXm2vfBwWAbKF60VZltXzJdwutB8GDpZM/epnomI/YLivNTstQncZPJz67vnzrF7cCmIjAF8ylwqHUC+hPLpxbQn2ggGM270lrEPUaXvXlICx1ywbIRAb0P/ILuXG06EvmO2cUbdOu9rZmepHHAs= 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=XCdll9/W; arc=none smtp.client-ip=113.46.200.224 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="XCdll9/W" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=kQJChy4CSig7WwWYt7pGFEdPu8K8NX2y5MQxbd1imwo=; b=XCdll9/WfiN+9U5PmTpPKoAREVR7KqYPR4vpBiFW1qdQOrehyTN+qOdp6g4vWfpvcmKX4Ek1o ZaxJoqJiZOKKoW/7JzAhVQ/sWCNiZDkXuW++bpMiXhOo2Nrn6NWbHi9iKn+3lhHdK12FtfG96OU FbilBiHRQZ6cuST6Q8DJ/bk= Received: from mail.maildlp.com (unknown [172.19.163.17]) by canpmsgout09.his.huawei.com (SkyGuard) with ESMTPS id 4d97rT4yJXz1cyqF; Mon, 17 Nov 2025 21:29:29 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id AB31B1A0188; Mon, 17 Nov 2025 21:31:12 +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, 17 Nov 2025 21:31:11 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: Subject: [PATCH v7 05/11] arm64/ptrace: Handle ptrace_report_syscall_entry() error Date: Mon, 17 Nov 2025 21:30:42 +0800 Message-ID: <20251117133048.53182-6-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251117133048.53182-1-ruanjinjie@huawei.com> References: <20251117133048.53182-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: kwepems100002.china.huawei.com (7.221.188.206) To dggpemf500011.china.huawei.com (7.185.36.131) Content-Type: text/plain; charset="utf-8" The generic entry handle error of ptrace_report_syscall_entry(), but arm64 not. As the comment said, the calling arch code should abort the system call and must prevent normal entry so no system call is made if ptrace_report_syscall_entry() return nonzero. In preparation for moving arm64 over to the generic entry code, return early if ptrace_report_syscall_entry() encounters an error. Signed-off-by: Jinjie Ruan --- arch/arm64/kernel/ptrace.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index 95984bbf53db..707951ad5d24 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -2317,10 +2317,10 @@ enum ptrace_syscall_dir { PTRACE_SYSCALL_EXIT, }; =20 -static void report_syscall_enter(struct pt_regs *regs) +static int report_syscall_enter(struct pt_regs *regs) { - int regno; unsigned long saved_reg; + int regno, ret; =20 /* * We have some ABI weirdness here in the way that we handle syscall @@ -2342,9 +2342,13 @@ static void report_syscall_enter(struct pt_regs *reg= s) saved_reg =3D regs->regs[regno]; regs->regs[regno] =3D PTRACE_SYSCALL_ENTER; =20 - 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) @@ -2374,9 +2378,11 @@ static void report_syscall_exit(struct pt_regs *regs) =20 int syscall_trace_enter(struct pt_regs *regs, long syscall, unsigned long = flags) { + int ret; + if (flags & (_TIF_SYSCALL_EMU | _TIF_SYSCALL_TRACE)) { - report_syscall_enter(regs); - if (flags & _TIF_SYSCALL_EMU) + ret =3D report_syscall_enter(regs); + if (ret || (flags & _TIF_SYSCALL_EMU)) return NO_SYSCALL; } =20 --=20 2.34.1 From nobody Tue Dec 2 02:52:23 2025 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 10F77334C10; Mon, 17 Nov 2025 13:31:22 +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=1763386285; cv=none; b=pVJ1dzYCS44MGvW78b3pNHTLpB4GJ2DoL1iiU47RM2/nh8f6qt1ZL7w+Bq0sZ7C3RZjvlPONHK4SS8oik0hAiQ23oVj1XDBcM4CCPT5ifSD9vONJBY8VBNolsYhlqIEFpRlV93cUVHjp99o71L3d7DbcyaDY8e/tK5diHU6rrKE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763386285; c=relaxed/simple; bh=eJuBDNGuRK1zWani3rxt9NUaoN3lvcp+TJtZRlKVcI0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LziJgxC3zE4m6p32UBi56bRD1vgZjtUuIMtJF2WLB8PqiC+lgLwMu5rfl+2s1ND1s0XdNNt7r3NuNLV9PGyfuEGc//WAfUcRzEIGAuvpx7th9BjPh6p11BnxTJTYCinPNr07Rw4IZktxSIw07BQESZD9e/F+kwFovxTK5/URkFw= 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=Z1uA/unQ; 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="Z1uA/unQ" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=30ysq1zKlbnYeZwp+m2gLXTGDwEJmQJK7zrgP/PsCwA=; b=Z1uA/unQOJAeHJXfkKp+yStnZd4muxK8p5GFf9i9u82AOLbVoFgwUMcFfC6D4XNNnKqj1scJ8 nECxV8SYy1tpy6yxSOp+UOdVnvo1wjm2wdToy8ivrQtR09iAQqYiGzIdYUFSICykJUnQM/3Ya0M qsAV5G8NPZQUBPDBZwNEUAE= Received: from mail.maildlp.com (unknown [172.19.88.194]) by canpmsgout04.his.huawei.com (SkyGuard) with ESMTPS id 4d97rV55prz1prKL; Mon, 17 Nov 2025 21:29:30 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id 148EB140132; Mon, 17 Nov 2025 21:31: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, 17 Nov 2025 21:31:12 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: Subject: [PATCH v7 06/11] arm64/ptrace: Expand secure_computing() in place Date: Mon, 17 Nov 2025 21:30:43 +0800 Message-ID: <20251117133048.53182-7-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251117133048.53182-1-ruanjinjie@huawei.com> References: <20251117133048.53182-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: kwepems100002.china.huawei.com (7.221.188.206) 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. Signed-off-by: Jinjie Ruan --- arch/arm64/kernel/ptrace.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index 707951ad5d24..9af3046a2ce9 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -2387,8 +2387,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(NULL); + if (ret =3D=3D -1L) + return NO_SYSCALL; + } =20 /* Either of the above might have changed the syscall number */ syscall =3D syscall_get_nr(current, regs); --=20 2.34.1 From nobody Tue Dec 2 02:52:23 2025 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 BD18A332ED9; Mon, 17 Nov 2025 13:31:18 +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=1763386282; cv=none; b=q16aYfXdd0nWtnouAEiFKPz+ViOgYQUvbVOA2DlYTPFY0egzWyvNPpDdfnFMFswxLJOmquG7/RSw8mhwCadQpZqFEQd8v7k1JMAtTgKmAQvQ4Wdg4AFUrx7mjkhZU2Wtp3UQQEGwp2ayPXUlb40kLjwPYvWfTg9wK4vtWgFw+Uk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763386282; c=relaxed/simple; bh=pIgmyIPdr04iwBMGzgc1Eze631etDhQUWA5uqPUAIZY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ol8aFSdWd4GaPC4tXgRuGNy+4KQC3kFRkq+CbuFBU4CDRx2PSnWqenQemRu+wOZ0OJQBvBjs1Zat/EmGNcNgRNzkHeCtX+vDxwth4FPSfXN70B9uLC2o+JMlnQYyZusiwo28L5jpj3Lm26FO/POznpuhjQTEs3ZZB/XZrDjp8Mg= 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=3EKFsV5C; 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="3EKFsV5C" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=O3MpI9LxI/OlMZoqxaz/4H0SoLaP3c9QUvB4fy5mP1A=; b=3EKFsV5Cza6woM5b+7/9KO21oWD3ebNmUQfUorFXJgBFOnJc+TeLzpC4gPEMpecW3kzaJp50X Rc8t5B8D3kKY6RfYFkm7QXfN4EWH3Q+oW4ZgAEeoKjuE8XJ58PY6qs27Q9rLjAKjnfH0SZAz6uS uRhmZNwBbM9cmJcAT0ISzF0= Received: from mail.maildlp.com (unknown [172.19.163.44]) by canpmsgout10.his.huawei.com (SkyGuard) with ESMTPS id 4d97rZ3Tc0z1K9Bq; Mon, 17 Nov 2025 21:29:34 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id 7929814010D; Mon, 17 Nov 2025 21:31:15 +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, 17 Nov 2025 21:31:14 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: Subject: [PATCH v7 07/11] arm64/ptrace: Use syscall_get_arguments() heleper Date: Mon, 17 Nov 2025 21:30:44 +0800 Message-ID: <20251117133048.53182-8-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251117133048.53182-1-ruanjinjie@huawei.com> References: <20251117133048.53182-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: kwepems100002.china.huawei.com (7.221.188.206) 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 the helper. - Extract the syscall_enter_audit() helper to make it clear. - Check audit context for syscall_enter_audit(), which only adds one additional check without any other differences as audit_syscall_entry() check it first otherwise do nothing. No functional changes. Signed-off-by: Jinjie Ruan --- arch/arm64/kernel/ptrace.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index 9af3046a2ce9..9455ccf1ecc1 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -2376,6 +2376,17 @@ 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; @@ -2406,8 +2417,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 regs->syscallno; } --=20 2.34.1 From nobody Tue Dec 2 02:52:23 2025 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 01437333424; Mon, 17 Nov 2025 13:31:18 +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=1763386281; cv=none; b=RYJW7Mbf0ahxIg4ni09DYpOMoqmMAtVLaWEPGancUqU03ifMWidNivO2wurbeLQ7T1+4eBzcywmd1nptGmGf6+XdtB4R4Uzz55bT/bJQ0QeAymk0xfTaq2dlFXdUY1qQlGX0ylxZXO4ckog1fv7uk+mEuJDqtQDgt8vyEnOmNt8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763386281; c=relaxed/simple; bh=EF2iXe3ciK3258zQTRLplMfgEvw0qWOVl2x4DdApvlY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GG5/aniSsRFAcGakir3kjk2y9eCS4P0lZpIhtZaLvLqxmdlV2sV8HgYtjyzDXWSo8VmQ/PJQXvvFvyM9ciJzf+JPjfeaAwRcrWPsYNVTY9ttxWdau1GietjEs+Yc9DumQfP8wB6CXRUd+SAz0C3drUcVC/U/lyzFEgtUDicalfM= 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=KmCsfjIb; 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="KmCsfjIb" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=1MqVMJTTo6T38F+TamEic2utqXgvdR5R1B5+ka+htpM=; b=KmCsfjIbe5OZG8mPkBkAf7aSmDbVJXEEuudK77nDVckGswYjWj2Kq03qz9Lmhv7uWsTCPZfSs pBncWxfGQ9qpVsUABLLe2BQSMApCF8lJe9OAvWm0zeJwLVIkQqm1r8nwu4kTilkBPHEB5mm62bS VipywHoR2ah4t+hf3LglecA= Received: from mail.maildlp.com (unknown [172.19.88.214]) by canpmsgout10.his.huawei.com (SkyGuard) with ESMTPS id 4d97rb6B0Dz1K9Bq; Mon, 17 Nov 2025 21:29:35 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id D815E1A016C; Mon, 17 Nov 2025 21:31: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, 17 Nov 2025 21:31:15 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: Subject: [PATCH v7 08/11] entry: Add arch_ptrace_report_syscall_entry/exit() Date: Mon, 17 Nov 2025 21:30:45 +0800 Message-ID: <20251117133048.53182-9-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251117133048.53182-1-ruanjinjie@huawei.com> References: <20251117133048.53182-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: kwepems100002.china.huawei.com (7.221.188.206) 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. Suggested-by: Mark Rutland Suggested-by: Kevin Brodsky Suggested-by: Thomas Gleixner Signed-off-by: Jinjie Ruan --- kernel/entry/syscall-common.c | 43 +++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/kernel/entry/syscall-common.c b/kernel/entry/syscall-common.c index 66e6ba7fa80c..27310e611567 100644 --- a/kernel/entry/syscall-common.c +++ b/kernel/entry/syscall-common.c @@ -17,6 +17,25 @@ static inline void syscall_enter_audit(struct pt_regs *r= egs, long syscall) } } =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) { @@ -34,7 +53,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; } @@ -84,6 +103,26 @@ static inline bool report_single_step(unsigned long wor= k) return work & SYSCALL_WORK_SYSCALL_EXIT_TRAP; } =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 + void syscall_exit_work(struct pt_regs *regs, unsigned long work) { bool step; @@ -108,5 +147,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 Tue Dec 2 02:52:23 2025 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 34FDE333755; Mon, 17 Nov 2025 13:31:20 +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=1763386282; cv=none; b=fsVqNcaZjnqktrXF8ErOTk8KFPibKSroEJkHzKz9yBzunSTbhWfw37ny5Tcqm96OaCV//KtQB0+yr3i/q5g1mDqclCTJ1+KxQ5dlZoXRPdrEu83jfF8oTEZV0bSIGBiTlGdHo4KGl2kErXMRqHmZRWnGHVo83gQ3B+e9U7DMr+g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763386282; c=relaxed/simple; bh=Ju/mymHs/AiYsKpoIWu/nrpZTM9/XFNzstz5vCKBKhk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RCTl85bugrjqjaAnWWH2T0viPkTuEGJBU0LI74MXjRk3FlGPp/7CAVopoKsBspbRsvkhPoy16fA7jzMfhfaxMGFiEpCOQBdxsNp9BzP9vWKudK8Cx3XF4jlUPDRJm/D/fHmcK+TajYtsJyRZ/PKpWjTGiRmoIlLHbMlVhYLqhPs= 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=l4fE+B9Z; 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="l4fE+B9Z" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=dLrfgy8TOLZhKOg9TpR8Wk1N6DHgABzMsigfkHUhMuM=; b=l4fE+B9ZcmKRodkU19wgUeoEYbjgTYiJpAhW1gBJsI9B/Gynd68hmIhfHa7TxofVBEQomoGl0 0PcO+Wqg2f+Vr6G6/uZ2ZiO4UEwEofN8BNdj0lw66KGA6FMeebwcgT0+5ihTjN0L/txrb2caviJ N38zBiqZXgCt9kfZz4dPkvE= Received: from mail.maildlp.com (unknown [172.19.88.105]) by canpmsgout03.his.huawei.com (SkyGuard) with ESMTPS id 4d97rQ2ZghzpTKW; Mon, 17 Nov 2025 21:29:26 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id 42291140277; Mon, 17 Nov 2025 21:31:18 +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, 17 Nov 2025 21:31:16 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: Subject: [PATCH v7 09/11] entry: Add has_syscall_work() helper Date: Mon, 17 Nov 2025 21:30:46 +0800 Message-ID: <20251117133048.53182-10-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251117133048.53182-1-ruanjinjie@huawei.com> References: <20251117133048.53182-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: kwepems100002.china.huawei.com (7.221.188.206) To dggpemf500011.china.huawei.com (7.185.36.131) Content-Type: text/plain; charset="utf-8" Add has_syscall_work() helper to facilitate reuse of this function in other places. No functional changes. Signed-off-by: Jinjie Ruan --- include/linux/entry-common.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/linux/entry-common.h b/include/linux/entry-common.h index cd6dacb2d8bf..e0f94e937e84 100644 --- a/include/linux/entry-common.h +++ b/include/linux/entry-common.h @@ -44,6 +44,11 @@ SYSCALL_WORK_SYSCALL_EXIT_TRAP | \ ARCH_SYSCALL_WORK_EXIT) =20 +static inline bool has_syscall_work(unsigned long work) +{ + return unlikely(work & SYSCALL_WORK_ENTER); +} + /** * syscall_enter_from_user_mode_prepare - Establish state and enable inter= rupts * @regs: Pointer to currents pt_regs @@ -91,7 +96,7 @@ static __always_inline long syscall_enter_from_user_mode_= work(struct pt_regs *re { unsigned long work =3D READ_ONCE(current_thread_info()->syscall_work); =20 - if (work & SYSCALL_WORK_ENTER) + if (has_syscall_work(work)) syscall =3D syscall_trace_enter(regs, syscall, work); =20 return syscall; --=20 2.34.1 From nobody Tue Dec 2 02:52:23 2025 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 A779C3346BA; Mon, 17 Nov 2025 13:31:22 +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=1763386285; cv=none; b=LL5PfzUY7qQWkDRn0qS2QRof2B5vkjIH4GpWL2Ama71qgl6NSJXrwGtF28AYh+Io7YvyOXRXCIzny9ZxWA9uJKB9YPiPaGgWYKphfluyDgH7ocjqnKtpTXDW8Ufx95o634CgCXrKpA6Wq42o770qH3KSo4GDhl1nIfQV85g3WFk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763386285; c=relaxed/simple; bh=wOSzUID5qwfY2zEeZPGRxBzi5ANl0fZMn5d6fQy743o=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WpUQAzAGdWEDvVyy8leyR8WrhXIQwbIgcJ+msJ6Cl32OQlRV5iF9sOtkTJlwDuF2x+5KXHzuLI6zE1vQ9T3XPIAHgytAEfn+g9xNE4Fcoi8xUwA3DsjqRno6+Rrm4oWsE297pqUuiQpugE9Qs1xY5QaQRWGiAmkhQPc6J+07hb4= 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=h8V4KGco; 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="h8V4KGco" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=ZzvLZs9DS16FcBd66jmcnc3n/TDW7tqCG0DiOdquUbU=; b=h8V4KGcoB7xkeiWLSYXnkNRx2BpcNqjuzDRIBsGvQmi6Q9ZpWLMZI9bPFh/Wv/eVbapWDagXW IXgt4XD9/CgslUDYhspZ48071WG24PgYWmRrao+vYFqDK859CkwkeCn8pMQCBjiESgnW+wo2zFD VOycsXVSBCW6dQUWwnWtN+Y= Received: from mail.maildlp.com (unknown [172.19.162.112]) by canpmsgout10.his.huawei.com (SkyGuard) with ESMTPS id 4d97rf4ycgz1K9Bx; Mon, 17 Nov 2025 21:29:38 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id ABDBF140276; Mon, 17 Nov 2025 21:31: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, 17 Nov 2025 21:31:18 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: Subject: [PATCH v7 10/11] arm64: entry: Convert to generic entry Date: Mon, 17 Nov 2025 21:30:47 +0800 Message-ID: <20251117133048.53182-11-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251117133048.53182-1-ruanjinjie@huawei.com> References: <20251117133048.53182-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: kwepems100002.china.huawei.com (7.221.188.206) 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, _TIF_WORK_MASK, _TIF_SYSCALL_WORK. - Implement arch_ptrace_report_syscall_entry/exit() with report_syscall_enter/exit() to do arm64-specific save/restore during syscall entry/exit. - Remove arm64 syscall_trace_enter(), syscall_exit_to_user_mode_prepare(), and related sub-functions including syscall_trace_exit() and syscall_enter_audit(), by calling generic entry's functions with similar functionality. - Implement arch_syscall_is_vdso_sigreturn() to support "Syscall User Dispatch". Suggested-by: Mark Rutland Signed-off-by: Jinjie Ruan --- arch/arm64/Kconfig | 2 +- arch/arm64/include/asm/entry-common.h | 69 +++++++++++++ arch/arm64/include/asm/syscall.h | 30 +++++- arch/arm64/include/asm/thread_info.h | 22 +---- arch/arm64/kernel/debug-monitors.c | 7 ++ arch/arm64/kernel/ptrace.c | 134 -------------------------- arch/arm64/kernel/signal.c | 2 +- arch/arm64/kernel/syscall.c | 6 +- 8 files changed, 108 insertions(+), 164 deletions(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 6663ffd23f25..1463ff15d67a 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -152,9 +152,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..ee4dda1b01a2 100644 --- a/arch/arm64/include/asm/entry-common.h +++ b/arch/arm64/include/asm/entry-common.h @@ -11,6 +11,11 @@ #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 +59,68 @@ 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 int arch_ptrace_report_syscall_entry(struct pt_regs= *regs) +{ + unsigned long saved_reg; + int regno, ret; + + /* + * 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 PTRACE_SYSCALL_ENTER; + + 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; + + /* See comment for arch_ptrace_report_syscall_entry() */ + regno =3D (is_compat_task() ? 12 : 7); + saved_reg =3D regs->regs[regno]; + regs->regs[regno] =3D PTRACE_SYSCALL_EXIT; + + 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 6225981fbbdb..c91938718468 100644 --- a/arch/arm64/include/asm/syscall.h +++ b/arch/arm64/include/asm/syscall.h @@ -9,6 +9,8 @@ #include #include =20 +#include + typedef long (*syscall_fn_t)(const struct pt_regs *regs); =20 extern const syscall_fn_t sys_call_table[]; @@ -114,12 +116,30 @@ static inline int syscall_get_arch(struct task_struct= *task) return AUDIT_ARCH_AARCH64; } =20 -static inline bool has_syscall_work(unsigned long flags) +static inline bool arch_syscall_is_vdso_sigreturn(struct pt_regs *regs) { - return unlikely(flags & _TIF_SYSCALL_WORK); -} + unsigned long vdso =3D (unsigned long)current->mm->context.vdso; + unsigned long vdso_pages, vdso_text_len; + unsigned long pc =3D regs->pc - 4; =20 -int syscall_trace_enter(struct pt_regs *regs, long syscall, unsigned long = flags); -void syscall_exit_to_user_mode_prepare(struct pt_regs *regs); +#ifdef CONFIG_COMPAT + if (is_compat_task()) { + vdso =3D (unsigned long)current->mm->context.sigpage; + if (pc >=3D vdso && pc < vdso + PAGE_SIZE) + return true; + + return false; + } +#endif + if (regs->syscallno !=3D __NR_rt_sigreturn) + return false; + + vdso_pages =3D (vdso_end - vdso_start) >> PAGE_SHIFT; + vdso_text_len =3D vdso_pages << PAGE_SHIFT; + if (pc < vdso || pc >=3D vdso + vdso_text_len) + return false; + + return true; +} =20 #endif /* __ASM_SYSCALL_H */ diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/= thread_info.h index f241b8601ebd..0c083be23018 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,30 +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_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) - #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 9455ccf1ecc1..9e3b39e207d1 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -42,9 +42,6 @@ #include #include =20 -#define CREATE_TRACE_POINTS -#include - struct pt_regs_offset { const char *name; int offset; @@ -2312,137 +2309,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 int report_syscall_enter(struct pt_regs *regs) -{ - unsigned long saved_reg; - int regno, ret; - - /* - * 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 PTRACE_SYSCALL_ENTER; - - 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) -{ - int regno; - unsigned long saved_reg; - - /* See comment for report_syscall_enter() above */ - regno =3D (is_compat_task() ? 12 : 7); - saved_reg =3D regs->regs[regno]; - regs->regs[regno] =3D PTRACE_SYSCALL_EXIT; - - 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_enter(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(NULL); - if (ret =3D=3D -1L) - 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 regs->syscallno; -} - -static void syscall_trace_exit(struct pt_regs *regs, unsigned long flags) -{ - audit_syscall_exit(regs); - - if (flags & _TIF_SYSCALL_TRACEPOINT) - trace_sys_exit(regs, syscall_get_return_value(current, regs)); - - if (flags & (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP)) - report_syscall_exit(regs); -} - -void syscall_exit_to_user_mode_prepare(struct pt_regs *regs) -{ - unsigned long flags =3D read_thread_flags(); - - rseq_syscall(regs); - - if (has_syscall_work(flags) || flags & _TIF_SINGLESTEP) - syscall_trace_exit(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 9713b038d750..61e24eba9a86 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 (has_syscall_work(flags)) { + if (has_syscall_work(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 @@ -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, regs->syscallno, flags); + scno =3D syscall_trace_enter(regs, regs->syscallno, work); if (scno =3D=3D NO_SYSCALL) { syscall_exit_to_user_mode_prepare(regs); return; --=20 2.34.1 From nobody Tue Dec 2 02:52:23 2025 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 810F93328EC; Mon, 17 Nov 2025 13:31:23 +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=1763386285; cv=none; b=sDkae78wFZhLAWrqqPOxPZLB3RxhIr5blIlNNGfDxe+cZoXXgcQ0TNGcHpwE4BhYJivo97+E26TkJUtdATcZo/+Kc5mUValRaPJZYqg6jkti/mFjbVo1gDQsh9LraoWrv8K3jPHffEw6rtv81fsdfEtkBi4xbYgw34kMSuuxZb8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763386285; c=relaxed/simple; bh=e2EqaLHY+hi8mOpTTTohUlXK6N1GgMucbwUdNtAo4mQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IFsz26mNkc1vTjh2j1hYgIJ5NLVCXGMnioQJQ9pHh1q/AiR+hmF5tNoBEJ0tOtVGrRsdM5+MyjvJZ1HUc72s3pz43M+fx0PdjyfRF69NkCh2l7LgNxVdc/PLNBKaAQt9s/eSKM72W2FJOB0HXKw5kx/2Rpzd7L2J0syp7rybzYI= 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=S7xkFUo5; 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="S7xkFUo5" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=g+Lx46iAeOgPpubr+gkS3rp+7tkakNKdnP1SW8F/O7E=; b=S7xkFUo5md6dhTG0nsu8qRM2GgJ9v6v89JBKj8/wzVd31elaHwd1fP2zVW/A3+qqgBnQ+4A7z wQSKuQnOtm3YmNhaO5bKVUSjbLwTiKvCKE8XvNbByBo36USluVhNnhXIY0Y4Mhox+LsCBXRGBki kDx0a9NwJN4XiI12mMBbuSU= Received: from mail.maildlp.com (unknown [172.19.163.48]) by canpmsgout03.his.huawei.com (SkyGuard) with ESMTPS id 4d97rT0vnSzpSyw; Mon, 17 Nov 2025 21:29:29 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id 0F9F7180477; Mon, 17 Nov 2025 21:31: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, 17 Nov 2025 21:31:19 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: Subject: [PATCH v7 11/11] selftests: sud_test: Support aarch64 Date: Mon, 17 Nov 2025 21:30:48 +0800 Message-ID: <20251117133048.53182-12-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251117133048.53182-1-ruanjinjie@huawei.com> References: <20251117133048.53182-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: kwepems100002.china.huawei.com (7.221.188.206) 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_test.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/testing/selftests/syscall_user_dispatch/sud_test.c b/too= ls/testing/selftests/syscall_user_dispatch/sud_test.c index 2eb2c06303f2..f53ebc89befc 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