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 17:07:57 +03:00
// SPDX-License-Identifier: GPL-2.0
2013-01-21 03:43:10 +04:00
# include <linux/module.h>
2010-11-21 14:41:57 +03:00
# include <linux/kernel.h>
2013-01-21 03:43:10 +04:00
# include <linux/slab.h>
2017-02-04 02:16:44 +03:00
# include <linux/mm_types.h>
2010-11-21 14:41:57 +03:00
# include <asm/cputype.h>
2011-09-30 14:43:29 +04:00
# include <asm/idmap.h>
2018-12-13 16:04:56 +03:00
# include <asm/hwcap.h>
2010-11-21 14:41:57 +03:00
# include <asm/pgalloc.h>
# include <asm/pgtable.h>
2011-09-30 14:43:29 +04:00
# include <asm/sections.h>
2012-03-28 21:30:01 +04:00
# include <asm/system_info.h>
2011-09-30 14:43:29 +04:00
2014-07-29 15:18:34 +04:00
/*
* Note : accesses outside of the kernel image and the identity map area
* are not supported on any CPU using the idmap tables as its current
* page tables .
*/
2017-12-12 03:25:30 +03:00
pgd_t * idmap_pgd __ro_after_init ;
long long arch_phys_to_idmap_offset __ro_after_init ;
2010-11-21 14:41:57 +03:00
2011-11-22 21:30:32 +04:00
# ifdef CONFIG_ARM_LPAE
static void idmap_add_pmd ( pud_t * pud , unsigned long addr , unsigned long end ,
unsigned long prot )
{
pmd_t * pmd ;
unsigned long next ;
if ( pud_none_or_clear_bad ( pud ) | | ( pud_val ( * pud ) & L_PGD_SWAPPER ) ) {
pmd = pmd_alloc_one ( & init_mm , addr ) ;
if ( ! pmd ) {
2014-09-16 23:41:43 +04:00
pr_warn ( " Failed to allocate identity pmd. \n " ) ;
2011-11-22 21:30:32 +04:00
return ;
}
ARM: 8115/1: LPAE: reduce damage caused by idmap to virtual memory layout
On LPAE, each level 1 (pgd) page table entry maps 1GiB, and the level 2
(pmd) entries map 2MiB.
When the identity mapping is created on LPAE, the pgd pointers are copied
from the swapper_pg_dir. If we find that we need to modify the contents
of a pmd, we allocate a new empty pmd table and insert it into the
appropriate 1GB slot, before then filling it with the identity mapping.
However, if the 1GB slot covers the kernel lowmem mappings, we obliterate
those mappings.
When replacing a PMD, first copy the old PMD contents to the new PMD, so
that we preserve the existing mappings, particularly the mappings of the
kernel itself.
[rewrote commit message and added code comment -- rmk]
Fixes: ae2de101739c ("ARM: LPAE: Add identity mapping support for the 3-level page table format")
Signed-off-by: Konstantin Khlebnikov <k.khlebnikov@samsung.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-07-25 12:17:12 +04:00
/*
* Copy the original PMD to ensure that the PMD entries for
* the kernel image are preserved .
*/
if ( ! pud_none ( * pud ) )
memcpy ( pmd , pmd_offset ( pud , 0 ) ,
PTRS_PER_PMD * sizeof ( pmd_t ) ) ;
2011-11-22 21:30:32 +04:00
pud_populate ( & init_mm , pud , pmd ) ;
pmd + = pmd_index ( addr ) ;
} else
pmd = pmd_offset ( pud , addr ) ;
do {
next = pmd_addr_end ( addr , end ) ;
* pmd = __pmd ( ( addr & PMD_MASK ) | prot ) ;
flush_pmd_entry ( pmd ) ;
} while ( pmd + + , addr = next , addr ! = end ) ;
}
# else /* !CONFIG_ARM_LPAE */
2010-11-21 19:27:49 +03:00
static void idmap_add_pmd ( pud_t * pud , unsigned long addr , unsigned long end ,
2010-11-21 14:48:16 +03:00
unsigned long prot )
{
2010-11-21 19:27:49 +03:00
pmd_t * pmd = pmd_offset ( pud , addr ) ;
2010-11-21 14:48:16 +03:00
addr = ( addr & PMD_MASK ) | prot ;
pmd [ 0 ] = __pmd ( addr ) ;
addr + = SECTION_SIZE ;
pmd [ 1 ] = __pmd ( addr ) ;
flush_pmd_entry ( pmd ) ;
}
2011-11-22 21:30:32 +04:00
# endif /* CONFIG_ARM_LPAE */
2010-11-21 14:48:16 +03:00
2010-11-21 19:27:49 +03:00
static void idmap_add_pud ( pgd_t * pgd , unsigned long addr , unsigned long end ,
unsigned long prot )
{
pud_t * pud = pud_offset ( pgd , addr ) ;
unsigned long next ;
do {
next = pud_addr_end ( addr , end ) ;
idmap_add_pmd ( pud , addr , next , prot ) ;
} while ( pud + + , addr = next , addr ! = end ) ;
}
2013-01-21 03:43:10 +04:00
static void identity_mapping_add ( pgd_t * pgd , const char * text_start ,
const char * text_end , unsigned long prot )
2010-11-21 14:41:57 +03:00
{
2013-01-21 03:43:10 +04:00
unsigned long addr , end ;
unsigned long next ;
2013-07-31 20:44:42 +04:00
addr = virt_to_idmap ( text_start ) ;
end = virt_to_idmap ( text_end ) ;
2013-07-31 20:44:43 +04:00
pr_info ( " Setting up static identity map for 0x%lx - 0x%lx \n " , addr , end ) ;
2013-01-21 03:43:10 +04:00
prot | = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_AF ;
2010-11-21 14:41:57 +03:00
ARM: make xscale iwmmxt code multiplatform aware
In a multiplatform configuration, we may end up building a kernel for
both Marvell PJ1 and an ARMv4 CPU implementation. In that case, the
xscale-cp0 code is built with gcc -march=armv4{,t}, which results in a
build error from the coprocessor instructions.
Since we know this code will only have to run on an actual xscale
processor, we can simply build the entire file for ARMv5TE.
Related to this, we need to handle the iWMMXT initialization sequence
differently during boot, to ensure we don't try to touch xscale
specific registers on other CPUs from the xscale_cp0_init initcall.
cpu_is_xscale() used to be hardcoded to '1' in any configuration that
enables any XScale-compatible core, but this breaks once we can have a
combined kernel with MMP1 and something else.
In this patch, I replace the existing cpu_is_xscale() macro with a new
cpu_is_xscale_family() macro that evaluates true for xscale, xsc3 and
mohawk, which makes the behavior more deterministic.
The two existing users of cpu_is_xscale() are modified accordingly,
but slightly change behavior for kernels that enable CPU_MOHAWK without
also enabling CPU_XSCALE or CPU_XSC3. Previously, these would leave leave
PMD_BIT4 in the page tables untouched, now they clear it as we've always
done for kernels that enable both MOHAWK and the support for the older
CPU types.
Since the previous behavior was inconsistent, I assume it was
unintentional.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2014-04-15 17:38:39 +04:00
if ( cpu_architecture ( ) < = CPU_ARCH_ARMv5TEJ & & ! cpu_is_xscale_family ( ) )
2010-11-21 14:41:57 +03:00
prot | = PMD_BIT4 ;
2010-11-21 14:48:16 +03:00
pgd + = pgd_index ( addr ) ;
do {
next = pgd_addr_end ( addr , end ) ;
2010-11-21 19:27:49 +03:00
idmap_add_pud ( pgd , addr , next , prot ) ;
2010-11-21 14:48:16 +03:00
} while ( pgd + + , addr = next , addr ! = end ) ;
2010-11-21 14:41:57 +03:00
}
2011-09-30 14:43:29 +04:00
extern char __idmap_text_start [ ] , __idmap_text_end [ ] ;
static int __init init_static_idmap ( void )
{
idmap_pgd = pgd_alloc ( & init_mm ) ;
if ( ! idmap_pgd )
return - ENOMEM ;
2013-01-21 03:43:10 +04:00
identity_mapping_add ( idmap_pgd , __idmap_text_start ,
__idmap_text_end , 0 ) ;
2011-09-30 14:43:29 +04:00
2012-11-08 22:46:07 +04:00
/* Flush L1 for the hardware to see this page table content */
2018-12-13 16:04:56 +03:00
if ( ! ( elf_hwcap & HWCAP_LPAE ) )
flush_cache_louis ( ) ;
2012-11-08 22:46:07 +04:00
2013-04-12 22:12:03 +04:00
return 0 ;
2011-09-30 14:43:29 +04:00
}
2011-11-23 16:26:25 +04:00
early_initcall ( init_static_idmap ) ;
2011-09-30 14:43:29 +04:00
2010-11-21 14:41:57 +03:00
/*
2011-06-08 18:53:34 +04:00
* In order to soft - boot , we need to switch to a 1 : 1 mapping for the
* cpu_reset functions . This will then ensure that we have predictable
* results when turning off the mmu .
2010-11-21 14:41:57 +03:00
*/
2011-11-01 14:15:27 +04:00
void setup_mm_for_reboot ( void )
2010-11-21 14:41:57 +03:00
{
2011-06-08 18:53:34 +04:00
/* Switch to the identity mapping. */
cpu_switch_mm ( idmap_pgd , & init_mm ) ;
2013-02-28 20:48:40 +04:00
local_flush_bp_all ( ) ;
2011-06-08 18:53:34 +04:00
2012-11-08 22:46:07 +04:00
# ifdef CONFIG_CPU_HAS_ASID
/*
* We don ' t have a clean ASID for the identity mapping , which
* may clash with virtual addresses of the previous page tables
* and therefore potentially in the TLB .
*/
2010-11-21 14:41:57 +03:00
local_flush_tlb_all ( ) ;
2012-11-08 22:46:07 +04:00
# endif
2010-11-21 14:41:57 +03:00
}