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 22:07:57 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2008-03-04 01:12:53 +08:00
|
|
|
#include <linux/cpumask.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <linux/kernel_stat.h>
|
|
|
|
#include <linux/mc146818rtc.h>
|
|
|
|
#include <linux/cache.h>
|
|
|
|
#include <linux/cpu.h>
|
|
|
|
|
|
|
|
#include <asm/smp.h>
|
|
|
|
#include <asm/mtrr.h>
|
|
|
|
#include <asm/tlbflush.h>
|
|
|
|
#include <asm/mmu_context.h>
|
2009-02-17 20:58:15 +08:00
|
|
|
#include <asm/apic.h>
|
2008-03-04 01:12:53 +08:00
|
|
|
#include <asm/proto.h>
|
2009-01-30 11:31:49 +08:00
|
|
|
#include <asm/ipi.h>
|
2008-03-04 01:12:53 +08:00
|
|
|
|
2016-03-07 02:11:15 +08:00
|
|
|
void __default_send_IPI_shortcut(unsigned int shortcut, int vector, unsigned int dest)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Subtle. In the case of the 'never do double writes' workaround
|
|
|
|
* we have to lock out interrupts to be safe. As we don't care
|
|
|
|
* of the value read we use an atomic rmw access to avoid costly
|
|
|
|
* cli/sti. Otherwise we use an even cheaper single atomic write
|
|
|
|
* to the APIC.
|
|
|
|
*/
|
|
|
|
unsigned int cfg;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Wait for idle.
|
|
|
|
*/
|
|
|
|
__xapic_wait_icr_idle();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* No need to touch the target chip field
|
|
|
|
*/
|
|
|
|
cfg = __prepare_ICR(shortcut, vector, dest);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Send the IPI. The write to APIC_ICR fires this off.
|
|
|
|
*/
|
|
|
|
native_apic_mem_write(APIC_ICR, cfg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is used to send an IPI with no shorthand notation (the destination is
|
|
|
|
* specified in bits 56 to 63 of the ICR).
|
|
|
|
*/
|
|
|
|
void __default_send_IPI_dest_field(unsigned int mask, int vector, unsigned int dest)
|
|
|
|
{
|
|
|
|
unsigned long cfg;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Wait for idle.
|
|
|
|
*/
|
|
|
|
if (unlikely(vector == NMI_VECTOR))
|
|
|
|
safe_apic_wait_icr_idle();
|
|
|
|
else
|
|
|
|
__xapic_wait_icr_idle();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* prepare target chip field
|
|
|
|
*/
|
|
|
|
cfg = __prepare_ICR2(mask);
|
|
|
|
native_apic_mem_write(APIC_ICR2, cfg);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* program the ICR
|
|
|
|
*/
|
|
|
|
cfg = __prepare_ICR(0, vector, dest);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Send the IPI. The write to APIC_ICR fires this off.
|
|
|
|
*/
|
|
|
|
native_apic_mem_write(APIC_ICR, cfg);
|
|
|
|
}
|
|
|
|
|
2015-11-05 06:57:01 +08:00
|
|
|
void default_send_IPI_single_phys(int cpu, int vector)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
local_irq_save(flags);
|
|
|
|
__default_send_IPI_dest_field(per_cpu(x86_cpu_to_apicid, cpu),
|
|
|
|
vector, APIC_DEST_PHYSICAL);
|
|
|
|
local_irq_restore(flags);
|
|
|
|
}
|
|
|
|
|
2009-01-31 09:29:27 +08:00
|
|
|
void default_send_IPI_mask_sequence_phys(const struct cpumask *mask, int vector)
|
|
|
|
{
|
|
|
|
unsigned long query_cpu;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Hack. The clustered APIC addressing mode doesn't allow us to send
|
|
|
|
* to an arbitrary mask, so I do a unicast to each CPU instead.
|
|
|
|
* - mbligh
|
|
|
|
*/
|
|
|
|
local_irq_save(flags);
|
|
|
|
for_each_cpu(query_cpu, mask) {
|
|
|
|
__default_send_IPI_dest_field(per_cpu(x86_cpu_to_apicid,
|
|
|
|
query_cpu), vector, APIC_DEST_PHYSICAL);
|
|
|
|
}
|
|
|
|
local_irq_restore(flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
void default_send_IPI_mask_allbutself_phys(const struct cpumask *mask,
|
|
|
|
int vector)
|
|
|
|
{
|
|
|
|
unsigned int this_cpu = smp_processor_id();
|
|
|
|
unsigned int query_cpu;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
/* See Hack comment above */
|
|
|
|
|
|
|
|
local_irq_save(flags);
|
|
|
|
for_each_cpu(query_cpu, mask) {
|
|
|
|
if (query_cpu == this_cpu)
|
|
|
|
continue;
|
|
|
|
__default_send_IPI_dest_field(per_cpu(x86_cpu_to_apicid,
|
|
|
|
query_cpu), vector, APIC_DEST_PHYSICAL);
|
|
|
|
}
|
|
|
|
local_irq_restore(flags);
|
|
|
|
}
|
|
|
|
|
2015-11-05 06:57:07 +08:00
|
|
|
/*
|
|
|
|
* Helper function for APICs which insist on cpumasks
|
|
|
|
*/
|
|
|
|
void default_send_IPI_single(int cpu, int vector)
|
|
|
|
{
|
|
|
|
apic->send_IPI_mask(cpumask_of(cpu), vector);
|
|
|
|
}
|
|
|
|
|
2011-01-23 21:37:29 +08:00
|
|
|
#ifdef CONFIG_X86_32
|
|
|
|
|
2009-01-31 09:29:27 +08:00
|
|
|
void default_send_IPI_mask_sequence_logical(const struct cpumask *mask,
|
|
|
|
int vector)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
unsigned int query_cpu;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Hack. The clustered APIC addressing mode doesn't allow us to send
|
|
|
|
* to an arbitrary mask, so I do a unicasts to each CPU instead. This
|
|
|
|
* should be modified to do 1 message per cluster ID - mbligh
|
|
|
|
*/
|
|
|
|
|
|
|
|
local_irq_save(flags);
|
|
|
|
for_each_cpu(query_cpu, mask)
|
|
|
|
__default_send_IPI_dest_field(
|
2011-01-23 21:37:31 +08:00
|
|
|
early_per_cpu(x86_cpu_to_logical_apicid, query_cpu),
|
|
|
|
vector, apic->dest_logical);
|
2009-01-31 09:29:27 +08:00
|
|
|
local_irq_restore(flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
void default_send_IPI_mask_allbutself_logical(const struct cpumask *mask,
|
|
|
|
int vector)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
unsigned int query_cpu;
|
|
|
|
unsigned int this_cpu = smp_processor_id();
|
|
|
|
|
|
|
|
/* See Hack comment above */
|
|
|
|
|
|
|
|
local_irq_save(flags);
|
|
|
|
for_each_cpu(query_cpu, mask) {
|
|
|
|
if (query_cpu == this_cpu)
|
|
|
|
continue;
|
|
|
|
__default_send_IPI_dest_field(
|
2011-01-23 21:37:31 +08:00
|
|
|
early_per_cpu(x86_cpu_to_logical_apicid, query_cpu),
|
|
|
|
vector, apic->dest_logical);
|
2009-01-31 09:29:27 +08:00
|
|
|
}
|
|
|
|
local_irq_restore(flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is only used on smaller machines.
|
|
|
|
*/
|
|
|
|
void default_send_IPI_mask_logical(const struct cpumask *cpumask, int vector)
|
|
|
|
{
|
|
|
|
unsigned long mask = cpumask_bits(cpumask)[0];
|
|
|
|
unsigned long flags;
|
|
|
|
|
2013-01-19 01:58:47 +08:00
|
|
|
if (!mask)
|
x86: don't send an IPI to the empty set of CPU's
The default_send_IPI_mask_logical() function uses the "flat" APIC mode
to send an IPI to a set of CPU's at once, but if that set happens to be
empty, some older local APIC's will apparently be rather unhappy. So
just warn if a caller gives us an empty mask, and ignore it.
This fixes a regression in 2.6.30.x, due to commit 4595f9620 ("x86:
change flush_tlb_others to take a const struct cpumask"), documented
here:
http://bugzilla.kernel.org/show_bug.cgi?id=13933
which causes a silent lock-up. It only seems to happen on PPro, P2, P3
and Athlon XP cores. Most developers sadly (or not so sadly, if you're
a developer..) have more modern CPU's. Also, on x86-64 we don't use the
flat APIC mode, so it would never trigger there even if the APIC didn't
like sending an empty IPI mask.
Reported-by: Pavel Vilim <wylda@volny.cz>
Reported-and-tested-by: Thomas Björnell <thomas.bjornell@gmail.com>
Reported-and-tested-by: Martin Rogge <marogge@onlinehome.de>
Cc: Mike Travis <travis@sgi.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: stable@kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-08-22 00:23:57 +08:00
|
|
|
return;
|
|
|
|
|
2009-01-31 09:29:27 +08:00
|
|
|
local_irq_save(flags);
|
|
|
|
WARN_ON(mask & ~cpumask_bits(cpu_online_mask)[0]);
|
|
|
|
__default_send_IPI_dest_field(mask, vector, apic->dest_logical);
|
|
|
|
local_irq_restore(flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
void default_send_IPI_allbutself(int vector)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* if there are no other CPUs in the system then we get an APIC send
|
|
|
|
* error if we try to broadcast, thus avoid sending IPIs in this case.
|
|
|
|
*/
|
|
|
|
if (!(num_online_cpus() > 1))
|
|
|
|
return;
|
|
|
|
|
|
|
|
__default_local_send_IPI_allbutself(vector);
|
|
|
|
}
|
|
|
|
|
|
|
|
void default_send_IPI_all(int vector)
|
|
|
|
{
|
|
|
|
__default_local_send_IPI_all(vector);
|
|
|
|
}
|
|
|
|
|
2009-01-28 22:42:24 +08:00
|
|
|
void default_send_IPI_self(int vector)
|
2008-03-04 01:12:53 +08:00
|
|
|
{
|
2009-01-30 11:31:49 +08:00
|
|
|
__default_send_IPI_shortcut(APIC_DEST_SELF, vector, apic->dest_logical);
|
2008-03-04 01:12:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* must come after the send_IPI functions above for inlining */
|
|
|
|
static int convert_apicid_to_cpu(int apic_id)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for_each_possible_cpu(i) {
|
|
|
|
if (per_cpu(x86_cpu_to_apicid, i) == apic_id)
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int safe_smp_processor_id(void)
|
|
|
|
{
|
|
|
|
int apicid, cpuid;
|
|
|
|
|
2016-04-05 04:25:00 +08:00
|
|
|
if (!boot_cpu_has(X86_FEATURE_APIC))
|
2008-03-04 01:12:53 +08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
apicid = hard_smp_processor_id();
|
|
|
|
if (apicid == BAD_APICID)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
cpuid = convert_apicid_to_cpu(apicid);
|
|
|
|
|
|
|
|
return cpuid >= 0 ? cpuid : 0;
|
|
|
|
}
|
|
|
|
#endif
|