Thread (14 messages) 14 messages, 5 authors, 2024-12-13

Re: [PATCH v3 2/6] compiler.h: Introduce TYPEOF_UNQUAL() macro

From: Uros Bizjak <hidden>
Date: 2024-12-10 16:37:24
Also in: linux-arch, linux-bcachefs, linux-mm, lkml

On Mon, Dec 9, 2024 at 12:30 PM Peter Zijlstra [off-list ref] wrote:
On Sun, Dec 08, 2024 at 09:45:17PM +0100, Uros Bizjak wrote:
quoted
Define TYPEOF_UNQUAL() to use __typeof_unqual__() as typeof operator
when available, to return unqualified type of the expression.

Current version of sparse doesn't know anything about __typeof_unqual__()
operator. Avoid the usage of __typeof_unqual__() when sparse checking
is active to prevent sparse errors with unknowing keyword.
Ooooh, new toys.

I suppose __unqual_scalar_typeof() wants to be using this when
available?
Not only that, the new toy enables clang to check kernel's address
spaces in a generic way using address_space attribute.

Please find attached a follow-up patch that enables __percpu checks
for all targets, supported by clang. Clang is a little bit pickier
than gcc about named address space declarations (it warns for use of
duplicated address space attribute), so the patch in addition to the
obvious

+#  define __percpu_qual        __attribute__((address_space(3)))

also fixes a couple of macros that could result in a duplicated
address space attribute.

The patch, applied as a follow-up to the series, survives allyesconfig
compilation with clang-19 and produces a bootable kernel. The patch
was tested only for x86_64 target, for other targets a couple of
trivial fixes would be necessary (a cast or a substitution of typeof()
with TYPEOF_UNQUAL()).

AFAICS, the same approach using clang's address_space attribute can be
implemented to also check other address spaces: __user, __iommu  and
__rcu.

Uros.

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help