Re: [PATCH v3 2/6] syscall.h: add syscall_set_arguments() and syscall_set_return_value()

"Dmitry V. Levin" <[email protected]>
Newsgroups gmane.linux.uml.devel,gmane.linux.kernel.arc,gmane.linux.kernel,gmane.linux.ports.sparc,gmane.linux.ports.hexagon,gmane.linux.ports.sh.devel,gmane.comp.sysutils.strace.devel,gmane.linux.kernel.cross-arch,gmane.linux.ports.arm.kernel,gmane.linux.ports.parisc,gmane.linux.ports.mips,gmane.linux.ports.ppc64.devel,gmane.linux.ports.riscv
Message-ID <[email protected]>
On Thu, Jan 30, 2025 at 09:33:03AM +0100, Sven Schnelle wrote:
> "Dmitry V. Levin" <[email protected]> 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 <[email protected]>
> > Tested-by: Charlie Jenkins <[email protected]>
> > Reviewed-by: Charlie Jenkins <[email protected]>
> > ---
> >  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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.