From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.2 Received: (qmail 12318 invoked from network); 25 Apr 2020 23:11:48 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with UTF8ESMTPZ; 25 Apr 2020 23:11:48 -0000 Received: (qmail 1402 invoked by uid 550); 25 Apr 2020 23:11:45 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 1384 invoked from network); 25 Apr 2020 23:11:45 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:subject:to:cc:references:in-reply-to:mime-version :message-id:content-transfer-encoding; bh=b1I5VhmS8YlY121R50I9dZXRP0z5VOB+6nzHXeobRZ4=; b=Vn87GL3hdeo7q6ppZlZEa/w8RyrReG9X4iuCmVAVk/sWg6KZkFHI1pn/hOlNtAbL7v lfscA8xrncfUGRRbwIWd+Ov9VFsBXdQySAnpxn/N51KCmnvUIAyTQ1d+OnnAguxeAyz0 9u9JEqu5/H1BsRDYuSxRUFpU027aJ8tMvVn5M++YpnW0qktGwxWv233kZ+RtEwW0z7RQ Bp8O+pwIxejucCrt6bC9/w/A/W9p4IWeXfgQvH613IPIKsQXbOdjQMx+ebx90emDc03t JW7DXCKc3AprUqw2XA24QDXfA7Qza6eEiCdpJcI+mTbdg6pP3WqKBvcwkSYcWn6AZIx4 Cn5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:subject:to:cc:references:in-reply-to :mime-version:message-id:content-transfer-encoding; bh=b1I5VhmS8YlY121R50I9dZXRP0z5VOB+6nzHXeobRZ4=; b=iC/hxUg+4LgPq4nEav+x73mV8MVXpwf2OgPchRH6D2OMdnpC/Vkz4OZF8uWXRCzXmi 7co/NE2QPonwIRdwyoLNm6qbp+8vmq3hTUQKo2MRMJKUTGtuTpas+Kyog04YNLzjuobD VBryEuqIaPpOme2ZLudTS/i01qqcXRR0ZNrNJzojrqDtAey9h4fGUssVM9hShzECh3yg 15YMbOAt40d77ldeuWfcP5PbAqTWOaARLmRwm1fml1KwdqXT+ypCfDj4aFlcpWLnALVe CLB7j5squk+ySI+VSgqsZpS2+599rTs60sUgc6d0DT7SZ/RvW38Eo140PADWGtXPDkx1 L37Q== X-Gm-Message-State: AGi0PuavaRHeWQDYOAhpb26tWXBbHBngmTN/8VydhUsifycuEh7hrPMt lh8w/ihWscYf8IB8T64s6WM= X-Google-Smtp-Source: APiQypL9z+lErGO3Wv2xONslRLBtES/YBKacmV2UyBDfRuMs50K/d/6Z/lqEOzMwQ8lxDl7Id7383A== X-Received: by 2002:a17:90a:cb88:: with SMTP id a8mr3584852pju.82.1587856293025; Sat, 25 Apr 2020 16:11:33 -0700 (PDT) Date: Sun, 26 Apr 2020 09:07:57 +1000 From: Nicholas Piggin To: Rich Felker Cc: Adhemerval Zanella , binutils@sourceware.org, Christophe Leroy , libc-alpha@sourceware.org, libc-dev@lists.llvm.org, linuxppc-dev@lists.ozlabs.org, Andy Lutomirski , musl@lists.openwall.com, Thomas Gleixner , Vincenzo Frascino References: <1587790194.w180xsw5be.astroid@bobo.none> <9371cac5-20bb-0552-2609-0d537f41fecd@c-s.fr> <1587810370.tg8ym9yjpc.astroid@bobo.none> <20200425162204.GJ11469@brightrain.aerifal.cx> In-Reply-To: <20200425162204.GJ11469@brightrain.aerifal.cx> MIME-Version: 1.0 Message-Id: <1587855503.8grsasuwof.astroid@bobo.none> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [musl] Re: New powerpc vdso calling convention Excerpts from Rich Felker's message of April 26, 2020 2:22 am: > On Sat, Apr 25, 2020 at 08:56:54PM +1000, Nicholas Piggin wrote: >> >> The ELF v2 ABI convention would suit it well, because the caller alre= ady >> >> requires the function address for ctr, so having it in r12 will >> >> eliminate the need for address calculation, which suits the vdso data >> >> page access. >> >>=20 >> >> Is there a need for ELF v1 specific calls as well, or could those jus= t be >> >> deprecated and remain on existing functions or required to use the EL= F >> >> v2 calls using asm wrappers? >> >=20 >> > What's ELF v1 and ELF v2 ? Is ELF v1 what PPC32 uses ? If so, I'd say=20 >> > yes, it would be good to have it to avoid going through ASM in the mid= dle.. >>=20 >> I'm not sure about PPC32. On PPC64, ELFv2 functions must be called with=20 >> their address in r12 if called at their global entry point. ELFv1 have a= =20 >> function descriptor with call address and TOC in it, caller has to load=20 >> the TOC if it's global. >>=20 >> The vdso doesn't have TOC, it has one global address (the vdso data=20 >> page) which it loads by calculating its own address. >=20 > A function descriptor could be put in the VDSO data page, or as it's > done now by glibc the vdso linkage code could create it. My leaning is > to at least have a version of the code that's callable (with the right > descriptor around it) by v1 binaries, but since musl does not use > ELFv1 at all we really have no stake in this and I'm fine with > whatever outcome users of v1 decide on. I agree, I think it would be good to make it look as much like a normal function as possible. >> The kernel doesn't change the vdso based on whether it's called by a v1=20 >> or v2 userspace (it doesn't really know itself and would have to export=20 >> different functions). glibc has a hack to create something: >=20 > I'm pretty sure it does know because signal invocation has to know > whether the function pointer points to a descriptor or code. At least > for FDPIC archs (similar to PPC64 ELFv1 function descriptors) it knows > and has to know. It knows on a per-executable basis (by looking at the ELF header). It=20 doesn't know per-system though so we can't patch the vdso accordingly.=20 But we could include both sets of entry points and map in the=20 appropriate one at exec time I think. >> >> Is there a good reason for the system call fallback to go in the vdso >> >> function rather than have the caller handle it? >> >=20 >> > I've seen at least one while porting powerpc to the C VDSO: arguments=20 >> > toward VDSO functions are in volatile registers. If the caller has to=20 >> > call the fallback by itself, it has to save them before calling the=20 >> > VDSO, allthought in 99% of cases it won't use them again. With the=20 >> > fallback called by the VDSO itself, the arguments are still hot in=20 >> > volatile registers and ready for calling the fallback. That make it ve= ry=20 >> > easy to call them, see patch 5 in the series=20 >> > (https://patchwork.ozlabs.org/project/linuxppc-dev/patch/59bea35725ab4= cefc67a678577da8b3ab7771af5.1587401492.git.christophe.leroy@c-s.fr/) >=20 > This is actually a good reason not to spuriously fail and fallback. At > present musl wouldn't take advantage of it because musl uses the > fallback path for lazy initialization of the vdso function pointer and > doesn't special-case the MIPS badness, but if it made a big difference > we probably could shuffle things around to only do the fallback on > archs that need it and avoid saving the input arg registers across the > vdso call. It's a point for it yes. I don't know if any libc or app would want to=20 instrument it or do special accounting or something for system calls. Thanks, Nick