I know that it's forbidden to use any kind of floating-point code in the kernel, and we never should use any GCC flag that could generate FP / SIMD instructions, but what about some source code (especially arch/x86/crypto/*
) that uses kernel_fpu_begin()
and kernel_fpu_end()
?
I have an ancient Intel Core 2 Duo CPU that I use for my 64-bit Linux Kernel and in the main Makefile
I use the following C flags:
# Target specific Flags
KBUILD_CFLAGS += \
-m64 \
-march=core2 \
-mtune=core2 \
-mfpmath=sse \
-msoft-float \
-mno-fp-ret-in-387 \
-mno-mmx \
-mno-sse \
-mno-sse2 \
-mno-sse3 \
-mno-ssse3
# FPU Flags
FPU_CFLAGS := $(KBUILD_CFLAGS) \
-mhard-float \
-mfp-ret-in-387 \
-mmmx \
-msse \
-msse2 \
-msse3 \
-mssse3 \
-ftree-vectorize
and in files where kernel_fpu_begin()
is present, I pass the FPU_CFLAGS
in their Makefiles
like this:
CFLAGS_sha512_ssse3_glue.o := $(FPU_CFLAGS)
Is this correct and will it optimize the FP / SIMD code? Or is it not needed and this implementation could even break the state of the FPU / SIMD?