From: Dave Hansen <dave.hansen@intel.com>
To: Jiri Slaby <jirislaby@kernel.org>, Uros Bizjak <ubizjak@gmail.com>
Cc: x86@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org,
linux-bcachefs@vger.kernel.org, linux-arch@vger.kernel.org,
netdev@vger.kernel.org, Nadav Amit <nadav.amit@gmail.com>,
Dennis Zhou <dennis@kernel.org>, Tejun Heo <tj@kernel.org>,
Christoph Lameter <cl@linux.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@kernel.org>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Andy Lutomirski <luto@kernel.org>,
Brian Gerst <brgerst@gmail.com>,
Peter Zijlstra <peterz@infradead.org>,
Shung-Hsi Yu <shung-hsi.yu@suse.com>,
Alexei Starovoitov <alexei.starovoitov@gmail.com>
Subject: Re: Large modules with 6.15 [was: [PATCH v4 6/6] percpu/x86: Enable strict percpu checks via named AS qualifiers]
Date: Fri, 6 Jun 2025 08:43:57 -0700 [thread overview]
Message-ID: <6412d84a-edc3-4723-89f1-b2017fb0d1ea@intel.com> (raw)
In-Reply-To: <9767d411-81dc-491b-b6da-419240065ffe@kernel.org>
[-- Attachment #1: Type: text/plain, Size: 453 bytes --]
On 6/6/25 02:17, Jiri Slaby wrote:
> Given this is the second time I hit a bug with this, perhaps introduce
> an EXPERIMENTAL CONFIG option, so that random users can simply disable
> it if an issue occurs? Without the need of patching random userspace and
> changing random kernel headers?
What about something like the attached (untested) patch? That should at
least get folks back to the old, universal working behavior even when
using new compilers.
[-- Attachment #2: CC_USE_TYPEOF_UNQUAL1.patch --]
[-- Type: text/x-patch, Size: 2128 bytes --]
From 08d98b4fa08ba76be96e406b53ae69946842f6a9 Mon Sep 17 00:00:00 2001
From: Dave Hansen <dave.hansen@linux.intel.com>
Date: Fri, 6 Jun 2025 08:33:29 -0700
Subject: [PATCH] compiler.h: Enable config choice for using unqualified casts
TYPEOF_UNQUAL() has a noble goal of letting normal compilers do more
of the job normally reserved for sparse. But it has caused (or
exposed) a number of nasty bugs and is not quite ready for prime time.
Even nastier, some of these issues need separate userspace fixes.
Right now, __typeof_unqual__ will be whenever the compiler supports
it. Restrict it to cases where users have opted in with a new Kconfig
option. This option can either be removed or have its default polarity
flipped when userspace is widely fixed up.
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
---
include/linux/compiler.h | 2 +-
init/Kconfig | 11 +++++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 27725f1ab5abc..3efa93f8eca66 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -232,7 +232,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
* XXX: Remove test for __CHECKER__ once
* sparse learns about __typeof_unqual__().
*/
-#if CC_HAS_TYPEOF_UNQUAL && !defined(__CHECKER__)
+#if defined(CONFIG_CC_USE_TYPEOF_UNQUAL) && CC_HAS_TYPEOF_UNQUAL && !defined(__CHECKER__)
# define USE_TYPEOF_UNQUAL 1
#endif
diff --git a/init/Kconfig b/init/Kconfig
index 63f5974b9fa6e..74e5e8d640750 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1489,6 +1489,17 @@ config CC_OPTIMIZE_FOR_SIZE
endchoice
+config CC_USE_TYPEOF_UNQUAL
+ bool "Use compiler-provided unqualified casts (EXPERIMENTAL)"
+ depends on EXPERT
+ help
+ Newer compilers have the ability to do "unqualified" casts which
+ strip out type qualifiers like 'const'. Kernel builds can
+ leverage these to do more strict type checking with normal
+ compilers instead of resorting to using sparse.
+
+ If unsure, say N here.
+
config HAVE_LD_DEAD_CODE_DATA_ELIMINATION
bool
help
--
2.34.1
next prev parent reply other threads:[~2025-06-06 15:44 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-27 16:05 [PATCH v4 0/6] Enable strict percpu address space checks Uros Bizjak
2025-01-27 16:05 ` [PATCH v4 1/6] x86/kgdb: Use IS_ERR_PCPU() macro Uros Bizjak
2025-01-27 16:05 ` [PATCH v4 2/6] compiler.h: Introduce TYPEOF_UNQUAL() macro Uros Bizjak
2025-01-27 16:05 ` [PATCH v4 3/6] percpu: Use TYPEOF_UNQUAL() in variable declarations Uros Bizjak
2025-01-27 16:05 ` [PATCH v4 4/6] percpu: Use TYPEOF_UNQUAL() in *_cpu_ptr() accessors Uros Bizjak
2025-01-27 16:05 ` [PATCH v4 5/6] percpu: Repurpose __percpu tag as a named address space qualifier Uros Bizjak
2025-01-27 16:05 ` [PATCH v4 6/6] percpu/x86: Enable strict percpu checks via named AS qualifiers Uros Bizjak
2025-04-09 11:07 ` Jiri Slaby
2025-04-09 11:43 ` Uros Bizjak
2025-04-09 15:09 ` H. Peter Anvin
2025-04-09 15:15 ` Uros Bizjak
2025-06-05 14:27 ` Large modules with 6.15 [was: [PATCH v4 6/6] percpu/x86: Enable strict percpu checks via named AS qualifiers] Jiri Slaby
2025-06-05 14:32 ` Jiri Slaby
2025-06-05 16:17 ` Alexei Starovoitov
2025-06-05 14:39 ` Dr. David Alan Gilbert
2025-06-05 17:15 ` Dave Hansen
2025-06-05 17:31 ` Uros Bizjak
2025-06-06 9:17 ` Jiri Slaby
2025-06-06 9:27 ` Uros Bizjak
2025-06-06 13:56 ` James Bottomley
2025-06-06 16:39 ` Alexei Starovoitov
2025-06-06 18:48 ` Uros Bizjak
2025-06-06 15:43 ` Dave Hansen [this message]
2025-06-07 8:52 ` Uros Bizjak
2025-06-07 14:12 ` Dave Hansen
2025-06-07 14:31 ` James Bottomley
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=6412d84a-edc3-4723-89f1-b2017fb0d1ea@intel.com \
--to=dave.hansen@intel.com \
--cc=alexei.starovoitov@gmail.com \
--cc=bp@alien8.de \
--cc=brgerst@gmail.com \
--cc=cl@linux.com \
--cc=dave.hansen@linux.intel.com \
--cc=dennis@kernel.org \
--cc=hpa@zytor.com \
--cc=jirislaby@kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-bcachefs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=luto@kernel.org \
--cc=mingo@kernel.org \
--cc=nadav.amit@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=shung-hsi.yu@suse.com \
--cc=tglx@linutronix.de \
--cc=tj@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=ubizjak@gmail.com \
--cc=x86@kernel.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).