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,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: (qmail 23108 invoked from network); 16 Apr 2020 14:16:23 -0000 Received-SPF: pass (mother.openwall.net: domain of lists.openwall.com designates 195.42.179.200 as permitted sender) receiver=inbox.vuxu.org; client-ip=195.42.179.200 envelope-from= Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with UTF8ESMTPZ; 16 Apr 2020 14:16:23 -0000 Received: (qmail 4087 invoked by uid 550); 16 Apr 2020 14:16:21 -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 4069 invoked from network); 16 Apr 2020 14:16:20 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=to:cc:references:from:autocrypt:subject:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=2jRFHI5ps3vdsSbzjWk+rLpcuOkC9rFVTgqe62WLobQ=; b=hbNqsvpqsSCfz2fIUTF6HLg0dUF+BzLzzLC4HCtgrmBu1Nju8hDzRRwqIipPHfmBNW W86NWJETMOZZbjzGsEfeh7E6HCFCOKbDCUNF54OF4GKCau8KKsIkk+I9v7l+sqtSJ88j px9R0Ko+PKoZVe6y0x5OatIEiYlt5ImoJh1ZjiECLf74iia5lq2IUSG0Ea9HD/sFm09h MsdqyCVHl6D2pNP7a6YgSnuxPyENME9QUy4IKjoFd8EG4xJ7ebSTRXSEAtzosM8J32kF zqRkg1IC2lu3YTZTPuXV8cRQiGh115eLor/UF0LQvDimwftxmm3kPAZBYZI7el3PacTY Y4Yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:references:from:autocrypt:subject :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=2jRFHI5ps3vdsSbzjWk+rLpcuOkC9rFVTgqe62WLobQ=; b=FkX2jKSSdufhXoWU0JCIYuocN0v8FB+JJlGCjw8VGu1cbg7czekRBRLAq7L2N/gpTp +zLDwc4k3X50E3p002cB9aCL20pGjuKbLN/Ys0he3pIg+bWHsSVdAe2J+vgcRO5lYDlF fBFp8lEIPLEbMJA0SrrVTss5FDdNu0CcQZCUebg729IbjZPr6bkS98dV90YVnRJpHgSz R1ub5BwUgBb1/mQi6i8Mbi11ml31RDYMZkBMsx4IIZUNW7h7XtbYKrfgq+Vr+unSa9u6 JX+4Vt0U1vn5v0lXK87ltA199qPa4XlhI8i6WD0gRg5PAmPc7B4rWzln/rHCDCj7i8gM yC9g== X-Gm-Message-State: AGi0Pubs6uGKXbRRyKw5cpXJSyLGewqfAIhDnTxKUKDZXIqD18zhipGD kV7CWiGv+bLYR3fR/fNEK6KOWg== X-Google-Smtp-Source: APiQypLDSe5hHXmdzUMIU98nZUyVhdL6HOQ5VbrEfVST3BIp/kewsfhKVQ5xV+GtSPwt0P5uWCVVWA== X-Received: by 2002:a37:8741:: with SMTP id j62mr29962996qkd.441.1587046568837; Thu, 16 Apr 2020 07:16:08 -0700 (PDT) To: Rich Felker , Nicholas Piggin Cc: libc-alpha@sourceware.org, musl@lists.openwall.com, linuxppc-dev@lists.ozlabs.org, libc-dev@lists.llvm.org References: <1586931450.ub4c8cq8dj.astroid@bobo.none> <20200415225539.GL11469@brightrain.aerifal.cx> From: Adhemerval Zanella Autocrypt: addr=adhemerval.zanella@linaro.org; prefer-encrypt=mutual; keydata= xsFNBFcVGkoBEADiQU2x/cBBmAVf5C2d1xgz6zCnlCefbqa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doMt8aIFbe7YFLEExHpSk+HgN05Lg5TyTro8oW7TSMTk+8a5M kzaH4UGXTTBDP/g5cfL3RFPl79ubXwARAQABwsFfBBgBCAAJBQJXFRpKAhsMAAoJEKqx7BSn lIjvI/8P/jg0jl4Tbvg3B5kT6PxJOXHYu9OoyaHLcay6Cd+ZrOd1VQQCbOcgLFbf4Yr+rE9l mYsY67AUgq2QKmVVbn9pjvGsEaz8UmfDnz5epUhDxC6yRRvY4hreMXZhPZ1pbMa6A0a/WOSt AgFj5V6Z4dXGTM/lNManr0HjXxbUYv2WfbNt3/07Db9T+GZkpUotC6iknsTA4rJi6u2ls0W9 1UIvW4o01vb4nZRCj4rni0g6eWoQCGoVDk/xFfy7ZliR5B+3Z3EWRJcQskip/QAHjbLa3pml xAZ484fVxgeESOoaeC9TiBIp0NfH8akWOI0HpBCiBD5xaCTvR7ujUWMvhsX2n881r/hNlR9g fcE6q00qHSPAEgGr1bnFv74/1vbKtjeXLCcRKk3Ulw0bY1OoDxWQr86T2fZGJ/HIZuVVBf3+ gaYJF92GXFynHnea14nFFuFgOni0Mi1zDxYH/8yGGBXvo14KWd8JOW0NJPaCDFJkdS5hu0VY 7vJwKcyHJGxsCLU+Et0mryX8qZwqibJIzu7kUJQdQDljbRPDFd/xmGUFCQiQAncSilYOcxNU EMVCXPAQTteqkvA+gNqSaK1NM9tY0eQ4iJpo+aoX8HAcn4sZzt2pfUB9vQMTBJ2d4+m/qO6+ cFTAceXmIoFsN8+gFN3i8Is3u12u8xGudcBPvpoy4OoG Message-ID: Date: Thu, 16 Apr 2020 11:16:04 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200415225539.GL11469@brightrain.aerifal.cx> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 8bit Subject: Re: [musl] Powerpc Linux 'scv' system call ABI proposal take 2 On 15/04/2020 19:55, Rich Felker wrote: > On Thu, Apr 16, 2020 at 07:45:09AM +1000, Nicholas Piggin wrote: >> I would like to enable Linux support for the powerpc 'scv' instruction, >> as a faster system call instruction. >> >> This requires two things to be defined: Firstly a way to advertise to >> userspace that kernel supports scv, and a way to allocate and advertise >> support for individual scv vectors. Secondly, a calling convention ABI >> for this new instruction. >> >> Thanks to those who commented last time, since then I have removed my >> answered questions and unpopular alternatives but you can find them >> here >> >> https://lists.ozlabs.org/pipermail/linuxppc-dev/2020-January/203545.html >> >> Let me try one more with a wider cc list, and then we'll get something >> merged. Any questions or counter-opinions are welcome. >> >> System Call Vectored (scv) ABI >> ============================== >> >> The scv instruction is introduced with POWER9 / ISA3, it comes with an >> rfscv counter-part. The benefit of these instructions is performance >> (trading slower SRR0/1 with faster LR/CTR registers, and entering the >> kernel with MSR[EE] and MSR[RI] left enabled, which can reduce MSR >> updates. The scv instruction has 128 interrupt entry points (not enough >> to cover the Linux system call space). >> >> The proposal is to assign scv numbers very conservatively and allocate >> them as individual HWCAP features as we add support for more. The zero >> vector ('scv 0') will be used for normal system calls, equivalent to 'sc'. >> >> Advertisement >> >> Linux has not enabled FSCR[SCV] yet, so the instruction will cause a >> SIGILL in current environments. Linux has defined a HWCAP2 bit >> PPC_FEATURE2_SCV for SCV support, but does not set it. >> >> When scv instruction support and the scv 0 vector for system calls are >> added, PPC_FEATURE2_SCV will indicate support for these. Other vectors >> should not be used without future HWCAP bits indicating support, which is >> how we will allocate them. (Should unallocated ones generate SIGILL, or >> return -ENOSYS in r3?) >> >> Calling convention >> >> The proposal is for scv 0 to provide the standard Linux system call ABI >> with the following differences from sc convention[1]: >> >> - LR is to be volatile across scv calls. This is necessary because the >> scv instruction clobbers LR. From previous discussion, this should be >> possible to deal with in GCC clobbers and CFI. >> >> - CR1 and CR5-CR7 are volatile. This matches the C ABI and would allow the >> kernel system call exit to avoid restoring the CR register (although >> we probably still would anyway to avoid information leak). >> >> - Error handling: I think the consensus has been to move to using negative >> return value in r3 rather than CR0[SO]=1 to indicate error, which matches >> most other architectures and is closer to a function call. >> >> The number of scratch registers (r9-r12) at kernel entry seems >> sufficient that we don't have any costly spilling, patch is here[2]. >> >> [1] https://github.com/torvalds/linux/blob/master/Documentation/powerpc/syscall64-abi.rst >> [2] https://lists.ozlabs.org/pipermail/linuxppc-dev/2020-February/204840.html > > My preference would be that it work just like the i386 AT_SYSINFO > where you just replace "int $128" with "call *%%gs:16" and the kernel > provides a stub in the vdso that performs either scv or the old > mechanism with the same calling convention. Then if the kernel doesn't > provide it (because the kernel is too old) libc would have to provide > its own stub that uses the legacy method and matches the calling > convention of the one the kernel is expected to provide. What about pthread cancellation and the requirement of checking the cancellable syscall anchors in asynchronous cancellation? My plan is still to use musl strategy on glibc (BZ#12683) and for i686 it requires to always use old int$128 for program that uses cancellation (static case) or just threads (dynamic mode, which should be more common on glibc). Using the i686 strategy of a vDSO bridge symbol would require to always fallback to 'sc' to still use the same cancellation strategy (and thus defeating this optimization in such cases). > Note that any libc that actually makes use of the new functionality is > not going to be able to make clobbers conditional on support for it; > branching around different clobbers is going to defeat any gains vs > always just treating anything clobbered by either method as clobbered. > Likewise, it's not useful to have different error return mechanisms > because the caller just has to branch to support both (or the > kernel-provided stub just has to emulate one for it; that could work > if you really want to change the bad existing convention). > > Thoughts? > > Rich >