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
|
2008-12-25 12:39:50 +00:00
|
|
|
/*
|
|
|
|
* Copyright IBM Corp. 2008
|
|
|
|
* Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define KMSG_COMPONENT "cpu"
|
|
|
|
#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
|
|
|
|
|
2019-06-08 10:13:57 +00:00
|
|
|
#include <linux/stop_machine.h>
|
2016-05-07 10:15:34 +00:00
|
|
|
#include <linux/cpufeature.h>
|
2017-02-25 11:16:48 +00:00
|
|
|
#include <linux/bitops.h>
|
2008-12-25 12:39:50 +00:00
|
|
|
#include <linux/kernel.h>
|
2017-02-01 18:08:20 +00:00
|
|
|
#include <linux/sched/mm.h>
|
2008-12-25 12:39:50 +00:00
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/seq_file.h>
|
2017-02-03 23:16:44 +00:00
|
|
|
#include <linux/mm_types.h>
|
2008-12-25 12:39:50 +00:00
|
|
|
#include <linux/delay.h>
|
2011-01-05 11:48:17 +00:00
|
|
|
#include <linux/cpu.h>
|
2017-02-01 18:08:20 +00:00
|
|
|
|
2015-08-20 15:28:44 +00:00
|
|
|
#include <asm/diag.h>
|
2016-04-14 10:35:22 +00:00
|
|
|
#include <asm/facility.h>
|
2008-12-25 12:39:50 +00:00
|
|
|
#include <asm/elf.h>
|
|
|
|
#include <asm/lowcore.h>
|
|
|
|
#include <asm/param.h>
|
2015-01-28 06:43:56 +00:00
|
|
|
#include <asm/smp.h>
|
2008-12-25 12:39:50 +00:00
|
|
|
|
2016-04-14 10:35:22 +00:00
|
|
|
struct cpu_info {
|
|
|
|
unsigned int cpu_mhz_dynamic;
|
|
|
|
unsigned int cpu_mhz_static;
|
|
|
|
struct cpuid cpu_id;
|
|
|
|
};
|
|
|
|
|
|
|
|
static DEFINE_PER_CPU(struct cpu_info, cpu_info);
|
2019-05-17 10:50:42 +00:00
|
|
|
static DEFINE_PER_CPU(int, cpu_relax_retry);
|
2016-04-14 10:35:22 +00:00
|
|
|
|
|
|
|
static bool machine_has_cpu_mhz;
|
|
|
|
|
|
|
|
void __init cpu_detect_mhz_feature(void)
|
|
|
|
{
|
|
|
|
if (test_facility(34) && __ecag(ECAG_CPU_ATTRIBUTE, 0) != -1UL)
|
2017-01-02 08:59:40 +00:00
|
|
|
machine_has_cpu_mhz = true;
|
2016-04-14 10:35:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void update_cpu_mhz(void *arg)
|
|
|
|
{
|
|
|
|
unsigned long mhz;
|
|
|
|
struct cpu_info *c;
|
|
|
|
|
|
|
|
mhz = __ecag(ECAG_CPU_ATTRIBUTE, 0);
|
|
|
|
c = this_cpu_ptr(&cpu_info);
|
|
|
|
c->cpu_mhz_dynamic = mhz >> 32;
|
|
|
|
c->cpu_mhz_static = mhz & 0xffffffff;
|
|
|
|
}
|
|
|
|
|
|
|
|
void s390_update_cpu_mhz(void)
|
|
|
|
{
|
|
|
|
s390_adjust_jiffies();
|
|
|
|
if (machine_has_cpu_mhz)
|
|
|
|
on_each_cpu(update_cpu_mhz, NULL, 0);
|
|
|
|
}
|
2010-05-17 08:00:00 +00:00
|
|
|
|
2019-06-08 10:13:57 +00:00
|
|
|
void notrace stop_machine_yield(const struct cpumask *cpumask)
|
2015-01-28 06:43:56 +00:00
|
|
|
{
|
2019-05-17 10:50:42 +00:00
|
|
|
int cpu, this_cpu;
|
|
|
|
|
|
|
|
this_cpu = smp_processor_id();
|
|
|
|
if (__this_cpu_inc_return(cpu_relax_retry) >= spin_retry) {
|
|
|
|
__this_cpu_write(cpu_relax_retry, 0);
|
|
|
|
cpu = cpumask_next_wrap(this_cpu, cpumask, this_cpu, false);
|
|
|
|
if (cpu >= nr_cpu_ids)
|
|
|
|
return;
|
|
|
|
if (arch_vcpu_is_preempted(cpu))
|
|
|
|
smp_yield_cpu(cpu);
|
2015-08-20 15:28:44 +00:00
|
|
|
}
|
2015-01-28 06:43:56 +00:00
|
|
|
}
|
|
|
|
|
2010-05-17 08:00:00 +00:00
|
|
|
/*
|
|
|
|
* cpu_init - initializes state that is per-CPU.
|
|
|
|
*/
|
2013-06-18 21:04:52 +00:00
|
|
|
void cpu_init(void)
|
2010-05-17 08:00:00 +00:00
|
|
|
{
|
2016-04-14 10:35:22 +00:00
|
|
|
struct cpuid *id = this_cpu_ptr(&cpu_info.cpu_id);
|
2010-05-17 08:00:00 +00:00
|
|
|
|
|
|
|
get_cpu_id(id);
|
2016-04-14 10:35:22 +00:00
|
|
|
if (machine_has_cpu_mhz)
|
|
|
|
update_cpu_mhz(NULL);
|
2017-02-27 22:30:07 +00:00
|
|
|
mmgrab(&init_mm);
|
2010-05-17 08:00:00 +00:00
|
|
|
current->active_mm = &init_mm;
|
|
|
|
BUG_ON(current->mm);
|
|
|
|
enter_lazy_tlb(&init_mm, current);
|
|
|
|
}
|
|
|
|
|
2015-02-19 11:22:02 +00:00
|
|
|
/*
|
|
|
|
* cpu_have_feature - Test CPU features on module initialization
|
|
|
|
*/
|
|
|
|
int cpu_have_feature(unsigned int num)
|
|
|
|
{
|
|
|
|
return elf_hwcap & (1UL << num);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(cpu_have_feature);
|
|
|
|
|
2017-02-25 11:16:48 +00:00
|
|
|
static void show_facilities(struct seq_file *m)
|
|
|
|
{
|
|
|
|
unsigned int bit;
|
|
|
|
long *facilities;
|
|
|
|
|
|
|
|
facilities = (long *)&S390_lowcore.stfle_fac_list;
|
|
|
|
seq_puts(m, "facilities :");
|
|
|
|
for_each_set_bit_inv(bit, facilities, MAX_FACILITY_BIT)
|
|
|
|
seq_printf(m, " %d", bit);
|
|
|
|
seq_putc(m, '\n');
|
|
|
|
}
|
|
|
|
|
2016-04-14 06:57:19 +00:00
|
|
|
static void show_cpu_summary(struct seq_file *m, void *v)
|
2008-12-25 12:39:50 +00:00
|
|
|
{
|
2012-08-29 12:54:38 +00:00
|
|
|
static const char *hwcap_str[] = {
|
2008-12-25 12:39:50 +00:00
|
|
|
"esan3", "zarch", "stfle", "msa", "ldisp", "eimm", "dfp",
|
2019-02-05 15:15:01 +00:00
|
|
|
"edat", "etf3eh", "highgprs", "te", "vx", "vxd", "vxe", "gs",
|
|
|
|
"vxe2", "vxp", "sort", "dflt"
|
2008-12-25 12:39:50 +00:00
|
|
|
};
|
2015-02-24 14:54:47 +00:00
|
|
|
static const char * const int_hwcap_str[] = {
|
|
|
|
"sie"
|
|
|
|
};
|
2016-04-14 06:57:19 +00:00
|
|
|
int i, cpu;
|
|
|
|
|
|
|
|
seq_printf(m, "vendor_id : IBM/S390\n"
|
|
|
|
"# processors : %i\n"
|
|
|
|
"bogomips per cpu: %lu.%02lu\n",
|
|
|
|
num_online_cpus(), loops_per_jiffy/(500000/HZ),
|
|
|
|
(loops_per_jiffy/(5000/HZ))%100);
|
2016-06-27 11:19:22 +00:00
|
|
|
seq_printf(m, "max thread id : %d\n", smp_cpu_mtid);
|
2016-04-14 06:57:19 +00:00
|
|
|
seq_puts(m, "features\t: ");
|
|
|
|
for (i = 0; i < ARRAY_SIZE(hwcap_str); i++)
|
|
|
|
if (hwcap_str[i] && (elf_hwcap & (1UL << i)))
|
|
|
|
seq_printf(m, "%s ", hwcap_str[i]);
|
|
|
|
for (i = 0; i < ARRAY_SIZE(int_hwcap_str); i++)
|
|
|
|
if (int_hwcap_str[i] && (int_hwcap & (1UL << i)))
|
|
|
|
seq_printf(m, "%s ", int_hwcap_str[i]);
|
|
|
|
seq_puts(m, "\n");
|
2017-02-25 11:16:48 +00:00
|
|
|
show_facilities(m);
|
2016-04-14 06:57:19 +00:00
|
|
|
show_cacheinfo(m);
|
|
|
|
for_each_online_cpu(cpu) {
|
2016-04-14 10:35:22 +00:00
|
|
|
struct cpuid *id = &per_cpu(cpu_info.cpu_id, cpu);
|
2016-04-14 06:57:19 +00:00
|
|
|
|
|
|
|
seq_printf(m, "processor %d: "
|
2009-03-26 14:24:42 +00:00
|
|
|
"version = %02X, "
|
|
|
|
"identification = %06X, "
|
|
|
|
"machine = %04X\n",
|
2016-04-14 06:57:19 +00:00
|
|
|
cpu, id->version, id->ident, id->machine);
|
2009-03-26 14:24:42 +00:00
|
|
|
}
|
2016-04-14 06:57:19 +00:00
|
|
|
}
|
|
|
|
|
2020-01-29 11:15:15 +00:00
|
|
|
static void show_cpu_topology(struct seq_file *m, unsigned long n)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_SCHED_TOPOLOGY
|
|
|
|
seq_printf(m, "physical id : %d\n", topology_physical_package_id(n));
|
|
|
|
seq_printf(m, "core id : %d\n", topology_core_id(n));
|
|
|
|
seq_printf(m, "book id : %d\n", topology_book_id(n));
|
|
|
|
seq_printf(m, "drawer id : %d\n", topology_drawer_id(n));
|
|
|
|
seq_printf(m, "dedicated : %d\n", topology_cpu_dedicated(n));
|
2020-03-11 13:18:05 +00:00
|
|
|
seq_printf(m, "address : %d\n", smp_cpu_get_cpu_address(n));
|
2020-03-13 15:55:10 +00:00
|
|
|
seq_printf(m, "siblings : %d\n", cpumask_weight(topology_core_cpumask(n)));
|
2020-03-13 15:52:44 +00:00
|
|
|
seq_printf(m, "cpu cores : %d\n", topology_booted_cores(n));
|
2020-01-29 11:15:15 +00:00
|
|
|
#endif /* CONFIG_SCHED_TOPOLOGY */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void show_cpu_ids(struct seq_file *m, unsigned long n)
|
|
|
|
{
|
|
|
|
struct cpuid *id = &per_cpu(cpu_info.cpu_id, n);
|
|
|
|
|
|
|
|
seq_printf(m, "version : %02X\n", id->version);
|
|
|
|
seq_printf(m, "identification : %06X\n", id->ident);
|
|
|
|
seq_printf(m, "machine : %04X\n", id->machine);
|
|
|
|
}
|
|
|
|
|
2016-04-14 10:35:22 +00:00
|
|
|
static void show_cpu_mhz(struct seq_file *m, unsigned long n)
|
|
|
|
{
|
|
|
|
struct cpu_info *c = per_cpu_ptr(&cpu_info, n);
|
|
|
|
|
|
|
|
seq_printf(m, "cpu MHz dynamic : %d\n", c->cpu_mhz_dynamic);
|
|
|
|
seq_printf(m, "cpu MHz static : %d\n", c->cpu_mhz_static);
|
|
|
|
}
|
|
|
|
|
2016-04-14 06:57:19 +00:00
|
|
|
/*
|
|
|
|
* show_cpuinfo - Get information on one CPU for use by procfs.
|
|
|
|
*/
|
|
|
|
static int show_cpuinfo(struct seq_file *m, void *v)
|
|
|
|
{
|
|
|
|
unsigned long n = (unsigned long) v - 1;
|
2020-03-16 11:39:55 +00:00
|
|
|
unsigned long first = cpumask_first(cpu_online_mask);
|
2016-04-14 06:57:19 +00:00
|
|
|
|
2020-03-16 11:39:55 +00:00
|
|
|
if (n == first)
|
2016-04-14 06:57:19 +00:00
|
|
|
show_cpu_summary(m, v);
|
2016-04-14 10:35:22 +00:00
|
|
|
if (!machine_has_cpu_mhz)
|
|
|
|
return 0;
|
2016-06-21 09:05:05 +00:00
|
|
|
seq_printf(m, "\ncpu number : %ld\n", n);
|
2020-01-29 11:15:15 +00:00
|
|
|
show_cpu_topology(m, n);
|
|
|
|
show_cpu_ids(m, n);
|
2016-04-14 10:35:22 +00:00
|
|
|
show_cpu_mhz(m, n);
|
2009-03-26 14:24:42 +00:00
|
|
|
return 0;
|
2008-12-25 12:39:50 +00:00
|
|
|
}
|
|
|
|
|
2016-04-13 12:49:12 +00:00
|
|
|
static inline void *c_update(loff_t *pos)
|
|
|
|
{
|
|
|
|
if (*pos)
|
|
|
|
*pos = cpumask_next(*pos - 1, cpu_online_mask);
|
2020-03-16 11:39:55 +00:00
|
|
|
else
|
|
|
|
*pos = cpumask_first(cpu_online_mask);
|
2016-04-13 12:49:12 +00:00
|
|
|
return *pos < nr_cpu_ids ? (void *)*pos + 1 : NULL;
|
|
|
|
}
|
|
|
|
|
2008-12-25 12:39:50 +00:00
|
|
|
static void *c_start(struct seq_file *m, loff_t *pos)
|
|
|
|
{
|
2016-04-13 12:49:12 +00:00
|
|
|
get_online_cpus();
|
|
|
|
return c_update(pos);
|
2008-12-25 12:39:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void *c_next(struct seq_file *m, void *v, loff_t *pos)
|
|
|
|
{
|
|
|
|
++*pos;
|
2016-04-13 12:49:12 +00:00
|
|
|
return c_update(pos);
|
2008-12-25 12:39:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void c_stop(struct seq_file *m, void *v)
|
|
|
|
{
|
2016-04-13 12:49:12 +00:00
|
|
|
put_online_cpus();
|
2008-12-25 12:39:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const struct seq_operations cpuinfo_op = {
|
|
|
|
.start = c_start,
|
|
|
|
.next = c_next,
|
|
|
|
.stop = c_stop,
|
|
|
|
.show = show_cpuinfo,
|
|
|
|
};
|
2018-01-16 06:36:46 +00:00
|
|
|
|
|
|
|
int s390_isolate_bp(void)
|
|
|
|
{
|
|
|
|
if (!test_facility(82))
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
set_thread_flag(TIF_ISOLATE_BP);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(s390_isolate_bp);
|
|
|
|
|
|
|
|
int s390_isolate_bp_guest(void)
|
|
|
|
{
|
|
|
|
if (!test_facility(82))
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
set_thread_flag(TIF_ISOLATE_BP_GUEST);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(s390_isolate_bp_guest);
|