This is a port of kernel commit 69102311a57d1f ("./Makefile: tell gcc optimizer to never introduce new data races"), which does what it says on the tin: prevent gcc from replacing conditional loads with a non-conditional one as this could lead to issues around memory remapping functions. Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> --- .clangd | 2 +- Makefile | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.clangd b/.clangd index 58e83cd2871a..4057270b2a83 100644 --- a/.clangd +++ b/.clangd @@ -1,2 +1,2 @@ CompileFlags: - Remove: -mabi=lp64 + Remove: [ -mabi=lp64, -fno-allow-store-data-races] diff --git a/Makefile b/Makefile index 46707fb44f68..991e11bd0dee 100644 --- a/Makefile +++ b/Makefile @@ -670,6 +670,14 @@ KBUILD_CFLAGS += $(call cc-disable-warning, trampolines) KBUILD_CFLAGS += $(call cc-option, -fno-delete-null-pointer-checks,) +# Tell gcc to never replace conditional load with a non-conditional one +ifdef CONFIG_CC_IS_GCC +# gcc-10 renamed --param=allow-store-data-races=0 to +# -fno-allow-store-data-races. +KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0) +KBUILD_CFLAGS += $(call cc-option,-fno-allow-store-data-races) +endif + # disable invalid "can't wrap" optimizations for signed / pointers KBUILD_CFLAGS += $(call cc-option,-fno-strict-overflow) -- 2.39.5