From nobody Thu Oct 2 15:33:00 2025 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (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 3D7662EE272 for ; Tue, 16 Sep 2025 08:25:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758011142; cv=none; b=hkLNiNS949urR27cgmFmD1fPYiughneIVKSiY48Azurn4pJkLVhZTqNs+isoplKjUT56lguU1n3yxEwCqVcOQyc8F+mGq3HC+OOd2PL2DcsAYOaB1ZsuVevdqPziy2C2HJS9fzyY9amo4uKZFPLJAVS7ysfpwSCOO9bQuYnZq3I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758011142; c=relaxed/simple; bh=VdHvdR9xYKjIdNBbC8/KNtwOCuoWMLN2B+4bji7I5b4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OfpyudGwKjVDv8oGkvM3H3ec8sG7surZTc69XtoQbS3cTLBqCmSBuZV62Z3n94MentMQbyz1iGenxg07BOGabLRzvYHgBlSdslhPDFXY9n+ZkVCG79Ajuv9BzhHojXsjNYcHVBp4VELtAKZ75BzjNPnsoaNb/OTMXdM/vEeplps= 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; arc=none smtp.client-ip=45.249.212.188 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 Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4cQw1Q0WcDztTX0; Tue, 16 Sep 2025 16:24:42 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id 3714B180B68; Tue, 16 Sep 2025 16:25: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; Tue, 16 Sep 2025 16:25:35 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , CC: Subject: [PATCH -next v6 01/10] arm64/ptrace: Split report_syscall() into report_syscall_enter/exit() Date: Tue, 16 Sep 2025 16:26:02 +0800 Message-ID: <20250916082611.2972008-2-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250916082611.2972008-1-ruanjinjie@huawei.com> References: <20250916082611.2972008-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: kwepems200001.china.huawei.com (7.221.188.67) 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