linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/cpufeature: fix __percpu annotation in this_cpu_has()
@ 2019-03-28 15:49 Jann Horn
  2019-03-28 16:13 ` [tip:x86/urgent] x86/cpufeature: Fix " tip-bot for Jann Horn
  0 siblings, 1 reply; 2+ messages in thread
From: Jann Horn @ 2019-03-28 15:49 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin, jannh
  Cc: x86, linux-kernel

&cpu_info.x86_capability is __percpu, and the second argument of
x86_this_cpu_test_bit() is expected to be __percpu. Don't cast the __percpu
away and then implicitly add it again.
This gets rid of 106 lines of sparse warnings with the kernel config I'm
using.

Signed-off-by: Jann Horn <jannh@google.com>
---
 arch/x86/include/asm/cpufeature.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
index ce95b8cbd229..0df88893e767 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -113,7 +113,8 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
 
 #define this_cpu_has(bit)						\
 	(__builtin_constant_p(bit) && REQUIRED_MASK_BIT_SET(bit) ? 1 : 	\
-	 x86_this_cpu_test_bit(bit, (unsigned long *)&cpu_info.x86_capability))
+	 x86_this_cpu_test_bit(bit,					\
+		(unsigned long __percpu *)&cpu_info.x86_capability))
 
 /*
  * This macro is for detection of features which need kernel
-- 
2.21.0.392.gf8f6787159e-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [tip:x86/urgent] x86/cpufeature: Fix __percpu annotation in this_cpu_has()
  2019-03-28 15:49 [PATCH] x86/cpufeature: fix __percpu annotation in this_cpu_has() Jann Horn
@ 2019-03-28 16:13 ` tip-bot for Jann Horn
  0 siblings, 0 replies; 2+ messages in thread
From: tip-bot for Jann Horn @ 2019-03-28 16:13 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, x86, mingo, bp, jannh, mingo, hpa, tglx,
	yamada.masahiro, namit

Commit-ID:  f6027c81099e87516d27d123867f10abd04b2d38
Gitweb:     https://git.kernel.org/tip/f6027c81099e87516d27d123867f10abd04b2d38
Author:     Jann Horn <jannh@google.com>
AuthorDate: Thu, 28 Mar 2019 16:49:48 +0100
Committer:  Borislav Petkov <bp@suse.de>
CommitDate: Thu, 28 Mar 2019 17:03:11 +0100

x86/cpufeature: Fix __percpu annotation in this_cpu_has()

&cpu_info.x86_capability is __percpu, and the second argument of
x86_this_cpu_test_bit() is expected to be __percpu. Don't cast the
__percpu away and then implicitly add it again. This gets rid of 106
lines of sparse warnings with the kernel config I'm using.

Signed-off-by: Jann Horn <jannh@google.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Nadav Amit <namit@vmware.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: x86-ml <x86@kernel.org>
Link: https://lkml.kernel.org/r/20190328154948.152273-1-jannh@google.com
---
 arch/x86/include/asm/cpufeature.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
index ce95b8cbd229..0e56ff7e4848 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -112,8 +112,9 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
 	 test_cpu_cap(c, bit))
 
 #define this_cpu_has(bit)						\
-	(__builtin_constant_p(bit) && REQUIRED_MASK_BIT_SET(bit) ? 1 : 	\
-	 x86_this_cpu_test_bit(bit, (unsigned long *)&cpu_info.x86_capability))
+	(__builtin_constant_p(bit) && REQUIRED_MASK_BIT_SET(bit) ? 1 :	\
+	 x86_this_cpu_test_bit(bit,					\
+		(unsigned long __percpu *)&cpu_info.x86_capability))
 
 /*
  * This macro is for detection of features which need kernel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-03-28 16:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-28 15:49 [PATCH] x86/cpufeature: fix __percpu annotation in this_cpu_has() Jann Horn
2019-03-28 16:13 ` [tip:x86/urgent] x86/cpufeature: Fix " tip-bot for Jann Horn

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).