-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 ...
- Loading branch information
Showing
41 changed files
with
365 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
.. SPDX-License-Identifier: GPL-2.0+ | ||
Floating-point API | ||
================== | ||
|
||
Kernel code is normally prohibited from using floating-point (FP) registers or | ||
instructions, including the C float and double data types. This rule reduces | ||
system call overhead, because the kernel does not need to save and restore the | ||
userspace floating-point register state. | ||
|
||
However, occasionally drivers or library functions may need to include FP code. | ||
This is supported by isolating the functions containing FP code to a separate | ||
translation unit (a separate source file), and saving/restoring the FP register | ||
state around calls to those functions. This creates "critical sections" of | ||
floating-point usage. | ||
|
||
The reason for this isolation is to prevent the compiler from generating code | ||
touching the FP registers outside these critical sections. Compilers sometimes | ||
use FP registers to optimize inlined ``memcpy`` or variable assignment, as | ||
floating-point registers may be wider than general-purpose registers. | ||
|
||
Usability of floating-point code within the kernel is architecture-specific. | ||
Additionally, because a single kernel may be configured to support platforms | ||
both with and without a floating-point unit, FPU availability must be checked | ||
both at build time and at run time. | ||
|
||
Several architectures implement the generic kernel floating-point API from | ||
``linux/fpu.h``, as described below. Some other architectures implement their | ||
own unique APIs, which are documented separately. | ||
|
||
Build-time API | ||
-------------- | ||
|
||
Floating-point code may be built if the option ``ARCH_HAS_KERNEL_FPU_SUPPORT`` | ||
is enabled. For C code, such code must be placed in a separate file, and that | ||
file must have its compilation flags adjusted using the following pattern:: | ||
|
||
CFLAGS_foo.o += $(CC_FLAGS_FPU) | ||
CFLAGS_REMOVE_foo.o += $(CC_FLAGS_NO_FPU) | ||
|
||
Architectures are expected to define one or both of these variables in their | ||
top-level Makefile as needed. For example:: | ||
|
||
CC_FLAGS_FPU := -mhard-float | ||
|
||
or:: | ||
|
||
CC_FLAGS_NO_FPU := -msoft-float | ||
|
||
Normal kernel code is assumed to use the equivalent of ``CC_FLAGS_NO_FPU``. | ||
|
||
Runtime API | ||
----------- | ||
|
||
The runtime API is provided in ``linux/fpu.h``. This header cannot be included | ||
from files implementing FP code (those with their compilation flags adjusted as | ||
above). Instead, it must be included when defining the FP critical sections. | ||
|
||
.. c:function:: bool kernel_fpu_available( void ) | ||
This function reports if floating-point code can be used on this CPU or | ||
platform. The value returned by this function is not expected to change | ||
at runtime, so it only needs to be called once, not before every | ||
critical section. | ||
.. c:function:: void kernel_fpu_begin( void ) | ||
void kernel_fpu_end( void ) | ||
These functions create a floating-point critical section. It is only | ||
valid to call ``kernel_fpu_begin()`` after a previous call to | ||
``kernel_fpu_available()`` returned ``true``. These functions are only | ||
guaranteed to be callable from (preemptible or non-preemptible) process | ||
context. | ||
Preemption may be disabled inside critical sections, so their size | ||
should be minimized. They are *not* required to be reentrant. If the | ||
caller expects to nest critical sections, it must implement its own | ||
reference counting. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-only */ | ||
/* | ||
* 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 */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-only */ | ||
/* | ||
* 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 */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-only */ | ||
/* | ||
* Copyright (C) 2023 SiFive | ||
*/ | ||
|
||
#ifndef _ASM_POWERPC_FPU_H | ||
#define _ASM_POWERPC_FPU_H | ||
|
||
#include <linux/preempt.h> | ||
|
||
#include <asm/cpu_has_feature.h> | ||
#include <asm/switch_to.h> | ||
|
||
#define kernel_fpu_available() (!cpu_has_feature(CPU_FTR_FPU_UNAVAILABLE)) | ||
|
||
static inline void kernel_fpu_begin(void) | ||
{ | ||
preempt_disable(); | ||
enable_kernel_fp(); | ||
} | ||
|
||
static inline void kernel_fpu_end(void) | ||
{ | ||
disable_kernel_fp(); | ||
preempt_enable(); | ||
} | ||
|
||
#endif /* ! _ASM_POWERPC_FPU_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-only */ | ||
/* | ||
* Copyright (C) 2023 SiFive | ||
*/ | ||
|
||
#ifndef _ASM_RISCV_FPU_H | ||
#define _ASM_RISCV_FPU_H | ||
|
||
#include <asm/switch_to.h> | ||
|
||
#define kernel_fpu_available() has_fpu() | ||
|
||
void kernel_fpu_begin(void); | ||
void kernel_fpu_end(void); | ||
|
||
#endif /* ! _ASM_RISCV_FPU_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// SPDX-License-Identifier: GPL-2.0-only | ||
/* | ||
* Copyright (C) 2023 SiFive | ||
*/ | ||
|
||
#include <linux/export.h> | ||
#include <linux/preempt.h> | ||
|
||
#include <asm/csr.h> | ||
#include <asm/fpu.h> | ||
#include <asm/processor.h> | ||
#include <asm/switch_to.h> | ||
|
||
void kernel_fpu_begin(void) | ||
{ | ||
preempt_disable(); | ||
fstate_save(current, task_pt_regs(current)); | ||
csr_set(CSR_SSTATUS, SR_FS); | ||
} | ||
EXPORT_SYMBOL_GPL(kernel_fpu_begin); | ||
|
||
void kernel_fpu_end(void) | ||
{ | ||
csr_clear(CSR_SSTATUS, SR_FS); | ||
fstate_restore(current, task_pt_regs(current)); | ||
preempt_enable(); | ||
} | ||
EXPORT_SYMBOL_GPL(kernel_fpu_end); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.