Message ID | 20231208055501.2916202-5-samuel.holland@sifive.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Unified cross-architecture kernel-mode FPU API | expand |
> + * linux/arch/arm64/include/asm/fpu.h Same comment as for arm here. Except for that: Reviewed-by: Christoph Hellwig <hch@lst.de>
On Thu, Dec 07, 2023 at 09:54:34PM -0800, Samuel Holland wrote: > arm64 provides an equivalent to the common kernel-mode FPU API, but in a > different header and using different function names. Add a wrapper > header, and export CFLAGS adjustments as found in lib/raid6/Makefile. > > Signed-off-by: Samuel Holland <samuel.holland@sifive.com> > --- > > arch/arm64/Kconfig | 1 + > arch/arm64/Makefile | 9 ++++++++- > arch/arm64/include/asm/fpu.h | 17 +++++++++++++++++ > 3 files changed, 26 insertions(+), 1 deletion(-) > create mode 100644 arch/arm64/include/asm/fpu.h > > diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig > index 7b071a00425d..485ac389ac11 100644 > --- a/arch/arm64/Kconfig > +++ b/arch/arm64/Kconfig > @@ -30,6 +30,7 @@ config ARM64 > select ARCH_HAS_GCOV_PROFILE_ALL > select ARCH_HAS_GIGANTIC_PAGE > select ARCH_HAS_KCOV > + select ARCH_HAS_KERNEL_FPU_SUPPORT if KERNEL_MODE_NEON > select ARCH_HAS_KEEPINITRD > select ARCH_HAS_MEMBARRIER_SYNC_CORE > select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS > diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile > index 9a2d3723cd0f..4a65f24c7998 100644 > --- a/arch/arm64/Makefile > +++ b/arch/arm64/Makefile > @@ -36,7 +36,14 @@ ifeq ($(CONFIG_BROKEN_GAS_INST),y) > $(warning Detected assembler with broken .inst; disassembly will be unreliable) > endif > > -KBUILD_CFLAGS += -mgeneral-regs-only \ > +# The GCC option -ffreestanding is required in order to compile code containing > +# ARM/NEON intrinsics in a non C99-compliant environment (such as the kernel) > +CC_FLAGS_FPU := -ffreestanding > +# Enable <arm_neon.h> > +CC_FLAGS_FPU += -isystem $(shell $(CC) -print-file-name=include) > +CC_FLAGS_NO_FPU := -mgeneral-regs-only > + > +KBUILD_CFLAGS += $(CC_FLAGS_NO_FPU) \ > $(compat_vdso) $(cc_has_k_constraint) > KBUILD_CFLAGS += $(call cc-disable-warning, psabi) > KBUILD_AFLAGS += $(compat_vdso) Can you use this to replace the same logic in arch/arm64/lib/Makefile, like you do for arch/arm/? Will
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 7b071a00425d..485ac389ac11 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -30,6 +30,7 @@ config ARM64 select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_GIGANTIC_PAGE select ARCH_HAS_KCOV + select ARCH_HAS_KERNEL_FPU_SUPPORT if KERNEL_MODE_NEON select ARCH_HAS_KEEPINITRD select ARCH_HAS_MEMBARRIER_SYNC_CORE select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile index 9a2d3723cd0f..4a65f24c7998 100644 --- a/arch/arm64/Makefile +++ b/arch/arm64/Makefile @@ -36,7 +36,14 @@ ifeq ($(CONFIG_BROKEN_GAS_INST),y) $(warning Detected assembler with broken .inst; disassembly will be unreliable) endif -KBUILD_CFLAGS += -mgeneral-regs-only \ +# The GCC option -ffreestanding is required in order to compile code containing +# ARM/NEON intrinsics in a non C99-compliant environment (such as the kernel) +CC_FLAGS_FPU := -ffreestanding +# Enable <arm_neon.h> +CC_FLAGS_FPU += -isystem $(shell $(CC) -print-file-name=include) +CC_FLAGS_NO_FPU := -mgeneral-regs-only + +KBUILD_CFLAGS += $(CC_FLAGS_NO_FPU) \ $(compat_vdso) $(cc_has_k_constraint) KBUILD_CFLAGS += $(call cc-disable-warning, psabi) KBUILD_AFLAGS += $(compat_vdso) diff --git a/arch/arm64/include/asm/fpu.h b/arch/arm64/include/asm/fpu.h new file mode 100644 index 000000000000..664c0a192ab1 --- /dev/null +++ b/arch/arm64/include/asm/fpu.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * linux/arch/arm64/include/asm/fpu.h + * + * Copyright (C) 2023 SiFive + */ + +#ifndef __ASM_FPU_H +#define __ASM_FPU_H + +#include <asm/neon.h> + +#define kernel_fpu_available() cpu_has_neon() +#define kernel_fpu_begin() kernel_neon_begin() +#define kernel_fpu_end() kernel_neon_end() + +#endif /* ! __ASM_FPU_H */
arm64 provides an equivalent to the common kernel-mode FPU API, but in a different header and using different function names. Add a wrapper header, and export CFLAGS adjustments as found in lib/raid6/Makefile. Signed-off-by: Samuel Holland <samuel.holland@sifive.com> --- arch/arm64/Kconfig | 1 + arch/arm64/Makefile | 9 ++++++++- arch/arm64/include/asm/fpu.h | 17 +++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 arch/arm64/include/asm/fpu.h