mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Nicholas Wilson <nicholas.wilson@realvnc.com>
To: "musl@lists.openwall.com" <musl@lists.openwall.com>
Subject: Re: [PATCH] Wasm support patch 2 (static syscalls)
Date: Tue, 28 Nov 2017 13:23:15 +0000	[thread overview]
Message-ID: <VI1PR0502MB3885CC8B3DE060B46950E8DFE73A0@VI1PR0502MB3885.eurprd05.prod.outlook.com> (raw)
In-Reply-To: <20171128125948.GK15263@port70.net>

That suggestion is exactly what I'm trying to avoid!

With a jump table like that, you can't get static linkage. The compiler will link in *every* syscall. I don't think it's reasonable for the Wasm hosting environment to provide emulation for every syscall.

So then comes the impossible task of pleasing everyone: someone will say, "my application wants emulation for all 100 syscalls", and someone else will say, "I don't want to link in emulation for 100 syscalls when my application only uses one". There's just nowhere to draw the line - endless arguments over *which* syscalls are worthy in inclusion in your big jump table.

The patch I've proposed is really as minimal as things can get. Apart from the change to "__setxid", the rest of Musl is completely undisturbed.

Nick

________________________________________
From: Szabolcs Nagy <nsz@port70.net>
Sent: 28 November 2017 12:59:48
To: musl@lists.openwall.com
Subject: Re: [musl] [PATCH] Wasm support patch 2 (static syscalls)

* Nicholas Wilson <nicholas.wilson@realvnc.com> [2017-11-28 12:31:18 +0000]:
> Imagine an application that calls "getpid()".  This will cause "getpid.o" to be linked in, to provide the C API:
>
> pid_t getpid(void)
> {
>       return __syscall(SYS_getpid);
> }
>
> On all of Musl's existing archs, the syscalls are implemented via a seven generic "__syscallN" functions. The assumption is that the kernel provides all syscalls.
>
> For Wasm, what I've done is made it so that the interpreter environment instead provides *named* syscall functions, in this case, a "__syscall_getpid" function. Then, at link-time, when the linker links against libc.a it's able to link in to the application only the syscalls that are actually used.

we may change the syscall abstraction at some point, but
to do what you want, there is no need for intrusive changes.
just have

static inline long __syscall0(long n)
{
        switch (n) {
        ...
        case SYS_getpid: return __syscall_getpid();
        ...
        }
}

in arc/wasm/syscall_arch.h and the compiler will do the
right thing without any change to generic musl code.


  reply	other threads:[~2017-11-28 13:23 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-28 12:31 Nicholas Wilson
2017-11-28 12:59 ` Szabolcs Nagy
2017-11-28 13:23   ` Nicholas Wilson [this message]
2017-11-28 14:05     ` Szabolcs Nagy
2017-11-28 14:34       ` Nicholas Wilson
2017-11-28 14:35         ` Szabolcs Nagy
2017-11-28 14:53           ` Nicholas Wilson
2017-11-28 15:08             ` Szabolcs Nagy
2017-11-28 15:50               ` Rich Felker
2017-11-28 16:20                 ` Nicholas Wilson
2017-11-28 16:51         ` John Starks
2017-11-28 17:52           ` Szabolcs Nagy
2017-11-28 18:55             ` Rich Felker
2017-11-28 17:53           ` Nicholas Wilson

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=VI1PR0502MB3885CC8B3DE060B46950E8DFE73A0@VI1PR0502MB3885.eurprd05.prod.outlook.com \
    --to=nicholas.wilson@realvnc.com \
    --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).