[-tip,3/3] x86/percpu: Avoid sparse warning with cast to named address space

Message ID 20231203221151.794615-3-ubizjak@gmail.com
State New
Headers
Series [-tip,1/3] x86/percpu: Fix "const_pcpu_hot" version generation failure |

Commit Message

Uros Bizjak Dec. 3, 2023, 10:10 p.m. UTC
  Currently sparse does not know about __seg_fs and __seg_fs named
address space qualifiers. Avoid thousands of warnings about unexpected
keyword at the end of cast operator by removing named address space
qualifier from __my_cpu_type() when __CHECKER__ is defined.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202310080853.UhMe5iWa-lkp@intel.com/
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
---
 arch/x86/include/asm/percpu.h | 9 +++++++++
 1 file changed, 9 insertions(+)
  

Patch

diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h
index 7f6e978e21b1..07ee2aedb1f6 100644
--- a/arch/x86/include/asm/percpu.h
+++ b/arch/x86/include/asm/percpu.h
@@ -96,6 +96,15 @@ 
 
 #endif /* CONFIG_SMP */
 
+/*
+ * FIXME: Drop this hack once sparse learns how to ignore
+ * __seg_fs and __seg_gs named address space qualifiers.
+ */
+#ifdef __CHECKER__
+#undef __percpu_seg_override
+#define __percpu_seg_override
+#endif
+
 #define __my_cpu_type(var)	typeof(var) __percpu_seg_override
 #define __my_cpu_ptr(ptr)	(__my_cpu_type(*ptr) *)(uintptr_t)(ptr)
 #define __my_cpu_var(var)	(*__my_cpu_ptr(&var))