public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] riscv: Make sure toolchain supports zba before using zba instructions
@ 2025-03-28 11:54 Alexandre Ghiti
  2025-03-28 12:51 ` Clément Léger
  2025-04-03 16:20 ` patchwork-bot+linux-riscv
  0 siblings, 2 replies; 5+ messages in thread
From: Alexandre Ghiti @ 2025-03-28 11:54 UTC (permalink / raw)
  To: Paul Walmsley, Palmer Dabbelt, Alexandre Ghiti, linux-riscv,
	linux-kernel
  Cc: Alexandre Ghiti, kernel test robot

Old toolchain like gcc 8.5.0 does not support zba, so we must check that
the toolchain supports this extension before using it in the kernel.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202503281836.8pntHm6I-lkp@intel.com/
Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
---
 arch/riscv/Kconfig                     | 8 ++++++++
 arch/riscv/include/asm/runtime-const.h | 5 +++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 0d8def968a7e..ae6303f15b28 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -735,6 +735,14 @@ config TOOLCHAIN_HAS_VECTOR_CRYPTO
 	def_bool $(as-instr, .option arch$(comma) +v$(comma) +zvkb)
 	depends on AS_HAS_OPTION_ARCH
 
+config TOOLCHAIN_HAS_ZBA
+	bool
+	default y
+	depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zba)
+	depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zba)
+	depends on LLD_VERSION >= 150000 || LD_VERSION >= 23900
+	depends on AS_HAS_OPTION_ARCH
+
 config RISCV_ISA_ZBA
 	bool "Zba extension support for bit manipulation instructions"
 	default y
diff --git a/arch/riscv/include/asm/runtime-const.h b/arch/riscv/include/asm/runtime-const.h
index ea2e49c7149c..c07d049fdd5d 100644
--- a/arch/riscv/include/asm/runtime-const.h
+++ b/arch/riscv/include/asm/runtime-const.h
@@ -77,7 +77,8 @@
 	".long 1b - .\n\t"					\
 	".popsection"						\
 
-#if defined(CONFIG_RISCV_ISA_ZBA) && defined(CONFIG_RISCV_ISA_ZBKB)
+#if defined(CONFIG_RISCV_ISA_ZBA) && defined(CONFIG_TOOLCHAIN_HAS_ZBA)	\
+	&& defined(CONFIG_RISCV_ISA_ZBKB)
 #define runtime_const_ptr(sym)						\
 ({									\
 	typeof(sym) __ret, __tmp;					\
@@ -93,7 +94,7 @@
 		: [__ret] "=r" (__ret), [__tmp] "=r" (__tmp));		\
 	__ret;								\
 })
-#elif defined(CONFIG_RISCV_ISA_ZBA)
+#elif defined(CONFIG_RISCV_ISA_ZBA) && defined(CONFIG_TOOLCHAIN_HAS_ZBA)
 #define runtime_const_ptr(sym)						\
 ({									\
 	typeof(sym) __ret, __tmp;					\
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] riscv: Make sure toolchain supports zba before using zba instructions
  2025-03-28 11:54 [PATCH] riscv: Make sure toolchain supports zba before using zba instructions Alexandre Ghiti
@ 2025-03-28 12:51 ` Clément Léger
  2025-03-28 13:00   ` Alexandre Ghiti
  2025-04-03 16:20 ` patchwork-bot+linux-riscv
  1 sibling, 1 reply; 5+ messages in thread
From: Clément Léger @ 2025-03-28 12:51 UTC (permalink / raw)
  To: Alexandre Ghiti
  Cc: kernel test robot, Paul Walmsley, Alexandre Ghiti, linux-riscv,
	linux-kernel, Palmer Dabbelt



On 28/03/2025 12:54, Alexandre Ghiti wrote:
> Old toolchain like gcc 8.5.0 does not support zba, so we must check that
> the toolchain supports this extension before using it in the kernel.
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202503281836.8pntHm6I-lkp@intel.com/
> Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
> ---
>  arch/riscv/Kconfig                     | 8 ++++++++
>  arch/riscv/include/asm/runtime-const.h | 5 +++--
>  2 files changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index 0d8def968a7e..ae6303f15b28 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -735,6 +735,14 @@ config TOOLCHAIN_HAS_VECTOR_CRYPTO
>  	def_bool $(as-instr, .option arch$(comma) +v$(comma) +zvkb)
>  	depends on AS_HAS_OPTION_ARCH
>  
> +config TOOLCHAIN_HAS_ZBA
> +	bool
> +	default y
> +	depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zba)
> +	depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zba)
> +	depends on LLD_VERSION >= 150000 || LD_VERSION >= 23900
> +	depends on AS_HAS_OPTION_ARCH
> +
>  config RISCV_ISA_ZBA

Hi Alex,

Why not add a "depends on TOOLCHAIN_HAS_ZBA" here so you don't have to
check for that config option when using CONFIG_RISCV_ISA_ZBA ? This is
done like that for ZBB and ZBC.

Thanks,

Clément

>  	bool "Zba extension support for bit manipulation instructions"
>  	default y
> diff --git a/arch/riscv/include/asm/runtime-const.h b/arch/riscv/include/asm/runtime-const.h
> index ea2e49c7149c..c07d049fdd5d 100644
> --- a/arch/riscv/include/asm/runtime-const.h
> +++ b/arch/riscv/include/asm/runtime-const.h
> @@ -77,7 +77,8 @@
>  	".long 1b - .\n\t"					\
>  	".popsection"						\
>  
> -#if defined(CONFIG_RISCV_ISA_ZBA) && defined(CONFIG_RISCV_ISA_ZBKB)
> +#if defined(CONFIG_RISCV_ISA_ZBA) && defined(CONFIG_TOOLCHAIN_HAS_ZBA)	\
> +	&& defined(CONFIG_RISCV_ISA_ZBKB)


>  #define runtime_const_ptr(sym)						\
>  ({									\
>  	typeof(sym) __ret, __tmp;					\
> @@ -93,7 +94,7 @@
>  		: [__ret] "=r" (__ret), [__tmp] "=r" (__tmp));		\
>  	__ret;								\
>  })
> -#elif defined(CONFIG_RISCV_ISA_ZBA)
> +#elif defined(CONFIG_RISCV_ISA_ZBA) && defined(CONFIG_TOOLCHAIN_HAS_ZBA)
>  #define runtime_const_ptr(sym)						\
>  ({									\
>  	typeof(sym) __ret, __tmp;					\


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] riscv: Make sure toolchain supports zba before using zba instructions
  2025-03-28 12:51 ` Clément Léger
@ 2025-03-28 13:00   ` Alexandre Ghiti
  2025-03-28 13:02     ` Clément Léger
  0 siblings, 1 reply; 5+ messages in thread
From: Alexandre Ghiti @ 2025-03-28 13:00 UTC (permalink / raw)
  To: Clément Léger, Alexandre Ghiti
  Cc: kernel test robot, Paul Walmsley, linux-riscv, linux-kernel,
	Palmer Dabbelt

On 28/03/2025 13:51, Clément Léger wrote:
>
> On 28/03/2025 12:54, Alexandre Ghiti wrote:
>> Old toolchain like gcc 8.5.0 does not support zba, so we must check that
>> the toolchain supports this extension before using it in the kernel.
>>
>> Reported-by: kernel test robot <lkp@intel.com>
>> Closes: https://lore.kernel.org/oe-kbuild-all/202503281836.8pntHm6I-lkp@intel.com/
>> Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
>> ---
>>   arch/riscv/Kconfig                     | 8 ++++++++
>>   arch/riscv/include/asm/runtime-const.h | 5 +++--
>>   2 files changed, 11 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
>> index 0d8def968a7e..ae6303f15b28 100644
>> --- a/arch/riscv/Kconfig
>> +++ b/arch/riscv/Kconfig
>> @@ -735,6 +735,14 @@ config TOOLCHAIN_HAS_VECTOR_CRYPTO
>>   	def_bool $(as-instr, .option arch$(comma) +v$(comma) +zvkb)
>>   	depends on AS_HAS_OPTION_ARCH
>>   
>> +config TOOLCHAIN_HAS_ZBA
>> +	bool
>> +	default y
>> +	depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zba)
>> +	depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zba)
>> +	depends on LLD_VERSION >= 150000 || LD_VERSION >= 23900
>> +	depends on AS_HAS_OPTION_ARCH
>> +
>>   config RISCV_ISA_ZBA
> Hi Alex,
>
> Why not add a "depends on TOOLCHAIN_HAS_ZBA" here so you don't have to
> check for that config option when using CONFIG_RISCV_ISA_ZBA ? This is
> done like that for ZBB and ZBC.


Actually Conor changed that for Zbb in 
https://lore.kernel.org/lkml/20241024-aspire-rectify-9982da6943e5@spud/T/#m89d45ba3cbc6c2f953516c0e9977fecf397809b0 
which is queued for 6.15.

Zba is also used in BPF, so we should not require that the toolchain 
supports zba but instead just that the platform supports it.

Thanks,

Alex


>
> Thanks,
>
> Clément
>
>>   	bool "Zba extension support for bit manipulation instructions"
>>   	default y
>> diff --git a/arch/riscv/include/asm/runtime-const.h b/arch/riscv/include/asm/runtime-const.h
>> index ea2e49c7149c..c07d049fdd5d 100644
>> --- a/arch/riscv/include/asm/runtime-const.h
>> +++ b/arch/riscv/include/asm/runtime-const.h
>> @@ -77,7 +77,8 @@
>>   	".long 1b - .\n\t"					\
>>   	".popsection"						\
>>   
>> -#if defined(CONFIG_RISCV_ISA_ZBA) && defined(CONFIG_RISCV_ISA_ZBKB)
>> +#if defined(CONFIG_RISCV_ISA_ZBA) && defined(CONFIG_TOOLCHAIN_HAS_ZBA)	\
>> +	&& defined(CONFIG_RISCV_ISA_ZBKB)
>
>>   #define runtime_const_ptr(sym)						\
>>   ({									\
>>   	typeof(sym) __ret, __tmp;					\
>> @@ -93,7 +94,7 @@
>>   		: [__ret] "=r" (__ret), [__tmp] "=r" (__tmp));		\
>>   	__ret;								\
>>   })
>> -#elif defined(CONFIG_RISCV_ISA_ZBA)
>> +#elif defined(CONFIG_RISCV_ISA_ZBA) && defined(CONFIG_TOOLCHAIN_HAS_ZBA)
>>   #define runtime_const_ptr(sym)						\
>>   ({									\
>>   	typeof(sym) __ret, __tmp;					\

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] riscv: Make sure toolchain supports zba before using zba instructions
  2025-03-28 13:00   ` Alexandre Ghiti
@ 2025-03-28 13:02     ` Clément Léger
  0 siblings, 0 replies; 5+ messages in thread
From: Clément Léger @ 2025-03-28 13:02 UTC (permalink / raw)
  To: Alexandre Ghiti, Alexandre Ghiti
  Cc: kernel test robot, Paul Walmsley, linux-riscv, linux-kernel,
	Palmer Dabbelt



On 28/03/2025 14:00, Alexandre Ghiti wrote:
> On 28/03/2025 13:51, Clément Léger wrote:
>>
>> On 28/03/2025 12:54, Alexandre Ghiti wrote:
>>> Old toolchain like gcc 8.5.0 does not support zba, so we must check that
>>> the toolchain supports this extension before using it in the kernel.
>>>
>>> Reported-by: kernel test robot <lkp@intel.com>
>>> Closes: https://lore.kernel.org/oe-kbuild-all/202503281836.8pntHm6I-
>>> lkp@intel.com/
>>> Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
>>> ---
>>>   arch/riscv/Kconfig                     | 8 ++++++++
>>>   arch/riscv/include/asm/runtime-const.h | 5 +++--
>>>   2 files changed, 11 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
>>> index 0d8def968a7e..ae6303f15b28 100644
>>> --- a/arch/riscv/Kconfig
>>> +++ b/arch/riscv/Kconfig
>>> @@ -735,6 +735,14 @@ config TOOLCHAIN_HAS_VECTOR_CRYPTO
>>>       def_bool $(as-instr, .option arch$(comma) +v$(comma) +zvkb)
>>>       depends on AS_HAS_OPTION_ARCH
>>>   +config TOOLCHAIN_HAS_ZBA
>>> +    bool
>>> +    default y
>>> +    depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zba)
>>> +    depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zba)
>>> +    depends on LLD_VERSION >= 150000 || LD_VERSION >= 23900
>>> +    depends on AS_HAS_OPTION_ARCH
>>> +
>>>   config RISCV_ISA_ZBA
>> Hi Alex,
>>
>> Why not add a "depends on TOOLCHAIN_HAS_ZBA" here so you don't have to
>> check for that config option when using CONFIG_RISCV_ISA_ZBA ? This is
>> done like that for ZBB and ZBC.
> 
> 
> Actually Conor changed that for Zbb in https://lore.kernel.org/
> lkml/20241024-aspire-rectify-9982da6943e5@spud/T/
> #m89d45ba3cbc6c2f953516c0e9977fecf397809b0 which is queued for 6.15.
> 
> Zba is also used in BPF, so we should not require that the toolchain
> supports zba but instead just that the platform supports it.

Indeed, makes sense !

Thanks,

Clément

> 
> Thanks,
> 
> Alex
> 
> 
>>
>> Thanks,
>>
>> Clément
>>
>>>       bool "Zba extension support for bit manipulation instructions"
>>>       default y
>>> diff --git a/arch/riscv/include/asm/runtime-const.h b/arch/riscv/
>>> include/asm/runtime-const.h
>>> index ea2e49c7149c..c07d049fdd5d 100644
>>> --- a/arch/riscv/include/asm/runtime-const.h
>>> +++ b/arch/riscv/include/asm/runtime-const.h
>>> @@ -77,7 +77,8 @@
>>>       ".long 1b - .\n\t"                    \
>>>       ".popsection"                        \
>>>   -#if defined(CONFIG_RISCV_ISA_ZBA) && defined(CONFIG_RISCV_ISA_ZBKB)
>>> +#if defined(CONFIG_RISCV_ISA_ZBA) &&
>>> defined(CONFIG_TOOLCHAIN_HAS_ZBA)    \
>>> +    && defined(CONFIG_RISCV_ISA_ZBKB)
>>
>>>   #define runtime_const_ptr(sym)                        \
>>>   ({                                    \
>>>       typeof(sym) __ret, __tmp;                    \
>>> @@ -93,7 +94,7 @@
>>>           : [__ret] "=r" (__ret), [__tmp] "=r" (__tmp));        \
>>>       __ret;                                \
>>>   })
>>> -#elif defined(CONFIG_RISCV_ISA_ZBA)
>>> +#elif defined(CONFIG_RISCV_ISA_ZBA) &&
>>> defined(CONFIG_TOOLCHAIN_HAS_ZBA)
>>>   #define runtime_const_ptr(sym)                        \
>>>   ({                                    \
>>>       typeof(sym) __ret, __tmp;                    \


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] riscv: Make sure toolchain supports zba before using zba instructions
  2025-03-28 11:54 [PATCH] riscv: Make sure toolchain supports zba before using zba instructions Alexandre Ghiti
  2025-03-28 12:51 ` Clément Léger
@ 2025-04-03 16:20 ` patchwork-bot+linux-riscv
  1 sibling, 0 replies; 5+ messages in thread
From: patchwork-bot+linux-riscv @ 2025-04-03 16:20 UTC (permalink / raw)
  To: Alexandre Ghiti
  Cc: linux-riscv, paul.walmsley, palmer, alex, linux-kernel, lkp

Hello:

This patch was applied to riscv/linux.git (for-next)
by Alexandre Ghiti <alexghiti@rivosinc.com>:

On Fri, 28 Mar 2025 12:54:22 +0100 you wrote:
> Old toolchain like gcc 8.5.0 does not support zba, so we must check that
> the toolchain supports this extension before using it in the kernel.
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202503281836.8pntHm6I-lkp@intel.com/
> Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
> 
> [...]

Here is the summary with links:
  - riscv: Make sure toolchain supports zba before using zba instructions
    https://git.kernel.org/riscv/c/8a2f20ac8e14

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-04-03 16:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-28 11:54 [PATCH] riscv: Make sure toolchain supports zba before using zba instructions Alexandre Ghiti
2025-03-28 12:51 ` Clément Léger
2025-03-28 13:00   ` Alexandre Ghiti
2025-03-28 13:02     ` Clément Léger
2025-04-03 16:20 ` patchwork-bot+linux-riscv

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox