Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp1157034lqb; Thu, 30 May 2024 01:48:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXX8IEOSTsjiYOTBsjCf5Hl6QAZzyUXhDPEpdcOZK4lT6M03CVwoy1UY6HPOaR4ms7urM4xZVPn2dqNx4Jf8URHvGLeOew8zy144/qH7Q== X-Google-Smtp-Source: AGHT+IHG3yvrT6Qi7M0VKVahKbDJXBV07YFdamvOydEMo5O1l0ZcbEXS7eqb3BoDvhoefOyr9tJy X-Received: by 2002:a05:6358:71b:b0:18f:673e:fce2 with SMTP id e5c5f4694b2df-199b937eabamr162536455d.6.1717058936269; Thu, 30 May 2024 01:48:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717058936; cv=pass; d=google.com; s=arc-20160816; b=IExSweaQTW2fhSIRepwRA7PKSPA9U9jXNfmEH3JDN8OW8C951Q5sN2y7O5jC4RXc82 bH7jZ+p2hhmOhRGU8qE/UU3MkJjOGJcqskrR1wGspNm6l5FY6OlKFojJ1DkJPv/Sw4/c a/HOEncbZUgn9VNOTtE4c6r4PpvLfEYFHVbyexETCMWeRJ4UDTlsnacuYPC23vW/YTyx yJVyl05WAAv2xN2v+DRzDokv5BQ34DFMx4p+FElraQBQM1dnal5YOR0k9aykcua5aOfR gioiBv2qghHh4OLpqXu6/eiGbD9Dee4vtT38clG9gxSMu3h4Gjtpgh3EjanrTlsW3Ck2 c73Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=WORC7D01wmgU91QV0bcqKL937BAD95vzhIgmnodKhhM=; fh=lz6KU9//eCP4wwlmAWviu3E0hHcoS+fzyr/KAU3H3ss=; b=H5lEzye+7QPHG/qzRNKcKW4BJqorlnFK5aaht9su/llxCjA5oUxw68dVwWgXmAtOvx hDERll4ga2gnJE57u15/ID3VYn9mZPLmFOigfXlVU5cPBTiqAQwfczVBYXP1bV8rFDwm SiMHIgPG7ykH768gAnBPqvO3tIYYmCeYetKXfC5MqhhMv+HhZDKpO6EnD/HYa8poVElo FT6u97sbgyiax4RjoEUlKgVLxX4nhG7LE5Rf/vvWDq++KpGqwI0wai+2x0inkUF3YXeb KZx0da1JYNbodLOmFcGzBTnruyNMMUfkP0yYXFRJyBKi0TL23j/qhTCx58E36uxaOVkO vHUA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=OQhQ8Std; arc=pass (i=1 spf=pass spfdomain=ventanamicro.com dkim=pass dkdomain=ventanamicro.com); spf=pass (google.com: domain of linux-kernel+bounces-195087-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195087-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6c016431236si882440a12.533.2024.05.30.01.48.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 01:48:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-195087-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=OQhQ8Std; arc=pass (i=1 spf=pass spfdomain=ventanamicro.com dkim=pass dkdomain=ventanamicro.com); spf=pass (google.com: domain of linux-kernel+bounces-195087-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195087-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 6542EB20B38 for ; Thu, 30 May 2024 08:47:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2497613B290; Thu, 30 May 2024 08:47:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="OQhQ8Std" Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C9706F2E4 for ; Thu, 30 May 2024 08:47:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717058845; cv=none; b=VOlKtDFieITXuDKlgYKzw5knw+lBd7UpYosOsj44bIZY78/YO9wOHPxPJiBan+TMShmXJgPcML4OLoY/Ul3DHWF2wWxCuqo+u6zRQgTwuLLPR5zZYQtYOftDEr5VA/4IDT9pyHua2a4zrv4Xy5PxRUPANCDgqvLuh8iaTsT9gMk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717058845; c=relaxed/simple; bh=XAVn95vkU7Jfz4kiZXaaYzX53jTdcgwbAioJOtjzr9I=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hPC82JNd1TdvZsX3HeBkr3E0uz5JGoaHKaUkwgtlQXoxplS8SA1LIaMsdQOOJuLV6vTa0fCMO3ukb63R3D7ZIW7rxFlO20ELFh9t70gsCGsDGvcCC5hIuzJuT8s6kB8yzu8gNO4qWd5uR9CgPEB1+h21KHPeWpTxCJIo3NoFfrg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=OQhQ8Std; arc=none smtp.client-ip=209.85.221.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-35507a3a038so428174f8f.0 for ; Thu, 30 May 2024 01:47:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1717058841; x=1717663641; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=WORC7D01wmgU91QV0bcqKL937BAD95vzhIgmnodKhhM=; b=OQhQ8StdhJGTpaQ8Ay1VLMXxoTYcHx0QD/cUngJmx257Lr9wf97RMd5xVAMOaT7OV9 25ZJWLiTvZqUtZWjWQEw4UE/6nY0sdNsh4d3VjZL5ke1wOqw50dctzs364PAlCjcSe7j wgnpMt1fjdRRhYdDaXuMx1eVPS101oy9iD7D3R0BgDVvlAiftu+nToKerIFcavVe5xkx ME8yR7ji5gW+dcBgjDOvhy6ItNJyVtQqFhfcw1JbORsWYD2ROEpqjcI7zMj302YL3Vmz ORxU8Edhe9aLUeQtEDwNXwxZaP/0q4Up17LQuIDTpHw/+scWr0ySs7A5hyz3tjmo3J4X /dzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717058841; x=1717663641; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=WORC7D01wmgU91QV0bcqKL937BAD95vzhIgmnodKhhM=; b=tEqyuN9+4HFFMPz/4SImTMvBLwoOFIrkEDzhhZtPLEcNbp4jrBYuKdrmplXRI2h/WR eDJGHIHDjnRNMI2zjbc5Fi9LqIPkth4OeWPzc5aML2I+tlHGV3OMqpWlX32wUEu2VcJD haeh5LvjC9Zmmh5F68Q2pPLD2NIymrOV5QmLYf9m4HQq99KdgY9RiPComtA9KzTT6QeL 87zn0/mToRXZoK1Ey5XiVyWKeN37jWfB6PwvQMTp6Q1UlRe+eMby59xa7TMSYzioL+Vq EBi8ri+8jhZXXC9lO43o68O9e3HOgLeiYCy0tioZ3mWRZBKY9tipy7V+dwcFfGkwG/Vi Dq7w== X-Forwarded-Encrypted: i=1; AJvYcCWgrF2OtZVP2V4y7I+TygFQmwI+8UpUgWmzYmfnn9ff6aWKC35Jt5axCAqr8sJfmekCdNN1DVYP9/Mu6RMSxm5wPw1tPA6nafJhxOQs X-Gm-Message-State: AOJu0YxBhOzrjKy7wivOuKom7o9Do88AmUEYv7i+Akzzo6nyGPakx2jG XHQn8s9lIlKsbusfLmJeLEHWyRqNtpM6RAAi2F1ivYcgmWjnIxVCzeQIa/fliZ0= X-Received: by 2002:a5d:452d:0:b0:355:18a:3748 with SMTP id ffacd0b85a97d-35dc009cc07mr1742333f8f.40.1717058841339; Thu, 30 May 2024 01:47:21 -0700 (PDT) Received: from localhost (2001-1ae9-1c2-4c00-20f-c6b4-1e57-7965.ip6.tmcz.cz. [2001:1ae9:1c2:4c00:20f:c6b4:1e57:7965]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35dc9d0750csm957787f8f.63.2024.05.30.01.47.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 01:47:20 -0700 (PDT) Date: Thu, 30 May 2024 10:47:20 +0200 From: Andrew Jones To: Alexandre Ghiti Cc: Yong-Xuan Wang , linux-riscv@lists.infradead.org, kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, greentime.hu@sifive.com, vincent.chen@sifive.com, cleger@rivosinc.com, Jinyu Tang , Paul Walmsley , Palmer Dabbelt , Albert Ou , Anup Patel , Conor Dooley , Mayuresh Chitale , Samuel Holland , Samuel Ortiz , Evan Green , Xiao Wang , Alexandre Ghiti , Andrew Morton , Kemeng Shi , "Mike Rapoport (IBM)" , Jisheng Zhang , "Matthew Wilcox (Oracle)" , Charlie Jenkins , Leonardo Bras , linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH v4 1/5] RISC-V: Detect and Enable Svadu Extension Support Message-ID: <20240530-3e5538b8e4dea932e2d3edc4@orel> References: <20240524103307.2684-1-yongxuan.wang@sifive.com> <20240524103307.2684-2-yongxuan.wang@sifive.com> <20240527-41b376a2bfedb3b9cf7e9c7b@orel> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Thu, May 30, 2024 at 10:19:12AM GMT, Alexandre Ghiti wrote: > Hi Yong-Xuan, > > On 27/05/2024 18:25, Andrew Jones wrote: > > On Fri, May 24, 2024 at 06:33:01PM GMT, Yong-Xuan Wang wrote: > > > Svadu is a RISC-V extension for hardware updating of PTE A/D bits. > > > > > > In this patch we detect Svadu extension support from DTB and enable it > > > with SBI FWFT extension. Also we add arch_has_hw_pte_young() to enable > > > optimization in MGLRU and __wp_page_copy_user() if Svadu extension is > > > available. > > > So we talked about this yesterday during the linux-riscv patchwork meeting. > We came to the conclusion that we should not wait for the SBI FWFT extension > to enable Svadu but instead, it should be enabled by default by openSBI if > the extension is present in the device tree. This is because we did not find > any backward compatibility issues, meaning that enabling Svadu should not > break any S-mode software. Unfortunately I joined yesterday's patchwork call late and missed this discussion. I'm still not sure how we avoid concerns with S-mode software expecting exceptions by purposely not setting A/D bits, but then not getting those exceptions. > This is what you did in your previous versions of > this patchset so the changes should be easy. This behaviour must be added to > the dtbinding description of the Svadu extension. > > Another thing that we discussed yesterday. There exist 2 schemes to manage > the A/D bits updates, Svade and Svadu. If a platform supports both > extensions and both are present in the device tree, it is M-mode firmware's > responsibility to provide a "sane" device tree to the S-mode software, > meaning the device tree can not contain both extensions. And because on such > platforms, Svadu is more performant than Svade, Svadu should be enabled by > the M-mode firmware and only Svadu should be present in the device tree. I'm not sure firmware will be able to choose svadu when it's available. For example, platforms which want to conform to the upcoming "Server Platform" specification must also conform to the RVA23 profile, which mandates Svade and lists Svadu as an optional extension. This implies to me that S-mode should be boot with both svade and svadu in the DT and with svade being the active one. Then, S-mode can choose to request switching to svadu with FWFT. Thanks, drew > > I hope that clearly explains what we discussed yesterday, let me know if you > (or anyone else) need more explanations. If no one is opposed to this > solution, do you think you can implement this behaviour? If not, I can deal > with it, just let me know. > > Thanks > > > > > > > > Co-developed-by: Jinyu Tang > > > Signed-off-by: Jinyu Tang > > > Signed-off-by: Yong-Xuan Wang > > > Reviewed-by: Conor Dooley > > > Reviewed-by: Andrew Jones > > I think this patch changed too much to keep r-b's. We didn't have the > > FWFT part before. > > > > > --- > > > arch/riscv/Kconfig | 1 + > > > arch/riscv/include/asm/csr.h | 1 + > > > arch/riscv/include/asm/hwcap.h | 1 + > > > arch/riscv/include/asm/pgtable.h | 8 +++++++- > > > arch/riscv/kernel/cpufeature.c | 11 +++++++++++ > > > 5 files changed, 21 insertions(+), 1 deletion(-) > > > > > > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig > > > index be09c8836d56..30fa558ee284 100644 > > > --- a/arch/riscv/Kconfig > > > +++ b/arch/riscv/Kconfig > > > @@ -34,6 +34,7 @@ config RISCV > > > select ARCH_HAS_PMEM_API > > > select ARCH_HAS_PREPARE_SYNC_CORE_CMD > > > select ARCH_HAS_PTE_SPECIAL > > > + select ARCH_HAS_HW_PTE_YOUNG > > > select ARCH_HAS_SET_DIRECT_MAP if MMU > > > select ARCH_HAS_SET_MEMORY if MMU > > > select ARCH_HAS_STRICT_KERNEL_RWX if MMU && !XIP_KERNEL > > > diff --git a/arch/riscv/include/asm/csr.h b/arch/riscv/include/asm/csr.h > > > index 2468c55933cd..2ac270ad4acd 100644 > > > --- a/arch/riscv/include/asm/csr.h > > > +++ b/arch/riscv/include/asm/csr.h > > > @@ -194,6 +194,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 e17d0078a651..8d539e3f4e11 100644 > > > --- a/arch/riscv/include/asm/hwcap.h > > > +++ b/arch/riscv/include/asm/hwcap.h > > > @@ -81,6 +81,7 @@ > > > #define RISCV_ISA_EXT_ZTSO 72 > > > #define RISCV_ISA_EXT_ZACAS 73 > > > #define RISCV_ISA_EXT_XANDESPMU 74 > > > +#define RISCV_ISA_EXT_SVADU 75 > > > #define RISCV_ISA_EXT_XLINUXENVCFG 127 > > > diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h > > > index 9f8ea0e33eb1..1f1b326ccf63 100644 > > > --- a/arch/riscv/include/asm/pgtable.h > > > +++ b/arch/riscv/include/asm/pgtable.h > > > @@ -117,6 +117,7 @@ > > > #include > > > #include > > > #include > > > +#include > > > #define __page_val_to_pfn(_val) (((_val) & _PAGE_PFN_MASK) >> _PAGE_PFN_SHIFT) > > > @@ -285,7 +286,6 @@ static inline pte_t pud_pte(pud_t pud) > > > } > > > #ifdef CONFIG_RISCV_ISA_SVNAPOT > > > -#include > > > static __always_inline bool has_svnapot(void) > > > { > > > @@ -621,6 +621,12 @@ static inline pgprot_t pgprot_writecombine(pgprot_t _prot) > > > return __pgprot(prot); > > > } > > > +#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 3ed2359eae35..b023908c5932 100644 > > > --- a/arch/riscv/kernel/cpufeature.c > > > +++ b/arch/riscv/kernel/cpufeature.c > > > @@ -93,6 +93,16 @@ static bool riscv_isa_extension_check(int id) > > > return false; > > > } > > > return true; > > > + case RISCV_ISA_EXT_SVADU: > > > + if (sbi_probe_extension(SBI_EXT_FWFT) > 0) { > > I think we've decided the appropriate way to prove for SBI extensions is > > to first ensure the SBI version and then do the probe, like we do for STA > > in has_pv_steal_clock() > > > > > + struct sbiret ret; > > > + > > > + ret = sbi_ecall(SBI_EXT_FWFT, SBI_EXT_FWFT_SET, SBI_FWFT_PTE_AD_HW_UPDATING, > > > + 1, 0, 0, 0, 0); > > > + > > > + return ret.error == SBI_SUCCESS; > > > + } > > > + return false; > > > case RISCV_ISA_EXT_INVALID: > > > return false; > > > } > > > @@ -301,6 +311,7 @@ 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_SUPERSET(svadu, RISCV_ISA_EXT_SVADU, riscv_xlinuxenvcfg_exts), > > We do we need XLINUXENVCFG? > > > > Thanks, > > drew > > > > > __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), > > > -- > > > 2.17.1 > > > > > _______________________________________________ > > linux-riscv mailing list > > linux-riscv@lists.infradead.org > > http://lists.infradead.org/mailman/listinfo/linux-riscv