Re: [PATCH v2 1/7] powerpc: properly negate error in syscall_set_return_value()

Dmitry V. Levin
2025-01-25T20:48:16Z

On Sat, Jan 25, 2025 at 11:17:58PM +1100, Michael Ellerman wrote:
> "Dmitry V. Levin" <ldv@strace.io> writes:
> > On Thu, Jan 23, 2025 at 08:28:15PM +0200, Dmitry V. Levin wrote:
> ...
> >> After looking at system_call_exception() I doubt this inconsistency can be
> >> easily avoided, so I don't see how this patch could be enhanced further,
> >> and what else could I do with the patch besides dropping it and letting
> >> !trap_is_scv case be unsupported by PTRACE_SET_SYSCALL_INFO API, which
> >> would be unfortunate.
> >
> > If you say this would bring some consistency, I can extend the patch with
> > something like this:
>
> Yes that would improve things IMHO, with one caveat ....
>
> > diff --git a/arch/powerpc/kernel/ptrace/ptrace.c b/arch/powerpc/kernel/ptrace/ptrace.c
> > index 727ed4a14545..dda276a934fd 100644
> > --- a/arch/powerpc/kernel/ptrace/ptrace.c
> > +++ b/arch/powerpc/kernel/ptrace/ptrace.c
> > @@ -207,7 +207,7 @@ static int do_seccomp(struct pt_regs *regs)
> > * syscall parameter. This is different to the ptrace ABI where
> > * both r3 and orig_gpr3 contain the first syscall parameter.
> > */
> > - regs->gpr[3] = -ENOSYS;
> > + syscall_set_return_value(current, regs, -ENOSYS, 0);
> >
> > /*
> > * We use the __ version here because we have already checked
> > @@ -225,7 +225,7 @@ static int do_seccomp(struct pt_regs *regs)
> > * modify the first syscall parameter (in orig_gpr3) and also
> > * allow the syscall to proceed.
> > */
> > - regs->gpr[3] = regs->orig_gpr3;
> > + syscall_set_return_value(current, regs, 0, regs->orig_gpr3);
>
> This case should remain as-is. The orig_gpr3 value here is not a syscall
> error code, it's the original r3 value, which is a syscall parameter.

I agree, but shouldn't CCR.SO be cleared somehow after it was set earlier by
syscall_set_return_value(current, regs, -ENOSYS, 0);
?

--
ldv