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-06-25 21:58:11 +00:00
|
|
|
/*
|
2012-07-20 09:15:04 +00:00
|
|
|
* Copyright IBM Corp. 2005, 2011
|
2005-06-25 21:58:11 +00:00
|
|
|
*
|
2006-12-04 14:40:33 +00:00
|
|
|
* Author(s): Rolf Adelsberger,
|
2011-10-30 14:16:40 +00:00
|
|
|
* Michael Holzheu <holzheu@linux.vnet.ibm.com>
|
2005-06-25 21:58:11 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/kexec.h>
|
|
|
|
#include <linux/delay.h>
|
2007-02-05 20:16:47 +00:00
|
|
|
#include <linux/reboot.h>
|
2011-03-15 16:08:33 +00:00
|
|
|
#include <linux/ftrace.h>
|
2012-03-11 15:59:32 +00:00
|
|
|
#include <linux/debug_locks.h>
|
2024-02-05 20:32:13 +00:00
|
|
|
#include <asm/guarded_storage.h>
|
2023-07-24 15:20:26 +00:00
|
|
|
#include <asm/pfault.h>
|
2006-02-12 01:56:01 +00:00
|
|
|
#include <asm/cio.h>
|
2024-02-03 10:45:02 +00:00
|
|
|
#include <asm/fpu.h>
|
2006-02-12 01:56:01 +00:00
|
|
|
#include <asm/setup.h>
|
|
|
|
#include <asm/smp.h>
|
2007-03-05 22:35:45 +00:00
|
|
|
#include <asm/ipl.h>
|
2011-10-30 14:16:40 +00:00
|
|
|
#include <asm/diag.h>
|
2012-09-14 12:11:32 +00:00
|
|
|
#include <asm/elf.h>
|
2011-10-30 14:16:40 +00:00
|
|
|
#include <asm/asm-offsets.h>
|
2016-05-31 07:14:00 +00:00
|
|
|
#include <asm/cacheflush.h>
|
2022-07-20 06:22:01 +00:00
|
|
|
#include <asm/abs_lowcore.h>
|
2012-05-18 13:10:05 +00:00
|
|
|
#include <asm/os_info.h>
|
2017-05-08 22:58:08 +00:00
|
|
|
#include <asm/set_memory.h>
|
2019-01-28 07:33:08 +00:00
|
|
|
#include <asm/stacktrace.h>
|
2016-01-26 13:10:34 +00:00
|
|
|
#include <asm/nmi.h>
|
2021-09-03 09:08:48 +00:00
|
|
|
#include <asm/sclp.h>
|
2005-06-25 21:58:11 +00:00
|
|
|
|
2023-04-03 06:44:38 +00:00
|
|
|
typedef void (*relocate_kernel_t)(unsigned long, unsigned long, unsigned long);
|
2023-04-03 06:44:39 +00:00
|
|
|
typedef int (*purgatory_t)(int);
|
2005-06-25 21:58:11 +00:00
|
|
|
|
2006-06-26 16:57:34 +00:00
|
|
|
extern const unsigned char relocate_kernel[];
|
|
|
|
extern const unsigned long long relocate_kernel_len;
|
2005-06-25 21:58:11 +00:00
|
|
|
|
2011-10-30 14:16:40 +00:00
|
|
|
#ifdef CONFIG_CRASH_DUMP
|
|
|
|
|
|
|
|
/*
|
2015-10-29 09:28:26 +00:00
|
|
|
* Reset the system, copy boot CPU registers to absolute zero,
|
|
|
|
* and jump to the kdump image
|
2011-10-30 14:16:40 +00:00
|
|
|
*/
|
2023-04-03 06:44:39 +00:00
|
|
|
static void __do_machine_kdump(void *data)
|
2011-10-30 14:16:40 +00:00
|
|
|
{
|
2023-04-03 06:44:39 +00:00
|
|
|
struct kimage *image = data;
|
|
|
|
purgatory_t purgatory;
|
2015-10-29 09:28:26 +00:00
|
|
|
unsigned long prefix;
|
|
|
|
|
2023-04-03 06:44:39 +00:00
|
|
|
purgatory = (purgatory_t)image->start;
|
|
|
|
|
2015-10-29 09:28:26 +00:00
|
|
|
/* store_status() saved the prefix register to lowcore */
|
2024-06-10 11:45:25 +00:00
|
|
|
prefix = (unsigned long)get_lowcore()->prefixreg_save_area;
|
2015-10-29 09:28:26 +00:00
|
|
|
|
|
|
|
/* Now do the reset */
|
|
|
|
s390_reset_system();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copy dump CPU store status info to absolute zero.
|
|
|
|
* This need to be done *after* s390_reset_system set the
|
|
|
|
* prefix register of this CPU to zero
|
|
|
|
*/
|
2022-04-06 12:06:27 +00:00
|
|
|
memcpy(absolute_pointer(__LC_FPREGS_SAVE_AREA),
|
2023-04-03 06:44:38 +00:00
|
|
|
phys_to_virt(prefix + __LC_FPREGS_SAVE_AREA), 512);
|
2011-10-30 14:16:40 +00:00
|
|
|
|
2023-04-03 06:44:39 +00:00
|
|
|
call_nodat(1, int, purgatory, int, 1);
|
2015-10-29 09:28:26 +00:00
|
|
|
|
2023-04-03 06:44:39 +00:00
|
|
|
/* Die if kdump returns */
|
2019-04-30 10:33:45 +00:00
|
|
|
disabled_wait();
|
2015-10-29 09:28:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Start kdump: create a LGR log entry, store status of all CPUs and
|
|
|
|
* branch to __do_machine_kdump.
|
|
|
|
*/
|
|
|
|
static noinline void __machine_kdump(void *image)
|
|
|
|
{
|
2016-01-26 13:10:34 +00:00
|
|
|
struct mcesa *mcesa;
|
2017-10-12 11:24:45 +00:00
|
|
|
union ctlreg2 cr2_old, cr2_new;
|
2015-10-29 09:28:26 +00:00
|
|
|
int this_cpu, cpu;
|
|
|
|
|
|
|
|
lgr_info_log();
|
|
|
|
/* Get status of the other CPUs */
|
|
|
|
this_cpu = smp_find_processor_id(stap());
|
|
|
|
for_each_online_cpu(cpu) {
|
|
|
|
if (cpu == this_cpu)
|
|
|
|
continue;
|
|
|
|
if (smp_store_status(cpu))
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
/* Store status of the boot CPU */
|
2024-06-10 11:45:25 +00:00
|
|
|
mcesa = __va(get_lowcore()->mcesad & MCESA_ORIGIN_MASK);
|
2023-12-01 14:42:19 +00:00
|
|
|
if (cpu_has_vx())
|
2016-01-26 13:10:34 +00:00
|
|
|
save_vx_regs((__vector128 *) mcesa->vector_save_area);
|
|
|
|
if (MACHINE_HAS_GS) {
|
2023-09-11 19:40:04 +00:00
|
|
|
local_ctl_store(2, &cr2_old.reg);
|
2017-10-12 11:24:45 +00:00
|
|
|
cr2_new = cr2_old;
|
|
|
|
cr2_new.gse = 1;
|
2023-09-11 19:40:04 +00:00
|
|
|
local_ctl_load(2, &cr2_new.reg);
|
2016-01-26 13:10:34 +00:00
|
|
|
save_gs_cb((struct gs_cb *) mcesa->guarded_storage_save_area);
|
2023-09-11 19:40:04 +00:00
|
|
|
local_ctl_load(2, &cr2_old.reg);
|
2016-01-26 13:10:34 +00:00
|
|
|
}
|
2015-10-29 09:28:26 +00:00
|
|
|
/*
|
|
|
|
* To create a good backchain for this CPU in the dump store_status
|
|
|
|
* is passed the address of a function. The address is saved into
|
|
|
|
* the PSW save area of the boot CPU and the function is invoked as
|
|
|
|
* a tail call of store_status. The backchain in the dump will look
|
|
|
|
* like this:
|
|
|
|
* restart_int_handler -> __machine_kexec -> __do_machine_kdump
|
|
|
|
* The call to store_status() will not return.
|
|
|
|
*/
|
|
|
|
store_status(__do_machine_kdump, image);
|
2011-10-30 14:16:40 +00:00
|
|
|
}
|
|
|
|
|
2019-06-10 15:22:38 +00:00
|
|
|
#endif /* CONFIG_CRASH_DUMP */
|
|
|
|
|
2011-10-30 14:16:40 +00:00
|
|
|
/*
|
|
|
|
* Check if kdump checksums are valid: We call purgatory with parameter "0"
|
|
|
|
*/
|
2017-10-17 10:28:08 +00:00
|
|
|
static bool kdump_csum_valid(struct kimage *image)
|
2011-10-30 14:16:40 +00:00
|
|
|
{
|
|
|
|
#ifdef CONFIG_CRASH_DUMP
|
2023-04-03 06:44:40 +00:00
|
|
|
purgatory_t purgatory = (purgatory_t)image->start;
|
2011-10-30 14:16:40 +00:00
|
|
|
int rc;
|
|
|
|
|
2023-04-03 06:44:40 +00:00
|
|
|
rc = call_nodat(1, int, purgatory, int, 0);
|
2017-10-17 10:28:08 +00:00
|
|
|
return rc == 0;
|
2011-10-30 14:16:40 +00:00
|
|
|
#else
|
2017-10-17 10:28:08 +00:00
|
|
|
return false;
|
2011-10-30 14:16:40 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-05-23 23:24:22 +00:00
|
|
|
#ifdef CONFIG_CRASH_DUMP
|
|
|
|
|
2016-05-31 07:13:59 +00:00
|
|
|
void crash_free_reserved_phys_range(unsigned long begin, unsigned long end)
|
|
|
|
{
|
|
|
|
unsigned long addr, size;
|
|
|
|
|
|
|
|
for (addr = begin; addr < end; addr += PAGE_SIZE)
|
|
|
|
free_reserved_page(pfn_to_page(addr >> PAGE_SHIFT));
|
|
|
|
size = begin - crashk_res.start;
|
|
|
|
if (size)
|
|
|
|
os_info_crashkernel_add(crashk_res.start, size);
|
|
|
|
else
|
|
|
|
os_info_crashkernel_add(0, 0);
|
|
|
|
}
|
|
|
|
|
2016-05-31 07:14:00 +00:00
|
|
|
static void crash_protect_pages(int protect)
|
2011-10-30 14:16:44 +00:00
|
|
|
{
|
2016-05-31 07:14:00 +00:00
|
|
|
unsigned long size;
|
2011-10-30 14:16:44 +00:00
|
|
|
|
2016-05-31 07:14:00 +00:00
|
|
|
if (!crashk_res.end)
|
|
|
|
return;
|
|
|
|
size = resource_size(&crashk_res);
|
|
|
|
if (protect)
|
|
|
|
set_memory_ro(crashk_res.start, size >> PAGE_SHIFT);
|
2016-05-31 07:13:59 +00:00
|
|
|
else
|
2016-05-31 07:14:00 +00:00
|
|
|
set_memory_rw(crashk_res.start, size >> PAGE_SHIFT);
|
2011-10-30 14:16:44 +00:00
|
|
|
}
|
|
|
|
|
2016-05-23 23:24:22 +00:00
|
|
|
void arch_kexec_protect_crashkres(void)
|
2011-10-30 14:16:44 +00:00
|
|
|
{
|
2016-05-31 07:14:00 +00:00
|
|
|
crash_protect_pages(1);
|
2011-10-30 14:16:44 +00:00
|
|
|
}
|
|
|
|
|
2016-05-23 23:24:22 +00:00
|
|
|
void arch_kexec_unprotect_crashkres(void)
|
2011-10-30 14:16:44 +00:00
|
|
|
{
|
2016-05-31 07:14:00 +00:00
|
|
|
crash_protect_pages(0);
|
2011-10-30 14:16:44 +00:00
|
|
|
}
|
|
|
|
|
2016-05-23 23:24:22 +00:00
|
|
|
#endif
|
|
|
|
|
2011-10-30 14:16:40 +00:00
|
|
|
/*
|
|
|
|
* Give back memory to hypervisor before new kdump is loaded
|
|
|
|
*/
|
|
|
|
static int machine_kexec_prepare_kdump(void)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_CRASH_DUMP
|
|
|
|
if (MACHINE_IS_VM)
|
|
|
|
diag10_range(PFN_DOWN(crashk_res.start),
|
|
|
|
PFN_DOWN(crashk_res.end - crashk_res.start + 1));
|
|
|
|
return 0;
|
|
|
|
#else
|
|
|
|
return -EINVAL;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2006-12-04 14:40:33 +00:00
|
|
|
int machine_kexec_prepare(struct kimage *image)
|
2005-06-25 21:58:11 +00:00
|
|
|
{
|
2006-12-04 14:40:33 +00:00
|
|
|
void *reboot_code_buffer;
|
2005-06-25 21:58:11 +00:00
|
|
|
|
2011-10-30 14:16:40 +00:00
|
|
|
if (image->type == KEXEC_TYPE_CRASH)
|
|
|
|
return machine_kexec_prepare_kdump();
|
|
|
|
|
2005-06-25 21:58:11 +00:00
|
|
|
/* We don't support anything but the default image type for now. */
|
|
|
|
if (image->type != KEXEC_TYPE_DEFAULT)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* Get the destination where the assembler code should be copied to.*/
|
2023-04-03 06:44:38 +00:00
|
|
|
reboot_code_buffer = page_to_virt(image->control_code_page);
|
2005-06-25 21:58:11 +00:00
|
|
|
|
|
|
|
/* Then copy it */
|
2006-12-04 14:40:33 +00:00
|
|
|
memcpy(reboot_code_buffer, relocate_kernel, relocate_kernel_len);
|
2005-06-25 21:58:11 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-12-04 14:40:33 +00:00
|
|
|
void machine_kexec_cleanup(struct kimage *image)
|
2005-06-25 21:58:11 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-12-04 14:40:33 +00:00
|
|
|
void machine_shutdown(void)
|
2005-06-25 21:58:11 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-27 13:50:29 +00:00
|
|
|
void machine_crash_shutdown(struct pt_regs *regs)
|
|
|
|
{
|
2018-04-04 12:42:41 +00:00
|
|
|
set_os_info_reipl_block();
|
2012-08-27 13:50:29 +00:00
|
|
|
}
|
|
|
|
|
2011-10-30 14:16:40 +00:00
|
|
|
/*
|
|
|
|
* Do normal kexec
|
|
|
|
*/
|
|
|
|
static void __do_machine_kexec(void *data)
|
2005-06-25 21:58:11 +00:00
|
|
|
{
|
2023-04-03 06:44:38 +00:00
|
|
|
unsigned long data_mover, entry, diag308_subcode;
|
2010-02-26 21:37:34 +00:00
|
|
|
struct kimage *image = data;
|
2005-06-25 21:58:11 +00:00
|
|
|
|
2023-04-03 06:44:38 +00:00
|
|
|
data_mover = page_to_phys(image->control_code_page);
|
|
|
|
entry = virt_to_phys(&image->head);
|
2021-09-03 09:08:48 +00:00
|
|
|
diag308_subcode = DIAG308_CLEAR_RESET;
|
|
|
|
if (sclp.has_iplcc)
|
|
|
|
diag308_subcode |= DIAG308_FLAG_EI;
|
2023-04-03 06:44:36 +00:00
|
|
|
s390_reset_system();
|
|
|
|
|
2023-04-03 06:44:39 +00:00
|
|
|
call_nodat(3, void, (relocate_kernel_t)data_mover,
|
|
|
|
unsigned long, entry,
|
|
|
|
unsigned long, image->start,
|
|
|
|
unsigned long, diag308_subcode);
|
2015-10-29 09:28:26 +00:00
|
|
|
|
|
|
|
/* Die if kexec returns */
|
2019-04-30 10:33:45 +00:00
|
|
|
disabled_wait();
|
2005-06-25 21:58:11 +00:00
|
|
|
}
|
2010-02-26 21:37:34 +00:00
|
|
|
|
2011-10-30 14:16:40 +00:00
|
|
|
/*
|
|
|
|
* Reset system and call either kdump or normal kexec
|
|
|
|
*/
|
|
|
|
static void __machine_kexec(void *data)
|
|
|
|
{
|
|
|
|
pfault_fini();
|
2012-03-11 15:59:32 +00:00
|
|
|
tracing_off();
|
|
|
|
debug_locks_off();
|
2015-01-14 16:52:10 +00:00
|
|
|
#ifdef CONFIG_CRASH_DUMP
|
2015-10-29 09:28:26 +00:00
|
|
|
if (((struct kimage *) data)->type == KEXEC_TYPE_CRASH)
|
|
|
|
__machine_kdump(data);
|
2015-01-14 16:52:10 +00:00
|
|
|
#endif
|
2015-10-29 09:28:26 +00:00
|
|
|
__do_machine_kexec(data);
|
2011-10-30 14:16:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Do either kdump or normal kexec. In case of kdump we first ask
|
|
|
|
* purgatory, if kdump checksums are valid.
|
|
|
|
*/
|
2010-02-26 21:37:34 +00:00
|
|
|
void machine_kexec(struct kimage *image)
|
|
|
|
{
|
2011-10-30 14:16:40 +00:00
|
|
|
if (image->type == KEXEC_TYPE_CRASH && !kdump_csum_valid(image))
|
|
|
|
return;
|
2011-03-15 16:08:33 +00:00
|
|
|
tracer_disable();
|
2010-02-26 21:37:34 +00:00
|
|
|
smp_send_stop();
|
2012-03-11 15:59:26 +00:00
|
|
|
smp_call_ipl_cpu(__machine_kexec, image);
|
2010-02-26 21:37:34 +00:00
|
|
|
}
|