From patchwork Tue May 21 13:58:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= X-Patchwork-Id: 1937472 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=sfyJw+a2; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=eq3KDiSC; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=Fh7Jid02; 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 4VkHh25l1Yz20dd for ; Wed, 22 May 2024 01:01:20 +1000 (AEST) 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:References:In-Reply-To: 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: List-Owner; bh=Dc1LS+uQ+lRn5xTDkp/jTAjG+I37ZktBSib0PJG5CCU=; b=sfyJw+a2PdKUWi L54w/N1IyDWEFb2iYkZLut9bQk3eoZZOBdCyPeadVVu1KRSBPdQKZBZDEWcof60vk1M2jcObn5paw NH5pq5vabeMiAoYWo7XOm2M4knkDDCP5iuV3J7/fLLuCUSLAgQzhQp80R749Qk/GU505nMMcTPUJa dDYkSghpw9ynrqosNKqJV9mTeNo8Og9E69vgzNY7dgpUr62Rfeli2uWs3sL9WgX4fhO1Zd6pOD04B /Rbactqiq2aI1UC9tohkw1htS+n1B5nKHIrl3LzmvAXEwdFQsoMpQkVSnLZTQuH0mx1mtla7N6md8 xjXdc7e8hWN3YaTlqjwg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s9QzI-00000000GlF-3toj; Tue, 21 May 2024 15:01:12 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s9Q0u-000000004qQ-0N6D for opensbi@bombadil.infradead.org; Tue, 21 May 2024 13:58:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:Content-Type :MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Sender:Reply-To:Content-ID:Content-Description; bh=4dymFE0MInKYpFF/GO5UdCeTf7QrNJlDbY11apOHTzc=; b=eq3KDiSCT8L0jPSPXB9OtQ8aAC vQwnvxks5vwParJvTidwwumX6krCmJFpQc0Y4bIKDu0/vxIw3dXSO+qoj6xw/+cq6QOlJ04TCJpRv GEDUHp9M2sjUNhsFKgo2lnnArNX9mD7k5JxxjTvqw8/2p9JLt/CAAOhuJDTChRz8lZYzusNr30lvS 437JZZgkAT/WCY171VmhP4NN34CGHKgXD3PctrY4gex72pESTbPKqj7tghoy0ENeMTZ9KBrYPROj/ 2tgNauXdGU7eeDurF+TH6qrpGZGM7rCDTr64C0Se+JnAuvwBsI0kKDTOx+WX68dWHM04Csn1sZ7eP h65JMPqA==; Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s9Q0q-00000006joP-3PZ7 for opensbi@lists.infradead.org; Tue, 21 May 2024 13:58:46 +0000 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-351c2c48effso803563f8f.3 for ; Tue, 21 May 2024 06:58:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1716299920; x=1716904720; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4dymFE0MInKYpFF/GO5UdCeTf7QrNJlDbY11apOHTzc=; b=Fh7Jid02gBRlmv4h4DSkwyJbcG3XqChlRUyx11puRNdnGng8oXvpTn3LplkithvjJv z+j9CpG9ryPDx7Fv5Wr5zGJLNfw3S+lReE0rcrd/p8R7k0zlGFPJGqmjDXgFz1XnuBf6 xt+NvDhIx8Da8qo/T/dzuOjBAjkxHVFAAd/oWWX/9EOaHK+XzwpnjzapQC8Rpusz94Fo Us97H/+Zmf9vIEXpojCRl/a5KBv7Av22JlAgHk5pyZye9+sb9pnfFc57N+gZ940Yv/2O y+K/qBdEIB+wT7wpAS6e8o3KO3LykTAHWpUciyd7kXOo5Ucc03oVriSNLi5GbtOrQMXJ n1Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716299920; x=1716904720; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4dymFE0MInKYpFF/GO5UdCeTf7QrNJlDbY11apOHTzc=; b=InUu+Nm7SgS8uI/4H5I2gnw94iex25dvJJv1PEsDMcp34fiiO6KDhMxPhMkNo6UL+d cPvMp/b1XQqpdnlKM4JxSM170kqKVk95in71sVjB8Kmm1//Rb3m628ytFJYWO88UPRiF c3RT4YxIqVc1KFHGNxJ8V/pAyyX1buy+kmVumG132W2bzdnS+tmEuB4da9s09tHvfAdv B/yD+3QjExssPftwgPOSCP3PYS88CL6iTBY7JVWqXnqziJtWsI3ucWSCLPA1nf3tL2eF gOsEEd1E+rgOatVUZJMFftvdecXw8XxD+/vxd/vWwFuajWZrcvCTX9qO4pNhMq0aqQ/D WF/A== X-Gm-Message-State: AOJu0YzGHcwLllX0FGDi8ULUm+8OCDIl14WTWvbS++SyTfUJoQgCayEt Xd3rSt82A0N5UhKsHyXLpBgF2FEesowv84CQmFFr4kniHyQq4cF/y1Jl9l9/C0YFXs9ef67vZLx c2OQ= X-Google-Smtp-Source: AGHT+IGBwBxEKiv61KKg/gAw5LoPSqWF57h8DerlESq88nFMKmiKRg3zFJzlRsF2rimminec9vj76Q== X-Received: by 2002:a05:600c:3b0a:b0:418:2719:6b14 with SMTP id 5b1f17b1804b1-41feac5a400mr243133985e9.3.1716299920741; Tue, 21 May 2024 06:58:40 -0700 (PDT) Received: from carbon-x1.. ([2a01:e0a:999:a3a0:a963:3072:e647:c890]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-41fccce73f5sm470275585e9.21.2024.05.21.06.58.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 06:58:40 -0700 (PDT) From: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= To: opensbi@lists.infradead.org Cc: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= , Anup Patel , Atish Patra Subject: [PATCH v1 1/5] lib: sbi: Add SVADU extension support Date: Tue, 21 May 2024 15:58:29 +0200 Message-ID: <20240521135835.371485-2-cleger@rivosinc.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240521135835.371485-1-cleger@rivosinc.com> References: <20240521135835.371485-1-cleger@rivosinc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240521_145844_952136_9B2DBB36 X-CRM114-Status: UNSURE ( 9.57 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.0 (/) X-Spam-Report: =?unknown-8bit?q?Spam_detection_software=2C_running_on_the_sy?= =?unknown-8bit?q?stem_=22desiato=2Einfradead=2Eorg=22=2C?= =?unknown-8bit?q?_has_NOT_identified_this_incoming_email_as_spam=2E__The_ori?= =?unknown-8bit?q?ginal?= =?unknown-8bit?q?_message_has_been_attached_to_this_so_you_can_view_it_or_la?= =?unknown-8bit?q?bel?= =?unknown-8bit?q?_similar_future_email=2E__If_you_have_any_questions=2C_see?= =?unknown-8bit?q?_the_administrator_of_that_system_for_details=2E?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_Content_preview=3A__Add_SVADU_ISA_extension_support=2E_By_?= =?unknown-8bit?q?default=2C_clear_the_ADUE?= =?unknown-8bit?q?_bit_to_maintain_backward-compatibility=2E_Signed-off-by=3A?= =?unknown-8bit?q?_Cl=C3=A9ment_L=C3=A9ger_=3Ccleger=40rivosinc=2Ecom=3E?= =?unknown-8bit?q?_---_include/sbi/riscv=5Fencoding=2Eh_=7C_1_+_include/sbi/s?= =?unknown-8bit?q?bi=5Fhart=2Eh_=7C_2_++_lib/sbi/sbi=5Fhart=2Ec?= =?unknown-8bit?q?_=7C_9_+++++++++_3_files_changed=2C_12_insertions=28+=29_?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_Content_analysis_details=3A___=280=2E0_points=2C_5=2E0_req?= =?unknown-8bit?q?uired=29?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_pts_rule_name______________description?= =?unknown-8bit?q?_----_----------------------_------------------------------?= =?unknown-8bit?q?--------------------?= =?unknown-8bit?q?_-0=2E0_RCVD=5FIN=5FDNSWL=5FNONE_____RBL=3A_Sender_listed_a?= =?unknown-8bit?q?t_https=3A//www=2Ednswl=2Eorg/=2C_no?= =?unknown-8bit?q?_trust?= =?unknown-8bit?b?IFsyYTAwOjE0NTA6NDg2NDoyMDowOjA6MDo0MmYgbGlzdGVkIGluXQ==?= =?unknown-8bit?b?IFtsaXN0LmRuc3dsLm9yZ10=?= =?unknown-8bit?q?_0=2E0_SPF=5FHELO=5FNONE__________SPF=3A_HELO_does_not_publ?= =?unknown-8bit?q?ish_an_SPF_Record?= =?unknown-8bit?q?_-0=2E0_SPF=5FPASS_______________SPF=3A_sender_matches_SPF_?= =?unknown-8bit?q?record?= =?unknown-8bit?q?_-0=2E1_DKIM=5FVALID_____________Message_has_at_least_one_v?= =?unknown-8bit?q?alid_DKIM_or_DK_signature?= =?unknown-8bit?q?_0=2E1_DKIM=5FSIGNED____________Message_has_a_DKIM_or_DK_si?= =?unknown-8bit?q?gnature=2C_not_necessarily_valid?= 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 Add SVADU ISA extension support. By default, clear the ADUE bit to maintain backward-compatibility. Signed-off-by: Clément Léger Reviewed-by: Anup Patel --- include/sbi/riscv_encoding.h | 1 + include/sbi/sbi_hart.h | 2 ++ lib/sbi/sbi_hart.c | 9 +++++++++ 3 files changed, 12 insertions(+) diff --git a/include/sbi/riscv_encoding.h b/include/sbi/riscv_encoding.h index d914828..477fa3a 100644 --- a/include/sbi/riscv_encoding.h +++ b/include/sbi/riscv_encoding.h @@ -211,6 +211,7 @@ #define ENVCFG_STCE (_ULL(1) << 63) #define ENVCFG_PBMTE (_ULL(1) << 62) +#define ENVCFG_ADUE (_ULL(1) << 61) #define ENVCFG_CDE (_ULL(1) << 60) #define ENVCFG_CBZE (_UL(1) << 7) #define ENVCFG_CBCFE (_UL(1) << 6) diff --git a/include/sbi/sbi_hart.h b/include/sbi/sbi_hart.h index cc78eec..10dd90c 100644 --- a/include/sbi/sbi_hart.h +++ b/include/sbi/sbi_hart.h @@ -63,6 +63,8 @@ enum sbi_hart_extensions { SBI_HART_EXT_SSCSRIND, /** Hart has Ssccfg extension */ SBI_HART_EXT_SSCCFG, + /** Hart has Svadu extension */ + SBI_HART_EXT_SVADU, /** Maximum index of Hart extension */ SBI_HART_EXT_MAX, diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c index cd974cc..2170a82 100644 --- a/lib/sbi/sbi_hart.c +++ b/lib/sbi/sbi_hart.c @@ -148,6 +148,14 @@ static void mstatus_init(struct sbi_scratch *scratch) csr_set(CSR_MSECCFG, MSECCFG_SSEED); csr_clear(CSR_MSECCFG, MSECCFG_USEED); } + + if (sbi_hart_has_extension(scratch, SBI_HART_EXT_SVADU)) { +#if __riscv_xlen == 32 + csr_clear(CSR_MENVCFGH, ENVCFG_ADUE >> 32); +#else + csr_clear(CSR_MENVCFG, ENVCFG_ADUE); +#endif + } } /* Disable all interrupts */ @@ -668,6 +676,7 @@ const struct sbi_hart_ext_data sbi_hart_ext[] = { __SBI_HART_EXT_DATA(smcdeleg, SBI_HART_EXT_SMCDELEG), __SBI_HART_EXT_DATA(sscsrind, SBI_HART_EXT_SSCSRIND), __SBI_HART_EXT_DATA(ssccfg, SBI_HART_EXT_SSCCFG), + __SBI_HART_EXT_DATA(svadu, SBI_HART_EXT_SVADU), }; _Static_assert(SBI_HART_EXT_MAX == array_size(sbi_hart_ext),