Skip to content

Commit 71883ae

Browse files
SiFiveHollandakpm00
authored andcommitted
arm64: implement ARCH_HAS_KERNEL_FPU_SUPPORT
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. Link: https://lkml.kernel.org/r/20240329072441.591471-5-samuel.holland@sifive.com Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Acked-by: Christian König <christian.koenig@amd.com> Cc: Alex Deucher <alexander.deucher@amd.com> Cc: Borislav Petkov (AMD) <bp@alien8.de> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: Huacai Chen <chenhuacai@kernel.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Masahiro Yamada <masahiroy@kernel.org> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Nathan Chancellor <nathan@kernel.org> Cc: Nicolas Schier <nicolas@fjasle.eu> Cc: Palmer Dabbelt <palmer@rivosinc.com> Cc: Russell King <linux@armlinux.org.uk> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: WANG Xuerui <git@xen0n.name> Cc: Will Deacon <will@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent c416243 commit 71883ae

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

arch/arm64/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ config ARM64
3030
select ARCH_HAS_GCOV_PROFILE_ALL
3131
select ARCH_HAS_GIGANTIC_PAGE
3232
select ARCH_HAS_KCOV
33+
select ARCH_HAS_KERNEL_FPU_SUPPORT if KERNEL_MODE_NEON
3334
select ARCH_HAS_KEEPINITRD
3435
select ARCH_HAS_MEMBARRIER_SYNC_CORE
3536
select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS

arch/arm64/Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,14 @@ ifeq ($(CONFIG_BROKEN_GAS_INST),y)
3636
$(warning Detected assembler with broken .inst; disassembly will be unreliable)
3737
endif
3838

39-
KBUILD_CFLAGS += -mgeneral-regs-only \
39+
# The GCC option -ffreestanding is required in order to compile code containing
40+
# ARM/NEON intrinsics in a non C99-compliant environment (such as the kernel)
41+
CC_FLAGS_FPU := -ffreestanding
42+
# Enable <arm_neon.h>
43+
CC_FLAGS_FPU += -isystem $(shell $(CC) -print-file-name=include)
44+
CC_FLAGS_NO_FPU := -mgeneral-regs-only
45+
46+
KBUILD_CFLAGS += $(CC_FLAGS_NO_FPU) \
4047
$(compat_vdso) $(cc_has_k_constraint)
4148
KBUILD_CFLAGS += $(call cc-disable-warning, psabi)
4249
KBUILD_AFLAGS += $(compat_vdso)

arch/arm64/include/asm/fpu.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
/*
3+
* Copyright (C) 2023 SiFive
4+
*/
5+
6+
#ifndef __ASM_FPU_H
7+
#define __ASM_FPU_H
8+
9+
#include <asm/neon.h>
10+
11+
#define kernel_fpu_available() cpu_has_neon()
12+
#define kernel_fpu_begin() kernel_neon_begin()
13+
#define kernel_fpu_end() kernel_neon_end()
14+
15+
#endif /* ! __ASM_FPU_H */

0 commit comments

Comments
 (0)