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 21:07:57 +07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2008-07-24 03:28:58 +07:00
|
|
|
/*
|
|
|
|
* Split spinlock implementation out into its own file, so it can be
|
|
|
|
* compiled in a FTRACE-compatible way.
|
|
|
|
*/
|
2018-11-19 20:59:45 +07:00
|
|
|
#include <linux/kernel.h>
|
2008-07-24 03:28:58 +07:00
|
|
|
#include <linux/spinlock.h>
|
2013-06-05 21:44:47 +07:00
|
|
|
#include <linux/slab.h>
|
2018-11-08 14:35:06 +07:00
|
|
|
#include <linux/atomic.h>
|
2008-07-24 03:28:58 +07:00
|
|
|
|
|
|
|
#include <asm/paravirt.h>
|
2017-09-07 00:36:25 +07:00
|
|
|
#include <asm/qspinlock.h>
|
2008-07-24 03:28:58 +07:00
|
|
|
|
|
|
|
#include <xen/events.h>
|
|
|
|
|
|
|
|
#include "xen-ops.h"
|
2008-08-21 07:02:19 +07:00
|
|
|
|
2015-04-25 01:56:40 +07:00
|
|
|
static DEFINE_PER_CPU(int, lock_kicker_irq) = -1;
|
|
|
|
static DEFINE_PER_CPU(char *, irq_name);
|
2018-11-08 14:35:06 +07:00
|
|
|
static DEFINE_PER_CPU(atomic_t, xen_qlock_wait_nest);
|
2015-04-25 01:56:40 +07:00
|
|
|
static bool xen_pvspin = true;
|
|
|
|
|
|
|
|
static void xen_qlock_kick(int cpu)
|
|
|
|
{
|
2016-04-22 19:05:31 +07:00
|
|
|
int irq = per_cpu(lock_kicker_irq, cpu);
|
|
|
|
|
|
|
|
/* Don't kick if the target's kicker interrupt is not initialized. */
|
|
|
|
if (irq == -1)
|
|
|
|
return;
|
|
|
|
|
2015-04-25 01:56:40 +07:00
|
|
|
xen_send_IPI_one(cpu, XEN_SPIN_UNLOCK_VECTOR);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Halt the current CPU & release it back to the host
|
|
|
|
*/
|
|
|
|
static void xen_qlock_wait(u8 *byte, u8 val)
|
|
|
|
{
|
|
|
|
int irq = __this_cpu_read(lock_kicker_irq);
|
2018-11-08 14:35:06 +07:00
|
|
|
atomic_t *nest_cnt = this_cpu_ptr(&xen_qlock_wait_nest);
|
2015-04-25 01:56:40 +07:00
|
|
|
|
|
|
|
/* If kicker interrupts not initialized yet, just spin */
|
2018-10-01 12:57:42 +07:00
|
|
|
if (irq == -1 || in_nmi())
|
2015-04-25 01:56:40 +07:00
|
|
|
return;
|
|
|
|
|
2018-11-08 14:35:06 +07:00
|
|
|
/* Detect reentry. */
|
|
|
|
atomic_inc(nest_cnt);
|
2018-10-01 12:57:42 +07:00
|
|
|
|
2018-11-08 14:35:06 +07:00
|
|
|
/* If irq pending already and no nested call clear it. */
|
|
|
|
if (atomic_read(nest_cnt) == 1 && xen_test_irq_pending(irq)) {
|
2018-10-01 12:57:42 +07:00
|
|
|
xen_clear_irq_pending(irq);
|
2018-10-01 12:57:42 +07:00
|
|
|
} else if (READ_ONCE(*byte) == val) {
|
|
|
|
/* Block until irq becomes pending (or a spurious wakeup) */
|
|
|
|
xen_poll_irq(irq);
|
2018-10-01 12:57:42 +07:00
|
|
|
}
|
2015-04-25 01:56:40 +07:00
|
|
|
|
2018-11-08 14:35:06 +07:00
|
|
|
atomic_dec(nest_cnt);
|
2015-04-25 01:56:40 +07:00
|
|
|
}
|
|
|
|
|
2008-07-24 03:28:58 +07:00
|
|
|
static irqreturn_t dummy_handler(int irq, void *dev_id)
|
|
|
|
{
|
|
|
|
BUG();
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
x86: delete __cpuinit usage from all x86 files
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
are flagged as __cpuinit -- so if we remove the __cpuinit from
arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
content into no-ops as early as possible, since that will get rid
of these warnings. In any case, they are temporary and harmless.
This removes all the arch/x86 uses of the __cpuinit macros from
all C files. x86 only had the one __CPUINIT used in assembly files,
and it wasn't paired off with a .previous or a __FINIT, so we can
delete it directly w/o any corresponding additional change there.
[1] https://lkml.org/lkml/2013/5/20/589
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Acked-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: H. Peter Anvin <hpa@linux.intel.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2013-06-19 05:23:59 +07:00
|
|
|
void xen_init_lock_cpu(int cpu)
|
2008-07-24 03:28:58 +07:00
|
|
|
{
|
|
|
|
int irq;
|
2013-06-05 21:44:47 +07:00
|
|
|
char *name;
|
2008-07-24 03:28:58 +07:00
|
|
|
|
2019-06-26 15:57:09 +07:00
|
|
|
if (!xen_pvspin)
|
2013-08-27 01:28:06 +07:00
|
|
|
return;
|
|
|
|
|
2013-05-06 19:33:15 +07:00
|
|
|
WARN(per_cpu(lock_kicker_irq, cpu) >= 0, "spinlock on CPU%d exists on IRQ%d!\n",
|
2013-04-17 01:33:20 +07:00
|
|
|
cpu, per_cpu(lock_kicker_irq, cpu));
|
|
|
|
|
2008-07-24 03:28:58 +07:00
|
|
|
name = kasprintf(GFP_KERNEL, "spinlock%d", cpu);
|
|
|
|
irq = bind_ipi_to_irqhandler(XEN_SPIN_UNLOCK_VECTOR,
|
|
|
|
cpu,
|
|
|
|
dummy_handler,
|
2013-09-07 13:46:49 +07:00
|
|
|
IRQF_PERCPU|IRQF_NOBALANCING,
|
2008-07-24 03:28:58 +07:00
|
|
|
name,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (irq >= 0) {
|
|
|
|
disable_irq(irq); /* make sure it's never delivered */
|
|
|
|
per_cpu(lock_kicker_irq, cpu) = irq;
|
2013-06-05 21:44:47 +07:00
|
|
|
per_cpu(irq_name, cpu) = name;
|
2008-07-24 03:28:58 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
printk("cpu %d spinlock event irq %d\n", cpu, irq);
|
|
|
|
}
|
|
|
|
|
2008-08-22 17:52:15 +07:00
|
|
|
void xen_uninit_lock_cpu(int cpu)
|
|
|
|
{
|
2013-08-27 01:28:06 +07:00
|
|
|
if (!xen_pvspin)
|
|
|
|
return;
|
|
|
|
|
2008-08-22 17:52:15 +07:00
|
|
|
unbind_from_irqhandler(per_cpu(lock_kicker_irq, cpu), NULL);
|
2013-04-17 01:33:20 +07:00
|
|
|
per_cpu(lock_kicker_irq, cpu) = -1;
|
2013-06-05 21:44:47 +07:00
|
|
|
kfree(per_cpu(irq_name, cpu));
|
|
|
|
per_cpu(irq_name, cpu) = NULL;
|
2008-08-22 17:52:15 +07:00
|
|
|
}
|
|
|
|
|
2016-11-15 22:47:06 +07:00
|
|
|
PV_CALLEE_SAVE_REGS_THUNK(xen_vcpu_stolen);
|
|
|
|
|
2013-09-13 09:29:44 +07:00
|
|
|
/*
|
|
|
|
* Our init of PV spinlocks is split in two init functions due to us
|
|
|
|
* using paravirt patching and jump labels patching and having to do
|
|
|
|
* all of this before SMP code is invoked.
|
|
|
|
*
|
|
|
|
* The paravirt patching needs to be done _before_ the alternative asm code
|
|
|
|
* is started, otherwise we would not patch the core kernel code.
|
|
|
|
*/
|
2008-07-24 03:28:58 +07:00
|
|
|
void __init xen_init_spinlocks(void)
|
|
|
|
{
|
2018-07-20 04:39:57 +07:00
|
|
|
/* Don't need to use pvqspinlock code if there is only 1 vCPU. */
|
2019-10-23 18:16:23 +07:00
|
|
|
if (num_possible_cpus() == 1 || nopvspin)
|
2018-07-20 04:39:57 +07:00
|
|
|
xen_pvspin = false;
|
|
|
|
|
2013-08-09 21:21:54 +07:00
|
|
|
if (!xen_pvspin) {
|
|
|
|
printk(KERN_DEBUG "xen: PV spinlocks disabled\n");
|
2019-06-26 15:57:09 +07:00
|
|
|
static_branch_disable(&virt_spin_lock_key);
|
2013-08-09 21:21:54 +07:00
|
|
|
return;
|
|
|
|
}
|
2014-04-05 01:48:04 +07:00
|
|
|
printk(KERN_DEBUG "xen: PV spinlocks enabled\n");
|
2016-05-19 01:43:02 +07:00
|
|
|
|
2015-04-25 01:56:40 +07:00
|
|
|
__pv_init_lock_hash();
|
2018-08-28 14:40:19 +07:00
|
|
|
pv_ops.lock.queued_spin_lock_slowpath = __pv_queued_spin_lock_slowpath;
|
|
|
|
pv_ops.lock.queued_spin_unlock =
|
|
|
|
PV_CALLEE_SAVE(__pv_queued_spin_unlock);
|
|
|
|
pv_ops.lock.wait = xen_qlock_wait;
|
|
|
|
pv_ops.lock.kick = xen_qlock_kick;
|
|
|
|
pv_ops.lock.vcpu_is_preempted = PV_CALLEE_SAVE(xen_vcpu_stolen);
|
2008-07-24 03:28:58 +07:00
|
|
|
}
|
2008-08-21 07:02:19 +07:00
|
|
|
|
2013-08-09 21:21:54 +07:00
|
|
|
static __init int xen_parse_nopvspin(char *arg)
|
|
|
|
{
|
2019-10-23 18:16:23 +07:00
|
|
|
pr_notice("\"xen_nopvspin\" is deprecated, please use \"nopvspin\" instead\n");
|
2013-08-09 21:21:54 +07:00
|
|
|
xen_pvspin = false;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
early_param("xen_nopvspin", xen_parse_nopvspin);
|
|
|
|
|