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.1 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,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 20914 invoked from network); 25 Apr 2020 11:00:36 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with UTF8ESMTPZ; 25 Apr 2020 11:00:36 -0000 Received: (qmail 3597 invoked by uid 550); 25 Apr 2020 11:00:34 -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 3567 invoked from network); 25 Apr 2020 11:00:33 -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=WJ1ftYIEA71lZ9W+K+8CT7Do3y8++eTLYCbmeD3KoUI=; b=DEJCN4RXawMdO6MPziJCPk46ZSi544uBE0LvPk3myFTOdMoCvRtEtu/pnVyHn21YWX au4vGc6qlWFRxmgFOWhL46dTKD65LNMBRoMG2ciKmRTCsqL4xEYn/PUO76VTry0yMj5p Ak7B9dSFfEcdwvoPuflvrnHGdlXUZCd6wEzD+RSgh6g4XwElKh8ZOFg3CwRDy264fZjD ExJEt6ykIvZRWNVnm7WKOJtjZd7HE5bhFqp+B+TsjvF0bF9cE2sMbxNbFICh1Hc7/DKf T0xA+AEBKS01KSUIiEvDRENVYo5rqk/gEl0N6oRvhQ5KDoVeRzk9NhpPBelaFkXrQvHa 91xQ== 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=WJ1ftYIEA71lZ9W+K+8CT7Do3y8++eTLYCbmeD3KoUI=; b=tG0mSxRgFFWr306DxGtlVPHwWqPV0+McTN0fGmljPxz/mFSFgC8EWMM6PU38toVj1n sfQ2coLqaPvz77yP+t/85cDxo4aJRcH55sHnuhr3kKsfaWsDfn++fKELQnUDf7YKBTGu tzq8BtD7OTEqfSiF0ZH9a8VJUbAhmDXz5/T0Wcl+r9sfQ9LfQOCD/rLF2xjjHpCkMloW mNNg30xPkPgDjqV48hruY+3nhJGTWCIOQaEP4w3rqCeUtXJMbUfLZIAoEh8scAqgYKXP jLN3natjWMO+JYDX+RCI4ssf2JVV+eEY+qsZjYlUzHl4pVFD7NHt2ycnhqQTZRbKTIQ6 /AVA== X-Gm-Message-State: AGi0PuZP5rEs2G8LV9D8DYP30VcwqXIq9wa2m/1aaBAuiEyJ0CpMH1PM 0P5Vtnhh/VJugwe1B9dhha4= X-Google-Smtp-Source: APiQypItDEkctIh/qxACRlcEm3tb75XxC/s0wL9AAIHQLpsPTBcEow031P839mfNKFW4unJOZbVOFA== X-Received: by 2002:a63:7f1a:: with SMTP id a26mr1174761pgd.252.1587812421787; Sat, 25 Apr 2020 04:00:21 -0700 (PDT) Date: Sat, 25 Apr 2020 20:56:54 +1000 From: Nicholas Piggin To: binutils@sourceware.org, Christophe Leroy , linuxppc-dev@lists.ozlabs.org Cc: Adhemerval Zanella , Rich Felker , libc-alpha@sourceware.org, libc-dev@lists.llvm.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> In-Reply-To: <9371cac5-20bb-0552-2609-0d537f41fecd@c-s.fr> MIME-Version: 1.0 Message-Id: <1587810370.tg8ym9yjpc.astroid@bobo.none> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [musl] Re: New powerpc vdso calling convention Excerpts from Christophe Leroy's message of April 25, 2020 5:47 pm: >=20 >=20 > Le 25/04/2020 =C3=A0 07:22, Nicholas Piggin a =C3=A9crit=C2=A0: >> As noted in the 'scv' thread, powerpc's vdso calling convention does not >> match the C ELF ABI calling convention (or the proposed scv convention). >> I think we could implement a new ABI by basically duplicating function >> entry points with different names. >=20 > I think doing this is a real good idea. >=20 > I've been working at porting powerpc VDSO to the GENERIC C VDSO, and the=20 > main pitfall has been that our vdso calling convention is not compatible=20 > with C calling convention, so we have go through an ASM entry/exit. >=20 > See https://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=3D1714= 69 >=20 > We should kill this error flag return through CR[SO] and get it the=20 > "modern" way like other architectectures implementing the C VDSO: return=20 > 0 when successfull, return -err when failed. Agreed. >> The ELF v2 ABI convention would suit it well, because the caller already >> 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 just b= e >> deprecated and remain on existing functions or required to use the ELF >> 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 middle= . 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. The vdso doesn't have TOC, it has one global address (the vdso data=20 page) which it loads by calculating its own address. 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: # define VDSO_IFUNC_RET(value) \ ({ \ static Elf64_FuncDesc vdso_opd =3D { .fd_toc =3D ~0x0 }; \ vdso_opd.fd_func =3D (Elf64_Addr)value; \ &vdso_opd; \ }) If we could make something which links more like any other dso with ELFv1, that would be good. Otherwise I think v2 is preferable so it=20 doesn't have to calculate its own address. >> 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 very=20 > easy to call them, see patch 5 in the series=20 > (https://patchwork.ozlabs.org/project/linuxppc-dev/patch/59bea35725ab4cef= c67a678577da8b3ab7771af5.1587401492.git.christophe.leroy@c-s.fr/) I see. Well the kernel can probably patch in sc or scv depending on=20 which is supported, so we could keep the automatic fallback. Thanks, Nick