* [PATCH] kbuild: don't allow GCC data store races
@ 2024-11-25 15:08 Ahmad Fatoum
0 siblings, 0 replies; only message in thread
From: Ahmad Fatoum @ 2024-11-25 15:08 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
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@pengutronix.de>
---
.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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-11-25 15:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-25 15:08 [PATCH] kbuild: don't allow GCC data store races Ahmad Fatoum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox