public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ports/15054] New: MIPS/Linux syscall restart convention not respected by INTERNAL_SYSCALL_NCS
@ 2013-01-23 2:41 macro@linux-mips.org
2013-01-23 17:27 ` [Bug ports/15054] " bugdal at aerifal dot cx
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: macro@linux-mips.org @ 2013-01-23 2:41 UTC (permalink / raw)
To: glibc-bugs
http://sourceware.org/bugzilla/show_bug.cgi?id=15054
Bug #: 15054
Summary: MIPS/Linux syscall restart convention not respected by
INTERNAL_SYSCALL_NCS
Product: glibc
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: ports
AssignedTo: unassigned@sourceware.org
ReportedBy: macro@linux-mips.org
CC: carlos@systemhalted.org, roland@gnu.org
Classification: Unclassified
We have an issue with the INTERNAL_SYSCALL_NCS wrapper in that it does not
respect the kernel's syscall restart convention.
That convention requires the instruction immediately preceding SYSCALL to
initialize $v0 with the syscall number. Then if a restart triggers, $v0
will have been clobbered by the syscall interrupted, and needs to be
reinititalized. The kernel will decrement the PC by 4 before switching
back to the user mode so that $v0 has been reloaded before SYSCALL is
executed again. This implies the place $v0 is loaded from must be
preserved across a syscall, e.g. an immediate, static register, stack slot,
etc.
We use two wrapper macros to dispatch syscalls to the relevant pieces of
code: INTERNAL_SYSCALL and INTERNAL_SYSCALL_NCS. They both ultimately
cause a piece of inline assembly to be emitted. In the former case the
piece starts with an LI instruction that loads $v0 with an immediate number
of the syscall required. A SYSCALL instruction then immediately follows.
In the latter case $v0 is arranged to have been preloaded and the piece
starts with a SYSCALL instruction.
That works if the syscall is executed the first time, because the compiler
will have arranged for $v0 to contain the correct value. It does not in
the case of a syscall restart as the compiler-generated instruction
immediately preceding SYSCALL may not necessarily be one to load $v0 with
the value required.
The failure mode is unlikely to trigger as the INTERNAL_SYSCALL_NCS wrapper
is only used in a couple of places and then the offending syscall would
have to be restarted as well. The symptom would usually be an intermittent
program failure and would be hard to debug. The issue was noticed by code
inspection while making changes in this area.
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug ports/15054] MIPS/Linux syscall restart convention not respected by INTERNAL_SYSCALL_NCS
2013-01-23 2:41 [Bug ports/15054] New: MIPS/Linux syscall restart convention not respected by INTERNAL_SYSCALL_NCS macro@linux-mips.org
@ 2013-01-23 17:27 ` bugdal at aerifal dot cx
2013-01-23 17:38 ` joseph at codesourcery dot com
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: bugdal at aerifal dot cx @ 2013-01-23 17:27 UTC (permalink / raw)
To: glibc-bugs
http://sourceware.org/bugzilla/show_bug.cgi?id=15054
Rich Felker <bugdal at aerifal dot cx> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bugdal at aerifal dot cx
--- Comment #1 from Rich Felker <bugdal at aerifal dot cx> 2013-01-23 17:26:53 UTC ---
This issue only affects old kernels that are barely in the realm of
still-supported. See:
http://www.linux-mips.org/archives/linux-mips/2012-09/msg00072.html
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug ports/15054] MIPS/Linux syscall restart convention not respected by INTERNAL_SYSCALL_NCS
2013-01-23 2:41 [Bug ports/15054] New: MIPS/Linux syscall restart convention not respected by INTERNAL_SYSCALL_NCS macro@linux-mips.org
2013-01-23 17:27 ` [Bug ports/15054] " bugdal at aerifal dot cx
@ 2013-01-23 17:38 ` joseph at codesourcery dot com
2013-02-05 15:25 ` macro@linux-mips.org
2014-06-13 18:59 ` fweimer at redhat dot com
3 siblings, 0 replies; 5+ messages in thread
From: joseph at codesourcery dot com @ 2013-01-23 17:38 UTC (permalink / raw)
To: glibc-bugs
http://sourceware.org/bugzilla/show_bug.cgi?id=15054
--- Comment #2 from joseph at codesourcery dot com <joseph at codesourcery dot com> 2013-01-23 17:37:43 UTC ---
On Wed, 23 Jan 2013, bugdal at aerifal dot cx wrote:
> This issue only affects old kernels that are barely in the realm of
> still-supported. See:
The minimum kernel version currently supported by glibc is 2.6.16. If the
code can be simplified when the minimum kernel version moves to something
more recent, it would indeed be good for the comments about the syscall
restart convention to identify the relevant kernel version that removed
the issue so it is clear when the complexity is obsolete.
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug ports/15054] MIPS/Linux syscall restart convention not respected by INTERNAL_SYSCALL_NCS
2013-01-23 2:41 [Bug ports/15054] New: MIPS/Linux syscall restart convention not respected by INTERNAL_SYSCALL_NCS macro@linux-mips.org
2013-01-23 17:27 ` [Bug ports/15054] " bugdal at aerifal dot cx
2013-01-23 17:38 ` joseph at codesourcery dot com
@ 2013-02-05 15:25 ` macro@linux-mips.org
2014-06-13 18:59 ` fweimer at redhat dot com
3 siblings, 0 replies; 5+ messages in thread
From: macro@linux-mips.org @ 2013-02-05 15:25 UTC (permalink / raw)
To: glibc-bugs
http://sourceware.org/bugzilla/show_bug.cgi?id=15054
Maciej W. Rozycki <macro@linux-mips.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
--- Comment #3 from Maciej W. Rozycki <macro@linux-mips.org> 2013-02-05 15:25:00 UTC ---
I think the removal of code complication is not worth the hassle and
given how the MIPS ABI has been laid out there is normally no runtime
overhead from this arrangement, merely instruction shuffling.
I think addressing the issue of multiple stack pointer adjustments made
for o32 syscalls that make use of more than four arguments (the alloca
or FORCE_FRAME_POINTER hack) and the resulting space and time overhead
of unnecessary register juggling would be a better use of anyone's time
and resources.
Fixed thus:
commit b82ba2f011fc4628ceece07412846d0b4d50cac2
Author: Maciej W. Rozycki <macro@codesourcery.com>
Date: Tue Feb 5 14:41:32 2013 +0000
MIPS: Respect the legacy syscall restart convention.
That convention requires the instruction immediately preceding SYSCALL
to initialize $v0 with the syscall number. Then if a restart triggers,
$v0 will have been clobbered by the syscall interrupted, and needs to be
reinititalized. The kernel will decrement the PC by 4 before switching
back to the user mode so that $v0 has been reloaded before SYSCALL is
executed again. This implies the place $v0 is loaded from must be
preserved across a syscall, e.g. an immediate, static register, stack
slot, etc.
The restriction was lifted with Linux 2.6.36 kernel release and no
special requirements are placed around the SYSCALL instruction anymore,
however we still support older kernel binaries.
ChangeLog.mips:
2013-02-05 Maciej W. Rozycki <macro@codesourcery.com>
[BZ #15054]
* sysdeps/unix/sysv/linux/mips/mips32/sysdep.h (MOVE32):
New macro.
(INTERNAL_SYSCALL_NCS): Use it. Rewrite to respect the syscall
restart convention.
(INTERNAL_SYSCALL): Rewrite to respect the syscall restart
convention.
(internal_syscall0, internal_syscall1): Likewise.
(internal_syscall2, internal_syscall3): Likewise.
(internal_syscall4, internal_syscall5): Likewise.
(internal_syscall6, internal_syscall7): Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h (MOVE32):
New macro.
(INTERNAL_SYSCALL_NCS): Use it. Rewrite to respect the syscall
restart convention.
(INTERNAL_SYSCALL): Rewrite to respect the syscall restart
convention.
(internal_syscall0, internal_syscall1): Likewise.
(internal_syscall2, internal_syscall3): Likewise.
(internal_syscall4, internal_syscall5): Likewise.
(internal_syscall6): Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h (MOVE32):
New macro.
(INTERNAL_SYSCALL_NCS): Use it. Rewrite to respect the syscall
restart convention.
(INTERNAL_SYSCALL): Rewrite to respect the syscall restart
convention.
(internal_syscall0, internal_syscall1): Likewise.
(internal_syscall2, internal_syscall3): Likewise.
(internal_syscall4, internal_syscall5): Likewise.
(internal_syscall6): Likewise.
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug ports/15054] MIPS/Linux syscall restart convention not respected by INTERNAL_SYSCALL_NCS
2013-01-23 2:41 [Bug ports/15054] New: MIPS/Linux syscall restart convention not respected by INTERNAL_SYSCALL_NCS macro@linux-mips.org
` (2 preceding siblings ...)
2013-02-05 15:25 ` macro@linux-mips.org
@ 2014-06-13 18:59 ` fweimer at redhat dot com
3 siblings, 0 replies; 5+ messages in thread
From: fweimer at redhat dot com @ 2014-06-13 18:59 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=15054
Florian Weimer <fweimer at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Flags| |security-
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-06-13 18:59 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-23 2:41 [Bug ports/15054] New: MIPS/Linux syscall restart convention not respected by INTERNAL_SYSCALL_NCS macro@linux-mips.org
2013-01-23 17:27 ` [Bug ports/15054] " bugdal at aerifal dot cx
2013-01-23 17:38 ` joseph at codesourcery dot com
2013-02-05 15:25 ` macro@linux-mips.org
2014-06-13 18:59 ` fweimer at redhat dot com
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).