]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
x86/percpu: Make CONFIG_USE_X86_SEG_SUPPORT work with sparse
authorThomas Gleixner <tglx@kernel.org>
Sun, 18 Jan 2026 14:45:40 +0000 (15:45 +0100)
committerThomas Gleixner <tglx@kernel.org>
Sun, 18 Jan 2026 14:54:17 +0000 (15:54 +0100)
Now that sparse builds enforce the usage of typeof_unqual() the casts in
__raw_cpu_read/write() cause sparse to emit tons of false postive
warnings:

 warning: cast removes address space '__percpu' of expression

Address this by annotating the casts with __force.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Link: https://patch.msgid.link/87v7gz0yjv.ffs@tglx
Closes: https://lore.kernel.org/oe-kbuild-all/202601181733.YZOf9XU3-lkp@intel.com/
arch/x86/include/asm/percpu.h

index 725d0eff7acdf05543e797df6168e2042cb65b2e..c55058f3d75e889365683273697435e014b57808 100644 (file)
 
 #define __raw_cpu_read(size, qual, pcp)                                        \
 ({                                                                     \
-       *(qual __my_cpu_type(pcp) *)__my_cpu_ptr(&(pcp));               \
+       *(qual __my_cpu_type(pcp) * __force)__my_cpu_ptr(&(pcp));       \
 })
 
-#define __raw_cpu_write(size, qual, pcp, val)                          \
-do {                                                                   \
-       *(qual __my_cpu_type(pcp) *)__my_cpu_ptr(&(pcp)) = (val);       \
+#define __raw_cpu_write(size, qual, pcp, val)                                  \
+do {                                                                           \
+       *(qual __my_cpu_type(pcp) * __force)__my_cpu_ptr(&(pcp)) = (val);       \
 } while (0)
 
 #define __raw_cpu_read_const(pcp)      __raw_cpu_read(, , pcp)