Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp18063324rwd; Tue, 27 Jun 2023 11:04:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7KLIqq3bYwGGNoW2U73osQmNulIPRtJM6RfmTwIaAVkYZ2bbNFdFMUKp0xDsS9gUxYpi6T X-Received: by 2002:a2e:9998:0:b0:2b6:a344:29cf with SMTP id w24-20020a2e9998000000b002b6a34429cfmr4333926lji.17.1687889041252; Tue, 27 Jun 2023 11:04:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687889041; cv=none; d=google.com; s=arc-20160816; b=sj7Pk+rg7RSQ0MXBzWwM4RyN6dGaSbrofFFsdSSSQMbw9WJjdH4YwUBANRcngHX99i dl/WPJuC9wttyBdSu5DJKx8KJG2MWOEsXcKWUXqA5woWRVQOP9vLFn8tQCPWOo8Hx2rx A1KrsOQAR378k4ofZzK5fbe9ulLnrrXrFeZRXzUH91jNT4gxyKeV2s9Ki/7V6thwp38m MNPr5UQ5xj75djbrUc3Jc+4igICr+Foc/wKv0kDrBMijCNameCKTE/g6XtlcJZDRLWyg /Z924DOGPJTRfZ486+ZrDCV6l4/qOlp+zUAyqt8+BkWcF5+8dncgLbr5uRdebTZ4eMzq Aajw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=lYZF6RrCM9atbxDY1SKx0hOfA7+Ztx5vGgKSOu3B6wY=; fh=Jbmq4jyQDetEZaep9U19GxDsktjHJMaFMJqYuG5oDa4=; b=MwgEJJSMGsVTZooM0/22bw+dYaCl/wuDo0Yn+7LDukBzAzXbJOcjbdXDrzBrQgFNP2 G7MEZx69O02iA4YaNuRqEt6jyHDVZXabBI+aR4JvoKUzy4Ydh/5J2zeC5ImTmkbWbTL7 ZaQQbNcGqfXN/YNA5Re3Z2CSGFomzxMT2fjo//kQg4GL5psVHsEx2dquIwZwH91rD0Vr sQamv/bj4t+xqEcetBy0G/nCPFYBiKWRChkEwTOuJmGVVvmcTHdGLJEVdnhTf5KQvtor esHm9MbK+4kAESDT+bLGIu2h/gSNXkHsWs98fBCamyQGgQ5HAA/ZDyV9EtDqPFPcO4Yb G7Qg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xa10-20020a170907b9ca00b0097894b06eccsi4523382ejc.717.2023.06.27.11.03.35; Tue, 27 Jun 2023 11:04:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231847AbjF0R4u (ORCPT + 99 others); Tue, 27 Jun 2023 13:56:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229748AbjF0R4p (ORCPT ); Tue, 27 Jun 2023 13:56:45 -0400 Received: from port70.net (port70.net [81.7.13.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 82124296B; Tue, 27 Jun 2023 10:56:41 -0700 (PDT) Received: by port70.net (Postfix, from userid 1002) id D1130ABEC0C7; Tue, 27 Jun 2023 19:56:38 +0200 (CEST) Date: Tue, 27 Jun 2023 19:56:38 +0200 From: Szabolcs Nagy To: Stafford Horne Cc: LKML , Linux OpenRISC , Jonas Bonn , Stefan Kristiansson , Eric Biederman , Kees Cook , "Jason A. Donenfeld" , Dominik Brodowski , linux-mm@kvack.org, Rich Felker Subject: Re: [PATCH 3/4] openrisc: Support floating point user api Message-ID: <20230627175638.GD3630668@port70.net> References: <20230418165813.1900991-1-shorne@gmail.com> <20230418165813.1900991-4-shorne@gmail.com> <20230626213840.GA1236108@port70.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Stafford Horne [2023-06-27 17:41:03 +0100]: > On Mon, Jun 26, 2023 at 11:38:40PM +0200, Szabolcs Nagy wrote: > > * Stafford Horne [2023-04-18 17:58:12 +0100]: > > > Add support for handling floating point exceptions and forwarding the > > > SIGFPE signal to processes. Also, add fpu state to sigcontext. > > > > > > Signed-off-by: Stafford Horne > > > --- > > ... > > > --- a/arch/openrisc/include/uapi/asm/sigcontext.h > > > +++ b/arch/openrisc/include/uapi/asm/sigcontext.h > > > @@ -28,6 +28,7 @@ > > > > > > struct sigcontext { > > > struct user_regs_struct regs; /* needs to be first */ > > > + struct __or1k_fpu_state fpu; > > > unsigned long oldmask; > > > }; > > > > this seems to break userspace abi. > > glibc and musl have or1k abi without this field. > > > > either this is a new abi where binaries opt-in with some marking > > and then the base sigcontext should be unmodified, > > > > or the fp state needs to be added to the signal frame in a way that > > does not break existing abi (e.g. end of the struct ?) and also > > advertise the new thing via a hwcap, otherwise userspace cannot > > make use of it. > > > > unless i'm missing something. > > I think you are right, I meant to look into this but it must have slipped > though. Is this something causing you issues or did you just notice it? i noticed it while trying to update musl headers to linux 6.4 uapi. > I didn't run into issues when running the glibc test suite, but I may have > missed it. i would only expect issues when accessing ucontext entries after uc_mcontext.regs in a signal handler registered with SA_SIGINFO. in particular uc_sigmask is after uc_mcontext on or1k and e.g. musl thread cancellation uses this entry to affect the mask on signal return which will not work on a 6.4 kernel (not tested). i don't think glibc has tests for the ucontext signal abi. > Just moving this to the end of the sigcontext may be all that is needed. that won't help since uc_sigmask comes after sigcontext in ucontext. it has to go to the end of ucontext or outside of ucontext then. one way to have fpu in sigcontext is struct sigcontext { struct user_regs_struct regs; unsigned long oldmask; char padding[sizeof(__userspace_sigset_t)]; struct __or1k_fpu_state fpu; }; but the kernel still has to interpret the padding in a bwcompat way. (and if libc wants to expose fpu in its ucontext then it needs a flag day abi break as the ucontext size is abi.) (part of the userspace uc_sigmask is unused because sigset_t is larger than necessary so may be that can be reused but this is a hack as that's libc owned.) not sure how important this fpu field is, arm does not seem to have fpu state in ucontext and armhf works. there may be other ways, i'm adding Rich (musl maintainer) on cc in case he has an opinion.