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.