public inbox for libc-ports@sourceware.org
 help / color / mirror / Atom feed
From: "Maciej W. Rozycki" <macro@codesourcery.com>
To: Mike Frysinger <vapier@gentoo.org>
Cc: Ralf Baechle <ralf@linux-mips.org>, <libc-ports@sourceware.org>
Subject: Re: [PATCH][BZ #15054] MIPS: Fix syscall wrappers for syscall restart support
Date: Wed, 23 Jan 2013 05:40:00 -0000	[thread overview]
Message-ID: <alpine.DEB.1.10.1301230518180.4834@tp.orcam.me.uk> (raw)
In-Reply-To: <201301230009.23864.vapier@gentoo.org>

On Wed, 23 Jan 2013, Mike Frysinger wrote:

> >  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.
> 
> naïvely, but why can't the mips kernel paths take care of the reload itself ?  
> other arches have scratch space in their pt_regs for doing just this (a bunch 
> of arches use the orig_<reg> convention).

 I agree it would be the most reasonable approach if designing from 
scratch; unfortunately what we have is how the ABI has been set back in 
1994.  You won't be able to patch up all the kernel binaries out there, 
sigh...

 OTOH, the cost of hardcoding the extra instruction to precede SYSCALL is 
not something I would bend backwards to get rid of, especially given how 
rarely we make syscalls whose number is not a compilation-time constant.  
As a matter of curiosity I've run `objdump' across the set of shared 
libraries we build and found just two such places, in libpthread: 
sighandler_setxid and __nptl_setxid, out of 243 SYSCALL instances total.  
I don't suppose the number is going to rise dramatically anytime soon 
either.

  Maciej

  reply	other threads:[~2013-01-23  5:40 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-23  3:09 Maciej W. Rozycki
2013-01-23  5:05 ` Mike Frysinger
2013-01-23  5:40   ` Maciej W. Rozycki [this message]
2013-01-23 18:13     ` Mike Frysinger
2013-01-29 18:12       ` Maciej W. Rozycki
2013-01-29 19:04         ` Ralf Baechle
2013-01-29 19:12           ` Maciej W. Rozycki
2013-01-30  1:26             ` Ralf Baechle
2013-01-30  6:50               ` Mike Frysinger
2013-01-23 17:06 ` Joseph S. Myers
2013-01-24 12:47   ` Maciej W. Rozycki
2013-01-24 16:31     ` Joseph S. Myers
2013-01-29 18:10       ` Maciej W. Rozycki
2013-01-29 23:59         ` Joseph S. Myers
2013-02-05 15:26           ` Maciej W. Rozycki

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=alpine.DEB.1.10.1301230518180.4834@tp.orcam.me.uk \
    --to=macro@codesourcery.com \
    --cc=libc-ports@sourceware.org \
    --cc=ralf@linux-mips.org \
    --cc=vapier@gentoo.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).