2005-04-16 22:20:36 +00:00
|
|
|
#ifndef _ASM_GENERIC_BUG_H
|
|
|
|
#define _ASM_GENERIC_BUG_H
|
|
|
|
|
|
|
|
#include <linux/compiler.h>
|
|
|
|
|
2012-06-25 08:15:31 +00:00
|
|
|
#ifdef CONFIG_GENERIC_BUG
|
|
|
|
#define BUGFLAG_WARNING (1 << 0)
|
|
|
|
#define BUGFLAG_TAINT(taint) (BUGFLAG_WARNING | ((taint) << 8))
|
|
|
|
#define BUG_GET_TAINT(bug) ((bug)->flags >> 8)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
|
2005-05-01 15:59:01 +00:00
|
|
|
#ifdef CONFIG_BUG
|
[PATCH] Generic BUG implementation
This patch adds common handling for kernel BUGs, for use by architectures as
they wish. The code is derived from arch/powerpc.
The advantages of having common BUG handling are:
- consistent BUG reporting across architectures
- shared implementation of out-of-line file/line data
- implement CONFIG_DEBUG_BUGVERBOSE consistently
This means that in inline impact of BUG is just the illegal instruction
itself, which is an improvement for i386 and x86-64.
A BUG is represented in the instruction stream as an illegal instruction,
which has file/line information associated with it. This extra information is
stored in the __bug_table section in the ELF file.
When the kernel gets an illegal instruction, it first confirms it might
possibly be from a BUG (ie, in kernel mode, the right illegal instruction).
It then calls report_bug(). This searches __bug_table for a matching
instruction pointer, and if found, prints the corresponding file/line
information. If report_bug() determines that it wasn't a BUG which caused the
trap, it returns BUG_TRAP_TYPE_NONE.
Some architectures (powerpc) implement WARN using the same mechanism; if the
illegal instruction was the result of a WARN, then report_bug(Q) returns
CONFIG_DEBUG_BUGVERBOSE; otherwise it returns BUG_TRAP_TYPE_BUG.
lib/bug.c keeps a list of loaded modules which can be searched for __bug_table
entries. The architecture must call
module_bug_finalize()/module_bug_cleanup() from its corresponding
module_finalize/cleanup functions.
Unsetting CONFIG_DEBUG_BUGVERBOSE will reduce the kernel size by some amount.
At the very least, filename and line information will not be recorded for each
but, but architectures may decide to store no extra information per BUG at
all.
Unfortunately, gcc doesn't have a general way to mark an asm() as noreturn, so
architectures will generally have to include an infinite loop (or similar) in
the BUG code, so that gcc knows execution won't continue beyond that point.
gcc does have a __builtin_trap() operator which may be useful to achieve the
same effect, unfortunately it cannot be used to actually implement the BUG
itself, because there's no way to get the instruction's address for use in
generating the __bug_table entry.
[randy.dunlap@oracle.com: Handle BUG=n, GENERIC_BUG=n to prevent build errors]
[bunk@stusta.de: include/linux/bug.h must always #include <linux/module.h]
Signed-off-by: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Andi Kleen <ak@muc.de>
Cc: Hugh Dickens <hugh@veritas.com>
Cc: Michael Ellerman <michael@ellerman.id.au>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-08 10:36:19 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_GENERIC_BUG
|
|
|
|
struct bug_entry {
|
2008-12-16 11:40:27 +00:00
|
|
|
#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
|
[PATCH] Generic BUG implementation
This patch adds common handling for kernel BUGs, for use by architectures as
they wish. The code is derived from arch/powerpc.
The advantages of having common BUG handling are:
- consistent BUG reporting across architectures
- shared implementation of out-of-line file/line data
- implement CONFIG_DEBUG_BUGVERBOSE consistently
This means that in inline impact of BUG is just the illegal instruction
itself, which is an improvement for i386 and x86-64.
A BUG is represented in the instruction stream as an illegal instruction,
which has file/line information associated with it. This extra information is
stored in the __bug_table section in the ELF file.
When the kernel gets an illegal instruction, it first confirms it might
possibly be from a BUG (ie, in kernel mode, the right illegal instruction).
It then calls report_bug(). This searches __bug_table for a matching
instruction pointer, and if found, prints the corresponding file/line
information. If report_bug() determines that it wasn't a BUG which caused the
trap, it returns BUG_TRAP_TYPE_NONE.
Some architectures (powerpc) implement WARN using the same mechanism; if the
illegal instruction was the result of a WARN, then report_bug(Q) returns
CONFIG_DEBUG_BUGVERBOSE; otherwise it returns BUG_TRAP_TYPE_BUG.
lib/bug.c keeps a list of loaded modules which can be searched for __bug_table
entries. The architecture must call
module_bug_finalize()/module_bug_cleanup() from its corresponding
module_finalize/cleanup functions.
Unsetting CONFIG_DEBUG_BUGVERBOSE will reduce the kernel size by some amount.
At the very least, filename and line information will not be recorded for each
but, but architectures may decide to store no extra information per BUG at
all.
Unfortunately, gcc doesn't have a general way to mark an asm() as noreturn, so
architectures will generally have to include an infinite loop (or similar) in
the BUG code, so that gcc knows execution won't continue beyond that point.
gcc does have a __builtin_trap() operator which may be useful to achieve the
same effect, unfortunately it cannot be used to actually implement the BUG
itself, because there's no way to get the instruction's address for use in
generating the __bug_table entry.
[randy.dunlap@oracle.com: Handle BUG=n, GENERIC_BUG=n to prevent build errors]
[bunk@stusta.de: include/linux/bug.h must always #include <linux/module.h]
Signed-off-by: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Andi Kleen <ak@muc.de>
Cc: Hugh Dickens <hugh@veritas.com>
Cc: Michael Ellerman <michael@ellerman.id.au>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-08 10:36:19 +00:00
|
|
|
unsigned long bug_addr;
|
2008-12-16 11:40:27 +00:00
|
|
|
#else
|
|
|
|
signed int bug_addr_disp;
|
|
|
|
#endif
|
[PATCH] Generic BUG implementation
This patch adds common handling for kernel BUGs, for use by architectures as
they wish. The code is derived from arch/powerpc.
The advantages of having common BUG handling are:
- consistent BUG reporting across architectures
- shared implementation of out-of-line file/line data
- implement CONFIG_DEBUG_BUGVERBOSE consistently
This means that in inline impact of BUG is just the illegal instruction
itself, which is an improvement for i386 and x86-64.
A BUG is represented in the instruction stream as an illegal instruction,
which has file/line information associated with it. This extra information is
stored in the __bug_table section in the ELF file.
When the kernel gets an illegal instruction, it first confirms it might
possibly be from a BUG (ie, in kernel mode, the right illegal instruction).
It then calls report_bug(). This searches __bug_table for a matching
instruction pointer, and if found, prints the corresponding file/line
information. If report_bug() determines that it wasn't a BUG which caused the
trap, it returns BUG_TRAP_TYPE_NONE.
Some architectures (powerpc) implement WARN using the same mechanism; if the
illegal instruction was the result of a WARN, then report_bug(Q) returns
CONFIG_DEBUG_BUGVERBOSE; otherwise it returns BUG_TRAP_TYPE_BUG.
lib/bug.c keeps a list of loaded modules which can be searched for __bug_table
entries. The architecture must call
module_bug_finalize()/module_bug_cleanup() from its corresponding
module_finalize/cleanup functions.
Unsetting CONFIG_DEBUG_BUGVERBOSE will reduce the kernel size by some amount.
At the very least, filename and line information will not be recorded for each
but, but architectures may decide to store no extra information per BUG at
all.
Unfortunately, gcc doesn't have a general way to mark an asm() as noreturn, so
architectures will generally have to include an infinite loop (or similar) in
the BUG code, so that gcc knows execution won't continue beyond that point.
gcc does have a __builtin_trap() operator which may be useful to achieve the
same effect, unfortunately it cannot be used to actually implement the BUG
itself, because there's no way to get the instruction's address for use in
generating the __bug_table entry.
[randy.dunlap@oracle.com: Handle BUG=n, GENERIC_BUG=n to prevent build errors]
[bunk@stusta.de: include/linux/bug.h must always #include <linux/module.h]
Signed-off-by: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Andi Kleen <ak@muc.de>
Cc: Hugh Dickens <hugh@veritas.com>
Cc: Michael Ellerman <michael@ellerman.id.au>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-08 10:36:19 +00:00
|
|
|
#ifdef CONFIG_DEBUG_BUGVERBOSE
|
2008-12-16 11:40:27 +00:00
|
|
|
#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
|
[PATCH] Generic BUG implementation
This patch adds common handling for kernel BUGs, for use by architectures as
they wish. The code is derived from arch/powerpc.
The advantages of having common BUG handling are:
- consistent BUG reporting across architectures
- shared implementation of out-of-line file/line data
- implement CONFIG_DEBUG_BUGVERBOSE consistently
This means that in inline impact of BUG is just the illegal instruction
itself, which is an improvement for i386 and x86-64.
A BUG is represented in the instruction stream as an illegal instruction,
which has file/line information associated with it. This extra information is
stored in the __bug_table section in the ELF file.
When the kernel gets an illegal instruction, it first confirms it might
possibly be from a BUG (ie, in kernel mode, the right illegal instruction).
It then calls report_bug(). This searches __bug_table for a matching
instruction pointer, and if found, prints the corresponding file/line
information. If report_bug() determines that it wasn't a BUG which caused the
trap, it returns BUG_TRAP_TYPE_NONE.
Some architectures (powerpc) implement WARN using the same mechanism; if the
illegal instruction was the result of a WARN, then report_bug(Q) returns
CONFIG_DEBUG_BUGVERBOSE; otherwise it returns BUG_TRAP_TYPE_BUG.
lib/bug.c keeps a list of loaded modules which can be searched for __bug_table
entries. The architecture must call
module_bug_finalize()/module_bug_cleanup() from its corresponding
module_finalize/cleanup functions.
Unsetting CONFIG_DEBUG_BUGVERBOSE will reduce the kernel size by some amount.
At the very least, filename and line information will not be recorded for each
but, but architectures may decide to store no extra information per BUG at
all.
Unfortunately, gcc doesn't have a general way to mark an asm() as noreturn, so
architectures will generally have to include an infinite loop (or similar) in
the BUG code, so that gcc knows execution won't continue beyond that point.
gcc does have a __builtin_trap() operator which may be useful to achieve the
same effect, unfortunately it cannot be used to actually implement the BUG
itself, because there's no way to get the instruction's address for use in
generating the __bug_table entry.
[randy.dunlap@oracle.com: Handle BUG=n, GENERIC_BUG=n to prevent build errors]
[bunk@stusta.de: include/linux/bug.h must always #include <linux/module.h]
Signed-off-by: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Andi Kleen <ak@muc.de>
Cc: Hugh Dickens <hugh@veritas.com>
Cc: Michael Ellerman <michael@ellerman.id.au>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-08 10:36:19 +00:00
|
|
|
const char *file;
|
2008-12-16 11:40:27 +00:00
|
|
|
#else
|
|
|
|
signed int file_disp;
|
|
|
|
#endif
|
[PATCH] Generic BUG implementation
This patch adds common handling for kernel BUGs, for use by architectures as
they wish. The code is derived from arch/powerpc.
The advantages of having common BUG handling are:
- consistent BUG reporting across architectures
- shared implementation of out-of-line file/line data
- implement CONFIG_DEBUG_BUGVERBOSE consistently
This means that in inline impact of BUG is just the illegal instruction
itself, which is an improvement for i386 and x86-64.
A BUG is represented in the instruction stream as an illegal instruction,
which has file/line information associated with it. This extra information is
stored in the __bug_table section in the ELF file.
When the kernel gets an illegal instruction, it first confirms it might
possibly be from a BUG (ie, in kernel mode, the right illegal instruction).
It then calls report_bug(). This searches __bug_table for a matching
instruction pointer, and if found, prints the corresponding file/line
information. If report_bug() determines that it wasn't a BUG which caused the
trap, it returns BUG_TRAP_TYPE_NONE.
Some architectures (powerpc) implement WARN using the same mechanism; if the
illegal instruction was the result of a WARN, then report_bug(Q) returns
CONFIG_DEBUG_BUGVERBOSE; otherwise it returns BUG_TRAP_TYPE_BUG.
lib/bug.c keeps a list of loaded modules which can be searched for __bug_table
entries. The architecture must call
module_bug_finalize()/module_bug_cleanup() from its corresponding
module_finalize/cleanup functions.
Unsetting CONFIG_DEBUG_BUGVERBOSE will reduce the kernel size by some amount.
At the very least, filename and line information will not be recorded for each
but, but architectures may decide to store no extra information per BUG at
all.
Unfortunately, gcc doesn't have a general way to mark an asm() as noreturn, so
architectures will generally have to include an infinite loop (or similar) in
the BUG code, so that gcc knows execution won't continue beyond that point.
gcc does have a __builtin_trap() operator which may be useful to achieve the
same effect, unfortunately it cannot be used to actually implement the BUG
itself, because there's no way to get the instruction's address for use in
generating the __bug_table entry.
[randy.dunlap@oracle.com: Handle BUG=n, GENERIC_BUG=n to prevent build errors]
[bunk@stusta.de: include/linux/bug.h must always #include <linux/module.h]
Signed-off-by: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Andi Kleen <ak@muc.de>
Cc: Hugh Dickens <hugh@veritas.com>
Cc: Michael Ellerman <michael@ellerman.id.au>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-08 10:36:19 +00:00
|
|
|
unsigned short line;
|
|
|
|
#endif
|
|
|
|
unsigned short flags;
|
|
|
|
};
|
|
|
|
#endif /* CONFIG_GENERIC_BUG */
|
|
|
|
|
2009-01-06 22:41:01 +00:00
|
|
|
/*
|
|
|
|
* Don't use BUG() or BUG_ON() unless there's really no way out; one
|
|
|
|
* example might be detecting data structure corruption in the middle
|
|
|
|
* of an operation that can't be backed out of. If the (sub)system
|
|
|
|
* can somehow continue operating, perhaps with reduced functionality,
|
|
|
|
* it's probably not BUG-worthy.
|
|
|
|
*
|
|
|
|
* If you're tempted to BUG(), think again: is completely giving up
|
|
|
|
* really the *only* solution? There are usually better options, where
|
|
|
|
* users don't need to reboot ASAP and can mostly shut down cleanly.
|
|
|
|
*/
|
2005-04-16 22:20:36 +00:00
|
|
|
#ifndef HAVE_ARCH_BUG
|
|
|
|
#define BUG() do { \
|
2008-10-16 05:01:24 +00:00
|
|
|
printk("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __func__); \
|
2005-04-16 22:20:36 +00:00
|
|
|
panic("BUG!"); \
|
|
|
|
} while (0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef HAVE_ARCH_BUG_ON
|
2007-07-17 11:03:56 +00:00
|
|
|
#define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while(0)
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|
|
|
|
|
2009-01-06 22:41:01 +00:00
|
|
|
/*
|
|
|
|
* WARN(), WARN_ON(), WARN_ON_ONCE, and so on can be used to report
|
|
|
|
* significant issues that need prompt attention if they should ever
|
|
|
|
* appear at runtime. Use the versions with printk format strings
|
|
|
|
* to provide better diagnostics.
|
|
|
|
*/
|
2010-04-03 18:34:56 +00:00
|
|
|
#ifndef __WARN_TAINT
|
2011-11-01 00:11:33 +00:00
|
|
|
extern __printf(3, 4)
|
|
|
|
void warn_slowpath_fmt(const char *file, const int line,
|
|
|
|
const char *fmt, ...);
|
|
|
|
extern __printf(4, 5)
|
|
|
|
void warn_slowpath_fmt_taint(const char *file, const int line, unsigned taint,
|
|
|
|
const char *fmt, ...);
|
2009-05-06 23:02:53 +00:00
|
|
|
extern void warn_slowpath_null(const char *file, const int line);
|
2008-01-30 12:32:50 +00:00
|
|
|
#define WANT_WARN_ON_SLOWPATH
|
2009-05-06 23:02:53 +00:00
|
|
|
#define __WARN() warn_slowpath_null(__FILE__, __LINE__)
|
|
|
|
#define __WARN_printf(arg...) warn_slowpath_fmt(__FILE__, __LINE__, arg)
|
2010-04-03 18:34:56 +00:00
|
|
|
#define __WARN_printf_taint(taint, arg...) \
|
|
|
|
warn_slowpath_fmt_taint(__FILE__, __LINE__, taint, arg)
|
2008-07-25 08:45:53 +00:00
|
|
|
#else
|
2010-04-03 18:34:56 +00:00
|
|
|
#define __WARN() __WARN_TAINT(TAINT_WARN)
|
2008-11-28 16:56:14 +00:00
|
|
|
#define __WARN_printf(arg...) do { printk(arg); __WARN(); } while (0)
|
2010-04-03 18:34:56 +00:00
|
|
|
#define __WARN_printf_taint(taint, arg...) \
|
|
|
|
do { printk(arg); __WARN_TAINT(taint); } while (0)
|
2008-01-30 12:32:50 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef WARN_ON
|
2006-09-29 08:59:06 +00:00
|
|
|
#define WARN_ON(condition) ({ \
|
2007-08-01 04:12:07 +00:00
|
|
|
int __ret_warn_on = !!(condition); \
|
2008-01-30 12:32:50 +00:00
|
|
|
if (unlikely(__ret_warn_on)) \
|
|
|
|
__WARN(); \
|
2006-09-29 08:59:06 +00:00
|
|
|
unlikely(__ret_warn_on); \
|
|
|
|
})
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|
|
|
|
|
2008-07-25 08:45:53 +00:00
|
|
|
#ifndef WARN
|
|
|
|
#define WARN(condition, format...) ({ \
|
|
|
|
int __ret_warn_on = !!(condition); \
|
|
|
|
if (unlikely(__ret_warn_on)) \
|
|
|
|
__WARN_printf(format); \
|
|
|
|
unlikely(__ret_warn_on); \
|
|
|
|
})
|
|
|
|
#endif
|
|
|
|
|
2010-04-03 18:34:56 +00:00
|
|
|
#define WARN_TAINT(condition, taint, format...) ({ \
|
|
|
|
int __ret_warn_on = !!(condition); \
|
|
|
|
if (unlikely(__ret_warn_on)) \
|
|
|
|
__WARN_printf_taint(taint, format); \
|
|
|
|
unlikely(__ret_warn_on); \
|
|
|
|
})
|
|
|
|
|
2005-05-01 15:59:01 +00:00
|
|
|
#else /* !CONFIG_BUG */
|
|
|
|
#ifndef HAVE_ARCH_BUG
|
2009-04-15 18:34:56 +00:00
|
|
|
#define BUG() do {} while(0)
|
2005-05-01 15:59:01 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef HAVE_ARCH_BUG_ON
|
|
|
|
#define BUG_ON(condition) do { if (condition) ; } while(0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef HAVE_ARCH_WARN_ON
|
2006-10-20 06:28:34 +00:00
|
|
|
#define WARN_ON(condition) ({ \
|
2007-08-01 04:12:07 +00:00
|
|
|
int __ret_warn_on = !!(condition); \
|
2006-10-20 06:28:34 +00:00
|
|
|
unlikely(__ret_warn_on); \
|
|
|
|
})
|
2005-05-01 15:59:01 +00:00
|
|
|
#endif
|
2008-07-25 08:45:53 +00:00
|
|
|
|
|
|
|
#ifndef WARN
|
|
|
|
#define WARN(condition, format...) ({ \
|
|
|
|
int __ret_warn_on = !!(condition); \
|
|
|
|
unlikely(__ret_warn_on); \
|
|
|
|
})
|
|
|
|
#endif
|
|
|
|
|
2010-04-03 18:34:56 +00:00
|
|
|
#define WARN_TAINT(condition, taint, format...) WARN_ON(condition)
|
|
|
|
|
2005-05-01 15:59:01 +00:00
|
|
|
#endif
|
|
|
|
|
2006-10-06 07:43:49 +00:00
|
|
|
#define WARN_ON_ONCE(condition) ({ \
|
2012-03-23 22:01:52 +00:00
|
|
|
static bool __section(.data.unlikely) __warned; \
|
2007-08-01 04:12:07 +00:00
|
|
|
int __ret_warn_once = !!(condition); \
|
2006-10-06 07:43:49 +00:00
|
|
|
\
|
|
|
|
if (unlikely(__ret_warn_once)) \
|
|
|
|
if (WARN_ON(!__warned)) \
|
2009-12-15 02:00:13 +00:00
|
|
|
__warned = true; \
|
2006-10-06 07:43:49 +00:00
|
|
|
unlikely(__ret_warn_once); \
|
2006-06-25 12:48:09 +00:00
|
|
|
})
|
|
|
|
|
2008-09-15 23:43:18 +00:00
|
|
|
#define WARN_ONCE(condition, format...) ({ \
|
2012-03-23 22:01:52 +00:00
|
|
|
static bool __section(.data.unlikely) __warned; \
|
2008-09-15 23:43:18 +00:00
|
|
|
int __ret_warn_once = !!(condition); \
|
|
|
|
\
|
|
|
|
if (unlikely(__ret_warn_once)) \
|
|
|
|
if (WARN(!__warned, format)) \
|
2009-12-15 02:00:13 +00:00
|
|
|
__warned = true; \
|
2008-09-15 23:43:18 +00:00
|
|
|
unlikely(__ret_warn_once); \
|
|
|
|
})
|
|
|
|
|
2010-04-03 18:34:56 +00:00
|
|
|
#define WARN_TAINT_ONCE(condition, taint, format...) ({ \
|
2012-03-23 22:01:52 +00:00
|
|
|
static bool __section(.data.unlikely) __warned; \
|
2010-04-03 18:34:56 +00:00
|
|
|
int __ret_warn_once = !!(condition); \
|
|
|
|
\
|
|
|
|
if (unlikely(__ret_warn_once)) \
|
|
|
|
if (WARN_TAINT(!__warned, taint, format)) \
|
|
|
|
__warned = true; \
|
|
|
|
unlikely(__ret_warn_once); \
|
|
|
|
})
|
|
|
|
|
2011-03-17 19:21:06 +00:00
|
|
|
/*
|
|
|
|
* WARN_ON_SMP() is for cases that the warning is either
|
|
|
|
* meaningless for !SMP or may even cause failures.
|
|
|
|
* This is usually used for cases that we have
|
|
|
|
* WARN_ON(!spin_is_locked(&lock)) checks, as spin_is_locked()
|
|
|
|
* returns 0 for uniprocessor settings.
|
|
|
|
* It can also be used with values that are only defined
|
|
|
|
* on SMP:
|
|
|
|
*
|
|
|
|
* struct foo {
|
|
|
|
* [...]
|
|
|
|
* #ifdef CONFIG_SMP
|
|
|
|
* int bar;
|
|
|
|
* #endif
|
|
|
|
* };
|
|
|
|
*
|
|
|
|
* void func(struct foo *zoot)
|
|
|
|
* {
|
|
|
|
* WARN_ON_SMP(!zoot->bar);
|
|
|
|
*
|
|
|
|
* For CONFIG_SMP, WARN_ON_SMP() should act the same as WARN_ON(),
|
|
|
|
* and should be a nop and return false for uniprocessor.
|
|
|
|
*
|
|
|
|
* if (WARN_ON_SMP(x)) returns true only when CONFIG_SMP is set
|
|
|
|
* and x is true.
|
|
|
|
*/
|
2006-06-27 09:54:50 +00:00
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
# define WARN_ON_SMP(x) WARN_ON(x)
|
|
|
|
#else
|
2011-03-25 20:21:06 +00:00
|
|
|
/*
|
|
|
|
* Use of ({0;}) because WARN_ON_SMP(x) may be used either as
|
|
|
|
* a stand alone line statement or as a condition in an if ()
|
|
|
|
* statement.
|
|
|
|
* A simple "0" would cause gcc to give a "statement has no effect"
|
|
|
|
* warning.
|
|
|
|
*/
|
2011-03-17 19:21:06 +00:00
|
|
|
# define WARN_ON_SMP(x) ({0;})
|
2006-06-27 09:54:50 +00:00
|
|
|
#endif
|
|
|
|
|
2012-06-18 04:54:17 +00:00
|
|
|
#endif /* __ASSEMBLY__ */
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|