From 9189800760720d6b259b0aa2f907da50c609a01d Mon Sep 17 00:00:00 2001 From: liwenxiang1 Date: Fri, 26 Jul 2024 14:15:43 +0800 Subject: [PATCH] arch/x86_64:Add configuration to disable vectorization optimization With aggresive optimization enabled (-O3), ostest FPU test will fail.This is because the compiler will generate additional vector instructions between subsequent up_fpucmp() calls (loop vectorization somewhere in usleep() call), which will consequently overwrite the expected FPU context (XMM registers).The compilation option -fno-tree-vectorize can avoid this issue. Signed-off-by: liwenxiang1 --- arch/x86_64/src/common/Toolchain.defs | 12 ++++++++---- arch/x86_64/src/intel64/Kconfig | 4 ++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/arch/x86_64/src/common/Toolchain.defs b/arch/x86_64/src/common/Toolchain.defs index 879e5818b2bf7..e8613edf04712 100644 --- a/arch/x86_64/src/common/Toolchain.defs +++ b/arch/x86_64/src/common/Toolchain.defs @@ -51,6 +51,14 @@ ifeq ($(CONFIG_FRAME_POINTER),y) ARCHOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls endif +ifeq ($(CONFIG_ARCH_INTEL64_DISABLE_CET),y) + ARCHOPTIMIZATION += -fcf-protection=none +endif + +ifeq ($(CONFIG_ARCH_INTEL64_DISABLE_VECTORIZE),y) + ARCHOPTIMIZATION += -fno-tree-vectorize +endif + ARCHCFLAGS += -fno-common -Wno-attributes ARCHCXXFLAGS += -fno-common -Wno-attributes -nostdinc++ @@ -58,10 +66,6 @@ ARCHCPUFLAGS = -fno-pic -mcmodel=large -fno-stack-protector -mno-red-zone -mrdrn ARCHPICFLAGS = -fPIC ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -ifeq ($(CONFIG_ARCH_INTEL64_DISABLE_CET),y) - ARCHOPTIMIZATION += -fcf-protection=none -endif - # We have to use a cross-development toolchain under Cygwin because the native # Cygwin toolchains don't generate ELF binaries. diff --git a/arch/x86_64/src/intel64/Kconfig b/arch/x86_64/src/intel64/Kconfig index 53ce634be6c00..5c213f01178f8 100644 --- a/arch/x86_64/src/intel64/Kconfig +++ b/arch/x86_64/src/intel64/Kconfig @@ -203,5 +203,9 @@ config ARCH_INTEL64_DISABLE_CET It inserts the endbr64 instruction at the beginning of functions, which may impact CPU branch prediction performance. +config ARCH_INTEL64_DISABLE_VECTORIZE + bool "Disable vectorize completely" + ---help--- + Disable the compiler from vectorizing code optimization during compilation endif