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 15:07:57 +01:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2008-05-22 14:31:07 -04:00
|
|
|
#ifndef _ASM_POWERPC_FTRACE
|
|
|
|
#define _ASM_POWERPC_FTRACE
|
|
|
|
|
2016-06-06 22:26:10 +05:30
|
|
|
#include <asm/types.h>
|
|
|
|
|
2008-10-06 19:06:12 -04:00
|
|
|
#ifdef CONFIG_FUNCTION_TRACER
|
2015-07-12 17:52:24 +08:00
|
|
|
#define MCOUNT_ADDR ((unsigned long)(_mcount))
|
2008-06-21 23:47:27 +05:30
|
|
|
#define MCOUNT_INSN_SIZE 4 /* sizeof mcount call */
|
|
|
|
|
2019-09-05 23:50:29 +05:30
|
|
|
#define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
|
|
|
|
|
2022-08-09 16:24:25 +05:30
|
|
|
/* Ignore unused weak functions which will have larger offsets */
|
2023-06-19 15:17:34 +05:30
|
|
|
#if defined(CONFIG_MPROFILE_KERNEL) || defined(CONFIG_ARCH_USING_PATCHABLE_FUNCTION_ENTRY)
|
2023-06-19 15:17:19 +05:30
|
|
|
#define FTRACE_MCOUNT_MAX_OFFSET 16
|
2022-08-09 16:24:25 +05:30
|
|
|
#elif defined(CONFIG_PPC32)
|
|
|
|
#define FTRACE_MCOUNT_MAX_OFFSET 8
|
|
|
|
#endif
|
|
|
|
|
2021-12-20 16:38:22 +00:00
|
|
|
#ifndef __ASSEMBLY__
|
2008-05-22 14:31:07 -04:00
|
|
|
extern void _mcount(void);
|
2008-11-14 16:21:19 -08:00
|
|
|
|
2022-03-04 18:04:05 +01:00
|
|
|
unsigned long prepare_ftrace_return(unsigned long parent, unsigned long ip,
|
|
|
|
unsigned long sp);
|
|
|
|
|
2023-06-19 15:17:28 +05:30
|
|
|
struct module;
|
|
|
|
struct dyn_ftrace;
|
2008-11-14 16:21:19 -08:00
|
|
|
struct dyn_arch_ftrace {
|
2008-11-14 20:47:03 -08:00
|
|
|
struct module *mod;
|
2008-11-14 16:21:19 -08:00
|
|
|
};
|
2021-12-20 16:38:28 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_DYNAMIC_FTRACE_WITH_ARGS
|
2023-06-19 15:17:28 +05:30
|
|
|
#define ftrace_need_init_nop() (true)
|
|
|
|
int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec);
|
|
|
|
#define ftrace_init_nop ftrace_init_nop
|
|
|
|
|
2021-12-20 16:38:28 +00:00
|
|
|
struct ftrace_regs {
|
|
|
|
struct pt_regs regs;
|
|
|
|
};
|
|
|
|
|
|
|
|
static __always_inline struct pt_regs *arch_ftrace_get_regs(struct ftrace_regs *fregs)
|
|
|
|
{
|
2022-02-15 19:31:24 +01:00
|
|
|
/* We clear regs.msr in ftrace_call */
|
|
|
|
return fregs->regs.msr ? &fregs->regs : NULL;
|
2021-12-20 16:38:28 +00:00
|
|
|
}
|
|
|
|
|
2022-11-03 17:05:18 +00:00
|
|
|
static __always_inline void
|
|
|
|
ftrace_regs_set_instruction_pointer(struct ftrace_regs *fregs,
|
|
|
|
unsigned long ip)
|
2021-12-20 16:38:28 +00:00
|
|
|
{
|
|
|
|
regs_set_return_ip(&fregs->regs, ip);
|
|
|
|
}
|
2021-12-20 16:38:35 +00:00
|
|
|
|
2022-11-03 17:05:19 +00:00
|
|
|
static __always_inline unsigned long
|
|
|
|
ftrace_regs_get_instruction_pointer(struct ftrace_regs *fregs)
|
|
|
|
{
|
|
|
|
return instruction_pointer(&fregs->regs);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define ftrace_regs_get_argument(fregs, n) \
|
|
|
|
regs_get_kernel_argument(&(fregs)->regs, n)
|
|
|
|
#define ftrace_regs_get_stack_pointer(fregs) \
|
|
|
|
kernel_stack_pointer(&(fregs)->regs)
|
|
|
|
#define ftrace_regs_return_value(fregs) \
|
|
|
|
regs_return_value(&(fregs)->regs)
|
|
|
|
#define ftrace_regs_set_return_value(fregs, ret) \
|
|
|
|
regs_set_return_value(&(fregs)->regs, ret)
|
|
|
|
#define ftrace_override_function_with_return(fregs) \
|
|
|
|
override_function_with_return(&(fregs)->regs)
|
|
|
|
#define ftrace_regs_query_register_offset(name) \
|
|
|
|
regs_query_register_offset(name)
|
|
|
|
|
2021-12-20 16:38:35 +00:00
|
|
|
struct ftrace_ops;
|
|
|
|
|
|
|
|
#define ftrace_graph_func ftrace_graph_func
|
|
|
|
void ftrace_graph_func(unsigned long ip, unsigned long parent_ip,
|
|
|
|
struct ftrace_ops *op, struct ftrace_regs *fregs);
|
2021-12-20 16:38:28 +00:00
|
|
|
#endif
|
2008-11-14 16:21:19 -08:00
|
|
|
#endif /* __ASSEMBLY__ */
|
2008-05-22 14:31:07 -04:00
|
|
|
|
2016-03-03 15:26:59 +11:00
|
|
|
#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
|
|
|
|
#define ARCH_SUPPORTS_FTRACE_OPS 1
|
|
|
|
#endif
|
2018-03-27 15:29:06 +11:00
|
|
|
#endif /* CONFIG_FUNCTION_TRACER */
|
2008-06-21 23:47:27 +05:30
|
|
|
|
2018-04-19 12:34:01 +05:30
|
|
|
#ifndef __ASSEMBLY__
|
2018-06-03 20:32:02 +10:00
|
|
|
#ifdef CONFIG_FTRACE_SYSCALLS
|
2018-05-04 18:44:25 +05:30
|
|
|
/*
|
|
|
|
* Some syscall entry functions on powerpc start with "ppc_" (fork and clone,
|
|
|
|
* for instance) or ppc32_/ppc64_. We should also match the sys_ variant with
|
|
|
|
* those.
|
|
|
|
*/
|
2011-02-02 17:27:24 +00:00
|
|
|
#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
|
2018-05-04 18:44:25 +05:30
|
|
|
static inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
|
|
|
|
{
|
|
|
|
return !strcmp(sym, name) ||
|
|
|
|
(!strncmp(sym, "__se_sys", 8) && !strcmp(sym + 5, name)) ||
|
|
|
|
(!strncmp(sym, "ppc_", 4) && !strcmp(sym + 4, name + 4)) ||
|
|
|
|
(!strncmp(sym, "ppc32_", 6) && !strcmp(sym + 6, name + 4)) ||
|
|
|
|
(!strncmp(sym, "ppc64_", 6) && !strcmp(sym + 6, name + 4));
|
2011-02-02 17:27:24 +00:00
|
|
|
}
|
2018-06-03 20:32:02 +10:00
|
|
|
#endif /* CONFIG_FTRACE_SYSCALLS */
|
2018-04-19 12:34:02 +05:30
|
|
|
|
2022-05-16 12:44:22 +05:30
|
|
|
#if defined(CONFIG_PPC64) && defined(CONFIG_FUNCTION_TRACER)
|
2018-04-19 12:34:02 +05:30
|
|
|
#include <asm/paca.h>
|
|
|
|
|
|
|
|
static inline void this_cpu_disable_ftrace(void)
|
|
|
|
{
|
|
|
|
get_paca()->ftrace_enabled = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void this_cpu_enable_ftrace(void)
|
|
|
|
{
|
|
|
|
get_paca()->ftrace_enabled = 1;
|
|
|
|
}
|
2020-05-08 14:34:04 +10:00
|
|
|
|
|
|
|
/* Disable ftrace on this CPU if possible (may not be implemented) */
|
|
|
|
static inline void this_cpu_set_ftrace_enabled(u8 ftrace_enabled)
|
|
|
|
{
|
|
|
|
get_paca()->ftrace_enabled = ftrace_enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline u8 this_cpu_get_ftrace_enabled(void)
|
|
|
|
{
|
|
|
|
return get_paca()->ftrace_enabled;
|
|
|
|
}
|
2018-04-19 12:34:02 +05:30
|
|
|
#else /* CONFIG_PPC64 */
|
|
|
|
static inline void this_cpu_disable_ftrace(void) { }
|
|
|
|
static inline void this_cpu_enable_ftrace(void) { }
|
2020-05-08 14:34:04 +10:00
|
|
|
static inline void this_cpu_set_ftrace_enabled(u8 ftrace_enabled) { }
|
|
|
|
static inline u8 this_cpu_get_ftrace_enabled(void) { return 1; }
|
2018-04-19 12:34:02 +05:30
|
|
|
#endif /* CONFIG_PPC64 */
|
2023-06-19 15:17:24 +05:30
|
|
|
|
|
|
|
#ifdef CONFIG_FUNCTION_TRACER
|
|
|
|
extern unsigned int ftrace_tramp_text[], ftrace_tramp_init[];
|
|
|
|
void ftrace_free_init_tramp(void);
|
powerpc/ftrace: Ignore ftrace locations in exit text sections
Michael reported that we are seeing an ftrace bug on bootup when KASAN
is enabled and we are using -fpatchable-function-entry:
ftrace: allocating 47780 entries in 18 pages
ftrace-powerpc: 0xc0000000020b3d5c: No module provided for non-kernel address
------------[ ftrace bug ]------------
ftrace faulted on modifying
[<c0000000020b3d5c>] 0xc0000000020b3d5c
Initializing ftrace call sites
ftrace record flags: 0
(0)
expected tramp: c00000000008cef4
------------[ cut here ]------------
WARNING: CPU: 0 PID: 0 at kernel/trace/ftrace.c:2180 ftrace_bug+0x3c0/0x424
Modules linked in:
CPU: 0 PID: 0 Comm: swapper Not tainted 6.5.0-rc3-00120-g0f71dcfb4aef #860
Hardware name: IBM pSeries (emulated by qemu) POWER9 (raw) 0x4e1202 0xf000005 of:SLOF,HEAD hv:linux,kvm pSeries
NIP: c0000000003aa81c LR: c0000000003aa818 CTR: 0000000000000000
REGS: c0000000033cfab0 TRAP: 0700 Not tainted (6.5.0-rc3-00120-g0f71dcfb4aef)
MSR: 8000000002021033 <SF,VEC,ME,IR,DR,RI,LE> CR: 28028240 XER: 00000000
CFAR: c0000000002781a8 IRQMASK: 3
...
NIP [c0000000003aa81c] ftrace_bug+0x3c0/0x424
LR [c0000000003aa818] ftrace_bug+0x3bc/0x424
Call Trace:
ftrace_bug+0x3bc/0x424 (unreliable)
ftrace_process_locs+0x5f4/0x8a0
ftrace_init+0xc0/0x1d0
start_kernel+0x1d8/0x484
With CONFIG_FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY=y and
CONFIG_KASAN=y, compiler emits nops in functions that it generates for
registering and unregistering global variables (unlike with -pg and
-mprofile-kernel where calls to _mcount() are not generated in those
functions). Those functions then end up in INIT_TEXT and EXIT_TEXT
respectively. We don't expect to see any profiled functions in
EXIT_TEXT, so ftrace_init_nop() assumes that all addresses that aren't
in the core kernel text belongs to a module. Since these functions do
not match that criteria, we see the above bug.
Address this by having ftrace ignore all locations in the text exit
sections of vmlinux.
Fixes: 0f71dcfb4aef ("powerpc/ftrace: Add support for -fpatchable-function-entry")
Cc: stable@vger.kernel.org # v6.6+
Reported-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Naveen N Rao <naveen@kernel.org>
Reviewed-by: Benjamin Gray <bgray@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20240213175410.1091313-1-naveen@kernel.org
2024-02-13 23:24:10 +05:30
|
|
|
unsigned long ftrace_call_adjust(unsigned long addr);
|
2023-06-19 15:17:24 +05:30
|
|
|
#else
|
|
|
|
static inline void ftrace_free_init_tramp(void) { }
|
powerpc/ftrace: Ignore ftrace locations in exit text sections
Michael reported that we are seeing an ftrace bug on bootup when KASAN
is enabled and we are using -fpatchable-function-entry:
ftrace: allocating 47780 entries in 18 pages
ftrace-powerpc: 0xc0000000020b3d5c: No module provided for non-kernel address
------------[ ftrace bug ]------------
ftrace faulted on modifying
[<c0000000020b3d5c>] 0xc0000000020b3d5c
Initializing ftrace call sites
ftrace record flags: 0
(0)
expected tramp: c00000000008cef4
------------[ cut here ]------------
WARNING: CPU: 0 PID: 0 at kernel/trace/ftrace.c:2180 ftrace_bug+0x3c0/0x424
Modules linked in:
CPU: 0 PID: 0 Comm: swapper Not tainted 6.5.0-rc3-00120-g0f71dcfb4aef #860
Hardware name: IBM pSeries (emulated by qemu) POWER9 (raw) 0x4e1202 0xf000005 of:SLOF,HEAD hv:linux,kvm pSeries
NIP: c0000000003aa81c LR: c0000000003aa818 CTR: 0000000000000000
REGS: c0000000033cfab0 TRAP: 0700 Not tainted (6.5.0-rc3-00120-g0f71dcfb4aef)
MSR: 8000000002021033 <SF,VEC,ME,IR,DR,RI,LE> CR: 28028240 XER: 00000000
CFAR: c0000000002781a8 IRQMASK: 3
...
NIP [c0000000003aa81c] ftrace_bug+0x3c0/0x424
LR [c0000000003aa818] ftrace_bug+0x3bc/0x424
Call Trace:
ftrace_bug+0x3bc/0x424 (unreliable)
ftrace_process_locs+0x5f4/0x8a0
ftrace_init+0xc0/0x1d0
start_kernel+0x1d8/0x484
With CONFIG_FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY=y and
CONFIG_KASAN=y, compiler emits nops in functions that it generates for
registering and unregistering global variables (unlike with -pg and
-mprofile-kernel where calls to _mcount() are not generated in those
functions). Those functions then end up in INIT_TEXT and EXIT_TEXT
respectively. We don't expect to see any profiled functions in
EXIT_TEXT, so ftrace_init_nop() assumes that all addresses that aren't
in the core kernel text belongs to a module. Since these functions do
not match that criteria, we see the above bug.
Address this by having ftrace ignore all locations in the text exit
sections of vmlinux.
Fixes: 0f71dcfb4aef ("powerpc/ftrace: Add support for -fpatchable-function-entry")
Cc: stable@vger.kernel.org # v6.6+
Reported-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Naveen N Rao <naveen@kernel.org>
Reviewed-by: Benjamin Gray <bgray@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20240213175410.1091313-1-naveen@kernel.org
2024-02-13 23:24:10 +05:30
|
|
|
static inline unsigned long ftrace_call_adjust(unsigned long addr) { return addr; }
|
2023-06-19 15:17:24 +05:30
|
|
|
#endif
|
2018-04-19 12:34:01 +05:30
|
|
|
#endif /* !__ASSEMBLY__ */
|
2011-02-02 17:27:24 +00:00
|
|
|
|
2008-06-21 23:47:27 +05:30
|
|
|
#endif /* _ASM_POWERPC_FTRACE */
|