Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'mm-nonmm-stable-2024-05-22-17-30' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Pull more non-mm updates from Andrew Morton:

- A series ("kbuild: enable more warnings by default") from Arnd
Bergmann which enables a number of additional build-time warnings. We
fixed all the fallout which we could find, there may still be a few
stragglers.

- Samuel Holland has developed the series "Unified cross-architecture
kernel-mode FPU API". This does a lot of consolidation of
per-architecture kernel-mode FPU usage and enables the use of newer
AMD GPUs on RISC-V.

- Tao Su has fixed some selftests build warnings in the series
"Selftests: Fix compilation warnings due to missing _GNU_SOURCE
definition".

- This pull also includes a nilfs2 fixup from Ryusuke Konishi.

* tag 'mm-nonmm-stable-2024-05-22-17-30' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: (23 commits)
nilfs2: make block erasure safe in nilfs_finish_roll_forward()
selftests/harness: use 1024 in place of LINE_MAX
Revert "selftests/harness: remove use of LINE_MAX"
selftests/fpu: allow building on other architectures
selftests/fpu: move FP code to a separate translation unit
drm/amd/display: use ARCH_HAS_KERNEL_FPU_SUPPORT
drm/amd/display: only use hard-float, not altivec on powerpc
riscv: add support for kernel-mode FPU
x86: implement ARCH_HAS_KERNEL_FPU_SUPPORT
powerpc: implement ARCH_HAS_KERNEL_FPU_SUPPORT
LoongArch: implement ARCH_HAS_KERNEL_FPU_SUPPORT
lib/raid6: use CC_FLAGS_FPU for NEON CFLAGS
arm64: crypto: use CC_FLAGS_FPU for NEON CFLAGS
arm64: implement ARCH_HAS_KERNEL_FPU_SUPPORT
ARM: crypto: use CC_FLAGS_FPU for NEON CFLAGS
ARM: implement ARCH_HAS_KERNEL_FPU_SUPPORT
arch: add ARCH_HAS_KERNEL_FPU_SUPPORT
x86/fpu: fix asm/fpu/types.h include guard
kbuild: enable -Wcast-function-type-strict unconditionally
kbuild: enable -Wformat-truncation on clang
...

+365 -220
+78
Documentation/core-api/floating-point.rst
··· 1 + .. SPDX-License-Identifier: GPL-2.0+ 2 + 3 + Floating-point API 4 + ================== 5 + 6 + Kernel code is normally prohibited from using floating-point (FP) registers or 7 + instructions, including the C float and double data types. This rule reduces 8 + system call overhead, because the kernel does not need to save and restore the 9 + userspace floating-point register state. 10 + 11 + However, occasionally drivers or library functions may need to include FP code. 12 + This is supported by isolating the functions containing FP code to a separate 13 + translation unit (a separate source file), and saving/restoring the FP register 14 + state around calls to those functions. This creates "critical sections" of 15 + floating-point usage. 16 + 17 + The reason for this isolation is to prevent the compiler from generating code 18 + touching the FP registers outside these critical sections. Compilers sometimes 19 + use FP registers to optimize inlined ``memcpy`` or variable assignment, as 20 + floating-point registers may be wider than general-purpose registers. 21 + 22 + Usability of floating-point code within the kernel is architecture-specific. 23 + Additionally, because a single kernel may be configured to support platforms 24 + both with and without a floating-point unit, FPU availability must be checked 25 + both at build time and at run time. 26 + 27 + Several architectures implement the generic kernel floating-point API from 28 + ``linux/fpu.h``, as described below. Some other architectures implement their 29 + own unique APIs, which are documented separately. 30 + 31 + Build-time API 32 + -------------- 33 + 34 + Floating-point code may be built if the option ``ARCH_HAS_KERNEL_FPU_SUPPORT`` 35 + is enabled. For C code, such code must be placed in a separate file, and that 36 + file must have its compilation flags adjusted using the following pattern:: 37 + 38 + CFLAGS_foo.o += $(CC_FLAGS_FPU) 39 + CFLAGS_REMOVE_foo.o += $(CC_FLAGS_NO_FPU) 40 + 41 + Architectures are expected to define one or both of these variables in their 42 + top-level Makefile as needed. For example:: 43 + 44 + CC_FLAGS_FPU := -mhard-float 45 + 46 + or:: 47 + 48 + CC_FLAGS_NO_FPU := -msoft-float 49 + 50 + Normal kernel code is assumed to use the equivalent of ``CC_FLAGS_NO_FPU``. 51 + 52 + Runtime API 53 + ----------- 54 + 55 + The runtime API is provided in ``linux/fpu.h``. This header cannot be included 56 + from files implementing FP code (those with their compilation flags adjusted as 57 + above). Instead, it must be included when defining the FP critical sections. 58 + 59 + .. c:function:: bool kernel_fpu_available( void ) 60 + 61 + This function reports if floating-point code can be used on this CPU or 62 + platform. The value returned by this function is not expected to change 63 + at runtime, so it only needs to be called once, not before every 64 + critical section. 65 + 66 + .. c:function:: void kernel_fpu_begin( void ) 67 + void kernel_fpu_end( void ) 68 + 69 + These functions create a floating-point critical section. It is only 70 + valid to call ``kernel_fpu_begin()`` after a previous call to 71 + ``kernel_fpu_available()`` returned ``true``. These functions are only 72 + guaranteed to be callable from (preemptible or non-preemptible) process 73 + context. 74 + 75 + Preemption may be disabled inside critical sections, so their size 76 + should be minimized. They are *not* required to be reentrant. If the 77 + caller expects to nest critical sections, it must implement its own 78 + reference counting.
+1
Documentation/core-api/index.rst
··· 48 48 errseq 49 49 wrappers/atomic_t 50 50 wrappers/atomic_bitops 51 + floating-point 51 52 52 53 Low level entry and exit 53 54 ========================
+5
Makefile
··· 970 970 export CC_FLAGS_CFI 971 971 endif 972 972 973 + # Architectures can define flags to add/remove for floating-point support 974 + CC_FLAGS_FPU += -D_LINUX_FPU_COMPILATION_UNIT 975 + export CC_FLAGS_FPU 976 + export CC_FLAGS_NO_FPU 977 + 973 978 ifneq ($(CONFIG_FUNCTION_ALIGNMENT),0) 974 979 # Set the minimal function alignment. Use the newer GCC option 975 980 # -fmin-function-alignment if it is available, or fall back to -falign-funtions.
+6
arch/Kconfig
··· 1594 1594 address translations. Page table walkers that clear the accessed bit 1595 1595 may use this capability to reduce their search space. 1596 1596 1597 + config ARCH_HAS_KERNEL_FPU_SUPPORT 1598 + bool 1599 + help 1600 + Architectures that select this option can run floating-point code in 1601 + the kernel, as described in Documentation/core-api/floating-point.rst. 1602 + 1597 1603 source "kernel/gcov/Kconfig" 1598 1604 1599 1605 source "scripts/gcc-plugins/Kconfig"
+7
arch/arm/Makefile
··· 130 130 # Accept old syntax despite ".syntax unified" 131 131 AFLAGS_NOWARN :=$(call as-option,-Wa$(comma)-mno-warn-deprecated,-Wa$(comma)-W) 132 132 133 + # The GCC option -ffreestanding is required in order to compile code containing 134 + # ARM/NEON intrinsics in a non C99-compliant environment (such as the kernel) 135 + CC_FLAGS_FPU := -ffreestanding 136 + # Enable <arm_neon.h> 137 + CC_FLAGS_FPU += -isystem $(shell $(CC) -print-file-name=include) 138 + CC_FLAGS_FPU += -march=armv7-a -mfloat-abi=softfp -mfpu=neon 139 + 133 140 ifeq ($(CONFIG_THUMB2_KERNEL),y) 134 141 CFLAGS_ISA :=-Wa,-mimplicit-it=always $(AFLAGS_NOWARN) 135 142 AFLAGS_ISA :=$(CFLAGS_ISA) -Wa$(comma)-mthumb
+15
arch/arm/include/asm/fpu.h
··· 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 */
+1 -2
arch/arm/lib/Makefile
··· 40 40 $(obj)/csumpartialcopyuser.o: $(obj)/csumpartialcopygeneric.S 41 41 42 42 ifeq ($(CONFIG_KERNEL_MODE_NEON),y) 43 - NEON_FLAGS := -march=armv7-a -mfloat-abi=softfp -mfpu=neon 44 - CFLAGS_xor-neon.o += $(NEON_FLAGS) 43 + CFLAGS_xor-neon.o += $(CC_FLAGS_FPU) 45 44 obj-$(CONFIG_XOR_BLOCKS) += xor-neon.o 46 45 endif 47 46
+1
arch/arm64/Kconfig
··· 30 30 select ARCH_HAS_GCOV_PROFILE_ALL 31 31 select ARCH_HAS_GIGANTIC_PAGE 32 32 select ARCH_HAS_KCOV 33 + select ARCH_HAS_KERNEL_FPU_SUPPORT if KERNEL_MODE_NEON 33 34 select ARCH_HAS_KEEPINITRD 34 35 select ARCH_HAS_MEMBARRIER_SYNC_CORE 35 36 select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS
+8 -1
arch/arm64/Makefile
··· 36 36 $(warning Detected assembler with broken .inst; disassembly will be unreliable) 37 37 endif 38 38 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) \ 40 47 $(compat_vdso) $(cc_has_k_constraint) 41 48 KBUILD_CFLAGS += $(call cc-disable-warning, psabi) 42 49 KBUILD_AFLAGS += $(compat_vdso)
+15
arch/arm64/include/asm/fpu.h
··· 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 */
+2 -4
arch/arm64/lib/Makefile
··· 7 7 8 8 ifeq ($(CONFIG_KERNEL_MODE_NEON), y) 9 9 obj-$(CONFIG_XOR_BLOCKS) += xor-neon.o 10 - CFLAGS_REMOVE_xor-neon.o += -mgeneral-regs-only 11 - CFLAGS_xor-neon.o += -ffreestanding 12 - # Enable <arm_neon.h> 13 - CFLAGS_xor-neon.o += -isystem $(shell $(CC) -print-file-name=include) 10 + CFLAGS_xor-neon.o += $(CC_FLAGS_FPU) 11 + CFLAGS_REMOVE_xor-neon.o += $(CC_FLAGS_NO_FPU) 14 12 endif 15 13 16 14 lib-$(CONFIG_ARCH_HAS_UACCESS_FLUSHCACHE) += uaccess_flushcache.o
+1
arch/loongarch/Kconfig
··· 19 19 select ARCH_HAS_FAST_MULTIPLIER 20 20 select ARCH_HAS_FORTIFY_SOURCE 21 21 select ARCH_HAS_KCOV 22 + select ARCH_HAS_KERNEL_FPU_SUPPORT if CPU_HAS_FPU 22 23 select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS 23 24 select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE 24 25 select ARCH_HAS_PTE_SPECIAL
+4 -1
arch/loongarch/Makefile
··· 26 26 32bit-emul = elf32loongarch 27 27 64bit-emul = elf64loongarch 28 28 29 + CC_FLAGS_FPU := -mfpu=64 30 + CC_FLAGS_NO_FPU := -msoft-float 31 + 29 32 ifdef CONFIG_UNWINDER_ORC 30 33 orc_hash_h := arch/$(SRCARCH)/include/generated/asm/orc_hash.h 31 34 orc_hash_sh := $(srctree)/scripts/orc_hash.sh ··· 62 59 cflags-y += -mabi=lp64s 63 60 endif 64 61 65 - cflags-y += -pipe -msoft-float 62 + cflags-y += -pipe $(CC_FLAGS_NO_FPU) 66 63 LDFLAGS_vmlinux += -static -n -nostdlib 67 64 68 65 # When the assembler supports explicit relocation hint, we must use it.
+1
arch/loongarch/include/asm/fpu.h
··· 21 21 22 22 struct sigcontext; 23 23 24 + #define kernel_fpu_available() cpu_has_fpu 24 25 extern void kernel_fpu_begin(void); 25 26 extern void kernel_fpu_end(void); 26 27
+1
arch/powerpc/Kconfig
··· 137 137 select ARCH_HAS_GCOV_PROFILE_ALL 138 138 select ARCH_HAS_HUGEPD if HUGETLB_PAGE 139 139 select ARCH_HAS_KCOV 140 + select ARCH_HAS_KERNEL_FPU_SUPPORT if PPC_FPU 140 141 select ARCH_HAS_MEMBARRIER_CALLBACKS 141 142 select ARCH_HAS_MEMBARRIER_SYNC_CORE 142 143 select ARCH_HAS_MEMREMAP_COMPAT_ALIGN if PPC_64S_HASH_MMU
+4 -1
arch/powerpc/Makefile
··· 149 149 150 150 CFLAGS-$(CONFIG_PPC32) += $(call cc-option,-mno-readonly-in-sdata) 151 151 152 + CC_FLAGS_FPU := $(call cc-option,-mhard-float) 153 + CC_FLAGS_NO_FPU := $(call cc-option,-msoft-float) 154 + 152 155 ifdef CONFIG_FUNCTION_TRACER 153 156 ifdef CONFIG_ARCH_USING_PATCHABLE_FUNCTION_ENTRY 154 157 KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY ··· 173 170 174 171 KBUILD_CPPFLAGS += -I $(srctree)/arch/powerpc $(asinstr) 175 172 KBUILD_AFLAGS += $(AFLAGS-y) 176 - KBUILD_CFLAGS += $(call cc-option,-msoft-float) 173 + KBUILD_CFLAGS += $(CC_FLAGS_NO_FPU) 177 174 KBUILD_CFLAGS += $(CFLAGS-y) 178 175 CPP = $(CC) -E $(KBUILD_CFLAGS) 179 176
+28
arch/powerpc/include/asm/fpu.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-only */ 2 + /* 3 + * Copyright (C) 2023 SiFive 4 + */ 5 + 6 + #ifndef _ASM_POWERPC_FPU_H 7 + #define _ASM_POWERPC_FPU_H 8 + 9 + #include <linux/preempt.h> 10 + 11 + #include <asm/cpu_has_feature.h> 12 + #include <asm/switch_to.h> 13 + 14 + #define kernel_fpu_available() (!cpu_has_feature(CPU_FTR_FPU_UNAVAILABLE)) 15 + 16 + static inline void kernel_fpu_begin(void) 17 + { 18 + preempt_disable(); 19 + enable_kernel_fp(); 20 + } 21 + 22 + static inline void kernel_fpu_end(void) 23 + { 24 + disable_kernel_fp(); 25 + preempt_enable(); 26 + } 27 + 28 + #endif /* ! _ASM_POWERPC_FPU_H */
+1
arch/riscv/Kconfig
··· 28 28 select ARCH_HAS_GCOV_PROFILE_ALL 29 29 select ARCH_HAS_GIGANTIC_PAGE 30 30 select ARCH_HAS_KCOV 31 + select ARCH_HAS_KERNEL_FPU_SUPPORT if 64BIT && FPU 31 32 select ARCH_HAS_MEMBARRIER_CALLBACKS 32 33 select ARCH_HAS_MEMBARRIER_SYNC_CORE 33 34 select ARCH_HAS_MMIOWB
+3
arch/riscv/Makefile
··· 91 91 92 92 KBUILD_AFLAGS += -march=$(riscv-march-y) 93 93 94 + # For C code built with floating-point support, exclude V but keep F and D. 95 + CC_FLAGS_FPU := -march=$(shell echo $(riscv-march-y) | sed -E 's/(rv32ima|rv64ima)([^v_]*)v?/\1\2/') 96 + 94 97 KBUILD_CFLAGS += -mno-save-restore 95 98 KBUILD_CFLAGS += -DCONFIG_PAGE_OFFSET=$(CONFIG_PAGE_OFFSET) 96 99
+16
arch/riscv/include/asm/fpu.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-only */ 2 + /* 3 + * Copyright (C) 2023 SiFive 4 + */ 5 + 6 + #ifndef _ASM_RISCV_FPU_H 7 + #define _ASM_RISCV_FPU_H 8 + 9 + #include <asm/switch_to.h> 10 + 11 + #define kernel_fpu_available() has_fpu() 12 + 13 + void kernel_fpu_begin(void); 14 + void kernel_fpu_end(void); 15 + 16 + #endif /* ! _ASM_RISCV_FPU_H */
+1
arch/riscv/kernel/Makefile
··· 67 67 obj-$(CONFIG_RISCV_PROBE_UNALIGNED_ACCESS) += copy-unaligned.o 68 68 69 69 obj-$(CONFIG_FPU) += fpu.o 70 + obj-$(CONFIG_FPU) += kernel_mode_fpu.o 70 71 obj-$(CONFIG_RISCV_ISA_V) += vector.o 71 72 obj-$(CONFIG_RISCV_ISA_V) += kernel_mode_vector.o 72 73 obj-$(CONFIG_SMP) += smpboot.o
+28
arch/riscv/kernel/kernel_mode_fpu.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright (C) 2023 SiFive 4 + */ 5 + 6 + #include <linux/export.h> 7 + #include <linux/preempt.h> 8 + 9 + #include <asm/csr.h> 10 + #include <asm/fpu.h> 11 + #include <asm/processor.h> 12 + #include <asm/switch_to.h> 13 + 14 + void kernel_fpu_begin(void) 15 + { 16 + preempt_disable(); 17 + fstate_save(current, task_pt_regs(current)); 18 + csr_set(CSR_SSTATUS, SR_FS); 19 + } 20 + EXPORT_SYMBOL_GPL(kernel_fpu_begin); 21 + 22 + void kernel_fpu_end(void) 23 + { 24 + csr_clear(CSR_SSTATUS, SR_FS); 25 + fstate_restore(current, task_pt_regs(current)); 26 + preempt_enable(); 27 + } 28 + EXPORT_SYMBOL_GPL(kernel_fpu_end);
+1
arch/x86/Kconfig
··· 85 85 select ARCH_HAS_FORTIFY_SOURCE 86 86 select ARCH_HAS_GCOV_PROFILE_ALL 87 87 select ARCH_HAS_KCOV if X86_64 88 + select ARCH_HAS_KERNEL_FPU_SUPPORT 88 89 select ARCH_HAS_MEM_ENCRYPT 89 90 select ARCH_HAS_MEMBARRIER_SYNC_CORE 90 91 select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS
+20
arch/x86/Makefile
··· 74 74 KBUILD_RUSTFLAGS += --target=$(objtree)/scripts/target.json 75 75 KBUILD_RUSTFLAGS += -Ctarget-feature=-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2 76 76 77 + # 78 + # CFLAGS for compiling floating point code inside the kernel. 79 + # 80 + CC_FLAGS_FPU := -msse -msse2 81 + ifdef CONFIG_CC_IS_GCC 82 + # Stack alignment mismatch, proceed with caution. 83 + # GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3 84 + # (8B stack alignment). 85 + # See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383 86 + # 87 + # The "-msse" in the first argument is there so that the 88 + # -mpreferred-stack-boundary=3 build error: 89 + # 90 + # -mpreferred-stack-boundary=3 is not between 4 and 12 91 + # 92 + # can be triggered. Otherwise gcc doesn't complain. 93 + CC_FLAGS_FPU += -mhard-float 94 + CC_FLAGS_FPU += $(call cc-option,-msse -mpreferred-stack-boundary=3,-mpreferred-stack-boundary=4) 95 + endif 96 + 77 97 ifeq ($(CONFIG_X86_KERNEL_IBT),y) 78 98 # 79 99 # Kernel IBT has S_CET.NOTRACK_EN=0, as such the compilers must not generate
+13
arch/x86/include/asm/fpu.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-only */ 2 + /* 3 + * Copyright (C) 2023 SiFive 4 + */ 5 + 6 + #ifndef _ASM_X86_FPU_H 7 + #define _ASM_X86_FPU_H 8 + 9 + #include <asm/fpu/api.h> 10 + 11 + #define kernel_fpu_available() true 12 + 13 + #endif /* ! _ASM_X86_FPU_H */
+3 -3
arch/x86/include/asm/fpu/types.h
··· 2 2 /* 3 3 * FPU data structures: 4 4 */ 5 - #ifndef _ASM_X86_FPU_H 6 - #define _ASM_X86_FPU_H 5 + #ifndef _ASM_X86_FPU_TYPES_H 6 + #define _ASM_X86_FPU_TYPES_H 7 7 8 8 #include <asm/page_types.h> 9 9 ··· 596 596 /* FPU state configuration information */ 597 597 extern struct fpu_state_config fpu_kernel_cfg, fpu_user_cfg; 598 598 599 - #endif /* _ASM_X86_FPU_H */ 599 + #endif /* _ASM_X86_FPU_TYPES_H */
+1 -1
drivers/gpu/drm/amd/display/Kconfig
··· 8 8 depends on BROKEN || !CC_IS_CLANG || ARM64 || RISCV || SPARC64 || X86_64 9 9 select SND_HDA_COMPONENT if SND_HDA_CORE 10 10 # !CC_IS_CLANG: https://github.com/ClangBuiltLinux/linux/issues/1752 11 - select DRM_AMD_DC_FP if (X86 || LOONGARCH || (PPC64 && ALTIVEC) || (ARM64 && KERNEL_MODE_NEON && !CC_IS_CLANG)) 11 + select DRM_AMD_DC_FP if ARCH_HAS_KERNEL_FPU_SUPPORT && (!ARM64 || !CC_IS_CLANG) 12 12 help 13 13 Choose this option if you want to use the new display engine 14 14 support for AMDGPU. This adds required support for Vega and
+2 -33
drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c
··· 26 26 27 27 #include "dc_trace.h" 28 28 29 - #if defined(CONFIG_X86) 30 - #include <asm/fpu/api.h> 31 - #elif defined(CONFIG_PPC64) 32 - #include <asm/switch_to.h> 33 - #include <asm/cputable.h> 34 - #elif defined(CONFIG_ARM64) 35 - #include <asm/neon.h> 36 - #elif defined(CONFIG_LOONGARCH) 37 - #include <asm/fpu.h> 38 - #endif 29 + #include <linux/fpu.h> 39 30 40 31 /** 41 32 * DOC: DC FPU manipulation overview ··· 78 87 WARN_ON_ONCE(!in_task()); 79 88 preempt_disable(); 80 89 depth = __this_cpu_inc_return(fpu_recursion_depth); 81 - 82 90 if (depth == 1) { 83 - #if defined(CONFIG_X86) || defined(CONFIG_LOONGARCH) 91 + BUG_ON(!kernel_fpu_available()); 84 92 kernel_fpu_begin(); 85 - #elif defined(CONFIG_PPC64) 86 - if (cpu_has_feature(CPU_FTR_VSX_COMP)) 87 - enable_kernel_vsx(); 88 - else if (cpu_has_feature(CPU_FTR_ALTIVEC_COMP)) 89 - enable_kernel_altivec(); 90 - else if (!cpu_has_feature(CPU_FTR_FPU_UNAVAILABLE)) 91 - enable_kernel_fp(); 92 - #elif defined(CONFIG_ARM64) 93 - kernel_neon_begin(); 94 - #endif 95 93 } 96 94 97 95 TRACE_DCN_FPU(true, function_name, line, depth); ··· 102 122 103 123 depth = __this_cpu_dec_return(fpu_recursion_depth); 104 124 if (depth == 0) { 105 - #if defined(CONFIG_X86) || defined(CONFIG_LOONGARCH) 106 125 kernel_fpu_end(); 107 - #elif defined(CONFIG_PPC64) 108 - if (cpu_has_feature(CPU_FTR_VSX_COMP)) 109 - disable_kernel_vsx(); 110 - else if (cpu_has_feature(CPU_FTR_ALTIVEC_COMP)) 111 - disable_kernel_altivec(); 112 - else if (!cpu_has_feature(CPU_FTR_FPU_UNAVAILABLE)) 113 - disable_kernel_fp(); 114 - #elif defined(CONFIG_ARM64) 115 - kernel_neon_end(); 116 - #endif 117 126 } else { 118 127 WARN_ON_ONCE(depth < 0); 119 128 }
+2 -34
drivers/gpu/drm/amd/display/dc/dml/Makefile
··· 25 25 # It provides the general basic services required by other DAL 26 26 # subcomponents. 27 27 28 - ifdef CONFIG_X86 29 - dml_ccflags-$(CONFIG_CC_IS_GCC) := -mhard-float 30 - dml_ccflags := $(dml_ccflags-y) -msse 31 - endif 32 - 33 - ifdef CONFIG_PPC64 34 - dml_ccflags := -mhard-float -maltivec 35 - endif 36 - 37 - ifdef CONFIG_ARM64 38 - dml_rcflags := -mgeneral-regs-only 39 - endif 40 - 41 - ifdef CONFIG_LOONGARCH 42 - dml_ccflags := -mfpu=64 43 - dml_rcflags := -msoft-float 44 - endif 45 - 46 - ifdef CONFIG_CC_IS_GCC 47 - ifneq ($(call gcc-min-version, 70100),y) 48 - IS_OLD_GCC = 1 49 - endif 50 - endif 51 - 52 - ifdef CONFIG_X86 53 - ifdef IS_OLD_GCC 54 - # Stack alignment mismatch, proceed with caution. 55 - # GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3 56 - # (8B stack alignment). 57 - dml_ccflags += -mpreferred-stack-boundary=4 58 - else 59 - dml_ccflags += -msse2 60 - endif 61 - endif 28 + dml_ccflags := $(CC_FLAGS_FPU) 29 + dml_rcflags := $(CC_FLAGS_NO_FPU) 62 30 63 31 ifneq ($(CONFIG_FRAME_WARN),0) 64 32 ifeq ($(filter y,$(CONFIG_KASAN)$(CONFIG_KCSAN)),y)
+2 -34
drivers/gpu/drm/amd/display/dc/dml2/Makefile
··· 24 24 # 25 25 # Makefile for dml2. 26 26 27 - ifdef CONFIG_X86 28 - dml2_ccflags-$(CONFIG_CC_IS_GCC) := -mhard-float 29 - dml2_ccflags := $(dml2_ccflags-y) -msse 30 - endif 31 - 32 - ifdef CONFIG_PPC64 33 - dml2_ccflags := -mhard-float -maltivec 34 - endif 35 - 36 - ifdef CONFIG_ARM64 37 - dml2_rcflags := -mgeneral-regs-only 38 - endif 39 - 40 - ifdef CONFIG_LOONGARCH 41 - dml2_ccflags := -mfpu=64 42 - dml2_rcflags := -msoft-float 43 - endif 44 - 45 - ifdef CONFIG_CC_IS_GCC 46 - ifeq ($(call cc-ifversion, -lt, 0701, y), y) 47 - IS_OLD_GCC = 1 48 - endif 49 - endif 50 - 51 - ifdef CONFIG_X86 52 - ifdef IS_OLD_GCC 53 - # Stack alignment mismatch, proceed with caution. 54 - # GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3 55 - # (8B stack alignment). 56 - dml2_ccflags += -mpreferred-stack-boundary=4 57 - else 58 - dml2_ccflags += -msse2 59 - endif 60 - endif 27 + dml2_ccflags := $(CC_FLAGS_FPU) 28 + dml2_rcflags := $(CC_FLAGS_NO_FPU) 61 29 62 30 ifneq ($(CONFIG_FRAME_WARN),0) 63 31 ifeq ($(filter y,$(CONFIG_KASAN)$(CONFIG_KCSAN)),y)
+4
fs/nilfs2/recovery.c
··· 702 702 if (WARN_ON(!bh)) 703 703 return; /* should never happen */ 704 704 705 + lock_buffer(bh); 705 706 memset(bh->b_data, 0, bh->b_size); 707 + set_buffer_uptodate(bh); 706 708 set_buffer_dirty(bh); 709 + unlock_buffer(bh); 710 + 707 711 err = sync_dirty_buffer(bh); 708 712 if (unlikely(err)) 709 713 nilfs_warn(nilfs->ns_sb,
+12
include/linux/fpu.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + 3 + #ifndef _LINUX_FPU_H 4 + #define _LINUX_FPU_H 5 + 6 + #ifdef _LINUX_FPU_COMPILATION_UNIT 7 + #error FP code must be compiled separately. See Documentation/core-api/floating-point.rst. 8 + #endif 9 + 10 + #include <asm/fpu.h> 11 + 12 + #endif
+1 -1
lib/Kconfig.debug
··· 2925 2925 2926 2926 config TEST_FPU 2927 2927 tristate "Test floating point operations in kernel space" 2928 - depends on X86 && !KCOV_INSTRUMENT_ALL 2928 + depends on ARCH_HAS_KERNEL_FPU_SUPPORT && !KCOV_INSTRUMENT_ALL 2929 2929 help 2930 2930 Enable this option to add /sys/kernel/debug/selftest_helpers/test_fpu 2931 2931 which will trigger a sequence of floating point operations. This is used
+3 -23
lib/Makefile
··· 110 110 obj-$(CONFIG_FPROBE_SANITY_TEST) += test_fprobe.o 111 111 obj-$(CONFIG_TEST_OBJPOOL) += test_objpool.o 112 112 113 - # 114 - # CFLAGS for compiling floating point code inside the kernel. x86/Makefile turns 115 - # off the generation of FPU/SSE* instructions for kernel proper but FPU_FLAGS 116 - # get appended last to CFLAGS and thus override those previous compiler options. 117 - # 118 - FPU_CFLAGS := -msse -msse2 119 - ifdef CONFIG_CC_IS_GCC 120 - # Stack alignment mismatch, proceed with caution. 121 - # GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3 122 - # (8B stack alignment). 123 - # See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383 124 - # 125 - # The "-msse" in the first argument is there so that the 126 - # -mpreferred-stack-boundary=3 build error: 127 - # 128 - # -mpreferred-stack-boundary=3 is not between 4 and 12 129 - # 130 - # can be triggered. Otherwise gcc doesn't complain. 131 - FPU_CFLAGS += -mhard-float 132 - FPU_CFLAGS += $(call cc-option,-msse -mpreferred-stack-boundary=3,-mpreferred-stack-boundary=4) 133 - endif 134 - 135 113 obj-$(CONFIG_TEST_FPU) += test_fpu.o 136 - CFLAGS_test_fpu.o += $(FPU_CFLAGS) 114 + test_fpu-y := test_fpu_glue.o test_fpu_impl.o 115 + CFLAGS_test_fpu_impl.o += $(CC_FLAGS_FPU) 116 + CFLAGS_REMOVE_test_fpu_impl.o += $(CC_FLAGS_NO_FPU) 137 117 138 118 # Some KUnit files (hooks.o) need to be built-in even when KUnit is a module, 139 119 # so we can't just use obj-$(CONFIG_KUNIT).
+10 -23
lib/raid6/Makefile
··· 33 33 endif 34 34 endif 35 35 36 - # The GCC option -ffreestanding is required in order to compile code containing 37 - # ARM/NEON intrinsics in a non C99-compliant environment (such as the kernel) 38 - ifeq ($(CONFIG_KERNEL_MODE_NEON),y) 39 - NEON_FLAGS := -ffreestanding 40 - # Enable <arm_neon.h> 41 - NEON_FLAGS += -isystem $(shell $(CC) -print-file-name=include) 42 - ifeq ($(ARCH),arm) 43 - NEON_FLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=neon 44 - endif 45 - CFLAGS_recov_neon_inner.o += $(NEON_FLAGS) 46 - ifeq ($(ARCH),arm64) 47 - CFLAGS_REMOVE_recov_neon_inner.o += -mgeneral-regs-only 48 - CFLAGS_REMOVE_neon1.o += -mgeneral-regs-only 49 - CFLAGS_REMOVE_neon2.o += -mgeneral-regs-only 50 - CFLAGS_REMOVE_neon4.o += -mgeneral-regs-only 51 - CFLAGS_REMOVE_neon8.o += -mgeneral-regs-only 52 - endif 53 - endif 54 - 55 36 quiet_cmd_unroll = UNROLL $@ 56 37 cmd_unroll = $(AWK) -v N=$* -f $(src)/unroll.awk < $< > $@ 57 38 ··· 56 75 $(obj)/vpermxor%.c: $(src)/vpermxor.uc $(src)/unroll.awk FORCE 57 76 $(call if_changed,unroll) 58 77 59 - CFLAGS_neon1.o += $(NEON_FLAGS) 60 - CFLAGS_neon2.o += $(NEON_FLAGS) 61 - CFLAGS_neon4.o += $(NEON_FLAGS) 62 - CFLAGS_neon8.o += $(NEON_FLAGS) 78 + CFLAGS_neon1.o += $(CC_FLAGS_FPU) 79 + CFLAGS_neon2.o += $(CC_FLAGS_FPU) 80 + CFLAGS_neon4.o += $(CC_FLAGS_FPU) 81 + CFLAGS_neon8.o += $(CC_FLAGS_FPU) 82 + CFLAGS_recov_neon_inner.o += $(CC_FLAGS_FPU) 83 + CFLAGS_REMOVE_neon1.o += $(CC_FLAGS_NO_FPU) 84 + CFLAGS_REMOVE_neon2.o += $(CC_FLAGS_NO_FPU) 85 + CFLAGS_REMOVE_neon4.o += $(CC_FLAGS_NO_FPU) 86 + CFLAGS_REMOVE_neon8.o += $(CC_FLAGS_NO_FPU) 87 + CFLAGS_REMOVE_recov_neon_inner.o += $(CC_FLAGS_NO_FPU) 63 88 targets += neon1.c neon2.c neon4.c neon8.c 64 89 $(obj)/neon%.c: $(src)/neon.uc $(src)/unroll.awk FORCE 65 90 $(call if_changed,unroll)
+5 -32
lib/test_fpu.c lib/test_fpu_glue.c
··· 17 17 #include <linux/module.h> 18 18 #include <linux/kernel.h> 19 19 #include <linux/debugfs.h> 20 - #include <asm/fpu/api.h> 20 + #include <linux/fpu.h> 21 21 22 - static int test_fpu(void) 23 - { 24 - /* 25 - * This sequence of operations tests that rounding mode is 26 - * to nearest and that denormal numbers are supported. 27 - * Volatile variables are used to avoid compiler optimizing 28 - * the calculations away. 29 - */ 30 - volatile double a, b, c, d, e, f, g; 31 - 32 - a = 4.0; 33 - b = 1e-15; 34 - c = 1e-310; 35 - 36 - /* Sets precision flag */ 37 - d = a + b; 38 - 39 - /* Result depends on rounding mode */ 40 - e = a + b / 2; 41 - 42 - /* Denormal and very large values */ 43 - f = b / c; 44 - 45 - /* Depends on denormal support */ 46 - g = a + c * f; 47 - 48 - if (d > a && e > a && g > a) 49 - return 0; 50 - else 51 - return -EINVAL; 52 - } 22 + #include "test_fpu.h" 53 23 54 24 static int test_fpu_get(void *data, u64 *val) 55 25 { ··· 38 68 39 69 static int __init test_fpu_init(void) 40 70 { 71 + if (!kernel_fpu_available()) 72 + return -EINVAL; 73 + 41 74 selftest_dir = debugfs_create_dir("selftest_helpers", NULL); 42 75 if (!selftest_dir) 43 76 return -ENOMEM;
+8
lib/test_fpu.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 2 + 3 + #ifndef _LIB_TEST_FPU_H 4 + #define _LIB_TEST_FPU_H 5 + 6 + int test_fpu(void); 7 + 8 + #endif
+37
lib/test_fpu_impl.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 2 + 3 + #include <linux/errno.h> 4 + 5 + #include "test_fpu.h" 6 + 7 + int test_fpu(void) 8 + { 9 + /* 10 + * This sequence of operations tests that rounding mode is 11 + * to nearest and that denormal numbers are supported. 12 + * Volatile variables are used to avoid compiler optimizing 13 + * the calculations away. 14 + */ 15 + volatile double a, b, c, d, e, f, g; 16 + 17 + a = 4.0; 18 + b = 1e-15; 19 + c = 1e-310; 20 + 21 + /* Sets precision flag */ 22 + d = a + b; 23 + 24 + /* Result depends on rounding mode */ 25 + e = a + b / 2; 26 + 27 + /* Denormal and very large values */ 28 + f = b / c; 29 + 30 + /* Depends on denormal support */ 31 + g = a + c * f; 32 + 33 + if (d > a && e > a && g > a) 34 + return 0; 35 + else 36 + return -EINVAL; 37 + }
+11 -18
scripts/Makefile.extrawarn
··· 37 37 KBUILD_CFLAGS += -Wno-main 38 38 endif 39 39 40 - # These warnings generated too much noise in a regular build. 41 - # Use make W=1 to enable them (see scripts/Makefile.extrawarn) 42 - KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable) 43 - KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable) 44 - 45 40 # These result in bogus false positives 46 41 KBUILD_CFLAGS += $(call cc-disable-warning, dangling-pointer) 47 42 ··· 77 82 # Warn if there is an enum types mismatch 78 83 KBUILD_CFLAGS += $(call cc-option,-Wenum-conversion) 79 84 85 + KBUILD_CFLAGS += -Wextra 86 + KBUILD_CFLAGS += -Wunused 87 + 80 88 # 81 89 # W=1 - warnings which may be relevant and do not occur too often 82 90 # 83 91 ifneq ($(findstring 1, $(KBUILD_EXTRA_WARN)),) 84 92 85 - KBUILD_CFLAGS += -Wextra -Wunused -Wno-unused-parameter 86 - KBUILD_CFLAGS += $(call cc-option, -Wrestrict) 87 93 KBUILD_CFLAGS += -Wmissing-format-attribute 88 - KBUILD_CFLAGS += -Wold-style-definition 89 94 KBUILD_CFLAGS += -Wmissing-include-dirs 90 - KBUILD_CFLAGS += $(call cc-option, -Wunused-but-set-variable) 91 95 KBUILD_CFLAGS += $(call cc-option, -Wunused-const-variable) 92 - KBUILD_CFLAGS += $(call cc-option, -Wpacked-not-aligned) 93 - KBUILD_CFLAGS += $(call cc-option, -Wformat-overflow) 94 - KBUILD_CFLAGS += $(call cc-option, -Wformat-truncation) 95 - KBUILD_CFLAGS += $(call cc-option, -Wstringop-truncation) 96 96 97 97 KBUILD_CPPFLAGS += -Wundef 98 98 KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN1 ··· 98 108 # Suppress them by using -Wno... except for W=1. 99 109 KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable) 100 110 KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable) 101 - KBUILD_CFLAGS += $(call cc-disable-warning, restrict) 102 111 KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned) 103 112 KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow) 113 + ifdef CONFIG_CC_IS_GCC 104 114 KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation) 115 + else 116 + # Clang checks for overflow/truncation with '%p', while GCC does not: 117 + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111219 118 + KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow-non-kprintf) 119 + KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation-non-kprintf) 120 + endif 105 121 KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation) 106 122 107 123 KBUILD_CFLAGS += -Wno-override-init # alias for -Wno-initializer-overrides in clang ··· 129 133 KBUILD_CFLAGS += $(call cc-disable-warning, pointer-to-enum-cast) 130 134 KBUILD_CFLAGS += -Wno-tautological-constant-out-of-range-compare 131 135 KBUILD_CFLAGS += $(call cc-disable-warning, unaligned-access) 132 - KBUILD_CFLAGS += $(call cc-disable-warning, cast-function-type-strict) 133 136 KBUILD_CFLAGS += -Wno-enum-compare-conditional 134 137 KBUILD_CFLAGS += -Wno-enum-enum-conversion 135 138 endif ··· 143 148 KBUILD_CFLAGS += -Wdisabled-optimization 144 149 KBUILD_CFLAGS += -Wshadow 145 150 KBUILD_CFLAGS += $(call cc-option, -Wlogical-op) 146 - KBUILD_CFLAGS += -Wmissing-field-initializers 147 - KBUILD_CFLAGS += -Wtype-limits 148 - KBUILD_CFLAGS += $(call cc-option, -Wmaybe-uninitialized) 149 151 KBUILD_CFLAGS += $(call cc-option, -Wunused-macros) 150 152 151 153 KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN2 ··· 182 190 183 191 # The following turn off the warnings enabled by -Wextra 184 192 KBUILD_CFLAGS += -Wno-sign-compare 193 + KBUILD_CFLAGS += -Wno-unused-parameter 185 194 186 195 endif 187 196
+3 -8
tools/testing/selftests/kselftest_harness.h
··· 1216 1216 struct __test_metadata *t) 1217 1217 { 1218 1218 struct __test_xfail *xfail; 1219 - char *test_name; 1219 + char test_name[1024]; 1220 1220 const char *diagnostic; 1221 1221 1222 1222 /* reset test struct */ ··· 1227 1227 memset(t->env, 0, sizeof(t->env)); 1228 1228 memset(t->results->reason, 0, sizeof(t->results->reason)); 1229 1229 1230 - if (asprintf(&test_name, "%s%s%s.%s", f->name, 1231 - variant->name[0] ? "." : "", variant->name, t->name) == -1) { 1232 - ksft_print_msg("ERROR ALLOCATING MEMORY\n"); 1233 - t->exit_code = KSFT_FAIL; 1234 - _exit(t->exit_code); 1235 - } 1230 + snprintf(test_name, sizeof(test_name), "%s%s%s.%s", 1231 + f->name, variant->name[0] ? "." : "", variant->name, t->name); 1236 1232 1237 1233 ksft_print_msg(" RUN %s ...\n", test_name); 1238 1234 ··· 1266 1270 1267 1271 ksft_test_result_code(t->exit_code, test_name, 1268 1272 diagnostic ? "%s" : NULL, diagnostic); 1269 - free(test_name); 1270 1273 } 1271 1274 1272 1275 static int test_harness_run(int argc, char **argv)
-1
tools/testing/selftests/mm/mdwe_test.c
··· 7 7 #include <linux/mman.h> 8 8 #include <linux/prctl.h> 9 9 10 - #define _GNU_SOURCE 11 10 #include <stdio.h> 12 11 #include <stdlib.h> 13 12 #include <sys/auxv.h>