From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/4944 Path: news.gmane.org!not-for-mail From: Josiah Worcester Newsgroups: gmane.linux.lib.musl.general Subject: Re: Changes for no-legacy-syscalls archs Date: Mon, 21 Apr 2014 18:38:12 -0500 Message-ID: References: <20140421231332.GA7115@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=089e0122f2ce196abc04f795febe X-Trace: ger.gmane.org 1398123512 20119 80.91.229.3 (21 Apr 2014 23:38:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 21 Apr 2014 23:38:32 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-4948-gllmg-musl=m.gmane.org@lists.openwall.com Tue Apr 22 01:38:26 2014 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1WcNn6-0005Eq-DQ for gllmg-musl@plane.gmane.org; Tue, 22 Apr 2014 01:38:24 +0200 Original-Received: (qmail 13439 invoked by uid 550); 21 Apr 2014 23:38:23 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 13431 invoked from network); 21 Apr 2014 23:38:23 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=9vbV5R0qxTn8mDB3OyUJaGGu29lR1Fnw09hvjy17M2U=; b=Of2Epsa1/DuxVpER6yv5+rxMMNCKYV370IwfpjLEGYQDiEJAur66izkUnludRm49iY QMyis5D1F0SbPG/zb39vo/NDXZKUCAQF1JcqTH9daieKyFHn7ghNWJKAoObU1A7MULvW siLji31YkTqBLoQ/S773TmakdDUintfkbLWg4RTn0vvgZGN3E9lI2D1kXWrrc21v1eNP EcqmOPUxZMNUh8zp3TTrVuNYGsYMlWJKv3wZEXjhB93seSUDYJzoci6bMcamSxFX3R/j aXxyvnL/PQSFcl1k7liWlaGehZKMHhcHa6MG+8pN77rcfi/P19NPWUdAPA8dabUhGQv8 UJ/A== X-Received: by 10.194.171.167 with SMTP id av7mr30426498wjc.32.1398123492107; Mon, 21 Apr 2014 16:38:12 -0700 (PDT) In-Reply-To: <20140421231332.GA7115@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:4944 Archived-At: --089e0122f2ce196abc04f795febe Content-Type: text/plain; charset=UTF-8 On Mon, Apr 21, 2014 at 6:13 PM, Rich Felker wrote: > Based on reports from the in-progress aarch64 port, at least the > following syscalls musl uses internally in several places are missing > on "new" archs: > > - open > - stat > - pipe > > I'm actually surprised it way so few, but I think that's indicative > that our test coverage is insufficient; all of the syscalls with "at" > variants or 2/3/4 variants (pipe/dup/accept) should be problems. > The complete list of variants missing from new ports can be seen in include/uapi/asm-generic/unistd.h in the kernel tree, under the __ARCH_WANT_SYSCALL_NO_AT, __ARCH_WANT_SYSCALL_NO_FLAGS, and __ARCH_WANT_SYSCALL_DEPRECATED #ifdefs. As far as I'm aware this should apply to all future Linux archs, as the current Linux development policy is to use arch-generic constants for anything new, rather than the crazy approach of matching some old API. > > Anyway, as far as I can tell, of the above three, "open" is the only > one used as an inline syscall in multiple places across the source. > The others (stat and pipe) are just used via calls to the public > function, so any changes needed can be made in just one place. For > open, of the 8 uses, 3-4 are in places that need to be > namespace-protected (so we can't just call the open function, and > anyway it's a cancellation point which is problematic) and one, > __init_security, is in a place that's size-critical (linked in all > static programs) so we don't want to add a function call there anyway. > The rest of the call points are all largish functions where the inline > syscall is not making a significant difference to size. > > So, for all instances except __init_security and open itself, I think > it would make sense to call an external __open function. This would > also be a nice place to tuck away the O_LARGEFILE flag, rather than > having all calling code be aware of it. We could then just add two > additional, mildly-ugly #ifdef SYS_open checks to __init_security.c > and open.c and be done with it (open itself is special because it has > to make a cancellable syscall). > > Alternatively, instead of the external function __open, we could > define a macro __open, or sys_open, or similar, in internal/syscall.h > and have it expand to either an inline syscall to SYS_open or > SYS_openat depending on whether SYS_open is defined. This would avoid > any size increase and would also avoid having an #ifdef in > __init_security. > > The second solution might be preferable; eventually, we could > transition to having most/all syscalls be made via sys_* function-like > macros in syscall.h, which would facilitate porting to bare-metal > without implementing a huge numeric syscall dispatch function like > what's in the kernel. > I rather like this approach to doing the syscalls, as it does make it notably easier to port musl to environments where the numeric syscall dispatch function is not very nice. However, I would think it'd be preferable to switch to this for all the system calls rather than just have a single sys_open macro. So, for the minimally-invasive approach, I feel that just doing the #ifdef in the two places it's needed is nicer (particularly as it doesn't restrict you from switching to the sys_* macros in the future). > > Rich > --089e0122f2ce196abc04f795febe Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On M= on, Apr 21, 2014 at 6:13 PM, Rich Felker <dalias@libc.org> wro= te:
Based on reports from the in-progress aarch64 port, at least the
following syscalls musl uses internally in several places are missing
on "new" archs:

- open
- stat
- pipe

I'm actually surprised it way so few, but I think that's indicative=
that our test coverage is insufficient; all of the syscalls with "at&q= uot;
variants or 2/3/4 variants (pipe/dup/accept) should be problems.

The complete list of variants missing from new po= rts can be seen in include/uapi/asm-generic/unistd.h in the kernel tree, un= der the __ARCH_WANT_SYSCALL_NO_AT, __ARCH_WANT_SYSCALL_NO_FLAGS, and __ARCH= _WANT_SYSCALL_DEPRECATED #ifdefs. As far as I'm aware this should apply= to all future Linux archs, as the current Linux development policy is to u= se arch-generic constants for anything new, rather than the crazy approach = of matching some old API.
=C2=A0

Anyway, as far as I can tell, of the above three, "open" is the o= nly
one used as an inline syscall in multiple places across the source.
The others (stat and pipe) are just used via calls to the public
function, so any changes needed can be made in just one place. For
open, of the 8 uses, 3-4 are in places that need to be
namespace-protected (so we can't just call the open function, and
anyway it's a cancellation point which is problematic) and one,
__init_security, is in a place that's size-critical (linked in all
static programs) so we don't want to add a function call there anyway.<= br> The rest of the call points are all largish functions where the inline
syscall is not making a significant difference to size.

So, for all instances except __init_security and open itself, I think
it would make sense to call an external __open function. This would
also be a nice place to tuck away the O_LARGEFILE flag, rather than
having all calling code be aware of it. We could then just add two
additional, mildly-ugly #ifdef SYS_open checks to __init_security.c
and open.c and be done with it (open itself is special because it has
to make a cancellable syscall).

Alternatively, instead of the external function __open, we could
define a macro __open, or sys_open, or similar, in internal/syscall.h
and have it expand to either an inline syscall to SYS_open or
SYS_openat depending on whether SYS_open is defined. This would avoid
any size increase and would also avoid having an #ifdef in
__init_security.

The second solution might be preferable; eventually, we could
transition to having most/all syscalls be made via sys_* function-like
macros in syscall.h, which would facilitate porting to bare-metal
without implementing a huge numeric syscall dispatch function like
what's in the kernel.


I rather = like this approach to doing the syscalls, as it does make it notably easier= to port musl to environments where the numeric syscall dispatch function i= s not very nice. However, I would think it'd be preferable to switch to= this for all the system calls rather than just have a single sys_open macr= o. So, for the minimally-invasive approach, I feel that just doing the #ifd= ef in the two places it's needed is nicer (particularly as it doesn'= ;t restrict you from switching to the sys_* macros in the future).
=C2=A0

Rich

--089e0122f2ce196abc04f795febe--