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/[email protected] Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Acked-by: Christian König <[email protected]> Cc: Alex Deucher <[email protected]> Cc: Borislav Petkov (AMD) <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Huacai Chen <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: Masahiro Yamada <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Nathan Chancellor <[email protected]> Cc: Nicolas Schier <[email protected]> Cc: Palmer Dabbelt <[email protected]> Cc: Russell King <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: WANG Xuerui <[email protected]> Cc: Will Deacon <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
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)