From patchwork Fri Jul 26 08:49:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yong-Xuan Wang X-Patchwork-Id: 13742503 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 32862C3DA7F for ; Fri, 26 Jul 2024 08:49: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:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id: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=Rj9PJXAzmeDeuqeG4m/g51bB1xLgwG66XP7s+3E8Cg4=; b=AGmzk2DOnVDsSX eA4X5suaC586w5D+C/Ce51Frf8rVUHut2QZmxGUzs/Oi2BoCvovRtKljxis/TtO6wQMx2sSq9M3h5 jA3o16NsPIalFMobMwEkf+U6H8Mc/ch6moFGg1pBT/NWurJfsHj9yAfextp7JtwNjPHMZDyzsHueo p9+PQvxOmIJnL9TKZqw3CynJllZADt+kO4f1jaOuBoGNfYBdRgy5nL3rRKkaJRwAHpn/I4xVeQTAT JPFxWE6VxRnMIyyMZzMQ+jedgfvFwI4ASyim+Qu2z9pzfZBi9U0vYKH4bUSr8S+zj5Zis23ofd2QS UGQBn3esabMb77i4q8IQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXGe6-00000003MzK-3VAa; Fri, 26 Jul 2024 08:49:50 +0000 Received: from mail-il1-x131.google.com ([2607:f8b0:4864:20::131]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXGe3-00000003MwV-0wyp for linux-riscv@lists.infradead.org; Fri, 26 Jul 2024 08:49:49 +0000 Received: by mail-il1-x131.google.com with SMTP id e9e14a558f8ab-389ccd2f0abso6511075ab.2 for ; Fri, 26 Jul 2024 01:49:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1721983786; x=1722588586; darn=lists.infradead.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=lHaLJR8yQLFRkt8rAB7DdlXcc+QGeMQ97xuqoUwdKRk=; b=CEOf2mTWx9xiWNYKERH9kW/jnUCB9QwXi/05TnVMHBVwUPYFNUh5l8ceNan5G/v7hU 9If17w2GYex3rOWoOtMyn0Z4FSc2Qh4zgADQKPuTD/uJ2spTGyG7J1QHDvBArbgzyZ96 XTgAazk70hKG3MvIoIPZIxsF2dBqRL5G5Rvu+cREiymA+OLOPLM1HhQ43TXQdPQm4/88 JqGtRCX5oMeszFkbtv0oduVMc7rH4GUSyZm/Fz7fIKIxaUur02qDwLxB+Dhjpxh4mTiD jciNE1BPV55bvCh3z8xgoNsC6DMtPjWyudsI5B8ctcMm6pfkVkyJKeZ61+lX7SPrfnLA 6Pwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721983786; x=1722588586; h=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=lHaLJR8yQLFRkt8rAB7DdlXcc+QGeMQ97xuqoUwdKRk=; b=tQEUbDCmL7NbkX9J2kjKFpR+b8MaFbQ1mUIgLPwI6iRrIrmmxfIEUM//28/z/7AKyv UP95KaciLARqFoysgEPNPzTITtsX5IXR9pDnveVs1IhLu0Q8lgKQYYSafiiVAhLTEp9U E5xII6CASWAx8mMCOjgYAgXxLcWpkfdQ5ylzHqqTOO5GGv1hDd1h52TJIsFKWndJ/Hqx 69s7172RwY8XE+cWzo+YNE+7OABtvJUJK2r0lHQBwotUbZZrgwgOL0R1zPQ7ovKn+yCL E6PL1akSrzpYDut3B0/4m5s9cMvmREp/Nspc5sJul6fd33l2+mnyWsB7zFJAzCDA+dVQ HA6w== X-Forwarded-Encrypted: i=1; AJvYcCUdk2ngWB3ynJMpmpxBsPylVTwJc7//CwbvMVUxu5UR2DLEkUlMAUCNghkdQuBsxuMiy6rEvxrX1uh+m8O0WZx+pN1igkfGJTln+g7phO0L X-Gm-Message-State: AOJu0YzO4O4j/DnaxSKZIMpdA1LOVdRQP26dcEDAC8ukBywMU2k7XphB W4bHQnpowiU3MNVYhePWfQJx3t9D4lnc+GbgwWhOdB75VAIaFH0sjLrdncX33hg= X-Google-Smtp-Source: AGHT+IEpIF/ScJ6b02sius+AyE85eDMTtR0ejoZVPHfsbpYUV9YjFuBW2ZygOt0+5bnn6XeVCylZ0w== X-Received: by 2002:a05:6e02:1b0e:b0:397:d9a9:8770 with SMTP id e9e14a558f8ab-39a2400a147mr59383125ab.23.1721983786004; Fri, 26 Jul 2024 01:49:46 -0700 (PDT) Received: from hsinchu26.internal.sifive.com (59-124-168-89.hinet-ip.hinet.net. [59.124.168.89]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7a9f816db18sm2049645a12.33.2024.07.26.01.49.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 01:49:45 -0700 (PDT) From: Yong-Xuan Wang To: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, kvm-riscv@lists.infradead.org, kvm@vger.kernel.org Cc: greentime.hu@sifive.com, vincent.chen@sifive.com, Yong-Xuan Wang , Jinyu Tang , Paul Walmsley , Palmer Dabbelt , Albert Ou , Andrew Jones , Anup Patel , Conor Dooley , Mayuresh Chitale , Atish Patra , Samuel Ortiz , Daniel Henrique Barboza , Samuel Holland , =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= , Evan Green , Andy Chiu , Xiao Wang , Alexandre Ghiti , Andrew Morton , David Hildenbrand , Kemeng Shi , Charlie Jenkins , Peter Xu , "Matthew Wilcox (Oracle)" , =?utf-8?b?QmrDtnJuIFTDtnBl?= =?utf-8?b?bA==?= , Leonardo Bras Subject: [PATCH v8 1/5] RISC-V: Add Svade and Svadu Extensions Support Date: Fri, 26 Jul 2024 16:49:26 +0800 Message-Id: <20240726084931.28924-2-yongxuan.wang@sifive.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240726084931.28924-1-yongxuan.wang@sifive.com> References: <20240726084931.28924-1-yongxuan.wang@sifive.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240726_014947_316480_352D3624 X-CRM114-Status: GOOD ( 16.70 ) 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: , MIME-Version: 1.0 Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Svade and Svadu extensions represent two schemes for managing the PTE A/D bits. When the PTE A/D bits need to be set, Svade extension intdicates that a related page fault will be raised. In contrast, the Svadu extension supports hardware updating of PTE A/D bits. Since the Svade extension is mandatory and the Svadu extension is optional in RVA23 profile, by default the M-mode firmware will enable the Svadu extension in the menvcfg CSR when only Svadu is present in DT. This patch detects Svade and Svadu extensions from DT and adds arch_has_hw_pte_young() to enable optimization in MGLRU and __wp_page_copy_user() when we have the PTE A/D bits hardware updating support. Co-developed-by: Jinyu Tang Signed-off-by: Jinyu Tang Signed-off-by: Yong-Xuan Wang Reviewed-by: Andrew Jones Reviewed-by: Alexandre Ghiti --- arch/riscv/Kconfig | 1 + arch/riscv/include/asm/csr.h | 1 + arch/riscv/include/asm/hwcap.h | 2 ++ arch/riscv/include/asm/pgtable.h | 13 ++++++++++++- arch/riscv/kernel/cpufeature.c | 12 ++++++++++++ 5 files changed, 28 insertions(+), 1 deletion(-) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 3ceec2ca84fa..014e512854a6 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -29,6 +29,7 @@ config RISCV select ARCH_HAS_FORTIFY_SOURCE select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_GIGANTIC_PAGE + select ARCH_HAS_HW_PTE_YOUNG select ARCH_HAS_KCOV select ARCH_HAS_KERNEL_FPU_SUPPORT if 64BIT && FPU select ARCH_HAS_MEMBARRIER_CALLBACKS diff --git a/arch/riscv/include/asm/csr.h b/arch/riscv/include/asm/csr.h index 25966995da04..524cd4131c71 100644 --- a/arch/riscv/include/asm/csr.h +++ b/arch/riscv/include/asm/csr.h @@ -195,6 +195,7 @@ /* xENVCFG flags */ #define ENVCFG_STCE (_AC(1, ULL) << 63) #define ENVCFG_PBMTE (_AC(1, ULL) << 62) +#define ENVCFG_ADUE (_AC(1, ULL) << 61) #define ENVCFG_CBZE (_AC(1, UL) << 7) #define ENVCFG_CBCFE (_AC(1, UL) << 6) #define ENVCFG_CBIE_SHIFT 4 diff --git a/arch/riscv/include/asm/hwcap.h b/arch/riscv/include/asm/hwcap.h index b18b202ca141..b0435fda09ae 100644 --- a/arch/riscv/include/asm/hwcap.h +++ b/arch/riscv/include/asm/hwcap.h @@ -93,6 +93,8 @@ #define RISCV_ISA_EXT_ZCF 84 #define RISCV_ISA_EXT_ZCMOP 85 #define RISCV_ISA_EXT_ZAWRS 86 +#define RISCV_ISA_EXT_SVADE 87 +#define RISCV_ISA_EXT_SVADU 88 #define RISCV_ISA_EXT_XLINUXENVCFG 127 diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index 089f3c9f56a3..6f1a0534f319 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -120,6 +120,7 @@ #include #include #include +#include #define __page_val_to_pfn(_val) (((_val) & _PAGE_PFN_MASK) >> _PAGE_PFN_SHIFT) @@ -288,7 +289,6 @@ static inline pte_t pud_pte(pud_t pud) } #ifdef CONFIG_RISCV_ISA_SVNAPOT -#include static __always_inline bool has_svnapot(void) { @@ -649,6 +649,17 @@ static inline pgprot_t pgprot_writecombine(pgprot_t _prot) return __pgprot(prot); } +/* + * Both Svade and Svadu control the hardware behavior when the PTE A/D bits need to be set. By + * default the M-mode firmware enables the hardware updating scheme when only Svadu is present in + * DT. + */ +#define arch_has_hw_pte_young arch_has_hw_pte_young +static inline bool arch_has_hw_pte_young(void) +{ + return riscv_has_extension_unlikely(RISCV_ISA_EXT_SVADU); +} + /* * THP functions */ diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c index 0366dc3baf33..2a9cdfae21c6 100644 --- a/arch/riscv/kernel/cpufeature.c +++ b/arch/riscv/kernel/cpufeature.c @@ -156,6 +156,16 @@ static int riscv_ext_zcf_validate(const struct riscv_isa_ext_data *data, return -EPROBE_DEFER; } +static int riscv_ext_svadu_validate(const struct riscv_isa_ext_data *data, + const unsigned long *isa_bitmap) +{ + /* SVADE has already been detected, use SVADE only */ + if (__riscv_isa_extension_available(isa_bitmap, RISCV_ISA_EXT_SVADE)) + return -EOPNOTSUPP; + + return 0; +} + static const unsigned int riscv_zk_bundled_exts[] = { RISCV_ISA_EXT_ZBKB, RISCV_ISA_EXT_ZBKC, @@ -402,6 +412,8 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = { __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), + __RISCV_ISA_EXT_DATA(svade, RISCV_ISA_EXT_SVADE), + __RISCV_ISA_EXT_DATA_VALIDATE(svadu, RISCV_ISA_EXT_SVADU, riscv_ext_svadu_validate), __RISCV_ISA_EXT_DATA(svinval, RISCV_ISA_EXT_SVINVAL), __RISCV_ISA_EXT_DATA(svnapot, RISCV_ISA_EXT_SVNAPOT), __RISCV_ISA_EXT_DATA(svpbmt, RISCV_ISA_EXT_SVPBMT), From patchwork Fri Jul 26 08:49:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yong-Xuan Wang X-Patchwork-Id: 13742504 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 78D2FC3DA7F for ; Fri, 26 Jul 2024 08:49: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:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id: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=CQEtx5C3holwquz4DBunG35+AS40fA8Rq7yrnJwTq7g=; b=YT7gYGP2v8SvEV guPj3jqBo9N9ftSlht10UCckg3oH8PnhC/simwZanSr1wmk16NZ8LnYSEK3kYDROFNZDTRHmr0/Lo Wvd8Hgyr1ve0uMYKeqJaRMQfon5pdR00FPXdiwgXHLrf9eLfuVTCq5DfezFP+FwH9nCp6aHQ/lmXh UtY9DEb+MQxKmB0au9b9n+PHlbBGyXNpZU0IO59Nqj2zfgzKp0ws9RDOEzZcOCL3JheuE6pEgYlJD JAbnRfhfVjVFhf3ODp9oiKxlGMvQWXQ/sT8PPnCzRyMAbT7o6Vg2W6CutH6HvLP0x7Lsae90cvwfj oIiH7UHtrDuIgNgJ923g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXGeA-00000003N1k-1kX9; Fri, 26 Jul 2024 08:49:54 +0000 Received: from mail-oo1-xc2b.google.com ([2607:f8b0:4864:20::c2b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXGe7-00000003MzN-2E3n for linux-riscv@lists.infradead.org; Fri, 26 Jul 2024 08:49:53 +0000 Received: by mail-oo1-xc2b.google.com with SMTP id 006d021491bc7-5d4fb707895so470001eaf.0 for ; Fri, 26 Jul 2024 01:49:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1721983790; x=1722588590; darn=lists.infradead.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=77ZeIPjPX018h5j/Du3ed2s3nc75ljoul3aJ99owNM0=; b=ILG0hEjMTacgqIsMv+gh7Ri9lqw2jyfLfI6guGxSF6c7N4otJCI+bEvW4t53yy/mHm J69cbTXoupbRwsGGuXfNE8rOsna3UCkFqsxXK5zAonC5egJrX0YbyB9JB7iwQv3J/KH6 cTCV60dEMJ33rwh9fdtJGFJFzo9leTFNL+65bbA6bIXS324y2tk4csr9KoEyEbKD3rqR uE5GTsDt6vQgwAcAkB0pL0XS6u3oLXMxc1fcVVL+mgw4Yp34nfC6y5T6LWB9ioajopLp bCvIv2i6px/uG8sw6kI0TfNAqdyAh2rVP4rNB6zVCFASYsdQvval4sQ3xW6k/WQmoLm4 cCvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721983790; x=1722588590; h=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=77ZeIPjPX018h5j/Du3ed2s3nc75ljoul3aJ99owNM0=; b=L1Q6wLMHDAL5eJjuQ8n5XNB/8j7UPQ57KxSYANHr47jrlscjX36oOOi7gRswoxB5xd oxW+IBjUtBF8EIAd3DQ7SLJfJS7AZqsjr4YV2zqmDGYiHy4LJpfimsqF5LDeE7w3DrdE gi7E2xpn73Hano6BKKFJGCh7VAHo+Q1N8kC59MnU//COrAggjcsdy3BFD935NdPLzrgB V2i7uWG3g0ZFyu9UuWhiG8vloi/zSazSQJlRVCthsd3HqY4498EmUCla5j9zgDiwj1vG mGw0P2np8hUXCh3QHgzTbOzfMRo4nwqNwbzlzR49zwV+Ycg7Qhyk5I+3QxCdwTE62Qmy Zzjw== X-Forwarded-Encrypted: i=1; AJvYcCWGzz63llbkJogDykr8pecRK9bKhBqufr3Sq2wJC+ZURBJoymLeXqooQklCEPA6W+36rRmcQkDaM6K++k4hnt5/wWWJU6k4xgPQU7xNLpDD X-Gm-Message-State: AOJu0YxPUL2OHWbqgriBMCPkhw6HePOeZmxpUfLy1eXJkiG8jwHxrfWM lhY8vAbCJp58k5337Hr1flJ//jYwrdMkKJo8A+vOKNIagfN4P9YxcZTj2rz+QsA= X-Google-Smtp-Source: AGHT+IFWUVeizwcBPBvvU0CwwN+HhSdGaM3PUv2PgwHw7ovlutORf8Wnz0oqxg0bCN2ABKZmavFvLQ== X-Received: by 2002:a05:6358:784:b0:1a4:8048:56df with SMTP id e5c5f4694b2df-1acf88fa089mr701897855d.22.1721983790331; Fri, 26 Jul 2024 01:49:50 -0700 (PDT) Received: from hsinchu26.internal.sifive.com (59-124-168-89.hinet-ip.hinet.net. [59.124.168.89]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7a9f816db18sm2049645a12.33.2024.07.26.01.49.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 01:49:50 -0700 (PDT) From: Yong-Xuan Wang To: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, kvm-riscv@lists.infradead.org, kvm@vger.kernel.org Cc: greentime.hu@sifive.com, vincent.chen@sifive.com, Yong-Xuan Wang , Conor Dooley , Rob Herring , Krzysztof Kozlowski , Paul Walmsley , Palmer Dabbelt , Albert Ou , devicetree@vger.kernel.org Subject: [PATCH v8 2/5] dt-bindings: riscv: Add Svade and Svadu Entries Date: Fri, 26 Jul 2024 16:49:27 +0800 Message-Id: <20240726084931.28924-3-yongxuan.wang@sifive.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240726084931.28924-1-yongxuan.wang@sifive.com> References: <20240726084931.28924-1-yongxuan.wang@sifive.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240726_014951_660868_2D2939C0 X-CRM114-Status: GOOD ( 10.91 ) 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: , MIME-Version: 1.0 Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add entries for the Svade and Svadu extensions to the riscv,isa-extensions property. Signed-off-by: Yong-Xuan Wang Acked-by: Conor Dooley Reviewed-by: Alexandre Ghiti Reviewed-by: Samuel Holland --- .../devicetree/bindings/riscv/extensions.yaml | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Documentation/devicetree/bindings/riscv/extensions.yaml b/Documentation/devicetree/bindings/riscv/extensions.yaml index a06dbc6b4928..b3885756766d 100644 --- a/Documentation/devicetree/bindings/riscv/extensions.yaml +++ b/Documentation/devicetree/bindings/riscv/extensions.yaml @@ -153,6 +153,34 @@ properties: ratified at commit 3f9ed34 ("Add ability to manually trigger workflow. (#2)") of riscv-time-compare. + - const: svade + description: | + The standard Svade supervisor-level extension for SW-managed PTE A/D + bit updates as ratified in the 20240213 version of the privileged + ISA specification. + + Both Svade and Svadu extensions control the hardware behavior when + the PTE A/D bits need to be set. The default behavior for the four + possible combinations of these extensions in the device tree are: + 1) Neither Svade nor Svadu present in DT => It is technically + unknown whether the platform uses Svade or Svadu. Supervisor + software should be prepared to handle either hardware updating + of the PTE A/D bits or page faults when they need updated. + 2) Only Svade present in DT => Supervisor must assume Svade to be + always enabled. + 3) Only Svadu present in DT => Supervisor must assume Svadu to be + always enabled. + 4) Both Svade and Svadu present in DT => Supervisor must assume + Svadu turned-off at boot time. To use Svadu, supervisor must + explicitly enable it using the SBI FWFT extension. + + - const: svadu + description: | + The standard Svadu supervisor-level extension for hardware updating + of PTE A/D bits as ratified in the 20240528 version of the + privileged ISA specification. Please refer to Svade dt-binding + description for more details. + - const: svinval description: The standard Svinval supervisor-level extension for fine-grained From patchwork Fri Jul 26 08:49:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yong-Xuan Wang X-Patchwork-Id: 13742505 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 914DEC3DA7F for ; Fri, 26 Jul 2024 08:50:03 +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:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id: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=Dx43pk/9TgzZNt2hZlNypg1+cF+JgIuYsvl+FnLA+XA=; b=45qmY0D1xelB2I mgzoXMCI78zIGd/fEFrf5L48bHuTpTna1HeYhgbfvPQPP5PQS8Z/SDnp1UlZ1U9WJo9yc11wqtoWe DeUN8rM7Fbj555o1oLO8ZWI8uOmpUm5qFRaGa7js+gi6Q58mxXx/XnGWDJ4bbdCBH9FnbRb2RZ8dF x1ytGXpbrlnMi9RRWEbrv9f6qIwYGiRmevuS2paLwpZyui2gz1cPvfTr6/yLXsvLJ8/nA2iZeEijw l9Yc2E2VSlnp1/CuN7JGc9nwP5U7nVx0OgzOkZA8BfbQEmhJGCZcKMcLwYHIxNVKBffmv+lat+iOA 9giOkHyszjZZ4mQ/snMQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXGeG-00000003N7K-1drF; Fri, 26 Jul 2024 08:50:00 +0000 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXGeB-00000003N2E-2ADn for linux-riscv@lists.infradead.org; Fri, 26 Jul 2024 08:49:57 +0000 Received: by mail-pg1-x52f.google.com with SMTP id 41be03b00d2f7-7a103ac7be3so529586a12.3 for ; Fri, 26 Jul 2024 01:49:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1721983794; x=1722588594; darn=lists.infradead.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=34BL/sh0DZ6mInNrtxWV/KGc2m1HMCFv7aaLw74E+qY=; b=E8gXEAc39B6+tc7pwbU+Nl2RO8nW+ORqVTgzz2BpUV02TtWphdpha+eOJOA+0/fZ6c kOZzd/kEoRViR1lOIllODhDfKADuvwFCid9NxszDNs7JkNSCJmUP84jOP3YzQn8EgNiI TEqXjwlyKf3CdVdhyzg7IbwnzJBJw96zZDhEQqNuvEqhOhy9Evt1x9/hOB8d0uZlfDl9 tzVt02I86KK58AfnDhTXHzUTdwhCzvJ1yhWA8OYMMBmXCUdgYB8Wvd3kwe0fvjAn7Yx3 2S+uCUqacrWEOUCIXvQ8R1voMJBhMr5dDR0Sv+jwZf6b1KR8HT+P3aHFSfHF2NROUitu +v8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721983794; x=1722588594; h=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=34BL/sh0DZ6mInNrtxWV/KGc2m1HMCFv7aaLw74E+qY=; b=NlGkiawPb7cGMzTFraMgRLFyBdrgZ5LazhJk3hJcwlqncq73AHrn1+Bj9Qij2fJcpt 53UCnque2aD4tmQXQ6jXFYkGk9g+x0PtBh/DfnEpoCfR9znGda4i6zmHVFJMrgXydZsS GZ+7ipNymD5021s5xhmMqJ0Fcoa1Y2+vReZ6v3it5jl6fdg9vLISaI1aeCYxZus7e8dD ikkdrKz0AjqEzB0BiSlTHAl1D7RI699D69qCqDUUKAfQNWMJdd8FmwN77oOumfp9xkAB Bc2qbg/m2xEgbrYLkrAbFLllFle5RyEH67TuGGj/7t2a1sePk60fZWq1AGhp5aE9nwqY Ek5g== X-Forwarded-Encrypted: i=1; AJvYcCVwCOZegzAxTmZjXJCX/ASCXIfiYS41YjAEP1IafgRPREFcqgbyPraLTC7KjvwsUnPxyY4RJ5o8u49BSKEkqf737KOTPb8YcZyRIGU4lDym X-Gm-Message-State: AOJu0YxIFxFNMj50AvT1/vBmoRmewzRmQoRBeF5KMYwkwbYeolnaGc77 CuhDVGkaZO0/BPaaW1aRuhlFFYT/G2MYueB4tMQ3u5oRftF/NFP6fLwuYATZDkQ= X-Google-Smtp-Source: AGHT+IEsc2Lj8N3rTxeNWx9ih1V5tMTbZiHBB2CSobNOVFD8y6Tw1gE2nmjH3/iQ9cJEnLEnKggdVw== X-Received: by 2002:a05:6a20:a115:b0:1c2:8904:14c2 with SMTP id adf61e73a8af0-1c47b2d151amr5398963637.37.1721983794278; Fri, 26 Jul 2024 01:49:54 -0700 (PDT) Received: from hsinchu26.internal.sifive.com (59-124-168-89.hinet-ip.hinet.net. [59.124.168.89]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7a9f816db18sm2049645a12.33.2024.07.26.01.49.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 01:49:54 -0700 (PDT) From: Yong-Xuan Wang To: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, kvm-riscv@lists.infradead.org, kvm@vger.kernel.org Cc: greentime.hu@sifive.com, vincent.chen@sifive.com, Yong-Xuan Wang , Anup Patel , Atish Patra , Paul Walmsley , Palmer Dabbelt , Albert Ou Subject: [PATCH v8 3/5] RISC-V: KVM: Add Svade and Svadu Extensions Support for Guest/VM Date: Fri, 26 Jul 2024 16:49:28 +0800 Message-Id: <20240726084931.28924-4-yongxuan.wang@sifive.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240726084931.28924-1-yongxuan.wang@sifive.com> References: <20240726084931.28924-1-yongxuan.wang@sifive.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240726_014955_641800_37DDEEA5 X-CRM114-Status: GOOD ( 12.83 ) 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: , MIME-Version: 1.0 Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org We extend the KVM ISA extension ONE_REG interface to allow VMM tools to detect and enable Svade and Svadu extensions for Guest/VM. Since the henvcfg.ADUE is read-only zero if the menvcfg.ADUE is zero, the Svadu extension is available for Guest/VM and the Svade extension is allowed to disabledonly when arch_has_hw_pte_young() is true. Signed-off-by: Yong-Xuan Wang Reviewed-by: Andrew Jones Reviewed-by: Samuel Holland --- arch/riscv/include/uapi/asm/kvm.h | 2 ++ arch/riscv/kvm/vcpu.c | 4 ++++ arch/riscv/kvm/vcpu_onereg.c | 15 +++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/arch/riscv/include/uapi/asm/kvm.h b/arch/riscv/include/uapi/asm/kvm.h index e97db3296456..85bbc472989d 100644 --- a/arch/riscv/include/uapi/asm/kvm.h +++ b/arch/riscv/include/uapi/asm/kvm.h @@ -175,6 +175,8 @@ enum KVM_RISCV_ISA_EXT_ID { KVM_RISCV_ISA_EXT_ZCF, KVM_RISCV_ISA_EXT_ZCMOP, KVM_RISCV_ISA_EXT_ZAWRS, + KVM_RISCV_ISA_EXT_SVADE, + KVM_RISCV_ISA_EXT_SVADU, KVM_RISCV_ISA_EXT_MAX, }; diff --git a/arch/riscv/kvm/vcpu.c b/arch/riscv/kvm/vcpu.c index 8d7d381737ee..c78061a6d68b 100644 --- a/arch/riscv/kvm/vcpu.c +++ b/arch/riscv/kvm/vcpu.c @@ -544,6 +544,10 @@ static void kvm_riscv_vcpu_setup_config(struct kvm_vcpu *vcpu) if (riscv_isa_extension_available(isa, ZICBOZ)) cfg->henvcfg |= ENVCFG_CBZE; + if (riscv_isa_extension_available(isa, SVADU) && + !riscv_isa_extension_available(isa, SVADE)) + cfg->henvcfg |= ENVCFG_ADUE; + if (riscv_has_extension_unlikely(RISCV_ISA_EXT_SMSTATEEN)) { cfg->hstateen0 |= SMSTATEEN0_HSENVCFG; if (riscv_isa_extension_available(isa, SSAIA)) diff --git a/arch/riscv/kvm/vcpu_onereg.c b/arch/riscv/kvm/vcpu_onereg.c index b319c4c13c54..b3f58908902a 100644 --- a/arch/riscv/kvm/vcpu_onereg.c +++ b/arch/riscv/kvm/vcpu_onereg.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #define KVM_RISCV_BASE_ISA_MASK GENMASK(25, 0) @@ -38,6 +39,8 @@ static const unsigned long kvm_isa_ext_arr[] = { KVM_ISA_EXT_ARR(SSAIA), KVM_ISA_EXT_ARR(SSCOFPMF), KVM_ISA_EXT_ARR(SSTC), + KVM_ISA_EXT_ARR(SVADE), + KVM_ISA_EXT_ARR(SVADU), KVM_ISA_EXT_ARR(SVINVAL), KVM_ISA_EXT_ARR(SVNAPOT), KVM_ISA_EXT_ARR(SVPBMT), @@ -110,6 +113,12 @@ static bool kvm_riscv_vcpu_isa_enable_allowed(unsigned long ext) case KVM_RISCV_ISA_EXT_SSCOFPMF: /* Sscofpmf depends on interrupt filtering defined in ssaia */ return __riscv_isa_extension_available(NULL, RISCV_ISA_EXT_SSAIA); + case KVM_RISCV_ISA_EXT_SVADU: + /* + * The henvcfg.ADUE is read-only zero if menvcfg.ADUE is zero. + * Guest OS can use Svadu only when host OS enable Svadu. + */ + return arch_has_hw_pte_young(); case KVM_RISCV_ISA_EXT_V: return riscv_v_vstate_ctrl_user_allowed(); default: @@ -181,6 +190,12 @@ static bool kvm_riscv_vcpu_isa_disable_allowed(unsigned long ext) /* Extensions which can be disabled using Smstateen */ case KVM_RISCV_ISA_EXT_SSAIA: return riscv_has_extension_unlikely(RISCV_ISA_EXT_SMSTATEEN); + case KVM_RISCV_ISA_EXT_SVADE: + /* + * The henvcfg.ADUE is read-only zero if menvcfg.ADUE is zero. + * Svade is not allowed to disable when the platform use Svade. + */ + return arch_has_hw_pte_young(); default: break; } From patchwork Fri Jul 26 08:49:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yong-Xuan Wang X-Patchwork-Id: 13742506 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 3D046C3DA49 for ; Fri, 26 Jul 2024 08:50:10 +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:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id: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=cLuYxITzgEAi8w3CK1NaCEhRElm5Vyy+dSEsIO3vIQY=; b=RCVdmPt2fIdea+ JH1DTYwUynQf/XcBxASuoX2zOv9B6S4u27oCYYtHfoKHoSq6lZLxJdqPaVa9reTM9nMAGpmp764jZ TBvzhYwfHh3dESoC3m2qipvSws5IfWsfctOQnUIMZd1h7d2fHf6aGLJlK3O2gQv61Ghibe2EYhgSn bljuk13lorvpsthXYWeFk+tkUqoAophw9zH3Uw9EC7l+qgH3s0sNL7EBF9aqJFGorBODJuOiJZ/KP 3sLnyh1v/kYtSjTi6X5dUjQV1MPsggd1dO+/wlZifJB6wX4Xqu3zSh70FyyYJo+7o3TQeXKhHKwE1 QgRIIxCa8BOtGkAI5tGA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXGeL-00000003NB0-0EIF; Fri, 26 Jul 2024 08:50:05 +0000 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXGeF-00000003N5s-2xKv for linux-riscv@lists.infradead.org; Fri, 26 Jul 2024 08:50:02 +0000 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-70d357040dbso645566b3a.1 for ; Fri, 26 Jul 2024 01:49:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1721983799; x=1722588599; darn=lists.infradead.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=3dXGB9M68kLUD7MhXnrJa0QNMQINVnKrW/fzYtIxsFQ=; b=WcLkdqYeA9HlZ/mvbZtSD/aNMCKHFkTvbyUUKy3b8swbzbsVW9VehNv8MuSl0vOmBy zcmW1lnxToOD6qHWLm1tPD8Yr3WqK6wHjkjupQYje3rdcp0BmWoENrKXUOuNVLt6HBRh wFzB8wK3VoA2/kATIUOGQuo1i+buHtXZz5ts8DtcOqCNYiYNfKX2IXmAi40B0YNRYOgy 8l8IVXxk8xYdxRXsy6pU422EQHKroKbGUpFH8sl1IjST8BAz0ljx+un1PD4J/amHKe1x fHKX3z2a3G7mF0PsKZLL85M7KfJXv0QFafcYt7uy2pOZoF1ozEiw9MLy3Fy/rHiKdLYu scPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721983799; x=1722588599; h=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=3dXGB9M68kLUD7MhXnrJa0QNMQINVnKrW/fzYtIxsFQ=; b=XVDI1EZ+dsTWCYTDlmAaFxrC3CWc50YJXE8c2lLttLHtauOh7CeOyucbp+ck3u0YKs gStMPjTVbOzSXqzc3tj5Z151gHZkBTmRqAv7lg80lfZOzaP8ohD/2VhTNYlbhnwaTrO3 6ZHc2uFSwqKoa1I/ZG8+wHYxN+DT8JwETXDLRuzAiC8WXdolyW/zhGyKXFZNgke3+Bxw 1XEqNJm7DdD9f0gXHBpAPYLhX8E2GlAzCxiYMJEL7YtvV9yGxdoMc18dviqT7fpLTcOZ F02Ba8fjfeTNXC6OjJPG5o9UfKnOQEzVWkXZcevRQb3f2LtUv6ZSMSfb75VQhFcPvBlz tZyg== X-Forwarded-Encrypted: i=1; AJvYcCWNu4dcTgkvA0zMtmReXv2BZlLkUBeHYiQ86s+gENaSv7oeLpIKgX/v5OVDpnIpoSWrHzKzGdeaKrDQKeCTniARA8A6wbgJhEx4CSoCFwva X-Gm-Message-State: AOJu0Yw7urvvxECfUrLOm1uL7sUM7gk87RMtd3cIbDZBZ8MDrmuUAwa+ klUapQxnSa/MuOCqBOg4LosdnyBI4J28aWZmRoQBglmBDgzUDsrT76yRFifIQrw= X-Google-Smtp-Source: AGHT+IGznbiFSiAI8Fl6vXmZOoRo3AgApK1TPweDDMBRdHNs5h5IX0DOrE9eMPt7tTokhtzC2+Ebew== X-Received: by 2002:a05:6a20:2451:b0:1c4:7d53:bf76 with SMTP id adf61e73a8af0-1c47d53c6c7mr4526810637.38.1721983798630; Fri, 26 Jul 2024 01:49:58 -0700 (PDT) Received: from hsinchu26.internal.sifive.com (59-124-168-89.hinet-ip.hinet.net. [59.124.168.89]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7a9f816db18sm2049645a12.33.2024.07.26.01.49.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 01:49:58 -0700 (PDT) From: Yong-Xuan Wang To: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, kvm-riscv@lists.infradead.org, kvm@vger.kernel.org Cc: greentime.hu@sifive.com, vincent.chen@sifive.com, Yong-Xuan Wang , Anup Patel , Atish Patra , Paolo Bonzini , Shuah Khan , Paul Walmsley , Palmer Dabbelt , Albert Ou , =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= , linux-kselftest@vger.kernel.org Subject: [PATCH v8 4/5] KVM: riscv: selftests: Fix compile error Date: Fri, 26 Jul 2024 16:49:29 +0800 Message-Id: <20240726084931.28924-5-yongxuan.wang@sifive.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240726084931.28924-1-yongxuan.wang@sifive.com> References: <20240726084931.28924-1-yongxuan.wang@sifive.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240726_014959_797573_976BE55C X-CRM114-Status: UNSURE ( 8.42 ) 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: , MIME-Version: 1.0 Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Fix compile error introduced by commit d27c34a73514 ("KVM: riscv: selftests: Add some Zc* extensions to get-reg-list test"). These 4 lines should be end with ";". Fixes: d27c34a73514 ("KVM: riscv: selftests: Add some Zc* extensions to get-reg-list test") Signed-off-by: Yong-Xuan Wang Reviewed-by: Clément Léger --- tools/testing/selftests/kvm/riscv/get-reg-list.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/kvm/riscv/get-reg-list.c b/tools/testing/selftests/kvm/riscv/get-reg-list.c index f92c2fb23fcd..8e34f7fa44e9 100644 --- a/tools/testing/selftests/kvm/riscv/get-reg-list.c +++ b/tools/testing/selftests/kvm/riscv/get-reg-list.c @@ -961,10 +961,10 @@ KVM_ISA_EXT_SIMPLE_CONFIG(zbkb, ZBKB); KVM_ISA_EXT_SIMPLE_CONFIG(zbkc, ZBKC); KVM_ISA_EXT_SIMPLE_CONFIG(zbkx, ZBKX); KVM_ISA_EXT_SIMPLE_CONFIG(zbs, ZBS); -KVM_ISA_EXT_SIMPLE_CONFIG(zca, ZCA), -KVM_ISA_EXT_SIMPLE_CONFIG(zcb, ZCB), -KVM_ISA_EXT_SIMPLE_CONFIG(zcd, ZCD), -KVM_ISA_EXT_SIMPLE_CONFIG(zcf, ZCF), +KVM_ISA_EXT_SIMPLE_CONFIG(zca, ZCA); +KVM_ISA_EXT_SIMPLE_CONFIG(zcb, ZCB); +KVM_ISA_EXT_SIMPLE_CONFIG(zcd, ZCD); +KVM_ISA_EXT_SIMPLE_CONFIG(zcf, ZCF); KVM_ISA_EXT_SIMPLE_CONFIG(zcmop, ZCMOP); KVM_ISA_EXT_SIMPLE_CONFIG(zfa, ZFA); KVM_ISA_EXT_SIMPLE_CONFIG(zfh, ZFH); From patchwork Fri Jul 26 08:49:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yong-Xuan Wang X-Patchwork-Id: 13742507 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 1A9BDC3DA49 for ; Fri, 26 Jul 2024 08:50:16 +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:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id: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=kXB9hZ36/9dBo4bpLjvKevzi5hzrXS8Ptkg3hsbv8kg=; b=eQUYx0to3IjGNH hM2vjXNzmuUVUJg/N5vS54Ylh3t4iNdZFwm2v6mrsUBPCf139kBpxdCHq04sxbqyVx240RuYbHYdX 2nwehV8m4JtqaSG55mejri3WAhsF4GqGdaLn9gq6/o1MsSOdCN1i9ETYrsybV2Rsj6BdmSN+2rAM+ 0kjLn97VCmos+gOQJToB4eq4KGNk2K+QwDP3p47Fr5ZMVeMg3ydDcdd2QImDgrkaWYoLOZLYJIFr8 x1PD7HuwkUMBu+k37VENQ6PSEMHrhmT17ItDVnDM+atgaDHJ0puWh0CDOYn5wqE6wCwRMCUvJmKU4 qOkqGaquKihKOeQ4tjdg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXGeS-00000003NHY-38Hn; Fri, 26 Jul 2024 08:50:12 +0000 Received: from mail-il1-x129.google.com ([2607:f8b0:4864:20::129]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXGeJ-00000003N9k-3uoz for linux-riscv@lists.infradead.org; Fri, 26 Jul 2024 08:50:05 +0000 Received: by mail-il1-x129.google.com with SMTP id e9e14a558f8ab-396e2d21812so5765815ab.2 for ; Fri, 26 Jul 2024 01:50:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1721983802; x=1722588602; darn=lists.infradead.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=Bh0dPmnNd790JEXkCnnwPZ9r1VDA3UO+2QohszDGqoo=; b=WV7WCV1OqDOaphnSkrZdJOrj7L2gklGJ7nLmO7m2kGpz3n6psTEQXtUuCXQ+05yfV/ yhoqbQUsIS+8j4SGqs8Rkf6atrYZgbGsqbtU2W704wewUTXGwsObR7cQrvSFFwtujchB qyN73B9sedsVf2J+9lxbVCzlEnFrSOCi8yFDYF6EACDIAHyVGuknkkNBZvxeImaQlwdS F810LuHEV9vGHu6F6yztexCQIogA9vGLArbRQLdRzCI0SObYNYfBVAosLoCsErIxcv43 mpGMqsCmgAfhIDhNVyoX9h0IKteq7hI1cAflHEeuX+RaFGBbDGzUTT4F+vPM+Njh1mZ/ Stng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721983803; x=1722588603; h=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=Bh0dPmnNd790JEXkCnnwPZ9r1VDA3UO+2QohszDGqoo=; b=Ciy3KQmorzfUUlal4aUIyXweIYtWZcTu7l1LwIno90EKU1vO/Or0frIGvXQl2kUuXG FlwAR55Cj0HuuDfxQ/HSezMb7k1L+vDP3Qu8oCZslNCINOt/JcE5Mf7e8qz3oGoaI51d zKg9NbSxVaTo3oNOSjfSw4nE44qV3JwuaVEC8kCDA6uFrfQdd3K8Z6P4vxL3FLE4ZAfD Nq7SDupKxGxIEFhE3W5HzOmcfj/tEKRqfFsoeRfJnNhvEqDqlThlGGlKT+tttHnrY0qF BCW//Y5bgFugLbaonXrbWhqO2r4h0zOMPGoyao3dNc3KiEjDByy158GEa1rCsgBVr6R6 7FPg== X-Forwarded-Encrypted: i=1; AJvYcCUX7i19ZWGlWFkKbJsEIm8yZREbQRVAIbFjGsx34YY03+X4WvYUkMgIufMmb+m4x9x8XAByRFlbarx035x/V9ZRvSx6k35vXADu4hiVZDm7 X-Gm-Message-State: AOJu0YyO+UB6zODyk5FK+/tQHGT2ykj5rfEB65QzSZ+yMeOYYkfSHCUi yo6MzDR51feEXvjEVD7zAFlqaBuAkUfGDPjqK9j4Y7QhJvf+LVnbKNYEzpXhiYg= X-Google-Smtp-Source: AGHT+IEC0sacpJpGdjediwFUkg9JGJyg+dOU1D2hf0SgxjyukSNI0E33M4o24q3PFduqql67IyeZjQ== X-Received: by 2002:a05:6e02:2162:b0:374:9c67:1df6 with SMTP id e9e14a558f8ab-39a21814055mr55639775ab.22.1721983802742; Fri, 26 Jul 2024 01:50:02 -0700 (PDT) Received: from hsinchu26.internal.sifive.com (59-124-168-89.hinet-ip.hinet.net. [59.124.168.89]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7a9f816db18sm2049645a12.33.2024.07.26.01.50.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 01:50:02 -0700 (PDT) From: Yong-Xuan Wang To: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, kvm-riscv@lists.infradead.org, kvm@vger.kernel.org Cc: greentime.hu@sifive.com, vincent.chen@sifive.com, Yong-Xuan Wang , Anup Patel , Atish Patra , Paolo Bonzini , Shuah Khan , Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-kselftest@vger.kernel.org Subject: [PATCH v8 5/5] KVM: riscv: selftests: Add Svade and Svadu Extension to get-reg-list test Date: Fri, 26 Jul 2024 16:49:30 +0800 Message-Id: <20240726084931.28924-6-yongxuan.wang@sifive.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240726084931.28924-1-yongxuan.wang@sifive.com> References: <20240726084931.28924-1-yongxuan.wang@sifive.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240726_015004_102592_CC171596 X-CRM114-Status: UNSURE ( 8.23 ) 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: , MIME-Version: 1.0 Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Update the get-reg-list test to test the Svade and Svadu Extensions are available for guest OS. Signed-off-by: Yong-Xuan Wang Reviewed-by: Andrew Jones --- tools/testing/selftests/kvm/riscv/get-reg-list.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/testing/selftests/kvm/riscv/get-reg-list.c b/tools/testing/selftests/kvm/riscv/get-reg-list.c index 8e34f7fa44e9..aac40652e181 100644 --- a/tools/testing/selftests/kvm/riscv/get-reg-list.c +++ b/tools/testing/selftests/kvm/riscv/get-reg-list.c @@ -45,6 +45,8 @@ bool filter_reg(__u64 reg) case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | KVM_RISCV_ISA_EXT_SSAIA: case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | KVM_RISCV_ISA_EXT_SSCOFPMF: case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | KVM_RISCV_ISA_EXT_SSTC: + case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | KVM_RISCV_ISA_EXT_SVADE: + case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | KVM_RISCV_ISA_EXT_SVADU: case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | KVM_RISCV_ISA_EXT_SVINVAL: case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | KVM_RISCV_ISA_EXT_SVNAPOT: case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | KVM_RISCV_ISA_EXT_SVPBMT: @@ -418,6 +420,8 @@ static const char *isa_ext_single_id_to_str(__u64 reg_off) KVM_ISA_EXT_ARR(SSAIA), KVM_ISA_EXT_ARR(SSCOFPMF), KVM_ISA_EXT_ARR(SSTC), + KVM_ISA_EXT_ARR(SVADE), + KVM_ISA_EXT_ARR(SVADU), KVM_ISA_EXT_ARR(SVINVAL), KVM_ISA_EXT_ARR(SVNAPOT), KVM_ISA_EXT_ARR(SVPBMT), @@ -949,6 +953,8 @@ KVM_ISA_EXT_SIMPLE_CONFIG(h, H); KVM_ISA_EXT_SUBLIST_CONFIG(smstateen, SMSTATEEN); KVM_ISA_EXT_SIMPLE_CONFIG(sscofpmf, SSCOFPMF); KVM_ISA_EXT_SIMPLE_CONFIG(sstc, SSTC); +KVM_ISA_EXT_SIMPLE_CONFIG(svade, SVADE); +KVM_ISA_EXT_SIMPLE_CONFIG(svadu, SVADU); KVM_ISA_EXT_SIMPLE_CONFIG(svinval, SVINVAL); KVM_ISA_EXT_SIMPLE_CONFIG(svnapot, SVNAPOT); KVM_ISA_EXT_SIMPLE_CONFIG(svpbmt, SVPBMT); @@ -1012,6 +1018,8 @@ struct vcpu_reg_list *vcpu_configs[] = { &config_smstateen, &config_sscofpmf, &config_sstc, + &config_svade, + &config_svadu, &config_svinval, &config_svnapot, &config_svpbmt,