From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from vmicros1.altlinux.org (vmicros1.altlinux.org [194.107.17.57]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2C7301A7046; Thu, 30 Jan 2025 11:22:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.107.17.57 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738236138; cv=none; b=f8A/GY7YpDB9uvdOgPQyj9O6X3C85aHtx9/LJ/tPbkvuWkE07FJVZ4jbjV9KomO4gSNGeW6XCX1bdxMjmJU4Hffa5eY+dt2tOfhS0zCTr8mWjunm1sUGh75TLyYHq/NgMW99Ip3V3Wln52TlmR5MA58Amcnu9qcii9vtr8KGPC4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738236138; c=relaxed/simple; bh=MghFTWMvhJ+aN7aFXsfim1mSQbCrS8tySxPnq4M2kjM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=RH296WwIxTpxaq2ZXqI58hPWdhLFwSIXuhVTSqpnlXuO+n97xZKm/kN4PJWmnG6MMLA6agUxGzuuX4SReAzNyFDJsOgu8rvAnPfZlVVnPovc7dG0rdGbUV4jZ9ulEu0jE/e/vHNeBAe7uIerZ+WEHDqAN2nYfLjILMq55QeD1JE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=strace.io; spf=pass smtp.mailfrom=altlinux.org; arc=none smtp.client-ip=194.107.17.57 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=strace.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=altlinux.org Received: from mua.local.altlinux.org (mua.local.altlinux.org [192.168.1.14]) by vmicros1.altlinux.org (Postfix) with ESMTP id 2997B72C97E; Thu, 30 Jan 2025 14:22:08 +0300 (MSK) Received: by mua.local.altlinux.org (Postfix, from userid 508) id F28277CCB3A; Thu, 30 Jan 2025 13:22:07 +0200 (IST) Date: Thu, 30 Jan 2025 13:22:07 +0200 From: "Dmitry V. Levin" To: Sven Schnelle Cc: linux-snps-arc@lists.infradead.org, Rich Felker , Thomas Gleixner , Andreas Larsson , John Paul Adrian Glaubitz , x86@kernel.org, Arnd Bergmann , linux-kernel@vger.kernel.org, "James E.J. Bottomley" , Guo Ren , linux-csky@vger.kernel.org, "H. Peter Anvin" , sparclinux@vger.kernel.org, linux-hexagon@vger.kernel.org, WANG Xuerui , Will Deacon , Eugene Syromyatnikov , Anton Ivanov , Jonas Bonn , linux-s390@vger.kernel.org, Alexander Gordeev , Madhavan Srinivasan , Vasily Gorbik , Yoshinori Sato , linux-sh@vger.kernel.org, Michael Ellerman , Helge Deller , Huacai Chen , Russell King , Christophe Leroy , Dave Hansen , Ingo Molnar , Vineet Gupta , Christian Borntraeger , strace-devel@lists.strace.io, linux-arch@vger.kernel.org, Albert Ou , Mike Frysinger , Davide Berardi , Renzo Davoli , linux-um@lists.infradead.org, Heiko Carstens , Charlie Jenkins , Naveen N Rao , Nicholas Piggin , Stefan Kristiansson , Borislav Petkov , loongarch@lists.linux.dev, Paul Walmsley , Stafford Horne , linux-arm-kernel@lists.infradead.org, Brian Cain , Thomas Bogendoerfer , linux-parisc@vger.kernel.org, linux-openrisc@vger.kernel.org, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Oleg Nesterov , Dinh Nguyen , linux-riscv@lists.infradead.org, Palmer Dabbelt , Richard Weinberger , Johannes Berg , Alexey Gladkov , "David S. Miller" Subject: Re: [PATCH v3 2/6] syscall.h: add syscall_set_arguments() and syscall_set_return_value() Message-ID: <20250130112207.GA6617@strace.io> References: <20250128091626.GB8601@strace.io> 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=us-ascii Content-Disposition: inline In-Reply-To: On Thu, Jan 30, 2025 at 09:33:03AM +0100, Sven Schnelle wrote: > "Dmitry V. Levin" writes: > > > These functions are going to be needed on all HAVE_ARCH_TRACEHOOK > > architectures to implement PTRACE_SET_SYSCALL_INFO API. > > > > This partially reverts commit 7962c2eddbfe ("arch: remove unused > > function syscall_set_arguments()") by reusing some of old > > syscall_set_arguments() implementations. > > > > Signed-off-by: Dmitry V. Levin > > Tested-by: Charlie Jenkins > > Reviewed-by: Charlie Jenkins > > --- > > arch/arc/include/asm/syscall.h | 14 +++++++++++ > > arch/arm/include/asm/syscall.h | 13 ++++++++++ > > arch/arm64/include/asm/syscall.h | 13 ++++++++++ > > arch/csky/include/asm/syscall.h | 13 ++++++++++ > > arch/hexagon/include/asm/syscall.h | 14 +++++++++++ > > arch/loongarch/include/asm/syscall.h | 8 ++++++ > > arch/mips/include/asm/syscall.h | 32 ++++++++++++++++++++++++ > > arch/nios2/include/asm/syscall.h | 11 ++++++++ > > arch/openrisc/include/asm/syscall.h | 7 ++++++ > > arch/parisc/include/asm/syscall.h | 12 +++++++++ > > arch/powerpc/include/asm/syscall.h | 10 ++++++++ > > arch/riscv/include/asm/syscall.h | 9 +++++++ > > arch/s390/include/asm/syscall.h | 12 +++++++++ > > arch/sh/include/asm/syscall_32.h | 12 +++++++++ > > arch/sparc/include/asm/syscall.h | 10 ++++++++ > > arch/um/include/asm/syscall-generic.h | 14 +++++++++++ > > arch/x86/include/asm/syscall.h | 36 +++++++++++++++++++++++++++ > > arch/xtensa/include/asm/syscall.h | 11 ++++++++ > > include/asm-generic/syscall.h | 16 ++++++++++++ > > 19 files changed, 267 insertions(+) > > > > diff --git a/arch/s390/include/asm/syscall.h b/arch/s390/include/asm/syscall.h > > index 27e3d804b311..b3dd883699e7 100644 > > --- a/arch/s390/include/asm/syscall.h > > +++ b/arch/s390/include/asm/syscall.h > > @@ -78,6 +78,18 @@ static inline void syscall_get_arguments(struct task_struct *task, > > args[0] = regs->orig_gpr2 & mask; > > } > > > > +static inline void syscall_set_arguments(struct task_struct *task, > > + struct pt_regs *regs, > > + const unsigned long *args) > > +{ > > + unsigned int n = 6; > > + > > + while (n-- > 0) > > + if (n > 0) > > + regs->gprs[2 + n] = args[n]; > > + regs->orig_gpr2 = args[0]; > > +} > > Could that be changed to something like: > > for (int n = 1; n < 6; n++) > regs->gprs[2 + n] = args[n]; > regs->orig_gpr2 = args[0]; > > I think this is way easier to parse. I don't mind changing syscall_set_arguments() this way, but it just mirrors syscall_get_arguments(), so I think it would be better if these two functions were written in the same style. Would you like to change syscall_get_arguments() as well? -- ldv