From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12158 Path: news.gmane.org!.POSTED!not-for-mail From: Nicholas Wilson Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] Wasm support patch 2 (static syscalls) Date: Tue, 28 Nov 2017 13:23:15 +0000 Message-ID: References: ,<20171128125948.GK15263@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1511875414 20374 195.159.176.226 (28 Nov 2017 13:23:34 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 28 Nov 2017 13:23:34 +0000 (UTC) To: "musl@lists.openwall.com" Original-X-From: musl-return-12174-gllmg-musl=m.gmane.org@lists.openwall.com Tue Nov 28 14:23:30 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1eJfr9-0004aV-Dm for gllmg-musl@m.gmane.org; Tue, 28 Nov 2017 14:23:23 +0100 Original-Received: (qmail 32183 invoked by uid 550); 28 Nov 2017 13:23:28 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 32164 invoked from network); 28 Nov 2017 13:23:28 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=realvnc.onmicrosoft.com; s=selector1-realvnc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=ORC3NnkboDRK+JwTsWj/zzR9Ld+MPdkb5+EOejpl9kA=; b=UdjCsyd4fyEJzaneTZQN/eHxZv02axKU+UxPwtT8bYxyWWX0tH64AWkYJ18G2qXk+VrH4icjZhDHrNnhYkm9HwKQbGA6urOlQdvg6+4JT0tv0dlZd3Cbf/AXPdvbJNlOkJS/vozAx9QhzHvlYezSm5Zw93LS00tRD5uKtXw6JII= Thread-Topic: [musl] [PATCH] Wasm support patch 2 (static syscalls) Thread-Index: AQHTaEFVgDgYeA7kVEKWz4n1+gEDaKMpwQcAgAACxiU= In-Reply-To: <20171128125948.GK15263@port70.net> Accept-Language: en-GB, en-US Content-Language: en-GB X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [2a02:390:a001:192:d6be:d9ff:fe9c:1892] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;VI1PR0502MB3886;6:Ujet23ReCIzZWoKgPI1WTztcHTJTk0A5xTWEJIo4Lo3TyFYdgZtW6y+2p5W7StpEpFlHFV31YAFxnVIaQeTCBnpsjzQMNJOmgKqtJ+WU8FH0zFx6Qu+MveO6t/N7V1H1qRix5o4qcJEQ4KIbZqcWqZT6LMQ48RmDKlbq60HO3gy42Ten17N0jsqvm/jIDrFCKDQXnaDKXAJ6BjnlkDNXPNTxA5Z3zxZbkjSSE+luat4EjW7eEeJS6s3UIyWmkJwvz3+rkgweOd5J+jVuv0JIc9+qoTHq4EoKVvPhd9yMAe7vbIcKzUJRc26nJd/5GyylUzZxmT8Nc/VGSNEBK1IJtq3heyeRaGtQutE6dg/BjWQ=;5:7zCx27KhB5L7I+wPrkfloQvdGHXiyplXt06a6bK7DOwhxVNiqIT4Rp4G4W5WeIqyd5AIM7NTfssd8TvsysdGhnG/ye5+AHDmCeGOIEZ7P2FO74Y+y4GD7xpiEVoL0eC9qumS/F1eGCZBxW92PIK5IVwCyhAD2RmXnqe3yT4RtwA=;24:1P5gXSG6fakLWZ3tNGuQLuguDssKBkA2mNgNsCrNNJXYRWYdE9xJNCl+ZIrY1FnIVzxwTQuSKg8SoETIVkl7DQb2u/fCHXTC/+0NLmCh/IM=;7:Qy5ABw1qePnSrm07HbxVYZFsTwcmeonG0ppS4Sa0Op2qJD/4Zv2dU/HpnRkVerlTYyogdi/1BUdZ7KiS9tNjupKTkeHE n0NIA5XM9RsENcokQmY1nbYKgTXYHIhnsQcpVz5G9FKnk4aaWbP9pYbcp86Lsg9tGXBnUcSJgEnmAohz7xXBteWOZzcuzgJcmQ x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: 2f37b15f-e9f3-4160-b753-08d536632e6f x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(4534020)(4602075)(4603075)(4627115)(201702281549075)(5600026)(4604075)(2017052603258);SRVR:VI1PR0502MB3886; x-ms-traffictypediagnostic: VI1PR0502MB3886: authentication-results: spf=none (sender IP is ) smtp.mailfrom=nicholas.wilson@realvnc.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040450)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3002001)(3231022)(6041248)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123562025)(20161123558100)(2016111802025)(20161123564025)(6072148)(6043046)(201708071742011);SRVR:VI1PR0502MB3886;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:VI1PR0502MB3886; x-forefront-prvs: 0505147DDB x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(366004)(346002)(376002)(377424004)(189002)(199003)(68736007)(3660700001)(53936002)(99286004)(5660300001)(50986999)(3280700002)(54356999)(14454004)(76176999)(81156014)(105586002)(5640700003)(5250100002)(6916009)(81166006)(1730700003)(2900100001)(2351001)(9686003)(2950100002)(2501003)(53546010)(4001150100001)(97736004)(305945005)(106356001)(6246003)(86362001)(33656002)(7736002)(6116002)(8936002)(102836003)(8676002)(74316002)(189998001)(7696005)(2906002)(25786009)(55016002)(316002)(45080400002)(6436002)(6506006)(229853002)(478600001)(101416001);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR0502MB3886;H:VI1PR0502MB3885.eurprd05.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; received-spf: None (protection.outlook.com: realvnc.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM X-MS-Exchange-CrossTenant-Network-Message-Id: 2f37b15f-e9f3-4160-b753-08d536632e6f X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Nov 2017 13:23:15.0435 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 9ad766d3-c6a5-4458-8c58-244e7c118728 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0502MB3886 X-OriginatorOrg: realvnc.com Xref: news.gmane.org gmane.linux.lib.musl.general:12158 Archived-At: That suggestion is exactly what I'm trying to avoid! With a jump table like that, you can't get static linkage. The compiler wil= l link in *every* syscall. I don't think it's reasonable for the Wasm hosti= ng 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 applicati= on only uses one". There's just nowhere to draw the line - endless argument= s 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 Sent: 28 November 2017 12:59:48 To: musl@lists.openwall.com Subject: Re: [musl] [PATCH] Wasm support patch 2 (static syscalls) * Nicholas Wilson [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 i= nstead provides *named* syscall functions, in this case, a "__syscall_getpi= d" 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.