selftests/fpu: allow building on other architectures
[ Upstream commit 790a4a3dd1
]
Now that ARCH_HAS_KERNEL_FPU_SUPPORT provides a common way to compile and
run floating-point code, this test is no longer x86-specific.
Link: https://lkml.kernel.org/r/20240329072441.591471-16-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>
[ Backport from v6.10 ]
Signed-off-by: WangYuli <wangyuli@uniontech.com>
This commit is contained in:
parent
76cb1ae4a9
commit
0ab89aa5ba
|
@ -2920,7 +2920,7 @@ config TEST_FREE_PAGES
|
||||||
|
|
||||||
config TEST_FPU
|
config TEST_FPU
|
||||||
tristate "Test floating point operations in kernel space"
|
tristate "Test floating point operations in kernel space"
|
||||||
depends on X86 && !KCOV_INSTRUMENT_ALL
|
depends on ARCH_HAS_KERNEL_FPU_SUPPORT && !KCOV_INSTRUMENT_ALL
|
||||||
help
|
help
|
||||||
Enable this option to add /sys/kernel/debug/selftest_helpers/test_fpu
|
Enable this option to add /sys/kernel/debug/selftest_helpers/test_fpu
|
||||||
which will trigger a sequence of floating point operations. This is used
|
which will trigger a sequence of floating point operations. This is used
|
||||||
|
|
24
lib/Makefile
24
lib/Makefile
|
@ -107,31 +107,11 @@ obj-$(CONFIG_KPROBES_SANITY_TEST) += test_kprobes.o
|
||||||
obj-$(CONFIG_TEST_REF_TRACKER) += test_ref_tracker.o
|
obj-$(CONFIG_TEST_REF_TRACKER) += test_ref_tracker.o
|
||||||
CFLAGS_test_fprobe.o += $(CC_FLAGS_FTRACE)
|
CFLAGS_test_fprobe.o += $(CC_FLAGS_FTRACE)
|
||||||
obj-$(CONFIG_FPROBE_SANITY_TEST) += test_fprobe.o
|
obj-$(CONFIG_FPROBE_SANITY_TEST) += test_fprobe.o
|
||||||
#
|
|
||||||
# CFLAGS for compiling floating point code inside the kernel. x86/Makefile turns
|
|
||||||
# off the generation of FPU/SSE* instructions for kernel proper but FPU_FLAGS
|
|
||||||
# get appended last to CFLAGS and thus override those previous compiler options.
|
|
||||||
#
|
|
||||||
FPU_CFLAGS := -msse -msse2
|
|
||||||
ifdef CONFIG_CC_IS_GCC
|
|
||||||
# Stack alignment mismatch, proceed with caution.
|
|
||||||
# GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3
|
|
||||||
# (8B stack alignment).
|
|
||||||
# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383
|
|
||||||
#
|
|
||||||
# The "-msse" in the first argument is there so that the
|
|
||||||
# -mpreferred-stack-boundary=3 build error:
|
|
||||||
#
|
|
||||||
# -mpreferred-stack-boundary=3 is not between 4 and 12
|
|
||||||
#
|
|
||||||
# can be triggered. Otherwise gcc doesn't complain.
|
|
||||||
FPU_CFLAGS += -mhard-float
|
|
||||||
FPU_CFLAGS += $(call cc-option,-msse -mpreferred-stack-boundary=3,-mpreferred-stack-boundary=4)
|
|
||||||
endif
|
|
||||||
|
|
||||||
obj-$(CONFIG_TEST_FPU) += test_fpu.o
|
obj-$(CONFIG_TEST_FPU) += test_fpu.o
|
||||||
test_fpu-y := test_fpu_glue.o test_fpu_impl.o
|
test_fpu-y := test_fpu_glue.o test_fpu_impl.o
|
||||||
CFLAGS_test_fpu_impl.o += $(FPU_CFLAGS)
|
CFLAGS_test_fpu_impl.o += $(CC_FLAGS_FPU)
|
||||||
|
CFLAGS_REMOVE_test_fpu_impl.o += $(CC_FLAGS_NO_FPU)
|
||||||
|
|
||||||
obj-$(CONFIG_TEST_LIVEPATCH) += livepatch/
|
obj-$(CONFIG_TEST_LIVEPATCH) += livepatch/
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/kernel.h>
|
#include <linux/kernel.h>
|
||||||
#include <linux/debugfs.h>
|
#include <linux/debugfs.h>
|
||||||
#include <asm/fpu/api.h>
|
#include <linux/fpu.h>
|
||||||
|
|
||||||
#include "test_fpu.h"
|
#include "test_fpu.h"
|
||||||
|
|
||||||
|
@ -38,6 +38,9 @@ static struct dentry *selftest_dir;
|
||||||
|
|
||||||
static int __init test_fpu_init(void)
|
static int __init test_fpu_init(void)
|
||||||
{
|
{
|
||||||
|
if (!kernel_fpu_available())
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
selftest_dir = debugfs_create_dir("selftest_helpers", NULL);
|
selftest_dir = debugfs_create_dir("selftest_helpers", NULL);
|
||||||
if (!selftest_dir)
|
if (!selftest_dir)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
Loading…
Reference in New Issue