linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexey Gladkov <legion@kernel.org>
To: "Dmitry V. Levin" <ldv@strace.io>
Cc: Oleg Nesterov <oleg@redhat.com>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Eugene Syromyatnikov <evgsyr@gmail.com>,
	Mike Frysinger <vapier@gentoo.org>,
	Renzo Davoli <renzo@cs.unibo.it>,
	Davide Berardi <berardi.dav@gmail.com>,
	strace-devel@lists.strace.io,
	Madhavan Srinivasan <maddy@linux.ibm.com>,
	Nicholas Piggin <npiggin@gmail.com>,
	Christophe Leroy <christophe.leroy@csgroup.eu>,
	Naveen N Rao <naveen@kernel.org>,
	linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/7] powerpc: properly negate error in syscall_set_return_value()
Date: Tue, 14 Jan 2025 15:53:20 +0100	[thread overview]
Message-ID: <Z4Z6YJOsCl69_41-@example.org> (raw)
In-Reply-To: <20250114134844.GA10630@strace.io>

On Tue, Jan 14, 2025 at 03:48:44PM +0200, Dmitry V. Levin wrote:
> On Tue, Jan 14, 2025 at 02:00:16PM +0100, Alexey Gladkov wrote:
> > On Mon, Jan 13, 2025 at 07:10:54PM +0200, Dmitry V. Levin wrote:
> > > Bring syscall_set_return_value() in sync with syscall_get_error(),
> > > and let upcoming ptrace/set_syscall_info selftest pass on powerpc.
> > > 
> > > This reverts commit 1b1a3702a65c ("powerpc: Don't negate error in
> > > syscall_set_return_value()").
> > > 
> > > Signed-off-by: Dmitry V. Levin <ldv@strace.io>
> > > ---
> > >  arch/powerpc/include/asm/syscall.h | 6 +++++-
> > >  1 file changed, 5 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/arch/powerpc/include/asm/syscall.h b/arch/powerpc/include/asm/syscall.h
> > > index 3dd36c5e334a..422d7735ace6 100644
> > > --- a/arch/powerpc/include/asm/syscall.h
> > > +++ b/arch/powerpc/include/asm/syscall.h
> > > @@ -82,7 +82,11 @@ static inline void syscall_set_return_value(struct task_struct *task,
> > >  		 */
> > >  		if (error) {
> > >  			regs->ccr |= 0x10000000L;
> > > -			regs->gpr[3] = error;
> > > +			/*
> > > +			 * In case of an error regs->gpr[3] contains
> > > +			 * a positive ERRORCODE.
> > > +			 */
> > > +			regs->gpr[3] = -error;
> > 
> > After this change the syscall_get_error() will return positive value if
> > the system call failed. Since syscall_get_error() still believes
> > regs->gpr[3] is still positive in case !trap_is_scv().
> > 
> > Or am I missing something?
> 
> syscall_get_error() does the following in case of !trap_is_scv():
> 
>                 /*
>                  * If the system call failed,
>                  * regs->gpr[3] contains a positive ERRORCODE.
>                  */
>                 return (regs->ccr & 0x10000000UL) ? -regs->gpr[3] : 0;
> 
> That is, in !trap_is_scv() case it assumes that regs->gpr[3] is positive
> and is going to return a negative value (-ERRORCODE).

Yeah. Now I see it.

	if (trap_is_scv(regs)) {
		regs->result = -EINTR;
		regs->gpr[3] = -EINTR;
	} else {
		regs->result = -EINTR;
		regs->gpr[3] = EINTR;
		regs->ccr |= 0x10000000;
	}

Two different APIs imply gpr[3] with a different sign.

You can add:

Reviewed-by: Alexey Gladkov <legion@kernel.org>

> > It looks like the selftest you mentioned in the commit message doesn't
> > check the !trap_is_scv() branch.
> 
> The selftest is architecture-agnostic, it just executes syscalls and
> checks whether the data returned by PTRACE_GET_SYSCALL_INFO meets
> expectations.  Do you mean that syscall() is not good enough for syscall
> invocation from coverage perspective on powerpc?
> 
> See also commit d72500f99284 ("powerpc/64s/syscall: Fix ptrace syscall
> info with scv syscalls").
> 
> 
> -- 
> ldv

-- 
Rgrds, legion


  reply	other threads:[~2025-01-14 14:53 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20250113170925.GA392@strace.io>
2025-01-13 17:10 ` [PATCH v2 1/7] powerpc: properly negate error in syscall_set_return_value() Dmitry V. Levin
2025-01-13 17:34   ` Christophe Leroy
2025-01-13 17:54     ` Dmitry V. Levin
2025-01-14 17:04     ` Dmitry V. Levin
2025-01-20 13:51       ` Christophe Leroy
2025-01-20 17:12         ` Dmitry V. Levin
2025-01-21 11:13           ` Madhavan Srinivasan
2025-01-21 11:28             ` Christophe Leroy
2025-01-21 12:25               ` Madhavan Srinivasan
2025-01-21 12:42                 ` Dmitry V. Levin
2025-01-23 18:28         ` Dmitry V. Levin
2025-01-23 19:11           ` Eugene Syromyatnikov
2025-01-23 22:16             ` Dmitry V. Levin
2025-01-23 22:07           ` Christophe Leroy
2025-01-23 22:35             ` Dmitry V. Levin
2025-01-27 11:20             ` Dmitry V. Levin
2025-01-27 11:36               ` Christophe Leroy
2025-01-27 11:44                 ` Dmitry V. Levin
2025-01-27 12:04                   ` Christophe Leroy
2025-01-27 12:26                     ` Dmitry V. Levin
2025-01-23 23:43           ` Dmitry V. Levin
2025-01-24 15:18             ` Alexey Gladkov
2025-01-25  0:25               ` Dmitry V. Levin
2025-01-25 12:18               ` Michael Ellerman
2025-01-27 11:13                 ` Dmitry V. Levin
2025-01-25 12:17             ` Michael Ellerman
2025-01-25 20:48               ` Dmitry V. Levin
2025-01-25 12:17           ` Michael Ellerman
2025-01-25 21:25             ` Dmitry V. Levin
2025-01-14 13:00   ` Alexey Gladkov
2025-01-14 13:48     ` Dmitry V. Levin
2025-01-14 14:53       ` Alexey Gladkov [this message]
2025-01-13 17:11 ` [PATCH v2 2/7] mips: fix mips_get_syscall_arg() for O32 and N32 Dmitry V. Levin
2025-01-14  3:29   ` Maciej W. Rozycki
2025-01-14  8:47     ` Dmitry V. Levin
2025-01-14 16:03       ` Maciej W. Rozycki
2025-01-14 16:42         ` Dmitry V. Levin
2025-01-13 17:11 ` [PATCH v2 3/7] syscall.h: add syscall_set_arguments() and syscall_set_return_value() Dmitry V. Levin
2025-01-16  2:20   ` Charlie Jenkins
2025-01-17  0:59     ` H. Peter Anvin
2025-01-17 15:45       ` Eugene Syromyatnikov
2025-01-18  4:34         ` H. Peter Anvin
2025-01-13 17:11 ` [PATCH v2 4/7] syscall.h: introduce syscall_set_nr() Dmitry V. Levin
2025-01-16  2:20   ` Charlie Jenkins
2025-01-13 17:12 ` [PATCH v2 5/7] ptrace_get_syscall_info: factor out ptrace_get_syscall_info_op Dmitry V. Levin
2025-01-13 17:12 ` [PATCH v2 6/7] ptrace: introduce PTRACE_SET_SYSCALL_INFO request Dmitry V. Levin
2025-01-15 16:38   ` Oleg Nesterov
2025-01-15 17:36     ` Dmitry V. Levin
2025-01-15 19:10       ` Oleg Nesterov
2025-01-16  1:55   ` Charlie Jenkins
2025-01-16  8:33     ` Dmitry V. Levin
2025-01-16 21:07       ` Charlie Jenkins
2025-01-16 21:47         ` Charlie Jenkins
2025-01-16 15:21   ` Oleg Nesterov
2025-01-16 16:04     ` Dmitry V. Levin
2025-01-16 16:40       ` Dmitry V. Levin
2025-01-17 14:45       ` Oleg Nesterov
2025-01-17 15:06         ` Dmitry V. Levin
2025-01-17 15:32           ` Oleg Nesterov
2025-01-17 16:22             ` Dmitry V. Levin
2025-01-18 14:13               ` Oleg Nesterov
2025-01-19 12:44                 ` Dmitry V. Levin
2025-01-20 19:56                   ` Oleg Nesterov
2025-01-19 14:38                 ` Aleksa Sarai
2025-01-13 17:12 ` [PATCH v2 7/7] selftests/ptrace: add a test case for PTRACE_SET_SYSCALL_INFO Dmitry V. Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z4Z6YJOsCl69_41-@example.org \
    --to=legion@kernel.org \
    --cc=berardi.dav@gmail.com \
    --cc=christophe.leroy@csgroup.eu \
    --cc=evgsyr@gmail.com \
    --cc=ldv@strace.io \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=mpe@ellerman.id.au \
    --cc=naveen@kernel.org \
    --cc=npiggin@gmail.com \
    --cc=oleg@redhat.com \
    --cc=renzo@cs.unibo.it \
    --cc=strace-devel@lists.strace.io \
    --cc=vapier@gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).