From: Sven Schnelle <svens@linux.ibm.com>
To: "Michal Suchánek" <msuchanek@suse.de>
Cc: Heiko Carstens <hca@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
"H. Peter Anvin" <hpa@zytor.com>,
Thomas Gleixner <tglx@kernel.org>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Peter Zijlstra <peterz@infradead.org>,
linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] s390/syscall: Keep syscall return in extra ptregs member
Date: Tue, 21 Jul 2026 13:58:54 +0200 [thread overview]
Message-ID: <yt9dik68lfk1.fsf@linux.ibm.com> (raw)
In-Reply-To: <al9SKABzeTH8GXp9@kunlun.suse.cz>
Michal Suchánek <msuchanek@suse.de> writes:
> On Wed, Jul 15, 2026 at 03:38:29PM +0200, Sven Schnelle wrote:
>> diff --git a/arch/s390/kernel/syscall.c b/arch/s390/kernel/syscall.c
>> index 75d5a3cab14e..ce244dceec6d 100644
>> --- a/arch/s390/kernel/syscall.c
>> +++ b/arch/s390/kernel/syscall.c
>> @@ -117,25 +117,16 @@ void noinstr __do_syscall(struct pt_regs *regs, int per_trap)
>> regs->int_code |= nr;
>> }
>> regs->gprs[2] = nr;
>> + regs->syscall_ret = -ENOSYS;
>> if (nr == __NR_restart_syscall && !(current->restart_block.arch_data & 1)) {
>> regs->psw.addr = current->restart_block.arch_data;
>> current->restart_block.arch_data = 1;
>> }
>> nr = syscall_enter_from_user_mode_work(regs, nr);
>> - /*
>> - * In the s390 ptrace ABI, both the syscall number and the return value
>> - * use gpr2. However, userspace puts the syscall number either in the
>> - * svc instruction itself, or uses gpr1. To make at least skipping syscalls
>> - * work, the ptrace code sets PIF_SYSCALL_RET_SET, which is checked here
>> - * and if set, the syscall will be skipped.
>> - */
>> - if (unlikely(test_and_clear_pt_regs_flag(regs, PIF_SYSCALL_RET_SET)))
>> - goto out;
>> - regs->gprs[2] = -ENOSYS;
>> if (likely(nr < NR_syscalls)) {
>> nr = array_index_nospec(nr, NR_syscalls);
>> - regs->gprs[2] = sys_call_table[nr](regs);
>> + regs->syscall_ret = sys_call_table[nr](regs);
>> }
>> -out:
>> + regs->gprs[2] = regs->syscall_ret;
>> syscall_exit_to_user_mode(regs);
>
> Hello,
>
> I think this would break ptrace PTRACE_SETSIGINFO on syscall exit.
>
> It should use syscall_set_return_value but that now sets
> regs->syscall_ret, not regs->gprs[2]. At the same time the return value
> is in regs->gprs[2] at this point.
Thanks, Sashiko reported that already. I was thinking that syscall exit
tracing/filtering sets gpr[2] directly, but that's obviously wrong as it
uses syscall_set_return(). After trying to fix this I think I'll leave
the PIF_SYSCALL_RET_SET flag in place as it is - adding yet another
member to ptregs make it even more confusing.
next prev parent reply other threads:[~2026-07-21 11:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-15 13:38 [PATCH RFC 0/2] s390: keep syscall number / return value in separate pt_regs members Sven Schnelle
2026-07-15 13:38 ` [PATCH 1/2] s390/syscall: Keep syscall return in extra ptregs member Sven Schnelle
2026-07-15 14:04 ` sashiko-bot
2026-07-21 11:04 ` Michal Suchánek
2026-07-21 11:58 ` Sven Schnelle [this message]
2026-07-15 13:38 ` [PATCH 2/2] s390/syscall: Keep syscall number " Sven Schnelle
2026-07-15 13:59 ` Heiko Carstens
2026-07-15 14:10 ` sashiko-bot
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=yt9dik68lfk1.fsf@linux.ibm.com \
--to=svens@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=msuchanek@suse.de \
--cc=peterz@infradead.org \
--cc=tglx@kernel.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