All of lore.kernel.org
 help / color / mirror / Atom feed
From: Charlie Jenkins <charlie@rivosinc.com>
To: Ben Dooks <ben.dooks@codethink.co.uk>
Cc: "Paul Walmsley" <paul.walmsley@sifive.com>,
	"Palmer Dabbelt" <palmer@dabbelt.com>,
	"Albert Ou" <aou@eecs.berkeley.edu>,
	"Conor Dooley" <conor.dooley@microchip.com>,
	"Song Liu" <song@kernel.org>, "Xi Wang" <xi.wang@gmail.com>,
	"Björn Töpel" <bjorn@rivosinc.com>,
	"Clément Léger" <cleger@rivosinc.com>,
	"Jessica Clarke" <jrtc27@jrtc27.com>,
	"Andy Chiu" <andy.chiu@sifive.com>,
	linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/8] riscv: Add PLATFORM_SUPPORTS_RISCV_ISA_SVNAPOT Kconfig option
Date: Wed, 8 May 2024 10:05:30 -0700	[thread overview]
Message-ID: <Zjuw2t6vL6yIcPR9@ghost> (raw)
In-Reply-To: <b3ff587a-61f5-4abf-b71f-7ad48ff66969@codethink.co.uk>

On Wed, May 08, 2024 at 10:00:48AM +0100, Ben Dooks wrote:
> On 08/05/2024 02:36, Charlie Jenkins wrote:
> > The existing "RISCV_ISA_SVNAPOT" option is repurposed to be used to by
> > kernel code to determine if either
> > PLATFORM_MAY_SUPPORT_RISCV_ISA_SVNAPOT or
> > PLATFORM_SUPPORTS_RISCV_ISA_SVNAPOT has been set.
> > 
> > PLATFORM_MAY_SUPPORT_RISCV_ISA_SVNAPOT will check if the hardware
> > supports Svnapot before using it, while
> > PLATFORM_SUPPORTS_RISCV_ISA_SVNAPOT will assume that the hardware
> > supports Svnapot.
> > 
> > Signed-off-by: Charlie Jenkins <charlie@rivosinc.com>
> > ---
> >   arch/riscv/Kconfig               | 19 -----------------
> >   arch/riscv/Kconfig.isa           | 44 ++++++++++++++++++++++++++++++++++++++++
> >   arch/riscv/include/asm/pgtable.h |  3 ++-
> >   3 files changed, 46 insertions(+), 20 deletions(-)
> > 
> > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> > index c2e9eded0a7d..3c1960e8cd7c 100644
> > --- a/arch/riscv/Kconfig
> > +++ b/arch/riscv/Kconfig
> > @@ -484,25 +484,6 @@ config RISCV_ALTERNATIVE_EARLY
> >   	help
> >   	  Allows early patching of the kernel for special errata
> > -config RISCV_ISA_SVNAPOT
> > -	bool "Svnapot extension support for supervisor mode NAPOT pages"
> > -	depends on 64BIT && MMU
> > -	depends on RISCV_ALTERNATIVE
> > -	default y
> > -	help
> > -	  Add support for the Svnapot ISA-extension in the kernel when it
> > -	  is detected at boot.
> > -
> > -	  The Svnapot extension is used to mark contiguous PTEs as a range
> > -	  of contiguous virtual-to-physical translations for a naturally
> > -	  aligned power-of-2 (NAPOT) granularity larger than the base 4KB page
> > -	  size. When HUGETLBFS is also selected this option unconditionally
> > -	  allocates some memory for each NAPOT page size supported by the kernel.
> > -	  When optimizing for low memory consumption and for platforms without
> > -	  the Svnapot extension, it may be better to say N here.
> > -
> > -	  If you don't know what to do here, say Y.
> > -
> >   config RISCV_ISA_SVPBMT
> >   	bool "Svpbmt extension support for supervisor mode page-based memory types"
> >   	depends on 64BIT && MMU
> > diff --git a/arch/riscv/Kconfig.isa b/arch/riscv/Kconfig.isa
> > index 0663c98b5b17..37585bcd763e 100644
> > --- a/arch/riscv/Kconfig.isa
> > +++ b/arch/riscv/Kconfig.isa
> > @@ -124,3 +124,47 @@ config RISCV_ISA_V_PREEMPTIVE
> >   	  This config allows kernel to run SIMD without explicitly disable
> >   	  preemption. Enabling this config will result in higher memory
> >   	  consumption due to the allocation of per-task's kernel Vector context.
> > +
> > +config RISCV_ISA_SVNAPOT
> > +	bool
> > +
> > +choice
> > +	prompt "Svnapot extension support for supervisor mode NAPOT pages"
> > +	default PLATFORM_MAY_SUPPORT_RISCV_ISA_SVNAPOT
> > +	help
> > +	  This selects the level of support for Svnapot in the Linux Kernel.
> > +
> > +	  The Svnapot extension is used to mark contiguous PTEs as a range
> > +	  of contiguous virtual-to-physical translations for a naturally
> > +	  aligned power-of-2 (NAPOT) granularity larger than the base 4KB page
> > +	  size. When HUGETLBFS is also selected this option unconditionally
> > +	  allocates some memory for each NAPOT page size supported by the kernel.
> > +	  When optimizing for low memory consumption and for platforms without
> > +	  the Svnapot extension, it may be better to prohibit Svnapot.
> > +
> > +config PROHIBIT_RISCV_ISA_SVNAPOT
> > +	bool "Prohibit Svnapot extension"
> > +	help
> > +	  Regardless of if the platform supports Svnapot, prohibit the kernel
> > +	  from using Svnapot.
> > +
> > +config PLATFORM_MAY_SUPPORT_RISCV_ISA_SVNAPOT
> > +	bool "Allow Svnapot extension if supported"
> > +	depends on 64BIT && MMU
> > +	depends on RISCV_ALTERNATIVE
> > +	select RISCV_ISA_SVNAPOT
> > +	help
> > +	  Add support for the Svnapot ISA-extension in the kernel when it
> > +	  is detected at boot.
> > +
> > +config PLATFORM_SUPPORTS_RISCV_ISA_SVNAPOT
> > +	bool "Emit Svnapot mappings when building Linux"
> > +	depends on 64BIT && MMU
> > +	depends on NONPORTABLE
> > +	select RISCV_ISA_SVNAPOT
> > +	help
> > +	  Compile a kernel that assumes that the platform supports Svnapot.
> > +	  This option produces a kernel that will not run on systems that do
> > +	  not support Svnapot.
> > +
> > +endchoice
> > diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
> > index 6afd6bb4882e..432be9691b78 100644
> > --- a/arch/riscv/include/asm/pgtable.h
> > +++ b/arch/riscv/include/asm/pgtable.h
> > @@ -289,7 +289,8 @@ static inline pte_t pud_pte(pud_t pud)
> >   static __always_inline bool has_svnapot(void)
> >   {
> > -	return riscv_has_extension_likely(RISCV_ISA_EXT_SVNAPOT);
> > +	return IS_ENABLED(CONFIG_PLATFORM_SUPPORTS_RISCV_ISA_SVNAPOT) ||
> > +	       riscv_has_extension_likely(RISCV_ISA_EXT_SVNAPOT);
> 
> could you add the IS_ENABLED(*) check into riscv_has_extension_likely
> and other such functions?

I wasn't sure how to support that. An option I was debating about this
was fixing up riscv_has_extension_likely() so that it's a macro and
SVNAPOT could be expanded to both
CONFIG_PLATFORM_SUPPORTS_RISCV_ISA_SVNAPOT and RISCV_ISA_EXT_SVNAPOT.

- Charlie

> 
> 
> -- 
> Ben Dooks				http://www.codethink.co.uk/
> Senior Engineer				Codethink - Providing Genius
> 
> https://www.codethink.co.uk/privacy.html
> 

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

WARNING: multiple messages have this Message-ID (diff)
From: Charlie Jenkins <charlie@rivosinc.com>
To: Ben Dooks <ben.dooks@codethink.co.uk>
Cc: "Paul Walmsley" <paul.walmsley@sifive.com>,
	"Palmer Dabbelt" <palmer@dabbelt.com>,
	"Albert Ou" <aou@eecs.berkeley.edu>,
	"Conor Dooley" <conor.dooley@microchip.com>,
	"Song Liu" <song@kernel.org>, "Xi Wang" <xi.wang@gmail.com>,
	"Björn Töpel" <bjorn@rivosinc.com>,
	"Clément Léger" <cleger@rivosinc.com>,
	"Jessica Clarke" <jrtc27@jrtc27.com>,
	"Andy Chiu" <andy.chiu@sifive.com>,
	linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/8] riscv: Add PLATFORM_SUPPORTS_RISCV_ISA_SVNAPOT Kconfig option
Date: Wed, 8 May 2024 10:05:30 -0700	[thread overview]
Message-ID: <Zjuw2t6vL6yIcPR9@ghost> (raw)
In-Reply-To: <b3ff587a-61f5-4abf-b71f-7ad48ff66969@codethink.co.uk>

On Wed, May 08, 2024 at 10:00:48AM +0100, Ben Dooks wrote:
> On 08/05/2024 02:36, Charlie Jenkins wrote:
> > The existing "RISCV_ISA_SVNAPOT" option is repurposed to be used to by
> > kernel code to determine if either
> > PLATFORM_MAY_SUPPORT_RISCV_ISA_SVNAPOT or
> > PLATFORM_SUPPORTS_RISCV_ISA_SVNAPOT has been set.
> > 
> > PLATFORM_MAY_SUPPORT_RISCV_ISA_SVNAPOT will check if the hardware
> > supports Svnapot before using it, while
> > PLATFORM_SUPPORTS_RISCV_ISA_SVNAPOT will assume that the hardware
> > supports Svnapot.
> > 
> > Signed-off-by: Charlie Jenkins <charlie@rivosinc.com>
> > ---
> >   arch/riscv/Kconfig               | 19 -----------------
> >   arch/riscv/Kconfig.isa           | 44 ++++++++++++++++++++++++++++++++++++++++
> >   arch/riscv/include/asm/pgtable.h |  3 ++-
> >   3 files changed, 46 insertions(+), 20 deletions(-)
> > 
> > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> > index c2e9eded0a7d..3c1960e8cd7c 100644
> > --- a/arch/riscv/Kconfig
> > +++ b/arch/riscv/Kconfig
> > @@ -484,25 +484,6 @@ config RISCV_ALTERNATIVE_EARLY
> >   	help
> >   	  Allows early patching of the kernel for special errata
> > -config RISCV_ISA_SVNAPOT
> > -	bool "Svnapot extension support for supervisor mode NAPOT pages"
> > -	depends on 64BIT && MMU
> > -	depends on RISCV_ALTERNATIVE
> > -	default y
> > -	help
> > -	  Add support for the Svnapot ISA-extension in the kernel when it
> > -	  is detected at boot.
> > -
> > -	  The Svnapot extension is used to mark contiguous PTEs as a range
> > -	  of contiguous virtual-to-physical translations for a naturally
> > -	  aligned power-of-2 (NAPOT) granularity larger than the base 4KB page
> > -	  size. When HUGETLBFS is also selected this option unconditionally
> > -	  allocates some memory for each NAPOT page size supported by the kernel.
> > -	  When optimizing for low memory consumption and for platforms without
> > -	  the Svnapot extension, it may be better to say N here.
> > -
> > -	  If you don't know what to do here, say Y.
> > -
> >   config RISCV_ISA_SVPBMT
> >   	bool "Svpbmt extension support for supervisor mode page-based memory types"
> >   	depends on 64BIT && MMU
> > diff --git a/arch/riscv/Kconfig.isa b/arch/riscv/Kconfig.isa
> > index 0663c98b5b17..37585bcd763e 100644
> > --- a/arch/riscv/Kconfig.isa
> > +++ b/arch/riscv/Kconfig.isa
> > @@ -124,3 +124,47 @@ config RISCV_ISA_V_PREEMPTIVE
> >   	  This config allows kernel to run SIMD without explicitly disable
> >   	  preemption. Enabling this config will result in higher memory
> >   	  consumption due to the allocation of per-task's kernel Vector context.
> > +
> > +config RISCV_ISA_SVNAPOT
> > +	bool
> > +
> > +choice
> > +	prompt "Svnapot extension support for supervisor mode NAPOT pages"
> > +	default PLATFORM_MAY_SUPPORT_RISCV_ISA_SVNAPOT
> > +	help
> > +	  This selects the level of support for Svnapot in the Linux Kernel.
> > +
> > +	  The Svnapot extension is used to mark contiguous PTEs as a range
> > +	  of contiguous virtual-to-physical translations for a naturally
> > +	  aligned power-of-2 (NAPOT) granularity larger than the base 4KB page
> > +	  size. When HUGETLBFS is also selected this option unconditionally
> > +	  allocates some memory for each NAPOT page size supported by the kernel.
> > +	  When optimizing for low memory consumption and for platforms without
> > +	  the Svnapot extension, it may be better to prohibit Svnapot.
> > +
> > +config PROHIBIT_RISCV_ISA_SVNAPOT
> > +	bool "Prohibit Svnapot extension"
> > +	help
> > +	  Regardless of if the platform supports Svnapot, prohibit the kernel
> > +	  from using Svnapot.
> > +
> > +config PLATFORM_MAY_SUPPORT_RISCV_ISA_SVNAPOT
> > +	bool "Allow Svnapot extension if supported"
> > +	depends on 64BIT && MMU
> > +	depends on RISCV_ALTERNATIVE
> > +	select RISCV_ISA_SVNAPOT
> > +	help
> > +	  Add support for the Svnapot ISA-extension in the kernel when it
> > +	  is detected at boot.
> > +
> > +config PLATFORM_SUPPORTS_RISCV_ISA_SVNAPOT
> > +	bool "Emit Svnapot mappings when building Linux"
> > +	depends on 64BIT && MMU
> > +	depends on NONPORTABLE
> > +	select RISCV_ISA_SVNAPOT
> > +	help
> > +	  Compile a kernel that assumes that the platform supports Svnapot.
> > +	  This option produces a kernel that will not run on systems that do
> > +	  not support Svnapot.
> > +
> > +endchoice
> > diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
> > index 6afd6bb4882e..432be9691b78 100644
> > --- a/arch/riscv/include/asm/pgtable.h
> > +++ b/arch/riscv/include/asm/pgtable.h
> > @@ -289,7 +289,8 @@ static inline pte_t pud_pte(pud_t pud)
> >   static __always_inline bool has_svnapot(void)
> >   {
> > -	return riscv_has_extension_likely(RISCV_ISA_EXT_SVNAPOT);
> > +	return IS_ENABLED(CONFIG_PLATFORM_SUPPORTS_RISCV_ISA_SVNAPOT) ||
> > +	       riscv_has_extension_likely(RISCV_ISA_EXT_SVNAPOT);
> 
> could you add the IS_ENABLED(*) check into riscv_has_extension_likely
> and other such functions?

I wasn't sure how to support that. An option I was debating about this
was fixing up riscv_has_extension_likely() so that it's a macro and
SVNAPOT could be expanded to both
CONFIG_PLATFORM_SUPPORTS_RISCV_ISA_SVNAPOT and RISCV_ISA_EXT_SVNAPOT.

- Charlie

> 
> 
> -- 
> Ben Dooks				http://www.codethink.co.uk/
> Senior Engineer				Codethink - Providing Genius
> 
> https://www.codethink.co.uk/privacy.html
> 

  reply	other threads:[~2024-05-08 17:06 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-08  1:36 [PATCH v2 0/8] riscv: Support compiling the kernel with more extensions Charlie Jenkins
2024-05-08  1:36 ` Charlie Jenkins
2024-05-08  1:36 ` [PATCH v2 1/8] riscv: Add PLATFORM_MAY_SUPPORT_RISCV_ISA_C Kconfig option Charlie Jenkins
2024-05-08  1:36   ` Charlie Jenkins
2024-05-08  1:36 ` [PATCH v2 2/8] riscv: Add PLATFORM_MAY_SUPPORT_RISCV_ISA_V " Charlie Jenkins
2024-05-08  1:36   ` Charlie Jenkins
2024-05-10 20:43   ` Conor Dooley
2024-05-10 20:43     ` Conor Dooley
2024-05-10 21:43     ` Charlie Jenkins
2024-05-10 21:43       ` Charlie Jenkins
2024-05-10 22:26       ` Conor Dooley
2024-05-10 22:26         ` Conor Dooley
2024-05-15 14:34         ` Conor Dooley
2024-05-15 14:34           ` Conor Dooley
2024-05-08  1:36 ` [PATCH v2 3/8] riscv: Add PLATFORM_SUPPORTS_RISCV_ISA_SVNAPOT " Charlie Jenkins
2024-05-08  1:36   ` Charlie Jenkins
2024-05-08  9:00   ` Ben Dooks
2024-05-08  9:00     ` Ben Dooks
2024-05-08 17:05     ` Charlie Jenkins [this message]
2024-05-08 17:05       ` Charlie Jenkins
2024-05-08  1:36 ` [PATCH v2 4/8] riscv: Move RISCV_ISA_SVPBMT to Kconfig.isa Charlie Jenkins
2024-05-08  1:36   ` Charlie Jenkins
2024-05-08  1:36 ` [PATCH v2 5/8] riscv: Add PLATFORM_SUPPORTS_RISCV_ISA_ZBB Kconfig option Charlie Jenkins
2024-05-08  1:36   ` Charlie Jenkins
2024-05-08  1:36 ` [PATCH v2 6/8] riscv: Add PLATFORM_SUPPORTS_RISCV_ISA_ZBA " Charlie Jenkins
2024-05-08  1:36   ` Charlie Jenkins
2024-05-08  1:36 ` [PATCH v2 7/8] riscv: Add PLATFORM_SUPPORTS_RISCV_ISA_ZBC " Charlie Jenkins
2024-05-08  1:36   ` Charlie Jenkins
2024-05-08  1:36 ` [PATCH v2 8/8] riscv: Add PLATFORM_SUPPORTS_RISCV_ISA_ZBS " Charlie Jenkins
2024-05-08  1:36   ` Charlie Jenkins
2024-05-09 20:25 ` [PATCH v2 0/8] riscv: Support compiling the kernel with more extensions Conor Dooley
2024-05-09 20:25   ` Conor Dooley
2024-05-09 21:16   ` Charlie Jenkins
2024-05-09 21:16     ` Charlie Jenkins
2024-05-09 22:08     ` Conor Dooley
2024-05-09 22:08       ` Conor Dooley
2024-05-09 22:55       ` Charlie Jenkins
2024-05-09 22:55         ` Charlie Jenkins
2024-05-10  8:25         ` Conor Dooley
2024-05-10  8:25           ` Conor Dooley
2024-05-10  8:35           ` Conor Dooley
2024-05-10  8:35             ` Conor Dooley
2024-05-10 16:48           ` Charlie Jenkins
2024-05-10 16:48             ` Charlie Jenkins

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Zjuw2t6vL6yIcPR9@ghost \
    --to=charlie@rivosinc.com \
    --cc=andy.chiu@sifive.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=ben.dooks@codethink.co.uk \
    --cc=bjorn@rivosinc.com \
    --cc=cleger@rivosinc.com \
    --cc=conor.dooley@microchip.com \
    --cc=jrtc27@jrtc27.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=song@kernel.org \
    --cc=xi.wang@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.