License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 14:07:57 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2005-04-16 22:20:36 +00:00
|
|
|
#ifndef _ASM_GENERIC_BUG_H
|
|
|
|
#define _ASM_GENERIC_BUG_H
|
|
|
|
|
|
|
|
#include <linux/compiler.h>
|
|
|
|
|
2017-11-17 23:27:21 +00:00
|
|
|
#define CUT_HERE "------------[ cut here ]------------\n"
|
|
|
|
|
2012-06-25 08:15:31 +00:00
|
|
|
#ifdef CONFIG_GENERIC_BUG
|
|
|
|
#define BUGFLAG_WARNING (1 << 0)
|
2017-02-25 07:56:53 +00:00
|
|
|
#define BUGFLAG_ONCE (1 << 1)
|
|
|
|
#define BUGFLAG_DONE (1 << 2)
|
2017-04-10 08:49:39 +00:00
|
|
|
#define BUGFLAG_TAINT(taint) ((taint) << 8)
|
2012-06-25 08:15:31 +00:00
|
|
|
#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
|
2014-04-07 22:39:11 +00:00
|
|
|
#define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|
|
|
|
|
2017-02-25 07:56:53 +00:00
|
|
|
#ifdef __WARN_FLAGS
|
|
|
|
#define __WARN_TAINT(taint) __WARN_FLAGS(BUGFLAG_TAINT(taint))
|
|
|
|
#define __WARN_ONCE_TAINT(taint) __WARN_FLAGS(BUGFLAG_ONCE|BUGFLAG_TAINT(taint))
|
|
|
|
|
|
|
|
#define WARN_ON_ONCE(condition) ({ \
|
|
|
|
int __ret_warn_on = !!(condition); \
|
|
|
|
if (unlikely(__ret_warn_on)) \
|
|
|
|
__WARN_ONCE_TAINT(TAINT_WARN); \
|
|
|
|
unlikely(__ret_warn_on); \
|
|
|
|
})
|
|
|
|
#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
|
|
|
|
|
2016-03-17 21:23:04 +00:00
|
|
|
/* used internally by panic.c */
|
|
|
|
struct warn_args;
|
2017-07-10 22:50:55 +00:00
|
|
|
struct pt_regs;
|
2016-03-17 21:23:04 +00:00
|
|
|
|
|
|
|
void __warn(const char *file, int line, void *caller, unsigned taint,
|
|
|
|
struct pt_regs *regs, struct warn_args *args);
|
|
|
|
|
2008-01-30 12:32:50 +00:00
|
|
|
#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
|
2017-02-25 07:56:53 +00:00
|
|
|
#define WARN(condition, format...) ({ \
|
2008-07-25 08:45:53 +00:00
|
|
|
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); \
|
|
|
|
})
|
|
|
|
|
2017-02-25 07:56:53 +00:00
|
|
|
#ifndef WARN_ON_ONCE
|
2006-10-06 07:43:49 +00:00
|
|
|
#define WARN_ON_ONCE(condition) ({ \
|
2017-11-17 23:27:03 +00:00
|
|
|
static bool __section(.data.once) __warned; \
|
2007-08-01 04:12:07 +00:00
|
|
|
int __ret_warn_once = !!(condition); \
|
2006-10-06 07:43:49 +00:00
|
|
|
\
|
2016-03-17 21:21:12 +00:00
|
|
|
if (unlikely(__ret_warn_once && !__warned)) { \
|
|
|
|
__warned = true; \
|
|
|
|
WARN_ON(1); \
|
|
|
|
} \
|
2006-10-06 07:43:49 +00:00
|
|
|
unlikely(__ret_warn_once); \
|
2006-06-25 12:48:09 +00:00
|
|
|
})
|
2017-02-25 07:56:53 +00:00
|
|
|
#endif
|
2006-06-25 12:48:09 +00:00
|
|
|
|
2008-09-15 23:43:18 +00:00
|
|
|
#define WARN_ONCE(condition, format...) ({ \
|
2017-11-17 23:27:03 +00:00
|
|
|
static bool __section(.data.once) __warned; \
|
2008-09-15 23:43:18 +00:00
|
|
|
int __ret_warn_once = !!(condition); \
|
|
|
|
\
|
2016-03-17 21:21:12 +00:00
|
|
|
if (unlikely(__ret_warn_once && !__warned)) { \
|
|
|
|
__warned = true; \
|
|
|
|
WARN(1, format); \
|
|
|
|
} \
|
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...) ({ \
|
2017-11-17 23:27:03 +00:00
|
|
|
static bool __section(.data.once) __warned; \
|
2010-04-03 18:34:56 +00:00
|
|
|
int __ret_warn_once = !!(condition); \
|
|
|
|
\
|
2016-03-17 21:21:12 +00:00
|
|
|
if (unlikely(__ret_warn_once && !__warned)) { \
|
|
|
|
__warned = true; \
|
|
|
|
WARN_TAINT(1, taint, format); \
|
|
|
|
} \
|
2010-04-03 18:34:56 +00:00
|
|
|
unlikely(__ret_warn_once); \
|
|
|
|
})
|
|
|
|
|
2014-04-07 22:39:10 +00:00
|
|
|
#else /* !CONFIG_BUG */
|
|
|
|
#ifndef HAVE_ARCH_BUG
|
2014-04-07 22:39:13 +00:00
|
|
|
#define BUG() do {} while (1)
|
2014-04-07 22:39:10 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef HAVE_ARCH_BUG_ON
|
asm-generic: default BUG_ON(x) to if(x)BUG()
When CONFIG_BUG is disabled, BUG_ON() will only evaluate the condition,
but will not actually stop the current thread. GCC warns about a couple
of BUG_ON() users where this actually leads to further undefined
behavior:
include/linux/ceph/osdmap.h: In function 'ceph_can_shift_osds':
include/linux/ceph/osdmap.h:54:1: warning: control reaches end of non-void function
fs/ext4/inode.c: In function 'ext4_map_blocks':
fs/ext4/inode.c:548:5: warning: 'retval' may be used uninitialized in this function
drivers/mfd/db8500-prcmu.c: In function 'prcmu_config_clkout':
drivers/mfd/db8500-prcmu.c:762:10: warning: 'div_mask' may be used uninitialized in this function
drivers/mfd/db8500-prcmu.c:769:13: warning: 'mask' may be used uninitialized in this function
drivers/mfd/db8500-prcmu.c:757:7: warning: 'bits' may be used uninitialized in this function
drivers/tty/serial/8250/8250_core.c: In function 'univ8250_release_irq':
drivers/tty/serial/8250/8250_core.c:252:18: warning: 'i' may be used uninitialized in this function
drivers/tty/serial/8250/8250_core.c:235:19: note: 'i' was declared here
There is an obvious conflict of interest here: on the one hand, someone
who disables CONFIG_BUG() will want the kernel to be as small as possible
and doesn't care about printing error messages to a console that nobody
looks at. On the other hand, running into a BUG_ON() condition means that
something has gone wrong, and we probably want to also stop doing things
that might cause data corruption.
This patch picks the second choice, and changes the NOP to BUG(), which
normally stops the execution of the current thread in some form (endless
loop or a trap). This follows the logic we applied in a4b5d580e078 ("bug:
Make BUG() always stop the machine").
For ARM multi_v7_defconfig, the size slightly increases:
section CONFIG_BUG=y CONFIG_BUG=n CONFIG_BUG=n+patch
.text 8320248 | 8180944 | 8207688
.rodata 3633720 | 3567144 | 3570648
__bug_table 32508 | --- | ---
__modver 692 | 1584 | 2176
.init.text 558132 | 548300 | 550088
.exit.text 12380 | 12256 | 12380
.data 1016672 | 1016064 | 1016128
Total 14622556 | 14374510 | 14407326
So instead of saving 1.70% of the total image size, we only save 1.48%
by turning off CONFIG_BUG, but in return we can ensure that we don't run
into cases of uninitialized variable or return code uses when something
bad happens. Aside from that, we significantly reduce the number of
warnings in randconfig builds, which makes it easier to fix the warnings
about other problems.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2015-11-20 23:27:26 +00:00
|
|
|
#define BUG_ON(condition) do { if (condition) BUG(); } while (0)
|
2014-04-07 22:39:10 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef HAVE_ARCH_WARN_ON
|
|
|
|
#define WARN_ON(condition) ({ \
|
|
|
|
int __ret_warn_on = !!(condition); \
|
|
|
|
unlikely(__ret_warn_on); \
|
|
|
|
})
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef WARN
|
|
|
|
#define WARN(condition, format...) ({ \
|
|
|
|
int __ret_warn_on = !!(condition); \
|
2014-04-07 22:39:12 +00:00
|
|
|
no_printk(format); \
|
2014-04-07 22:39:10 +00:00
|
|
|
unlikely(__ret_warn_on); \
|
|
|
|
})
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define WARN_ON_ONCE(condition) WARN_ON(condition)
|
|
|
|
#define WARN_ONCE(condition, format...) WARN(condition, format)
|
|
|
|
#define WARN_TAINT(condition, taint, format...) WARN(condition, format)
|
|
|
|
#define WARN_TAINT_ONCE(condition, taint, format...) WARN(condition, format)
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
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
|