Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp29810980rwd; Wed, 5 Jul 2023 18:28:58 -0700 (PDT) X-Google-Smtp-Source: APBJJlH8rrUVRXHYkv7E5m8N0Uti630udCCslOL8iKwPZ2uDNayA1Iz36g8QE5VZYDKRUDc8anRO X-Received: by 2002:a92:cc0d:0:b0:345:ffab:be65 with SMTP id s13-20020a92cc0d000000b00345ffabbe65mr762596ilp.8.1688606937827; Wed, 05 Jul 2023 18:28:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688606937; cv=none; d=google.com; s=arc-20160816; b=w9AMm5XmqHaygCtWaDNtLVN47xThAGBo+LxgxT381GaGu9p0MDihJuyov4FBffsdwn BkMKmFa26Scg/liQjNDf7Cu90tPNtGCYiEXLEfoNIAoIrd3nRirFgQhuq5Sdjxnoh4uu x75XZrhgwqYPVbNvxEGV3zQ/2fgh6PqhJS8chkGAoqB/547+1Nh3zbhUvONbLlteE+z2 SS0EFVdn/36+n8Xh5Qt30LqHSoCgjIVabehEumOg39FZJlfIeyFnPVVQegEkD/f38nYy R34fVQGcfNZQNwi+mPJjbbJQVkq2TTSPwdxa0R2zvDH3Zo23N2qWXFY9p/fOUaMrFCfD z3Lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=pnPV0y2omUyMEy8qnZA8PWeI+96woKyDjz/Ohi+Jd/k=; fh=s/n1WHsZzi+A41pT+QCTIpZ6/1+5NawUP2S4Gdedi/I=; b=zsEmNvpJFJLp2QaEhWQdUI+bQJo9T+VVLg4aqeVSUhLNzkDo1fyop26JpRNTLKU0BR 7RllRo+03/03SVXp5gRnNclgHqh6l0X5qtDZOeGt+uaY8bjjDCKxy6/2uQEg35pJcGXD iBTXk6ITESvkdIKcMU9S+jX8ABN2evOyrMQ1ECHa+PRGKSa/fsi8SNyDm3x8TEzbkgqT LNVynYTFeE5ic9reCz5L6VJgKdxbbCXF5llfju6RghTnRkv9AzQsCkRH8kaG7xooBses CWvDdlzsIwQ640SOOyUuknQjLaX6UKDm2RCnVYFX0xbgrhBYuv6XPHjlNfFltU39w7DC QKBA== 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 x9-20020a631709000000b005538a3e801esi394890pgl.535.2023.07.05.18.28.45; Wed, 05 Jul 2023 18:28:57 -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 S229537AbjGFA7V (ORCPT + 99 others); Wed, 5 Jul 2023 20:59:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231334AbjGFA7U (ORCPT ); Wed, 5 Jul 2023 20:59:20 -0400 Received: from brightrain.aerifal.cx (brightrain.aerifal.cx [216.12.86.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 613311722 for ; Wed, 5 Jul 2023 17:59:18 -0700 (PDT) Date: Wed, 5 Jul 2023 20:59:16 -0400 From: Rich Felker To: Stafford Horne Cc: LKML , Szabolcs Nagy , Jonas Bonn , Stefan Kristiansson , linux-openrisc@vger.kernel.org Subject: Re: [RFC PATCH v2] openrisc: Union fpcsr and oldmask in sigcontext to unbreak userspace ABI Message-ID: <20230706005916.GW20050@brightrain.aerifal.cx> References: <20230705212646.3618706-1-shorne@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230705212646.3618706-1-shorne@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, 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 On Wed, Jul 05, 2023 at 10:26:45PM +0100, Stafford Horne wrote: > With commit 27267655c531 ("openrisc: Support floating point user api") I > inproperly added an entry to the struct sigcontext which caused an > unwanted to chagne to the userspace ABI. > > Since oldmask was never used in OpenRISC we now use it's space for the > floating point fpcsr state. We do this with a union to restore the ABI > back to the pre kernel v6.4 ABI and keep API compatibility. > > This does mean if there is some code somewhere that is setting oldmask > in a userspace sighandler it would end up setting the floating point > register status, but I think it's unlikely as oldmask was never used > before. > > Fixes: 27267655c531 ("openrisc: Support floating point user api") > Reported-by: Szabolcs Nagy > Closes: https://lore.kernel.org/openrisc/20230626213840.GA1236108@port70.net/ > Signed-off-by: Stafford Horne > --- > Changes since v1: > - Rather than revert the change, just use the oldmask slot for fpu state. > > arch/openrisc/include/uapi/asm/sigcontext.h | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/arch/openrisc/include/uapi/asm/sigcontext.h b/arch/openrisc/include/uapi/asm/sigcontext.h > index ca585e4af6b8..93817d7051aa 100644 > --- a/arch/openrisc/include/uapi/asm/sigcontext.h > +++ b/arch/openrisc/include/uapi/asm/sigcontext.h > @@ -28,8 +28,10 @@ > > struct sigcontext { > struct user_regs_struct regs; /* needs to be first */ > - struct __or1k_fpu_state fpu; > - unsigned long oldmask; > + union { > + struct __or1k_fpu_state fpu; > + unsigned long oldmask; /* unused */ > + }; > }; > > #endif /* __ASM_OPENRISC_SIGCONTEXT_H */ > -- > 2.39.1 Correctness/ABI-safety of this patch depends on struct __or1k_fpu_state being just a single unsigned long and never changing. Is this something it's possible to commit to? Otherwise, a much better idea would be making the union contain a struct __or1k_fpu_state * or some more general pointer type that points to an out-of-band, expandable data structure past the end of the ucontext_t. Rich