From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: Florian Weimer <fw@deneb.enyo.de>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH 03/15] sparc: Use Linux kABI for syscall return
Date: Tue, 11 Feb 2020 20:29:00 -0000 [thread overview]
Message-ID: <d78eb2db-e240-08a3-1c00-8823eab22c45@linaro.org> (raw)
In-Reply-To: <874kvxnczu.fsf@mid.deneb.enyo.de>
On 11/02/2020 16:24, Florian Weimer wrote:
> * Adhemerval Zanella:
>
>> On 11/02/2020 08:15, Florian Weimer wrote:
>>> * Adhemerval Zanella:
>>>
>>>> + if (__glibc_unlikely (__g1 != 0)) \
>>>
>>> This change is inconsistent with the other updates, which use __g1 ==
>>> -1. Is this deliberate?
>>>
>>> Thanks,
>>> Florian
>>>
>>
>> In fact __SYSCALL_STRING already sets the 'o0' to a negative value if
>> the 'xcc' condition is set (indicating that the syscall has failed).
>> The 'g1' check is superfluous, it will be always true since 'g1' will
>> be either 0 or 1.
>>
>> And both the set and check of 'g1' result is also superfluous, since 'o0'
>> will already hold all the required information.
>>
>> Below is an updated patch, checked on sparc64-linux-gnu and
>> sparcv9-linux-gnu.
>
> I see, nice additional cleanup.
>
>> It changes the sparc internal_syscall* macros to return a negative
>> value instead the 'g1' register value on 'err' macro argument.
> ^ of ^ in the?
>
>
Ack.
>> The __SYSCALL_STRING macro is also changed to no set the 'g1'
> ^ not
>> value, since 'o1' already holds all the required information
>> to check if syscall has failed.
>>
>> The macro INTERNAL_SYSCALL_DECL is no longer required, and the
>> INTERNAL_SYSCALL_ERROR_P follows the other Linux kABIS. The
> ^ macro? ^ kABIs
Ack.
> (or drop the âtheâ on the preceding line)
>
>> redefinition of INTERNAL_VSYSCALL_CALL is also no longer
>> required.
>>
>> Checked on sparc64-linux-gnu and sparcv9-linux-gnu. It fixes
>> the sporadic issues on sparc32 where clock_nanosleep does not
>> act as cancellation entrypoint.
>
> I double-checked this against the kernel sources, and entry.S has
> this:
>
> ret_sys_call:
> ld [%curptr + TI_FLAGS], %l6
> cmp %o0, -ERESTART_RESTARTBLOCK
> ld [%sp + STACKFRAME_SZ + PT_PSR], %g3
> set PSR_C, %g2
> bgeu 1f
>
> But ERESTART_RESTARTBLOCK is not 4095, so glibc with this change will
> now treat certain internal kernel error codes as errors, while they
> were previously reported as success. This looks like a kernel bug, in
> that ERESTART_RESTARTBLOCK was not updated when more error codes were
> added. On the other hand, these error codes should never leak into
> userspace.
My understanding is such errors should not be visible by the application,
as indicated by include/linux/errno.h comment. And it seems to be the
case for sparc, at least on:
arch/sparc/kernel/signal_64.c
477 static void do_signal(struct pt_regs *regs, unsigned long orig_i0)
[...]
514 restart_syscall = 0;
515 if (pt_regs_is_syscall(regs) &&
516 (regs->tstate & (TSTATE_XCARRY | TSTATE_ICARRY))) {
517 restart_syscall = 1;
518 orig_i0 = regs->u_regs[UREG_G6];
519 }
520
521 if (has_handler) {
522 if (restart_syscall)
523 syscall_restart(orig_i0, regs, &ksig.ka.sa);
524 signal_setup_done(setup_rt_frame(&ksig, regs), &ksig, 0);
525 } else {
526 if (restart_syscall) {
527 switch (regs->u_regs[UREG_I0]) {
528 case ERESTARTNOHAND:
529 case ERESTARTSYS:
530 case ERESTARTNOINTR:
531 /* replay the system call when we are done */
532 regs->u_regs[UREG_I0] = orig_i0;
533 regs->tpc -= 4;
534 regs->tnpc -= 4;
535 pt_regs_clear_syscall(regs);
536 /* fall through */
537 case ERESTART_RESTARTBLOCK:
538 regs->u_regs[UREG_G1] = __NR_restart_syscall;
539 regs->tpc -= 4;
540 regs->tnpc -= 4;
541 pt_regs_clear_syscall(regs);
542 }
543 }
544
If signal has a handler, syscall_restart will either set EINTR or
previous 'o0' value. Otherwise if syscall should be restarted,
either it will be trying again (line 538) or previous error code
would be set.
>
> To me, your patch looks good.
>
next prev parent reply other threads:[~2020-02-11 20:29 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-10 19:21 [PATCH 01/15] powerpc: Consolidate Linux syscall definition Adhemerval Zanella
2020-02-10 19:20 ` [PATCH 04/15] alpha: Refactor syscall and Use Linux kABI for syscall return Adhemerval Zanella
2020-02-10 19:20 ` [PATCH 02/15] powerpc: " Adhemerval Zanella
2020-02-11 11:18 ` Florian Weimer
2020-02-11 12:14 ` Adhemerval Zanella
2020-02-11 12:32 ` Florian Weimer
2020-02-11 13:31 ` Adhemerval Zanella
2020-02-11 19:47 ` Florian Weimer
2020-02-11 19:47 ` Florian Weimer
2020-02-12 13:24 ` Adhemerval Zanella
2020-02-10 19:20 ` [PATCH 03/15] sparc: " Adhemerval Zanella
2020-02-11 11:15 ` Florian Weimer
2020-02-11 18:55 ` Adhemerval Zanella
2020-02-11 19:26 ` Florian Weimer
2020-02-11 20:29 ` Adhemerval Zanella [this message]
2020-02-11 21:16 ` Florian Weimer
2020-02-12 12:35 ` Adhemerval Zanella
2020-02-12 12:40 ` Florian Weimer
2020-02-12 12:56 ` Adhemerval Zanella
2020-02-10 19:20 ` [PATCH 09/15] microblaze: Avoid clobbering register parameters in syscall Adhemerval Zanella
2020-02-11 11:21 ` Florian Weimer
2020-02-11 19:10 ` Adhemerval Zanella
2020-02-10 19:21 ` [PATCH 07/15] mips: Use Linux kABI for syscall return Adhemerval Zanella
2020-02-10 19:21 ` [PATCH 08/15] nios2: " Adhemerval Zanella
2020-02-11 11:20 ` Florian Weimer
2020-02-11 19:09 ` Adhemerval Zanella
2020-02-11 11:51 ` Andreas Schwab
2020-02-19 21:40 ` Vineet Gupta
2020-02-20 13:14 ` Adhemerval Zanella
2020-02-20 20:39 ` Vineet Gupta
2020-02-20 21:04 ` Vineet Gupta
2020-02-27 17:49 ` Adhemerval Zanella
2020-02-10 19:21 ` [PATCH 13/15] linux: Consolidate INLINE_SYSCALL Adhemerval Zanella
2020-02-11 12:04 ` Florian Weimer
2020-02-11 20:53 ` Adhemerval Zanella
2020-02-11 21:01 ` Florian Weimer
2020-02-10 19:21 ` [PATCH 06/15] mips64: Consolidate Linux sysdep.h Adhemerval Zanella
2020-02-10 22:48 ` Joseph Myers
2020-02-11 19:05 ` Adhemerval Zanella
2020-02-10 19:21 ` [PATCH 12/15] sparc: Avoid clobbering register parameters in syscall Adhemerval Zanella
2020-02-11 11:22 ` Florian Weimer
2020-02-11 19:17 ` Adhemerval Zanella
2020-02-10 19:21 ` [PATCH 14/15] nptl: Remove ununsed pthread-errnos.h rule Adhemerval Zanella
2020-02-11 11:24 ` Florian Weimer
2020-02-11 11:51 ` Florian Weimer
2020-02-11 21:01 ` Adhemerval Zanella
2020-02-10 19:21 ` [PATCH 11/15] s390: Consolidate Linux syscall definition Adhemerval Zanella
2020-02-10 19:21 ` [PATCH 05/15] ia64: Use Linux kABI for syscall return Adhemerval Zanella
2020-02-10 19:21 ` [PATCH 10/15] riscv: Avoid clobbering register parameters in syscall Adhemerval Zanella
2020-02-10 19:51 ` DJ Delorie
2020-02-10 21:27 ` Palmer Dabbelt
2020-02-10 21:55 ` Adhemerval Zanella
2020-02-10 19:21 ` [PATCH 15/15] linux: Remove INTERNAL_SYSCALL_DECL Adhemerval Zanella
2020-02-11 12:34 ` Florian Weimer
2020-02-11 12:36 ` Florian Weimer
2020-02-11 20:58 ` Adhemerval Zanella
2020-02-11 12:48 ` Florian Weimer
2020-02-11 20:56 ` Adhemerval Zanella
2020-02-15 7:51 ` Andreas Schwab
2020-02-15 9:32 ` [PATCH] arm: fix use of INTERNAL_SYSCALL_CALL Andreas Schwab
2020-02-15 9:57 ` Florian Weimer
2020-02-11 19:45 ` [PATCH 01/15] powerpc: Consolidate Linux syscall definition Florian Weimer
2020-02-12 13:19 ` Adhemerval Zanella
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=d78eb2db-e240-08a3-1c00-8823eab22c45@linaro.org \
--to=adhemerval.zanella@linaro.org \
--cc=fw@deneb.enyo.de \
--cc=libc-alpha@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).