[PATCH] riscv: avoid enabling vectorized code generation

Conor Dooley conor at kernel.org
Fri Dec 16 11:05:05 PST 2022


Hey Saleem,

On 16 December 2022 10:50:12 GMT-08:00, Saleem Abdulrasool <abdulras at google.com> wrote:
>The compiler is free to generate vectorized operations for zero'ing
>memory.  The kernel does not use the vector unit on RISCV, similar to
>architectures such as x86 where we use `-mno-mmx` et al to prevent the
>implicit vectorization.  Perform a similar check for
>`-mno-implicit-float` to avoid this on RISC-V targets.
>
>Signed-off-by: Saleem Abdulrasool <abdulras at google.com>
>---
> arch/riscv/Makefile | 4 ++++
> 1 file changed, 4 insertions(+)
>
>diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
>index 0d13b597cb55..68433476a96e 100644
>--- a/arch/riscv/Makefile
>+++ b/arch/riscv/Makefile
>@@ -89,6 +89,10 @@ KBUILD_AFLAGS_MODULE += $(call as-option,-Wa$(comma)-mno-relax)
> # architectures.  It's faster to have GCC emit only aligned accesses.
> KBUILD_CFLAGS += $(call cc-option,-mstrict-align)
> 
>+# Ensure that we do not vectorize the kernel code when the `v` extension is
>+# enabled.  This mirrors the `-mno-mmx` et al on x86.

The v extension should not be enabled at all though, right?
Excuse my naivity here, but what am I missing?
The vector support thread is here:
https://lore.kernel.org/linux-riscv/20220921214439.1491510-1-stillson@rivosinc.com/

What have I missed that causes a problem without that patchset?
And if I have missed something, this patch needs to be cc: stable?

Thanks,
Conor.

>+KBUILD_CFLAGS += $(call cc-option,-mno-implicit-float)
>+
> ifeq ($(CONFIG_STACKPROTECTOR_PER_TASK),y)
> prepare: stack_protector_prepare
> stack_protector_prepare: prepare0



More information about the linux-riscv mailing list