diff options
author | pan xinhui <xinhui.pan@linux.vnet.ibm.com> | 2016-02-23 06:05:01 -0500 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2016-02-24 04:08:48 -0500 |
commit | 10d8b1480e6966ba03cd3afad3b5d6eb5e341fae (patch) | |
tree | 5ab67c34061bb141ec4a6e231ebfd01d4d08faef | |
parent | 289543a5c21a20ca88b803750a6cfe1a951eed5f (diff) |
powerpc: Use BUILD_BUG_ON_MSG() for unsupported {cmp}xchg sizes
__xchg_called_with_bad_pointer() can't tell us which code uses {cmp}xchg
with an unsupported size, and no error is reported until the link stage.
To make such problems easier to debug, use BUILD_BUG_ON_MSG() instead.
Signed-off-by: pan xinhui <xinhui.pan@linux.vnet.ibm.com>
[mpe: Tweak change log wording & add relaxed/acquire]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
fixup
-rw-r--r-- | arch/powerpc/include/asm/cmpxchg.h | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/arch/powerpc/include/asm/cmpxchg.h b/arch/powerpc/include/asm/cmpxchg.h index cae4fa85250c..44efe739b6b9 100644 --- a/arch/powerpc/include/asm/cmpxchg.h +++ b/arch/powerpc/include/asm/cmpxchg.h | |||
@@ -5,6 +5,7 @@ | |||
5 | #include <linux/compiler.h> | 5 | #include <linux/compiler.h> |
6 | #include <asm/synch.h> | 6 | #include <asm/synch.h> |
7 | #include <asm/asm-compat.h> | 7 | #include <asm/asm-compat.h> |
8 | #include <linux/bug.h> | ||
8 | 9 | ||
9 | /* | 10 | /* |
10 | * Atomic exchange | 11 | * Atomic exchange |
@@ -83,12 +84,6 @@ __xchg_u64_relaxed(u64 *p, unsigned long val) | |||
83 | } | 84 | } |
84 | #endif | 85 | #endif |
85 | 86 | ||
86 | /* | ||
87 | * This function doesn't exist, so you'll get a linker error | ||
88 | * if something tries to do an invalid xchg(). | ||
89 | */ | ||
90 | extern void __xchg_called_with_bad_pointer(void); | ||
91 | |||
92 | static __always_inline unsigned long | 87 | static __always_inline unsigned long |
93 | __xchg_local(volatile void *ptr, unsigned long x, unsigned int size) | 88 | __xchg_local(volatile void *ptr, unsigned long x, unsigned int size) |
94 | { | 89 | { |
@@ -100,7 +95,7 @@ __xchg_local(volatile void *ptr, unsigned long x, unsigned int size) | |||
100 | return __xchg_u64_local(ptr, x); | 95 | return __xchg_u64_local(ptr, x); |
101 | #endif | 96 | #endif |
102 | } | 97 | } |
103 | __xchg_called_with_bad_pointer(); | 98 | BUILD_BUG_ON_MSG(1, "Unsupported size for __xchg"); |
104 | return x; | 99 | return x; |
105 | } | 100 | } |
106 | 101 | ||
@@ -115,7 +110,7 @@ __xchg_relaxed(void *ptr, unsigned long x, unsigned int size) | |||
115 | return __xchg_u64_relaxed(ptr, x); | 110 | return __xchg_u64_relaxed(ptr, x); |
116 | #endif | 111 | #endif |
117 | } | 112 | } |
118 | __xchg_called_with_bad_pointer(); | 113 | BUILD_BUG_ON_MSG(1, "Unsupported size for __xchg_local"); |
119 | return x; | 114 | return x; |
120 | } | 115 | } |
121 | #define xchg_local(ptr,x) \ | 116 | #define xchg_local(ptr,x) \ |
@@ -316,10 +311,6 @@ __cmpxchg_u64_acquire(u64 *p, unsigned long old, unsigned long new) | |||
316 | } | 311 | } |
317 | #endif | 312 | #endif |
318 | 313 | ||
319 | /* This function doesn't exist, so you'll get a linker error | ||
320 | if something tries to do an invalid cmpxchg(). */ | ||
321 | extern void __cmpxchg_called_with_bad_pointer(void); | ||
322 | |||
323 | static __always_inline unsigned long | 314 | static __always_inline unsigned long |
324 | __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, | 315 | __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, |
325 | unsigned int size) | 316 | unsigned int size) |
@@ -332,7 +323,7 @@ __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, | |||
332 | return __cmpxchg_u64(ptr, old, new); | 323 | return __cmpxchg_u64(ptr, old, new); |
333 | #endif | 324 | #endif |
334 | } | 325 | } |
335 | __cmpxchg_called_with_bad_pointer(); | 326 | BUILD_BUG_ON_MSG(1, "Unsupported size for __cmpxchg"); |
336 | return old; | 327 | return old; |
337 | } | 328 | } |
338 | 329 | ||
@@ -348,7 +339,7 @@ __cmpxchg_local(volatile void *ptr, unsigned long old, unsigned long new, | |||
348 | return __cmpxchg_u64_local(ptr, old, new); | 339 | return __cmpxchg_u64_local(ptr, old, new); |
349 | #endif | 340 | #endif |
350 | } | 341 | } |
351 | __cmpxchg_called_with_bad_pointer(); | 342 | BUILD_BUG_ON_MSG(1, "Unsupported size for __cmpxchg_local"); |
352 | return old; | 343 | return old; |
353 | } | 344 | } |
354 | 345 | ||
@@ -364,7 +355,7 @@ __cmpxchg_relaxed(void *ptr, unsigned long old, unsigned long new, | |||
364 | return __cmpxchg_u64_relaxed(ptr, old, new); | 355 | return __cmpxchg_u64_relaxed(ptr, old, new); |
365 | #endif | 356 | #endif |
366 | } | 357 | } |
367 | __cmpxchg_called_with_bad_pointer(); | 358 | BUILD_BUG_ON_MSG(1, "Unsupported size for __cmpxchg_relaxed"); |
368 | return old; | 359 | return old; |
369 | } | 360 | } |
370 | 361 | ||
@@ -380,7 +371,7 @@ __cmpxchg_acquire(void *ptr, unsigned long old, unsigned long new, | |||
380 | return __cmpxchg_u64_acquire(ptr, old, new); | 371 | return __cmpxchg_u64_acquire(ptr, old, new); |
381 | #endif | 372 | #endif |
382 | } | 373 | } |
383 | __cmpxchg_called_with_bad_pointer(); | 374 | BUILD_BUG_ON_MSG(1, "Unsupported size for __cmpxchg_acquire"); |
384 | return old; | 375 | return old; |
385 | } | 376 | } |
386 | #define cmpxchg(ptr, o, n) \ | 377 | #define cmpxchg(ptr, o, n) \ |