From: "Dmitry V. Levin" <ldv@strace.io>
To: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Michael Ellerman <mpe@ellerman.id.au>,
Alexey Gladkov <legion@kernel.org>,
Eugene Syromyatnikov <evgsyr@gmail.com>,
Oleg Nesterov <oleg@redhat.com>,
Madhavan Srinivasan <maddy@linux.ibm.com>,
Nicholas Piggin <npiggin@gmail.com>,
Naveen N Rao <naveen@kernel.org>,
linuxppc-dev@lists.ozlabs.org, strace-devel@lists.strace.io,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] powerpc: properly negate error in syscall_set_return_value() in sc case
Date: Tue, 28 Jan 2025 18:10:05 +0200 [thread overview]
Message-ID: <20250128161005.GC11869@strace.io> (raw)
In-Reply-To: <b12039ce-99da-41e9-ba2f-dc0e0c62f140@csgroup.eu>
On Tue, Jan 28, 2025 at 05:00:31PM +0100, Christophe Leroy wrote:
> Le 28/01/2025 à 16:52, Dmitry V. Levin a écrit :
> > On Tue, Jan 28, 2025 at 03:59:29PM +0100, Christophe Leroy wrote:
> >> Le 27/01/2025 à 19:13, Dmitry V. Levin a écrit :
> >>> According to the Power Architecture Linux system call ABI documented in
> >>> [1], when the syscall is made with the sc instruction, both a value and an
> >>> error condition are returned, where r3 register contains the return value,
> >>> and cr0.SO bit specifies the error condition. When cr0.SO is clear, the
> >>> syscall succeeded and r3 is the return value. When cr0.SO is set, the
> >>> syscall failed and r3 is the error value. This syscall return semantics
> >>> was implemented from the very beginning of Power Architecture on Linux,
> >>> and syscall tracers and debuggers like strace that read or modify syscall
> >>> return information also rely on this ABI.
> >>
> >> I see a quite similar ABI on microblaze, mips, nios2 and sparc. Do they
> >> behave all the same ?
> >
> > Yes, also on alpha. I don't think microblaze should be in this list,
> > though.
>
> Microblaze has
>
> static inline void syscall_set_return_value(struct task_struct *task,
> struct pt_regs *regs,
> int error, long val)
> {
> if (error)
> regs->r3 = -error;
> else
> regs->r3 = val;
> }
>
> So it has a positive error setting allthough it has no flag to tell it
> is an error. Wondering how it works at the end.
It's a bug, but given that microblaze doesn't enable
CONFIG_HAVE_ARCH_TRACEHOOK, most likely this function is unused there.
> Alpha I'm not sure, I see nothing obvious in include/asm/ptrace.h or
> include/asm/syscall.h
Alpha doesn't enable CONFIG_HAVE_ARCH_TRACEHOOK, it just lacks the
necessary interfaces, but it uses a3 register for this purpose, see
arch/alpha/kernel/entry.S for details.
--
ldv
next prev parent reply other threads:[~2025-01-28 16:10 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-27 18:13 [PATCH 1/2] powerpc: properly negate error in syscall_set_return_value() in sc case Dmitry V. Levin
2025-01-27 18:14 ` [PATCH 2/2] powerpc: fix inconsistencies in syscall error return handling Dmitry V. Levin
2025-01-28 18:01 ` Christophe Leroy
2025-01-28 21:39 ` Dmitry V. Levin
2025-01-28 14:59 ` [PATCH 1/2] powerpc: properly negate error in syscall_set_return_value() in sc case Christophe Leroy
2025-01-28 15:52 ` Dmitry V. Levin
2025-01-28 16:00 ` Christophe Leroy
2025-01-28 16:10 ` Dmitry V. Levin [this message]
2025-01-28 15:54 ` Eugene Syromyatnikov
2025-06-02 11:36 ` 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=20250128161005.GC11869@strace.io \
--to=ldv@strace.io \
--cc=christophe.leroy@csgroup.eu \
--cc=evgsyr@gmail.com \
--cc=legion@kernel.org \
--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=strace-devel@lists.strace.io \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.