From patchwork Tue Feb 13 03:37:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13554429 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 026A5C4829A for ; Tue, 13 Feb 2024 03:37:54 +0000 (UTC) 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=/BghsH0I9HOiQxqa8ZLfH8XZoH70SMiVL79xTFgmDvM=; b=y5xF+6SBEfHkjr aog5IM+cIZX04gXnqAp/+wrVhH4V/Ley7UU2VZsUpmvlSbst1jSjY8HrjQVJyJk7d32eebFYm384A qguEO64EfRY1hSj3t0khqtlEabSvHIe1ukAbnltAbUhrHwd3OyxB8LOCPpA524dToxjNGvVNNq/7E A8IIanVztNfwU7u8Ahmi7/NC0FF9gFcyLtII9N5fMaCX69jgbI4AlKYJqi1kfk5lRHt/JktX4uRrP DRLr7kQnYn+2pv1zkspn2rgQLjQSE+aNFPy0DIPALvAU7/4bwEoScMvBhYKH6jlObauYmWipDZ94v wZ2EDpxtM0XBp2tovxJw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rZjcF-00000007rLP-0YRx; Tue, 13 Feb 2024 03:37:51 +0000 Received: from mail-oi1-x22d.google.com ([2607:f8b0:4864:20::22d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rZjcC-00000007rJt-0hvk for linux-riscv@lists.infradead.org; Tue, 13 Feb 2024 03:37:49 +0000 Received: by mail-oi1-x22d.google.com with SMTP id 5614622812f47-3c031776e0cso2024251b6e.0 for ; Mon, 12 Feb 2024 19:37:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1707795467; x=1708400267; 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=DbCTJ5IGhkP1LmE7TbGdUdt79kYAcBAyFyeC8QWmnbA=; b=Fda81RMSzPC+IelzNn7jGRv9y/rtXsRZ12AyuZuUDkOEamGm3XXVfipHfJovLezCG+ FgaIqflhwUyDsTKdOoqnmYkwZ+KQtTptxr4UZuGgRA7+77ll+U6OO761uij4r1DOWzGK jCgS+Yks4ecnhSER+VbOvQqhhTMEGCSxz81DJr1XkvPlDkNQqUCAFuyecVWsu8yGmZjc wCwy9WC2FVwTLHd4Bjnf10aVtv2xExjaRiVrFdBxPmbzLkfxPo0NLXAmvHy+6ON/CsBs qtV/HRhjd1pcaxPBOTMCv4r2P/xb8UiERPlZDaoYcUU8th3Z+Qht3IYEQwwJVfQ5UNIe otnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707795467; x=1708400267; 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=DbCTJ5IGhkP1LmE7TbGdUdt79kYAcBAyFyeC8QWmnbA=; b=OXDbmHKhfoI81YmZtMkkxMihSH+GqbHKTcUROPZdhfQf5o9OVxDSPdo43fngEQRfAq pBxFROOp5/apLJ7KR2y8weNOVZwMlRAUEZ/0j0AZuCDIAvjOeUoVqsVpq4M8Hww0F1MQ EUDNs/WDrpHgfd2Ai1dC7nfu8tsNfBOTiPJhjBya1nz7cK3zCtF7VFCsJNGzCSrNvkRu nA+xe8bdVvwVP39itLYNPP1XzJfogXQ+pg97RAmcFOMOAjTT6sebPUb/W5pbkE3Zbm0U 84JDMWTEbG7SKTzxPLLmAmo9PQV7NzyNoDQUcXdBZF8yvSkOz7XHZMGcNxtbx3S/SWOc AsYw== X-Forwarded-Encrypted: i=1; AJvYcCUUoW4cuC4XQBU9MKDU6fGefu4RufBHPc17SQegVcVsWaupcIvtJGiL4cq2aMIsZ/F/levZitme4gJM3PO1lzYYMo5xjtwWB57gXeFFZf+Y X-Gm-Message-State: AOJu0YyMTgAQn0uKpK3h2BABoC2Bgi80jKxSn9TsocJD25rAaLKPAHEy h4Vkh+FR0wrFOsRAQSnU9/FGPlHZ61F0YytxubHk3MyG35I7gih2ytw1JLcf5zvoGwqiHx2XpZe t X-Google-Smtp-Source: AGHT+IE+bElS9VOEBRZYkJMFWhhPq2JzIWq5hlj3C9o2gaDkJNP1gz6btAf9jVpFKefBHdsEY+u7+g== X-Received: by 2002:a05:6808:298d:b0:3c0:2a95:d3c6 with SMTP id ex13-20020a056808298d00b003c02a95d3c6mr8180720oib.23.1707795466997; Mon, 12 Feb 2024 19:37:46 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVG/9tEvERy1/zBWmZWATN9vy2GlKgAccgGMVroA50EeE7/5k30EBoGfGzSPQVGrAPHngcjrgBYvF+RvNslSmRsSoRygVpR8QgfaonMsrMhR8Acp+tY2Km1utekPImLqFVD+seoCQDmoakBzopdLkYZdAgIlb3PDYm9oavZ06D3knOGVT+4oc8cObDPMQHZZNXQ3vsaHWtRonDxS4SpF6AEPKFEoBLA/OuzoSULbJ3HoFmYvyFM Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id v11-20020a056a00148b00b006e0334e3dd9sm6188633pfu.76.2024.02.12.19.37.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 19:37:46 -0800 (PST) From: Samuel Holland To: Palmer Dabbelt Cc: Andrew Jones , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Stefan O'Rear , Samuel Holland , stable@vger.kernel.org Subject: [PATCH -fixes v2 1/4] riscv: Fix enabling cbo.zero when running in M-mode Date: Mon, 12 Feb 2024 19:37:32 -0800 Message-ID: <20240213033744.4069020-2-samuel.holland@sifive.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240213033744.4069020-1-samuel.holland@sifive.com> References: <20240213033744.4069020-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240212_193748_230323_984DA287 X-CRM114-Status: GOOD ( 10.32 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org When the kernel is running in M-mode, the CBZE bit must be set in the menvcfg CSR, not in senvcfg. Cc: Fixes: 43c16d51a19b ("RISC-V: Enable cbo.zero in usermode") Reviewed-by: Andrew Jones Signed-off-by: Samuel Holland --- (no changes since v1) arch/riscv/include/asm/csr.h | 2 ++ arch/riscv/kernel/cpufeature.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/riscv/include/asm/csr.h b/arch/riscv/include/asm/csr.h index 510014051f5d..2468c55933cd 100644 --- a/arch/riscv/include/asm/csr.h +++ b/arch/riscv/include/asm/csr.h @@ -424,6 +424,7 @@ # define CSR_STATUS CSR_MSTATUS # define CSR_IE CSR_MIE # define CSR_TVEC CSR_MTVEC +# define CSR_ENVCFG CSR_MENVCFG # define CSR_SCRATCH CSR_MSCRATCH # define CSR_EPC CSR_MEPC # define CSR_CAUSE CSR_MCAUSE @@ -448,6 +449,7 @@ # define CSR_STATUS CSR_SSTATUS # define CSR_IE CSR_SIE # define CSR_TVEC CSR_STVEC +# define CSR_ENVCFG CSR_SENVCFG # define CSR_SCRATCH CSR_SSCRATCH # define CSR_EPC CSR_SEPC # define CSR_CAUSE CSR_SCAUSE diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c index 89920f84d0a3..c5b13f7dd482 100644 --- a/arch/riscv/kernel/cpufeature.c +++ b/arch/riscv/kernel/cpufeature.c @@ -950,7 +950,7 @@ arch_initcall(check_unaligned_access_all_cpus); void riscv_user_isa_enable(void) { if (riscv_cpu_has_extension_unlikely(smp_processor_id(), RISCV_ISA_EXT_ZICBOZ)) - csr_set(CSR_SENVCFG, ENVCFG_CBZE); + csr_set(CSR_ENVCFG, ENVCFG_CBZE); } #ifdef CONFIG_RISCV_ALTERNATIVE From patchwork Tue Feb 13 03:37:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13554430 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DE03FC48260 for ; Tue, 13 Feb 2024 03:37:56 +0000 (UTC) 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=dEhj0s3fY9J42KaDjlaPWEU/ZXnpvuNu4AvgWvKA57E=; b=c86p0mQM9z8o/d SwAkHLJPdi2uZx9HYeQULrH6awNgL2Wj4igQi83UwNjjhyTEtFY2gQ3sMKZAnSB+5+/2veKh47yyN pSGoXkdDISQuwWd2ohLYeVjzyGlYL/U5wK5jp7gjSnZ2n3u0cKZrhhAnvqEC0fMZ/f0dzbq0iGIYg YVxwH47//bV73eAfTbCndAC4fN8/AuipqEbyeedd8QCtab8IJUSrFLHWPPxEWOinlXWH2EQKGUPC2 1ZjdkGor/uHguh7o+X1FuEk7fgbBtPVqPyfBHhbCIr4AV1di3ydyxIXchrjph4kb5AR4CjwgYFzWG /lgBfbr54qukh84JsU6g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rZjcH-00000007rMV-3n5k; Tue, 13 Feb 2024 03:37:53 +0000 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rZjcD-00000007rKF-0q3U for linux-riscv@lists.infradead.org; Tue, 13 Feb 2024 03:37:50 +0000 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-6da6b0eb2d4so2798831b3a.1 for ; Mon, 12 Feb 2024 19:37:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1707795468; x=1708400268; 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=Jim7Yvb6VmY6JIh3NrVmUpVFosXkDK31kcFuWFcbExg=; b=cYsGx2fTJZe7d5DtyagBX+WM2SKSvnh6rmNJLnb9x3qZFoP65w+wMtKTL/Q+WdCLxg JmQdQirs2iK2N9v5JjG2g4oPlCDqU8raggdh5vaV4Ov+jWzycIL94SdS3aIrGPATFpFl chio1kgVWyesMLUe9eMza0GVWWa3ofDBGgy/WAR/kRh74QSrYhuwXUYaLfORJsT9b5iQ f8H9Kj7Ffvk7XIfBFjBqBVf7kr4vI9jgw4UCzcoh3OB2ESy/q9xlyQmRhhn4TeksMz6C 7o01mpbAFHIyJ9BS8okcntmIOh3tevjYVDXTt/4Qft5Cy3Z7iYFeATPvFxoKlSwypvbB pyjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707795468; x=1708400268; 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=Jim7Yvb6VmY6JIh3NrVmUpVFosXkDK31kcFuWFcbExg=; b=ASKTOykB4XKkv1VSM1hjvI5f3qd+FI8NA4q9EMJSTmMO+ybatrzjoc/mAVJGDT2aHl HZg6c4pcFuZh22/AQ0s5vrV9W2jgWqtrL90SEqQpC3h6yv35mRw3fEB+aBUIzSUkBEr5 J9TmKARE6z75uNAluDB/RiNVHTxVn7kKJ5+ONWYX/4fK87znmD5/wNMT/eADmC07P5xe 0KdT3Y7ITo2kCQAOV5aChAczAyQXPr5V+VKYhgdiV3ZWVypN7yZKnqTXS7JkrRj47N1T h5xSIjh/bmUaJl5lXx93f6bQ1CcBNuBIujZmj1Lb5Qd0SOHHq7V0q+//vNgOlaKaGLvR t+ug== X-Gm-Message-State: AOJu0YxpMgpXMsZ1MiW4xDhF33eLB4l4m720b6muENDur1G/bxODZFPc t36z19TmkFnQxpzcdz1vAlQFb2IZQOMs095cXVSZi8tQlb5eqrdoqQLaqtzFSBA= X-Google-Smtp-Source: AGHT+IFbg2lMISlaKKUl+aHHxXR8JKhjEYDdVh8gzIjglnj+bxXQjxbQ6rcFpTy0yXOTe8Cd48dVAQ== X-Received: by 2002:aa7:8685:0:b0:6e0:5317:6772 with SMTP id d5-20020aa78685000000b006e053176772mr6713708pfo.1.1707795468162; Mon, 12 Feb 2024 19:37:48 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUtDxXelkbmm+CM8OLoo8WM4giaZcxrKGw5FC1up94u0V6jYFdJloVUPvWRQ0Omxq/n9YRlGpQXAYGpmEIR7+klWd8162GgnV8tbjfr9NG9RNhsxttq1+vCK9foEoC0wKl6LWJ+VJ9OhaR6eZRwNvpqxF3p8xEUSYrb8ksnc2H07sCCYQfJvwH5l0u3YCp2Z9mi1xR2N69GDslZW7YF Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id v11-20020a056a00148b00b006e0334e3dd9sm6188633pfu.76.2024.02.12.19.37.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 19:37:47 -0800 (PST) From: Samuel Holland To: Palmer Dabbelt Cc: Andrew Jones , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Stefan O'Rear , Samuel Holland Subject: [PATCH -fixes v2 2/4] dt-bindings: riscv: Add ratified privileged ISA versions Date: Mon, 12 Feb 2024 19:37:33 -0800 Message-ID: <20240213033744.4069020-3-samuel.holland@sifive.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240213033744.4069020-1-samuel.holland@sifive.com> References: <20240213033744.4069020-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240212_193749_258544_2FA36FDB X-CRM114-Status: UNSURE ( 9.27 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org The baseline for the RISC-V privileged ISA is version 1.10. Using features from newer versions of the privileged ISA requires the supported version to be reported by platform firmware, either in the ISA string (where the binding already accepts version numbers) or in the riscv,isa-extensions property. So far two newer versions are ratified. Signed-off-by: Samuel Holland Reviewed-by: Andrew Jones --- Changes in v2: - New patch for v2 .../devicetree/bindings/riscv/extensions.yaml | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Documentation/devicetree/bindings/riscv/extensions.yaml b/Documentation/devicetree/bindings/riscv/extensions.yaml index 63d81dc895e5..7faf22df01af 100644 --- a/Documentation/devicetree/bindings/riscv/extensions.yaml +++ b/Documentation/devicetree/bindings/riscv/extensions.yaml @@ -121,6 +121,16 @@ properties: version of the privileged ISA specification. # multi-letter extensions, sorted alphanumerically + - const: sm1p11 + description: + The standard Machine ISA v1.11, as ratified in the 20190608 + version of the privileged ISA specification. + + - const: sm1p12 + description: + The standard Machine ISA v1.12, as ratified in the 20211203 + version of the privileged ISA specification. + - const: smaia description: | The standard Smaia supervisor-level extension for the advanced @@ -134,6 +144,16 @@ properties: added by other RISC-V extensions in H/S/VS/U/VU modes and as ratified at commit a28bfae (Ratified (#7)) of riscv-state-enable. + - const: ss1p11 + description: + The standard Supervisor ISA v1.11, as ratified in the 20190608 + version of the privileged ISA specification. + + - const: ss1p12 + description: + The standard Supervisor ISA v1.12, as ratified in the 20211203 + version of the privileged ISA specification. + - const: ssaia description: | The standard Ssaia supervisor-level extension for the advanced From patchwork Tue Feb 13 03:37:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13554432 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0938EC48BC1 for ; Tue, 13 Feb 2024 03:37:57 +0000 (UTC) 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=kQJv/Pk40PUEFKxIYS7uBZhliQipdZbRc3tNVUnV7kE=; b=u3gjiiYmFmILzX 5P2iGNFM+FCMTdhbDs+SaoFR5EpIxANfPbtoiWhDqeF9B2roTCwwhxVUx/vpwCM8jNrVDIhJBYVzK 2r1OsrdlS1hVPlf47jsNFQTilFGpgCqQ5EtE53ng3jnFXtnb6cE3pqYw3Sqz/F1XzAZzdmfxwoK3W 8dG7FeKWlFP7Xhjs46hh1H7kDQvxnotqay0gWdwFxe26uO8Kx4Cw+QbnV9caprKU+v2dk2Q92Wc3C 3asRwoxOkFX6vC81hDwuItu0nQv0ztGGxHJ6YaaMEXmmvaxh96E9qMRaWJgfQBFBZXTWTPa5hjOFl YE9enB1mmi/Dna/y+OfA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rZjcI-00000007rMo-2JgJ; Tue, 13 Feb 2024 03:37:54 +0000 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rZjcD-00000007rKa-3jUu for linux-riscv@lists.infradead.org; Tue, 13 Feb 2024 03:37:51 +0000 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-6e0eacc5078so789241b3a.0 for ; Mon, 12 Feb 2024 19:37:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1707795469; x=1708400269; 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=rK79X93EtBW9qJrpk3LrvTi516ybVeRsHV0te+WOVM0=; b=YxGJ37mGk5sih+RbFfNwNLGlwCNZSu5ksirCp3yCtBQT+MUknE+3MYiDoZ91Cui/qQ we3GixmaqWPKoeZj5PfTl2GtpMSH442mqeiQtW5fcGrpeR6QZPE1axetGewQeSklJ9kT qIgPt4BEkZx48jldRHaMWXB3gdbKD96fQyr8Bpm6AqNweYcJL3w51XG5iQ+u5PEGjdrv BfzF5rPYCUD1vwpZS4/VUcOLqR++tB/wcem2EkkE2KjLLsZCYy29iAwPpUKxPFd/VlCO hQ3IYjzhUI9HuhT0y0jVdSOQtt0YwvISGxgcrm9mStif8K1/Mo1pWtApewrHIbcJqrRu Do2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707795469; x=1708400269; 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=rK79X93EtBW9qJrpk3LrvTi516ybVeRsHV0te+WOVM0=; b=DkseAge3oVAv9X1L1vaaQScfAiuigbqbAI/jr1S/X2huxTNAGjTKsCyyme3BEfg86F ym94ujEjgyqNnCNCUKy+nhNmJjILPmaz00jdmKylMpG6Wx4/SWlqrEdlPP+C5vVpn4mC ffgtMUz1daTZIE+vQHBVUm5pLitDoQcEEDuhh02fQR1Vdt2n7WPYYMnSY8LABWgM51y7 6VNWr1gfo5YHSVzTJjJlrdvD+YQMS6qepT60/0AXVCzGykpYBglj3EFiI4mHn3KKzLuK KWHpSHjIxSRBY//4A0o650pKsAJ4qPKzWhmFgczwAdtXQJF4JtUprxycpSUUtto8AbcC 5STA== X-Forwarded-Encrypted: i=1; AJvYcCVjeOrB3RyBh0LqctVpRK1A062i0x49i1CwdUZqJ74fEtn09nPtcAWGmWvyOMoh4Y8GbJ5Lw/vO0Mn4ZZTNmXrR29ILnNagcgHYg2CX8PP2 X-Gm-Message-State: AOJu0YzQ0Sptg4IGv2YU+f+GKWWibpLKanN+914IGPnuZ3UD3im+g0cg WqAXPZt/wR+ZkRpCw9ojHk95WTXtyeoxpp3QqtYJ2Oyei4bNzMWa2bsm4AFyJJ8= X-Google-Smtp-Source: AGHT+IE1f48UdkFqKO1xCaun/zy54ImvbzLVNqfi6oeRp+4H1Zh+DSqHGiI3HcT/8D8HMS0DDClSGQ== X-Received: by 2002:a05:6a00:189c:b0:6e0:31c4:3f09 with SMTP id x28-20020a056a00189c00b006e031c43f09mr9843628pfh.3.1707795469256; Mon, 12 Feb 2024 19:37:49 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCU80nXNvG9IvTEkeb+gI3X5g1/YZ1z9f+aFTwEsVZd0YtQwmVXoa/KRvIon26KAt5cNSlHOeF71a2FjUjqRP5PAlJ+nc8CF55EDOUaiOA/PhkgZtMyNbXe6JSVbSCfvp7M3BnJ0NMLC4buORby3LxdT+OtSBYTQh5DYywQasxUalqsHQ7bHg8gdayxPwY7rNeHYSVcWKeeIrg6JNnJHFCh85OAs1TwkJJvw1jzosIxo0AzhuK8B Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id v11-20020a056a00148b00b006e0334e3dd9sm6188633pfu.76.2024.02.12.19.37.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 19:37:48 -0800 (PST) From: Samuel Holland To: Palmer Dabbelt Cc: Andrew Jones , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Stefan O'Rear , Samuel Holland , stable@vger.kernel.org Subject: [PATCH -fixes v2 3/4] riscv: Add ISA extension parsing for Sm and Ss Date: Mon, 12 Feb 2024 19:37:34 -0800 Message-ID: <20240213033744.4069020-4-samuel.holland@sifive.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240213033744.4069020-1-samuel.holland@sifive.com> References: <20240213033744.4069020-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240212_193749_957336_7BD92BC0 X-CRM114-Status: GOOD ( 18.68 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Previously, all extension version numbers were ignored. However, the version number is important for these two extensions. The simplest way to implement this is to use a separate bitmap bit for each supported version, with each successive version implying all of the previous ones. This allows alternatives and riscv_has_extension_[un]likely() to work naturally. To avoid duplicate extensions in /proc/cpuinfo, the new successor_id field allows hiding all but the newest implemented version of an extension. Cc: # v6.7+ Signed-off-by: Samuel Holland --- Changes in v2: - New patch for v2 arch/riscv/include/asm/cpufeature.h | 1 + arch/riscv/include/asm/hwcap.h | 8 ++++++ arch/riscv/kernel/cpu.c | 5 ++++ arch/riscv/kernel/cpufeature.c | 42 +++++++++++++++++++++++++---- 4 files changed, 51 insertions(+), 5 deletions(-) diff --git a/arch/riscv/include/asm/cpufeature.h b/arch/riscv/include/asm/cpufeature.h index 0bd11862b760..ac71384e7bc4 100644 --- a/arch/riscv/include/asm/cpufeature.h +++ b/arch/riscv/include/asm/cpufeature.h @@ -61,6 +61,7 @@ struct riscv_isa_ext_data { const char *property; const unsigned int *subset_ext_ids; const unsigned int subset_ext_size; + const unsigned int successor_id; }; extern const struct riscv_isa_ext_data riscv_isa_ext[]; diff --git a/arch/riscv/include/asm/hwcap.h b/arch/riscv/include/asm/hwcap.h index 5340f818746b..5b51aa1db15b 100644 --- a/arch/riscv/include/asm/hwcap.h +++ b/arch/riscv/include/asm/hwcap.h @@ -80,13 +80,21 @@ #define RISCV_ISA_EXT_ZFA 71 #define RISCV_ISA_EXT_ZTSO 72 #define RISCV_ISA_EXT_ZACAS 73 +#define RISCV_ISA_EXT_SM1p11 74 +#define RISCV_ISA_EXT_SM1p12 75 +#define RISCV_ISA_EXT_SS1p11 76 +#define RISCV_ISA_EXT_SS1p12 77 #define RISCV_ISA_EXT_MAX 128 #define RISCV_ISA_EXT_INVALID U32_MAX #ifdef CONFIG_RISCV_M_MODE +#define RISCV_ISA_EXT_Sx1p11 RISCV_ISA_EXT_SM1p11 +#define RISCV_ISA_EXT_Sx1p12 RISCV_ISA_EXT_SM1p12 #define RISCV_ISA_EXT_SxAIA RISCV_ISA_EXT_SMAIA #else +#define RISCV_ISA_EXT_Sx1p11 RISCV_ISA_EXT_SS1p11 +#define RISCV_ISA_EXT_Sx1p12 RISCV_ISA_EXT_SS1p12 #define RISCV_ISA_EXT_SxAIA RISCV_ISA_EXT_SSAIA #endif diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c index d11d6320fb0d..2e6b90ed0d51 100644 --- a/arch/riscv/kernel/cpu.c +++ b/arch/riscv/kernel/cpu.c @@ -215,6 +215,11 @@ static void print_isa(struct seq_file *f, const unsigned long *isa_bitmap) if (!__riscv_isa_extension_available(isa_bitmap, riscv_isa_ext[i].id)) continue; + /* Only show the newest implemented version of an extension */ + if (riscv_isa_ext[i].successor_id != RISCV_ISA_EXT_INVALID && + __riscv_isa_extension_available(isa_bitmap, riscv_isa_ext[i].successor_id)) + continue; + /* Only multi-letter extensions are split by underscores */ if (strnlen(riscv_isa_ext[i].name, 2) != 1) seq_puts(f, "_"); diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c index c5b13f7dd482..8e10b50120e9 100644 --- a/arch/riscv/kernel/cpufeature.c +++ b/arch/riscv/kernel/cpufeature.c @@ -113,23 +113,29 @@ static bool riscv_isa_extension_check(int id) return true; } -#define _RISCV_ISA_EXT_DATA(_name, _id, _subset_exts, _subset_exts_size) { \ +#define _RISCV_ISA_EXT_DATA(_name, _id, _subset_exts, _subset_exts_size, _successor) { \ .name = #_name, \ .property = #_name, \ .id = _id, \ .subset_ext_ids = _subset_exts, \ - .subset_ext_size = _subset_exts_size \ + .subset_ext_size = _subset_exts_size, \ + .successor_id = _successor, \ } -#define __RISCV_ISA_EXT_DATA(_name, _id) _RISCV_ISA_EXT_DATA(_name, _id, NULL, 0) +#define __RISCV_ISA_EXT_DATA(_name, _id) \ + _RISCV_ISA_EXT_DATA(_name, _id, NULL, 0, RISCV_ISA_EXT_INVALID) /* Used to declare pure "lasso" extension (Zk for instance) */ #define __RISCV_ISA_EXT_BUNDLE(_name, _bundled_exts) \ - _RISCV_ISA_EXT_DATA(_name, RISCV_ISA_EXT_INVALID, _bundled_exts, ARRAY_SIZE(_bundled_exts)) + _RISCV_ISA_EXT_DATA(_name, RISCV_ISA_EXT_INVALID, \ + _bundled_exts, ARRAY_SIZE(_bundled_exts), RISCV_ISA_EXT_INVALID) /* Used to declare extensions that are a superset of other extensions (Zvbb for instance) */ #define __RISCV_ISA_EXT_SUPERSET(_name, _id, _sub_exts) \ - _RISCV_ISA_EXT_DATA(_name, _id, _sub_exts, ARRAY_SIZE(_sub_exts)) + _RISCV_ISA_EXT_DATA(_name, _id, _sub_exts, ARRAY_SIZE(_sub_exts), RISCV_ISA_EXT_INVALID) + +#define __RISCV_ISA_EXT_VERSION(_name, _id, _preds, _preds_size, _successor) \ + _RISCV_ISA_EXT_DATA(_name, _id, _preds, _preds_size, _successor) static const unsigned int riscv_zk_bundled_exts[] = { RISCV_ISA_EXT_ZBKB, @@ -201,6 +207,16 @@ static const unsigned int riscv_zvbb_exts[] = { RISCV_ISA_EXT_ZVKB }; +static const unsigned int riscv_sm_ext_versions[] = { + RISCV_ISA_EXT_SM1p11, + RISCV_ISA_EXT_SM1p12, +}; + +static const unsigned int riscv_ss_ext_versions[] = { + RISCV_ISA_EXT_SS1p11, + RISCV_ISA_EXT_SS1p12, +}; + /* * The canonical order of ISA extension names in the ISA string is defined in * chapter 27 of the unprivileged specification. @@ -299,8 +315,16 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = { __RISCV_ISA_EXT_DATA(zvksh, RISCV_ISA_EXT_ZVKSH), __RISCV_ISA_EXT_BUNDLE(zvksg, riscv_zvksg_bundled_exts), __RISCV_ISA_EXT_DATA(zvkt, RISCV_ISA_EXT_ZVKT), + __RISCV_ISA_EXT_VERSION(sm1p11, RISCV_ISA_EXT_SM1p11, riscv_sm_ext_versions, 0, + RISCV_ISA_EXT_SM1p12), + __RISCV_ISA_EXT_VERSION(sm1p12, RISCV_ISA_EXT_SM1p12, riscv_sm_ext_versions, 1, + RISCV_ISA_EXT_INVALID), __RISCV_ISA_EXT_DATA(smaia, RISCV_ISA_EXT_SMAIA), __RISCV_ISA_EXT_DATA(smstateen, RISCV_ISA_EXT_SMSTATEEN), + __RISCV_ISA_EXT_VERSION(ss1p11, RISCV_ISA_EXT_SS1p11, riscv_ss_ext_versions, 0, + RISCV_ISA_EXT_SS1p12), + __RISCV_ISA_EXT_VERSION(ss1p12, RISCV_ISA_EXT_SS1p12, riscv_ss_ext_versions, 1, + RISCV_ISA_EXT_INVALID), __RISCV_ISA_EXT_DATA(ssaia, RISCV_ISA_EXT_SSAIA), __RISCV_ISA_EXT_DATA(sscofpmf, RISCV_ISA_EXT_SSCOFPMF), __RISCV_ISA_EXT_DATA(sstc, RISCV_ISA_EXT_SSTC), @@ -414,6 +438,14 @@ static void __init riscv_parse_isa_string(unsigned long *this_hwcap, struct risc ; ++ext_end; + + /* + * As a special case for the Sm and Ss extensions, where the version + * number is important, include it in the extension name. + */ + if (ext_end - ext == 2 && tolower(ext[0]) == 's' && + (tolower(ext[1]) == 'm' || tolower(ext[1]) == 's')) + ext_end = isa; break; default: /* From patchwork Tue Feb 13 03:37:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13554431 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 859EFC4829A for ; Tue, 13 Feb 2024 03:37:57 +0000 (UTC) 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=5ZQ5QRoPNWSVZlfQT65msIMARQN8Y1A1rYhoXA0VJCE=; b=0G+ZlTeFcNWhFh IIKZT0kfmxXBBsNVyWUFH0rNaQTY8CTyYKBQP7YDtxrUJ+8L5+k6Quseyy2GysQcHs+ljJYp0mJU4 CNQYyTpnpUyGb7GBbFa4zX2wOlQwrmON+MIORu/LGEoMqVTk6GDafK8OAOg7krvIqI1j2PRrAiivB cDLiZHZ9kRHOpsK6KhYDPVIdDyV150/RfaqD7P6JXnZUKZTqtgHeFyDoatZo07ziVJlbsP4yBSZa/ munHlAYAMCgSfVENlTpUWsIGIeCxw9Sq03BQBa11HNJTGXA6ol8BBNEqxaNUGyv0XedozwYdGGjBu 30XAOu5CbvUxhwniN0qw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rZjcJ-00000007rNB-19fV; Tue, 13 Feb 2024 03:37:55 +0000 Received: from mail-oi1-x234.google.com ([2607:f8b0:4864:20::234]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rZjcF-00000007rLL-1tnJ for linux-riscv@lists.infradead.org; Tue, 13 Feb 2024 03:37:52 +0000 Received: by mail-oi1-x234.google.com with SMTP id 5614622812f47-3be9e11ee59so1944521b6e.1 for ; Mon, 12 Feb 2024 19:37:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1707795470; x=1708400270; 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=Xt5jr7Ps3GScSgM4o7qnaO9gd+HMLeMAVDsngYj3hEM=; b=bpyzuejKkJDY2DvumxPWLYBo9xGEPg7HAnuQ4ZGjmTXFyeXCUo4nbMf3McIAxo0he/ niUipnC+HP5UaAYOZw3SsJJ9pnBoeNPT0BWdXnDHB689Tquru1tgdM887yK/5gOOa3sT bNboTKY6QrhfZrRxmScdm4ao1nH2I3m4IyIqRBr4IQciNaIPZcz5+wQPWDSGL6DXFyBW bUZEAElpRhg7MRb5xphMAIiaROesUOodFO3KEkL8vbDRAJzjHicjTHUbg7Cb7HUjbHOa y9582wrpVCtcSu54NgqaXV/OPC4MkSkQDiXn6+T67/Pa8MkpvqJQHQGcuZtnTmDM7fCM kzEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707795470; x=1708400270; 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=Xt5jr7Ps3GScSgM4o7qnaO9gd+HMLeMAVDsngYj3hEM=; b=hwxFjk5snWJqZQe9jiaAFq42sv5FdQtjA0hwLgXmZUlxEXH/YNGa3fZX0EbO/SKG0l L1F/DltWm26jwlQ4ibFeS4I0pimev8VDifccoCQg6mCo1DCuYFUtCVO8cRUbCt+mm895 YvXKNTu4s2dV7qGfu0kvLjJv2SPujuIkHc8lHOVJjTqDGPVMXwwf5a5g5TJJGlqeCDYl EBU7qTTN7k3En5AqcBDyhLApr+HQp7a49VHtb8L/ssMVlujqLDUh/c4e6fxEePcyBdwl b5wQQBS04uHZneqcc837S7SZOBmzx08TmpjEVpkQBc9P8Y5lDWBRh8vVu8rvk3FQ/jqG tEwg== X-Forwarded-Encrypted: i=1; AJvYcCVapGTbf84vW1qVWSXcGk7F1N1q0mYZ9q1g4sUye4aTiKNiA5I9nQ1rfz9Lv0sGWxyeLteseQ4iV/RKLnuO6AXQlOv7s93nIrDjGVoqrcnN X-Gm-Message-State: AOJu0Yy1icOUt0JXHFUTmlaYJauSgWdh+77X+M88VnOMqy3GxXMCTSLq /Npr0FjByvwxbg/JV+YFhHkPE+1ot54KPZ+sPBjKLYkEjWYx3AqzRAJhOxebMRY= X-Google-Smtp-Source: AGHT+IFxDqSZbCOTRS1NHVNzCKhxZQyImRcw90Jz8SlHs0SSV2MQ75bbrukIBm2CKyA3KzugicZ3nw== X-Received: by 2002:a05:6808:318e:b0:3c0:3e26:5259 with SMTP id cd14-20020a056808318e00b003c03e265259mr3613268oib.55.1707795470293; Mon, 12 Feb 2024 19:37:50 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCU1Rc/sB1dWFTQwmx8p2iRKVv5LgWrJCCSeKr8P6rkMbd1uH7JfQSG1Hh74JOY/jKeiuxbEy02WDs3e/g0A9q30Q69s839YsJVcUxX+VSSGNa6J9l4dlN7oNmWZViRGWfRPnJ4HGTtAfEOZMIknw36bZj+YL2HlkbpMT607pb4e7y6zq/Em6Inl3R1cLd8ht02GMlwLAyCC8dUbcCwwaoAhdKHd9WN0x4go0e/Cp4Rmx44os1Oj Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id v11-20020a056a00148b00b006e0334e3dd9sm6188633pfu.76.2024.02.12.19.37.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 19:37:49 -0800 (PST) From: Samuel Holland To: Palmer Dabbelt Cc: Andrew Jones , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Stefan O'Rear , Samuel Holland , stable@vger.kernel.org Subject: [PATCH -fixes v2 4/4] riscv: Save/restore envcfg CSR during CPU suspend Date: Mon, 12 Feb 2024 19:37:35 -0800 Message-ID: <20240213033744.4069020-5-samuel.holland@sifive.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240213033744.4069020-1-samuel.holland@sifive.com> References: <20240213033744.4069020-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240212_193751_548252_D7951B0D X-CRM114-Status: GOOD ( 10.32 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org The value of the [ms]envcfg CSR is lost when entering a nonretentive idle state, so the CSR must be rewritten when resuming the CPU. Cc: # v6.7+ Fixes: 43c16d51a19b ("RISC-V: Enable cbo.zero in usermode") Signed-off-by: Samuel Holland --- Changes in v2: - Check for privileged ISA v1.12 instead of the specific CSR - Use riscv_has_extension_likely() instead of new ALTERNATIVE()s arch/riscv/include/asm/suspend.h | 1 + arch/riscv/kernel/suspend.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/arch/riscv/include/asm/suspend.h b/arch/riscv/include/asm/suspend.h index 02f87867389a..491296a335d0 100644 --- a/arch/riscv/include/asm/suspend.h +++ b/arch/riscv/include/asm/suspend.h @@ -14,6 +14,7 @@ struct suspend_context { struct pt_regs regs; /* Saved and restored by high-level functions */ unsigned long scratch; + unsigned long envcfg; unsigned long tvec; unsigned long ie; #ifdef CONFIG_MMU diff --git a/arch/riscv/kernel/suspend.c b/arch/riscv/kernel/suspend.c index 239509367e42..be03615486ed 100644 --- a/arch/riscv/kernel/suspend.c +++ b/arch/riscv/kernel/suspend.c @@ -15,6 +15,8 @@ void suspend_save_csrs(struct suspend_context *context) { context->scratch = csr_read(CSR_SCRATCH); + if (riscv_has_extension_likely(RISCV_ISA_EXT_Sx1p12)) + context->envcfg = csr_read(CSR_ENVCFG); context->tvec = csr_read(CSR_TVEC); context->ie = csr_read(CSR_IE); @@ -36,6 +38,8 @@ void suspend_save_csrs(struct suspend_context *context) void suspend_restore_csrs(struct suspend_context *context) { csr_write(CSR_SCRATCH, context->scratch); + if (riscv_has_extension_likely(RISCV_ISA_EXT_Sx1p12)) + csr_write(CSR_ENVCFG, context->envcfg); csr_write(CSR_TVEC, context->tvec); csr_write(CSR_IE, context->ie);