From patchwork Mon Feb 26 05:56:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nylon Chen X-Patchwork-Id: 1904082 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=OimGHfdq; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sifive.com header.i=@sifive.com header.a=rsa-sha256 header.s=google header.b=ADM8khST; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TjqdB41J8z23qD for ; Mon, 26 Feb 2024 16:57:02 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=8bLyVmG9Rvp2X1F2yrJRsyCX7ZLfJmxlcKmYNHQ6ia4=; b=OimGHfdqBcRmiw PXSIZjDFhriltAfYNkD1ZlfFNvSE/FuY2w7xUSp3QOH6AorYKUi48ZunGxQSuBzgt9sCsdG29Znti Umvoh5hc7AaVNcBhOmYzY1PZbrTo1PCZcgLqbR9cPPKUPmh4Em7WZqOi2LlwIN7CKZXiflh8x6P/C SkEw+NzcW0PP6J4rQ7lTtJjQldCeVRqAc6rP8IeABgawKTuXYz1p9SPZkLHWJ1YlT59W7qtwVoh+a Nka24KeNHPf5F2y/rQm+rejySbUNj8UUx1rbtEadY82Vi3uNaWrvbhKG9Rfdv3pRzfSHY6OGbMkl6 mmN5In1jejHdC+YRT5qQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1reTyv-0000000Gaqs-3Tqr; Mon, 26 Feb 2024 05:56:53 +0000 Received: from mail-yb1-xb30.google.com ([2607:f8b0:4864:20::b30]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1reTys-0000000GaqP-416c for opensbi@lists.infradead.org; Mon, 26 Feb 2024 05:56:52 +0000 Received: by mail-yb1-xb30.google.com with SMTP id 3f1490d57ef6-dc6e080c1f0so2064359276.2 for ; Sun, 25 Feb 2024 21:56:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1708927009; x=1709531809; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=qPqfnffNZyNighhZTXkQKo0z83LOoucyNVvzMTLIsAA=; b=ADM8khSTVXMik5CcghlyvUNgx4nCwfIXUVUu5K0+NA0ycD8ZQ+UGOxbVS0hyHNNiy3 MjVIPbTgbndGYg3EF690KE/DcYEmlgc397pVU07rqzpZym5m1U7AsiPn9sxz11RzOcQT QiU0rxDdGgmseRRYyqjbk0SETnBEPbUDYxpFL8unRbLQ6WwA99q8g3xB6DcMnWUvF+Tu nz79t+OGg4nTaKyTnTihfhR8q93eXN3wWP5r1pcVowY87EA2Mf7499o/1L99Uv3goYzD jDkv4ytycaHs8iWyme3WIGyGYBHXl/KuDs3MJxKEhNAPhYATOgTXXZPHWvSLNT8Lf5+p /x9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708927009; x=1709531809; 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=qPqfnffNZyNighhZTXkQKo0z83LOoucyNVvzMTLIsAA=; b=qaM1HseBXHrkMBnvKsEFk8b5takjWehUUUsw0/+IQ6WxFVzAFNEGCUNzM4/yL1aoY/ BBHF17JXeh5RNwiYSXzXBrFGsUSFdKlIAsboOGBVFeElRU6kBZ6SUNk0Q/ziPhTYA+nm Ns0I7/EOwWmPT/1UgQyCZV4inyzzaJtf9hwdf+BuDp35jkKCOqsCBB2cFJUu7e8vvbB4 xkNwC0LelKJo85TUbIFPbDH8a/PtPnn4LgLhWMiy9tsPTkj3Mk8uehX1JOqw4Rn2vUZH 0XwBc2i6op8F0PI8m7jiDxh0As4fA8VTehQ/fFhOivx99RXEcUSR+Gbsr6OD4eIefiDg iQUw== X-Gm-Message-State: AOJu0YykAStgP/Ahu8XWG3uopCU1URM2t5AXSvKI7aObv1JVNWC2M2p4 YOXF99zUKGl8t0Msb2umSIszuychHnlzYdUltEJ+NJbGuYHTo5FOWUUDna3mQ41ASf1glGmasAU A7mHDqgml48gN/tTT0GNy2qxNRhYfk5d0p7pqnBb7+TvdDXcWq8njtLAol8HEoiGP3GDG9DvIQa UTejOJKKG83viQF+BgpKqEE+/1TYc6+OQscLz2uIoL6lbPKw== X-Google-Smtp-Source: AGHT+IFKFi1czAp2JhE3qjWuiFrSxvBreODgAECFyGH/yVPCsdenKVxzixhLYxHzIf9GbdphPISyuQ== X-Received: by 2002:a5b:451:0:b0:dc7:465a:2cb2 with SMTP id s17-20020a5b0451000000b00dc7465a2cb2mr4078964ybp.30.1708927009015; Sun, 25 Feb 2024 21:56:49 -0800 (PST) Received: from hsinchu15.internal.sifive.com (59-124-168-89.hinet-ip.hinet.net. [59.124.168.89]) by smtp.gmail.com with ESMTPSA id m9-20020a629409000000b006e4d336c420sm3343876pfe.69.2024.02.25.21.56.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 21:56:48 -0800 (PST) From: Nylon Chen To: opensbi@lists.infradead.org Cc: nylon7717@gmail.com, zong.li@sifive.com, "Nylon Chen" Subject: [PATCH] lib: sbi_misaligned_ldst: Add handling of C.LHU/C.LH and C.SH Date: Mon, 26 Feb 2024 13:56:44 +0800 Message-ID: <20240226055644.881161-1-nylon.chen@sifive.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240225_215651_081202_5725E9B4 X-CRM114-Status: UNSURE ( 7.27 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: "Nylon Chen" Added exception handling for compressed instructions C.LHU, C.LH, and C.SH from the zcb extension to the sbi_misaligned_ldst library. Signed-off-by: Nylon Chen --- include/sbi/riscv_encoding.h | 7 +++++++ lib/sbi/sbi_misaligned_ldst.c | 10 ++++++++++ 2 files changed, 17 insertions(+) Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:b30 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.0 T_SCC_BODY_TEXT_LINE No description available. X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: "Nylon Chen" Added exception handling for compressed instructions C.LHU, C.LH, and C.SH from the zcb extension to the sbi_misaligned_ldst library. Signed-off-by: Nylon Chen Reviewed-by: Anup Patel --- include/sbi/riscv_encoding.h | 7 +++++++ lib/sbi/sbi_misaligned_ldst.c | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/sbi/riscv_encoding.h b/include/sbi/riscv_encoding.h index e74cc0d..3d77e26 100644 --- a/include/sbi/riscv_encoding.h +++ b/include/sbi/riscv_encoding.h @@ -837,6 +837,13 @@ #define INSN_MATCH_C_FSWSP 0xe002 #define INSN_MASK_C_FSWSP 0xe003 +#define INSN_MATCH_C_LHU 0x8400 +#define INSN_MASK_C_LHU 0xfc43 +#define INSN_MATCH_C_LH 0x8440 +#define INSN_MASK_C_LH 0xfc43 +#define INSN_MATCH_C_SH 0x8c00 +#define INSN_MASK_C_SH 0xfc43 + #define INSN_MASK_WFI 0xffffff00 #define INSN_MATCH_WFI 0x10500000 diff --git a/lib/sbi/sbi_misaligned_ldst.c b/lib/sbi/sbi_misaligned_ldst.c index aa512de..9ca225a 100644 --- a/lib/sbi/sbi_misaligned_ldst.c +++ b/lib/sbi/sbi_misaligned_ldst.c @@ -123,6 +123,13 @@ int sbi_misaligned_load_handler(ulong addr, ulong tval2, ulong tinst, len = 4; #endif #endif + } else if ((insn & INSN_MASK_C_LHU) == INSN_MATCH_C_LHU) { + len = 2; + insn = RVC_RS2S(insn) << SH_RD; + } else if ((insn & INSN_MASK_C_LH) == INSN_MATCH_C_LH) { + len = 2; + shift = 8 * (sizeof(ulong) - len); + insn = RVC_RS2S(insn) << SH_RD; } else { uptrap.epc = regs->mepc; uptrap.cause = CAUSE_MISALIGNED_LOAD; @@ -237,6 +244,9 @@ int sbi_misaligned_store_handler(ulong addr, ulong tval2, ulong tinst, val.data_ulong = GET_F32_RS2C(insn, regs); #endif #endif + } else if ((insn & INSN_MASK_C_SH) == INSN_MATCH_C_SH) { + len = 2; + val.data_ulong = GET_RS2S(insn, regs); } else { uptrap.epc = regs->mepc; uptrap.cause = CAUSE_MISALIGNED_STORE;