mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] kbuild: don't allow GCC data store races
@ 2024-11-25 15:08 Ahmad Fatoum
  2024-11-28 10:02 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages 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] 2+ messages in thread

* Re: [PATCH] kbuild: don't allow GCC data store races
  2024-11-25 15:08 [PATCH] kbuild: don't allow GCC data store races Ahmad Fatoum
@ 2024-11-28 10:02 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2024-11-28 10:02 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum


On Mon, 25 Nov 2024 16:08:38 +0100, Ahmad Fatoum wrote:
> 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.
> 
> 
> [...]

Applied, thanks!

[1/1] kbuild: don't allow GCC data store races
      https://git.pengutronix.de/cgit/barebox/commit/?id=8170af4789c7 (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-11-28 10:02 UTC | newest]

Thread overview: 2+ messages (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
2024-11-28 10:02 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox