From patchwork Fri Jul 7 21:22:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 117307 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp3557683vqx; Fri, 7 Jul 2023 14:51:18 -0700 (PDT) X-Google-Smtp-Source: APBJJlHYqNi13GACJGA5kCXQhtcrd14wo/yUWjvNXXKShf7cOSakw/2e/TKtGIhgXzwxg0jPnjb/ X-Received: by 2002:a17:902:f7c4:b0:1b1:af8e:d31d with SMTP id h4-20020a170902f7c400b001b1af8ed31dmr5008135plw.40.1688766678225; Fri, 07 Jul 2023 14:51:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688766678; cv=none; d=google.com; s=arc-20160816; b=DcPxJuqhRrnUlE5k5mWq/a4ql+TjGakiFLosGtpFSm5mBjfFDZ18Fb7DwnsjS0fgYI ZCKXwlS4oT8Fo5OtVspAF8WDGh0H309dbbMc6K2AvFxuwdhRgLmVQe1supFTi80qVLwI M8Nq0UB4bN7bjU6ONCv7xA0jZ0RexhJXschUW0AfUEoqUBojtJkW9LCO2tmBr6e20qQy LitbYe0CSxQt5KrwwSMjEaTNm1FjX4cWOhogtBakXKmCB81Eh8bDYAzhy/z5QiZXzWdj e0XHzA8B9IfAkYtya3tjOIujzau/HJOWupEagU9Zy0YRoVbWdDmq6KjTaCyORh5Co1Zv WYyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=jpRfv0tpTRGbIbIqr1xIENMhATsCOnSuVBh9rAn5bZc=; fh=4lmX05O34bJTwQeoF6sOUQNNUsAwz1REDAxA5RzEW5w=; b=RTxlYuM2Ii8sfX4iVOe34OtbUbpKLKyftynP0C8NwS8tJm6KJniBSzlPmJ9Y8TiU0E l3GLDiZ+KL5Jx8TxsTJsITjsZDxVYQIpA615ZY2yCCkBaOQMsq6HU9ercleM4qwyLG2I VGhnp9cXrcwcU0zvcgKOkfMVFnTmiyN7mlRANzAdaOoFpmbElhT3L6tGI/dubQwpAwz8 DFHrfyNA69MUwvaecgSROlg6M0Fu46gQQOYCLXJb0Kw0oHP1vFp/kKo3jiX5g4iZTXrt 7oQcYu3s4zwMXlpktnQ5+NknLraCl25wa38TZx3NVCFptAeegZsSsdvk14wROtvC277N 3Zeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=axzxEZcw; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j3-20020a170903028300b001b9d03d0bdesi9274plr.79.2023.07.07.14.51.05; Fri, 07 Jul 2023 14:51:18 -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; dkim=pass header.i=@gmail.com header.s=20221208 header.b=axzxEZcw; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232693AbjGGVXG (ORCPT + 99 others); Fri, 7 Jul 2023 17:23:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229963AbjGGVXF (ORCPT ); Fri, 7 Jul 2023 17:23:05 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAE1F1FD9; Fri, 7 Jul 2023 14:23:02 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3fbc12181b6so26074335e9.2; Fri, 07 Jul 2023 14:23:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688764981; x=1691356981; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=jpRfv0tpTRGbIbIqr1xIENMhATsCOnSuVBh9rAn5bZc=; b=axzxEZcw2zNOny2sJyy26SKtO5JrSbx/+rijTVpE05o6yXzznFK90jjrz4cbWUBKgJ OOu/dkH6tJiMfdRQf8EhhP4DCWOMVj2TIxcesnF0p0svQfxKMoZWK0PUiIQuHKwJ6xOo NPLzt001Au678jD5uu8ywVdTTYBdYRCh7jpkqgmgTmAfX+eB4jFgIcwFp9bVqkLjDgKI fz4g7TKtDZYZWq/5LWPbfmW0805CHg2zoJgY6+oHAqls/j63cNUjtWBRcLEbm88l40lV /xGQycAIvOzmlBch3WzMNL8BUDabUkJ2KWb1sv4HabB8lr30sMcOLpyFYVg6BEx1oRGY ANwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688764981; x=1691356981; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=jpRfv0tpTRGbIbIqr1xIENMhATsCOnSuVBh9rAn5bZc=; b=dYW+BttHGOPZe8BPMbXUjwk90icQPufDBY1iUIkeJzrniGFPTuF9E8sCpp/kQ8AHwK t9lEfaNJNIQhl24uxN6btZsQ3dS7H8q1krrqhK2rNhInXfOUj9BwYvTJdhZqQfYBKwP7 LHdVnPzq+ycGh5RKO2LsF4jex242XXA5tQ95rEewv33oV1pxx1AlvMj09FN8ALUS8kFY LEMu3VNXoEBbPElRRruV55r93Ji271Xbm0FvTjx84XNYDGISqVxmjou1YSBgTXIvA5BI ODfDnYsS1aWATcT8zyfEFK87pZSTbUw8EdbIvRD50qUduQWtQPdnTJn5cdublgmbz8VG ZpaQ== X-Gm-Message-State: ABy/qLYKf/nnmtq5/dXLa4OwyFX2s9DgAxEIZ0GAYP+QI76WXwe1UDuF FeCR8+CqafYTFXFlEH+56OOCSTk46uBY9g== X-Received: by 2002:a7b:ce87:0:b0:3fc:2d2:caa8 with SMTP id q7-20020a7bce87000000b003fc02d2caa8mr947641wmj.29.1688764980599; Fri, 07 Jul 2023 14:23:00 -0700 (PDT) Received: from localhost (cpc1-brnt4-2-0-cust862.4-2.cable.virginm.net. [86.9.131.95]) by smtp.gmail.com with ESMTPSA id n21-20020a1c7215000000b003f91e32b1ebsm3440529wmc.17.2023.07.07.14.23.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jul 2023 14:23:00 -0700 (PDT) From: Stafford Horne To: LKML Cc: Rich Felker , Stafford Horne , Szabolcs Nagy , Jonas Bonn , Stefan Kristiansson , linux-openrisc@vger.kernel.org Subject: [PATCH v3] openrisc: Union fpcsr and oldmask in sigcontext to unbreak userspace ABI Date: Fri, 7 Jul 2023 22:22:51 +0100 Message-Id: <20230707212252.3898950-1-shorne@gmail.com> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770800208285952170?= X-GMAIL-MSGID: =?utf-8?q?1770800208285952170?= With commit 27267655c531 ("openrisc: Support floating point user api") I added an entry to the struct sigcontext which caused an unwanted to change to the userspace ABI. To fix this we use the previously unused oldmask field 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 an OpenRISC specific userspace sighandler it would end up setting the floating point register status, but I think it's unlikely as oldmask was never functional 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 --- arch/openrisc/include/uapi/asm/sigcontext.h | 6 ++++-- arch/openrisc/kernel/signal.c | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/openrisc/include/uapi/asm/sigcontext.h b/arch/openrisc/include/uapi/asm/sigcontext.h index ca585e4af6b8..e7ffb58ff58f 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 { + unsigned long fpcsr; + unsigned long oldmask; /* unused */ + }; }; #endif /* __ASM_OPENRISC_SIGCONTEXT_H */ diff --git a/arch/openrisc/kernel/signal.c b/arch/openrisc/kernel/signal.c index 4664a18f0787..2e7257a433ff 100644 --- a/arch/openrisc/kernel/signal.c +++ b/arch/openrisc/kernel/signal.c @@ -50,7 +50,7 @@ static int restore_sigcontext(struct pt_regs *regs, err |= __copy_from_user(regs, sc->regs.gpr, 32 * sizeof(unsigned long)); err |= __copy_from_user(®s->pc, &sc->regs.pc, sizeof(unsigned long)); err |= __copy_from_user(®s->sr, &sc->regs.sr, sizeof(unsigned long)); - err |= __copy_from_user(®s->fpcsr, &sc->fpu.fpcsr, sizeof(unsigned long)); + err |= __copy_from_user(®s->fpcsr, &sc->fpcsr, sizeof(unsigned long)); /* make sure the SM-bit is cleared so user-mode cannot fool us */ regs->sr &= ~SPR_SR_SM; @@ -113,7 +113,7 @@ static int setup_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc) err |= __copy_to_user(sc->regs.gpr, regs, 32 * sizeof(unsigned long)); err |= __copy_to_user(&sc->regs.pc, ®s->pc, sizeof(unsigned long)); err |= __copy_to_user(&sc->regs.sr, ®s->sr, sizeof(unsigned long)); - err |= __copy_to_user(&sc->fpu.fpcsr, ®s->fpcsr, sizeof(unsigned long)); + err |= __copy_to_user(&sc->fpcsr, ®s->fpcsr, sizeof(unsigned long)); return err; }