mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] kbuild: don't allow GCC data store races
Date: Mon, 25 Nov 2024 16:08:38 +0100	[thread overview]
Message-ID: <20241125150838.96931-1-a.fatoum@pengutronix.de> (raw)

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




                 reply	other threads:[~2024-11-25 15:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241125150838.96931-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox