From: Rohan McLure <rmclure@linux.ibm.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: Rohan McLure <rmclure@linux.ibm.com>, Max Filippov <jcmvbkbc@gmail.com>
Subject: [PATCH 1/2] kcsan: xtensa: Add atomic builtin stubs for 32-bit systems
Date: Thu, 16 Feb 2023 16:09:37 +1100 [thread overview]
Message-ID: <20230216050938.2188488-1-rmclure@linux.ibm.com> (raw)
KCSAN instruments calls to atomic builtins, and will in turn call these
builtins itself. As such, architectures supporting KCSAN must have
compiler support for these atomic primitives.
Since 32-bit systems are unlikely to have 64-bit compiler builtins,
provide a stub for each missing builtin, and use BUG() to assert
unreachability.
In commit 725aea873261 ("xtensa: enable KCSAN"), xtensa implements these
locally. Move these definitions to be accessible to all 32-bit
architectures that do not provide the necessary builtins, with opt in
for PowerPC and xtensa.
Signed-off-by: Rohan McLure <rmclure@linux.ibm.com>
Reviewed-by: Max Filippov <jcmvbkbc@gmail.com>
---
Previously issued as a part of a patch series adding KCSAN support to
64-bit.
Link: https://lore.kernel.org/linuxppc-dev/167646486000.1421441.10070059569986228558.b4-ty@ellerman.id.au/T/#t
v1: Remove __has_builtin check, as gcc is not obligated to inline
builtins detected using this check, but instead is permitted to supply
them in libatomic:
Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108734
Instead, opt-in PPC32 and xtensa.
---
arch/xtensa/lib/Makefile | 1 -
kernel/kcsan/Makefile | 2 ++
arch/xtensa/lib/kcsan-stubs.c => kernel/kcsan/stubs.c | 0
3 files changed, 2 insertions(+), 1 deletion(-)
rename arch/xtensa/lib/kcsan-stubs.c => kernel/kcsan/stubs.c (100%)
diff --git a/arch/xtensa/lib/Makefile b/arch/xtensa/lib/Makefile
index 7ecef0519a27..d69356dc97df 100644
--- a/arch/xtensa/lib/Makefile
+++ b/arch/xtensa/lib/Makefile
@@ -8,5 +8,4 @@ lib-y += memcopy.o memset.o checksum.o \
divsi3.o udivsi3.o modsi3.o umodsi3.o mulsi3.o umulsidi3.o \
usercopy.o strncpy_user.o strnlen_user.o
lib-$(CONFIG_PCI) += pci-auto.o
-lib-$(CONFIG_KCSAN) += kcsan-stubs.o
KCSAN_SANITIZE_kcsan-stubs.o := n
diff --git a/kernel/kcsan/Makefile b/kernel/kcsan/Makefile
index 8cf70f068d92..86dd713d8855 100644
--- a/kernel/kcsan/Makefile
+++ b/kernel/kcsan/Makefile
@@ -12,6 +12,8 @@ CFLAGS_core.o := $(call cc-option,-fno-conserve-stack) \
-fno-stack-protector -DDISABLE_BRANCH_PROFILING
obj-y := core.o debugfs.o report.o
+obj-$(CONFIG_PPC32) += stubs.o
+obj-$(CONFIG_XTENSA) += stubs.o
KCSAN_INSTRUMENT_BARRIERS_selftest.o := y
obj-$(CONFIG_KCSAN_SELFTEST) += selftest.o
diff --git a/arch/xtensa/lib/kcsan-stubs.c b/kernel/kcsan/stubs.c
similarity index 100%
rename from arch/xtensa/lib/kcsan-stubs.c
rename to kernel/kcsan/stubs.c
--
2.37.2
next reply other threads:[~2023-02-16 5:12 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-16 5:09 Rohan McLure [this message]
2023-02-16 5:09 ` [PATCH 2/2] powerpc/{32,book3e}: kcsan: Extend KCSAN Support Rohan McLure
2023-02-16 7:14 ` Christophe Leroy
2023-02-16 23:23 ` Rohan McLure
2023-02-17 6:36 ` Christophe Leroy
2023-02-20 6:10 ` Michael Ellerman
2023-02-16 7:12 ` [PATCH 1/2] kcsan: xtensa: Add atomic builtin stubs for 32-bit systems Christophe Leroy
2023-02-16 8:09 ` Marco Elver
2023-02-16 23:23 ` Rohan McLure
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=20230216050938.2188488-1-rmclure@linux.ibm.com \
--to=rmclure@linux.ibm.com \
--cc=jcmvbkbc@gmail.com \
--cc=linuxppc-dev@lists.ozlabs.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;
as well as URLs for NNTP newsgroup(s).