mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [UGLY PATCH] Support for no-legacy-syscalls archs
Date: Sun, 25 May 2014 07:45:15 -0400	[thread overview]
Message-ID: <20140525114515.GX507@brightrain.aerifal.cx> (raw)
In-Reply-To: <20140525095257.GI12324@port70.net>

On Sun, May 25, 2014 at 11:52:57AM +0200, Szabolcs Nagy wrote:
> * Rich Felker <dalias@libc.org> [2014-05-25 01:42:37 -0400]:
> > Here's a proposed next phase for supporting no-legacy-syscall archs
> > (aarch64 and or1k, among others). It's not complete but I think it
> > covers most of the important syscalls for standard functionality (not
> > linux-specific stuff tho). Some of them might be missing some error
> > cases or otherwise buggy so I'm sending the patch for review before
> > committing.
> ....
> > +#ifdef SYS_poll
> >  	__syscall(SYS_poll, pfd, 3, 0);
> > +#else
> > +	__syscall(SYS_ppoll, pfd, 3, 0, 0, _NSIG/8);
> > +#endif
> 
> cant it be done the other way around so new syscalls
> are tried and then the classic ones are just fallbacks?

The "legacy" (I like the word "classic" better here, actually)
syscalls are actually preferred when available. Not only is there the
natural small amount of bloat decrease (fewer args, less chance of
having to shuffle the stack and spill registers in the caller, etc.),
and the consideration that using the new syscalls by default would
require fallback code for the ENOSYS case, but in some cases emulating
the behavior of the simpler function with the "general purpose"
syscall is actually expensive and error-prone.

I thought getpgid was an example of this (see the patch, which uses 4
syscalls instead of 1 to avoid a race reading the pid then using it,
which can race with fork from a signal handler) but it turned out an
argument of 0 to the syscall yields the getpgrp behavior, so I'm
updating that aspect of the patch.

An example that can't be optimized away is dup2, where special logic
is needed to deal with the case that dup3 treats differently. BTW,
the use of dup2 in posix_spawn also needs attention; I'm fixing it
now but the fix is rather ugly.

> and what will happen with SYS_open?

Already committed what seems to be the least invasive at both the
source and binary level. See the commit message; other approaches had
me worried that it might be too easy to break things (e.g. posix_spawn
where the child is sharing memory with the parent and thus can't touch
errno, cancellation state, etc.).

Rich


  parent reply	other threads:[~2014-05-25 11:45 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-25  5:42 Rich Felker
2014-05-25  9:52 ` Szabolcs Nagy
2014-05-25  9:57   ` Justin Cormack
2014-05-25 11:45   ` Rich Felker [this message]
2014-05-26  4:28 ` Rich Felker
2014-05-26 18:40 ` [UGLY PATCH v2] " Rich Felker
2014-05-26 21:13   ` Szabolcs Nagy
2014-05-26 21:54     ` Rich Felker
2014-05-26 22:39       ` Szabolcs Nagy
2014-05-26 22:46         ` Rich Felker
2014-05-27  5:26 ` [UGLY PATCH v3] " Rich Felker
2014-05-27 11:29   ` Szabolcs Nagy
2014-05-27 19:01     ` Rich Felker
2014-05-29 21:46   ` Rich Felker
2014-05-29 23:04   ` Rich Felker

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=20140525114515.GX507@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).