Message ID | 20231103090223.702340-1-cleger@rivosinc.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp889269vqu; Fri, 3 Nov 2023 02:02:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHsoNRhT4xqeEE9lran8DHCQkCXh2dW+/Tc8sZjBeT2kfSQuwnSyBSgxULdGM1c3AxrseCA X-Received: by 2002:a05:6358:5913:b0:168:ec90:95dd with SMTP id g19-20020a056358591300b00168ec9095ddmr18242061rwf.26.1699002174660; Fri, 03 Nov 2023 02:02:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699002174; cv=none; d=google.com; s=arc-20160816; b=ORyMt5D6ioSo+jzfvxQ6yZ1SV27GnhS3jPDe9h67MqVZs9iyqZ/TtmEyzngTe1Fwgj tVkvwWnYI/pD00+B/kVEovQ60btuIf8dxLdDQAL4bh8bbjM4hHl7zX8AosF+zQBlGELx xIf5OqgWzTGhbJKCa1mOxMeKanqOGYu23NQuws1M8PF5d3JHsGwdnMfcWSarZ4km2RDB KkVqyukengJj1qdGKJ4U+xT+3nvVX2KDsyl4m8XoKooSN3x6SfJPxJ4oQfR/j+zyxL+m xEBnq2A1kcfDH2kMv7uF30aFvV3hv9XYjcBvkHmINTMFurAg3scVYEp9fojvVOcmMz91 27Lg== 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=m+1tHEC+sLfsTYbEucEalWJbhmfqSui8PoKCdZjk+zI=; fh=7yRLsu/hyx38cvZ/OOClcMMc1C1U7rgETjIgz/vRBHs=; b=W6EYUs9/kIpXe6j1HjxM9RsAomrySpikN0kIQrXl/6bcQIi573wltPXkLguNjpVhdY 6Gfg/FA8FTd9n+bdmK6tFZ4DMUdiyQlAm5QsEEBPNPpMY0fdt7iowK08qx3LVfhZNccB b1UCsRjeQFsb1HlGQ/50JkdGJKxbR6MgMpSdDRdN/KUHW3XPhLNkoXh9Sqxk/8++VFcY AOijGxzFAgBrT5SgamX1wngS/3DX2SWpXo8lbbtWfc9X4prdVKUQCxvBhxjpcTi5AagP 8//eWgpzhAkZj5VZ3JL6/NCALRDZQQLFNWphDzhvtAmoeAcPyd8PiyvhT7MsdCG/NdLI g5Wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=R1sdotQX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id w190-20020a6382c7000000b005ace065e529si1168594pgd.333.2023.11.03.02.02.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 02:02:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=R1sdotQX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 39194826CB57; Fri, 3 Nov 2023 02:02:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346435AbjKCJCh (ORCPT <rfc822;lhua1029@gmail.com> + 36 others); Fri, 3 Nov 2023 05:02:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235199AbjKCJCe (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 3 Nov 2023 05:02:34 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05108187 for <linux-kernel@vger.kernel.org>; Fri, 3 Nov 2023 02:02:30 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-408ffb55b35so1268305e9.1 for <linux-kernel@vger.kernel.org>; Fri, 03 Nov 2023 02:02:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1699002148; x=1699606948; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=m+1tHEC+sLfsTYbEucEalWJbhmfqSui8PoKCdZjk+zI=; b=R1sdotQXKXwyUl2ag7nUS6FPVHY8dLkh33PXzlL12EZsA64ZK9d6b6F1I0p3IEhI00 wP/RPRSDQ9iFCHvtt+K/eF8R8GPF7BAB/ptg00o+uNhFDw2eHZJOwfmuApr+kH1z0gys A++HmbCFETHfBLqcZA0ADkJ9aawi6otrRX69KcCAfBTv8Z1h02xnaeaIbLUZdox58zwe IcgmkEYkrjsegUGWWvwR+1SZMsGorHV+yFRXlR3vsESEDvSRE82Et1g/X3lArPKBNPEu CUnkn/dqgJIYaG1xxYw6hacWXMFzxsrPO8QQKLJ4Mcb2wq1kgJr5mN+BX8daivQnB8Ub 1WEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699002148; x=1699606948; 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=m+1tHEC+sLfsTYbEucEalWJbhmfqSui8PoKCdZjk+zI=; b=T2LpKt0GMLjOCrysXRhPpoJD+n/Xd35Tt5pIho/YHeEHdoA/NtL5eAMVBJxHt8uvAJ sEZXJkduD0HJLB56C74hA+eESygIe141m5si0fd25l5rIjEa8Oe6MCs3cuBvaYJzL7+H QaOpM5jwLeDfPkJF/tI+fSh7I5Qsa9H9nsL1ia6igYx6gOmCe3wQF3N5qHARCGPjyrhs 4eUaWQXcFlCkb+HsFyzfweNSduf7tl9ckcKvQNwmcQxmmy9UVvCiQX/yDNqfUjR1dPWD lN5T+SaUB9uzA0NJRAgOUYs9A3cDTzop5u65Oa/ou57MjvWq2vwOWFeK4HDLgolJr6xw TBsQ== X-Gm-Message-State: AOJu0YycucCh7dMggQL8dwxkPYl9YJqhLiDwRmJODl0+Yhc0qs6X5r15 4WLKqOlvHPYYgkSa38C8sHgOiA== X-Received: by 2002:a05:600c:1c21:b0:401:7d3b:cc84 with SMTP id j33-20020a05600c1c2100b004017d3bcc84mr16977354wms.0.1699002148251; Fri, 03 Nov 2023 02:02:28 -0700 (PDT) Received: from carbon-x1.home (2a01cb008a4f7000834139aab36b6ffb.ipv6.abo.wanadoo.fr. [2a01:cb00:8a4f:7000:8341:39aa:b36b:6ffb]) by smtp.gmail.com with ESMTPSA id m21-20020a056000175500b0032326908972sm1346558wrf.17.2023.11.03.02.02.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 02:02:27 -0700 (PDT) From: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= <cleger@rivosinc.com> To: Paul Walmsley <paul.walmsley@sifive.com>, Palmer Dabbelt <palmer@dabbelt.com>, Albert Ou <aou@eecs.berkeley.edu>, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= <cleger@rivosinc.com> Subject: [PATCH] riscv: fix misaligned access handling of C.SWSP and C.SDSP Date: Fri, 3 Nov 2023 10:02:23 +0100 Message-ID: <20231103090223.702340-1-cleger@rivosinc.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Fri, 03 Nov 2023 02:02:52 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781532904340879141 X-GMAIL-MSGID: 1781532904340879141 |
Series |
riscv: fix misaligned access handling of C.SWSP and C.SDSP
|
|
Commit Message
Clément Léger
Nov. 3, 2023, 9:02 a.m. UTC
This is a backport of a fix that was done in OpenSBI: ec0559eb315b
("lib: sbi_misaligned_ldst: Fix handling of C.SWSP and C.SDSP").
Unlike C.LWSP/C.LDSP, these encodings can be used with the zero
register, so checking that the rs2 field is non-zero is unnecessary.
Additionally, the previous check was incorrect since it was checking
the immediate field of the instruction instead of the rs2 field.
Fixes: 956d705dd279 ("riscv: Unaligned load/store handling for M_MODE")
Signed-off-by: Clément Léger <cleger@rivosinc.com>
---
arch/riscv/kernel/traps_misaligned.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
Comments
Hello: This patch was applied to riscv/linux.git (fixes) by Palmer Dabbelt <palmer@rivosinc.com>: On Fri, 3 Nov 2023 10:02:23 +0100 you wrote: > This is a backport of a fix that was done in OpenSBI: ec0559eb315b > ("lib: sbi_misaligned_ldst: Fix handling of C.SWSP and C.SDSP"). > > Unlike C.LWSP/C.LDSP, these encodings can be used with the zero > register, so checking that the rs2 field is non-zero is unnecessary. > > Additionally, the previous check was incorrect since it was checking > the immediate field of the instruction instead of the rs2 field. > > [...] Here is the summary with links: - riscv: fix misaligned access handling of C.SWSP and C.SDSP https://git.kernel.org/riscv/c/22e0eb04837a You are awesome, thank you!
diff --git a/arch/riscv/kernel/traps_misaligned.c b/arch/riscv/kernel/traps_misaligned.c index 378f5b151443..5348d842c745 100644 --- a/arch/riscv/kernel/traps_misaligned.c +++ b/arch/riscv/kernel/traps_misaligned.c @@ -342,16 +342,14 @@ int handle_misaligned_store(struct pt_regs *regs) } else if ((insn & INSN_MASK_C_SD) == INSN_MATCH_C_SD) { len = 8; val.data_ulong = GET_RS2S(insn, regs); - } else if ((insn & INSN_MASK_C_SDSP) == INSN_MATCH_C_SDSP && - ((insn >> SH_RD) & 0x1f)) { + } else if ((insn & INSN_MASK_C_SDSP) == INSN_MATCH_C_SDSP) { len = 8; val.data_ulong = GET_RS2C(insn, regs); #endif } else if ((insn & INSN_MASK_C_SW) == INSN_MATCH_C_SW) { len = 4; val.data_ulong = GET_RS2S(insn, regs); - } else if ((insn & INSN_MASK_C_SWSP) == INSN_MATCH_C_SWSP && - ((insn >> SH_RD) & 0x1f)) { + } else if ((insn & INSN_MASK_C_SWSP) == INSN_MATCH_C_SWSP) { len = 4; val.data_ulong = GET_RS2C(insn, regs); } else {