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
2017-05-11 23:24:15 +03:00
/*
* Page Deallocation Table ( PDT ) support
*
2017-08-04 20:23:53 +03:00
* The Page Deallocation Table ( PDT ) is maintained by firmware and holds a
* list of memory addresses in which memory errors were detected .
* The list contains both single - bit ( correctable ) and double - bit
* ( uncorrectable ) errors .
2017-05-11 23:24:15 +03:00
*
* Copyright 2017 by Helge Deller < deller @ gmx . de >
*
2017-08-04 20:23:53 +03:00
* possible future enhancements :
* - add userspace interface via procfs or sysfs to clear PDT
2017-05-11 23:24:15 +03:00
*/
# include <linux/memblock.h>
# include <linux/seq_file.h>
2017-08-04 20:23:53 +03:00
# include <linux/kthread.h>
2017-09-18 18:55:24 +03:00
# include <linux/initrd.h>
2017-05-11 23:24:15 +03:00
# include <asm/pdc.h>
# include <asm/pdcpat.h>
# include <asm/sections.h>
# include <asm/pgtable.h>
enum pdt_access_type {
PDT_NONE ,
PDT_PDC ,
PDT_PAT_NEW ,
2017-08-04 20:23:53 +03:00
PDT_PAT_CELL
2017-05-11 23:24:15 +03:00
} ;
static enum pdt_access_type pdt_type ;
2017-08-04 20:23:53 +03:00
/* PDT poll interval: 1 minute if errors, 5 minutes if everything OK. */
# define PDT_POLL_INTERVAL_DEFAULT (5*60*HZ)
# define PDT_POLL_INTERVAL_SHORT (1*60*HZ)
static unsigned long pdt_poll_interval = PDT_POLL_INTERVAL_DEFAULT ;
2017-05-11 23:24:15 +03:00
/* global PDT status information */
static struct pdc_mem_retinfo pdt_status ;
# define MAX_PDT_TABLE_SIZE PAGE_SIZE
# define MAX_PDT_ENTRIES (MAX_PDT_TABLE_SIZE / sizeof(unsigned long))
static unsigned long pdt_entry [ MAX_PDT_ENTRIES ] __page_aligned_bss ;
2017-08-04 20:23:53 +03:00
/*
* Constants for the pdt_entry format :
* A pdt_entry holds the physical address in bits 0 - 57 , bits 58 - 61 are
* reserved , bit 62 is the perm bit and bit 63 is the error_type bit .
* The perm bit indicates whether the error have been verified as a permanent
* error ( value of 1 ) or has not been verified , and may be transient ( value
* of 0 ) . The error_type bit indicates whether the error is a single bit error
* ( value of 1 ) or a multiple bit error .
* On non - PAT machines phys_addr is encoded in bits 0 - 59 and error_type in bit
* 63. Those machines don ' t provide the perm bit .
*/
# define PDT_ADDR_PHYS_MASK (pdt_type != PDT_PDC ? ~0x3f : ~0x0f)
# define PDT_ADDR_PERM_ERR (pdt_type != PDT_PDC ? 2UL : 0UL)
# define PDT_ADDR_SINGLE_ERR 1UL
2017-05-11 23:24:15 +03:00
/* report PDT entries via /proc/meminfo */
void arch_report_meminfo ( struct seq_file * m )
{
if ( pdt_type = = PDT_NONE )
return ;
seq_printf ( m , " PDT_max_entries: %7lu \n " ,
pdt_status . pdt_size ) ;
seq_printf ( m , " PDT_cur_entries: %7lu \n " ,
pdt_status . pdt_entries ) ;
}
2017-08-04 20:23:53 +03:00
static int get_info_pat_new ( void )
{
struct pdc_pat_mem_retinfo pat_rinfo ;
int ret ;
/* newer PAT machines like C8000 report info for all cells */
if ( is_pdc_pat ( ) )
ret = pdc_pat_mem_pdt_info ( & pat_rinfo ) ;
else
return PDC_BAD_PROC ;
pdt_status . pdt_size = pat_rinfo . max_pdt_entries ;
pdt_status . pdt_entries = pat_rinfo . current_pdt_entries ;
pdt_status . pdt_status = 0 ;
pdt_status . first_dbe_loc = pat_rinfo . first_dbe_loc ;
pdt_status . good_mem = pat_rinfo . good_mem ;
return ret ;
}
static int get_info_pat_cell ( void )
{
struct pdc_pat_mem_cell_pdt_retinfo cell_rinfo ;
int ret ;
/* older PAT machines like rp5470 report cell info only */
if ( is_pdc_pat ( ) )
ret = pdc_pat_mem_pdt_cell_info ( & cell_rinfo , parisc_cell_num ) ;
else
return PDC_BAD_PROC ;
pdt_status . pdt_size = cell_rinfo . max_pdt_entries ;
pdt_status . pdt_entries = cell_rinfo . current_pdt_entries ;
pdt_status . pdt_status = 0 ;
pdt_status . first_dbe_loc = cell_rinfo . first_dbe_loc ;
pdt_status . good_mem = cell_rinfo . good_mem ;
return ret ;
}
static void report_mem_err ( unsigned long pde )
{
struct pdc_pat_mem_phys_mem_location loc ;
unsigned long addr ;
char dimm_txt [ 32 ] ;
addr = pde & PDT_ADDR_PHYS_MASK ;
/* show DIMM slot description on PAT machines */
if ( is_pdc_pat ( ) ) {
pdc_pat_mem_get_dimm_phys_location ( & loc , addr ) ;
sprintf ( dimm_txt , " DIMM slot %02x, " , loc . dimm_slot ) ;
} else
dimm_txt [ 0 ] = 0 ;
pr_warn ( " PDT: BAD MEMORY at 0x%08lx, %s%s%s-bit error. \n " ,
addr , dimm_txt ,
pde & PDT_ADDR_PERM_ERR ? " permanent " : " " ,
pde & PDT_ADDR_SINGLE_ERR ? " single " : " multi " ) ;
}
2017-05-11 23:24:15 +03:00
/*
* pdc_pdt_init ( )
*
* Initialize kernel PDT structures , read initial PDT table from firmware ,
* report all current PDT entries and mark bad memory with memblock_reserve ( )
* to avoid that the kernel will use broken memory areas .
*
*/
void __init pdc_pdt_init ( void )
{
int ret , i ;
unsigned long entries ;
struct pdc_mem_read_pdt pdt_read_ret ;
2017-08-04 20:23:53 +03:00
pdt_type = PDT_PAT_NEW ;
ret = get_info_pat_new ( ) ;
2017-05-11 23:24:15 +03:00
2017-08-04 20:23:53 +03:00
if ( ret ! = PDC_OK ) {
pdt_type = PDT_PAT_CELL ;
ret = get_info_pat_cell ( ) ;
}
if ( ret ! = PDC_OK ) {
2017-05-11 23:24:15 +03:00
pdt_type = PDT_PDC ;
2017-08-04 20:23:53 +03:00
/* non-PAT machines provide the standard PDC call */
2017-05-11 23:24:15 +03:00
ret = pdc_mem_pdt_info ( & pdt_status ) ;
}
if ( ret ! = PDC_OK ) {
pdt_type = PDT_NONE ;
pr_info ( " PDT: Firmware does not provide any page deallocation "
" information. \n " ) ;
return ;
}
entries = pdt_status . pdt_entries ;
2017-08-04 20:23:53 +03:00
if ( WARN_ON ( entries > MAX_PDT_ENTRIES ) )
entries = pdt_status . pdt_entries = MAX_PDT_ENTRIES ;
2017-05-11 23:24:15 +03:00
2017-08-04 20:23:53 +03:00
pr_info ( " PDT: type %s, size %lu, entries %lu, status %lu, dbe_loc 0x%lx, "
" good_mem %lu MB \n " ,
pdt_type = = PDT_PDC ? __stringify ( PDT_PDC ) :
pdt_type = = PDT_PAT_CELL ? __stringify ( PDT_PAT_CELL )
: __stringify ( PDT_PAT_NEW ) ,
2017-05-11 23:24:15 +03:00
pdt_status . pdt_size , pdt_status . pdt_entries ,
pdt_status . pdt_status , pdt_status . first_dbe_loc ,
2017-08-04 20:23:53 +03:00
pdt_status . good_mem / 1024 / 1024 ) ;
2017-05-11 23:24:15 +03:00
if ( entries = = 0 ) {
pr_info ( " PDT: Firmware reports all memory OK. \n " ) ;
return ;
}
if ( pdt_status . first_dbe_loc & &
pdt_status . first_dbe_loc < = __pa ( ( unsigned long ) & _end ) )
pr_crit ( " CRITICAL: Bad memory inside kernel image memory area! \n " ) ;
pr_warn ( " PDT: Firmware reports %lu entries of faulty memory: \n " ,
entries ) ;
if ( pdt_type = = PDT_PDC )
ret = pdc_mem_pdt_read_entries ( & pdt_read_ret , pdt_entry ) ;
else {
# ifdef CONFIG_64BIT
struct pdc_pat_mem_read_pd_retinfo pat_pret ;
2017-08-04 20:23:53 +03:00
if ( pdt_type = = PDT_PAT_CELL )
ret = pdc_pat_mem_read_cell_pdt ( & pat_pret , pdt_entry ,
MAX_PDT_ENTRIES ) ;
else
2017-05-11 23:24:15 +03:00
ret = pdc_pat_mem_read_pd_pdt ( & pat_pret , pdt_entry ,
MAX_PDT_TABLE_SIZE , 0 ) ;
# else
ret = PDC_BAD_PROC ;
# endif
}
if ( ret ! = PDC_OK ) {
pdt_type = PDT_NONE ;
2017-08-04 20:23:53 +03:00
pr_warn ( " PDT: Get PDT entries failed with %d \n " , ret ) ;
2017-05-11 23:24:15 +03:00
return ;
}
for ( i = 0 ; i < pdt_status . pdt_entries ; i + + ) {
2017-09-18 18:55:24 +03:00
unsigned long addr ;
2017-08-04 20:23:53 +03:00
report_mem_err ( pdt_entry [ i ] ) ;
2017-09-18 18:55:24 +03:00
addr = pdt_entry [ i ] & PDT_ADDR_PHYS_MASK ;
if ( IS_ENABLED ( CONFIG_BLK_DEV_INITRD ) & &
addr > = initrd_start & & addr < initrd_end )
pr_crit ( " CRITICAL: initrd possibly broken "
" due to bad memory! \n " ) ;
2017-08-04 20:23:53 +03:00
/* mark memory page bad */
memblock_reserve ( pdt_entry [ i ] & PAGE_MASK , PAGE_SIZE ) ;
}
}
2017-07-25 21:12:25 +03:00
2017-08-04 20:23:53 +03:00
/*
* This is the PDT kernel thread main loop .
*/
static int pdt_mainloop ( void * unused )
{
struct pdc_mem_read_pdt pdt_read_ret ;
struct pdc_pat_mem_read_pd_retinfo pat_pret __maybe_unused ;
unsigned long old_num_entries ;
unsigned long * bad_mem_ptr ;
int num , ret ;
for ( ; ; ) {
set_current_state ( TASK_INTERRUPTIBLE ) ;
old_num_entries = pdt_status . pdt_entries ;
schedule_timeout ( pdt_poll_interval ) ;
if ( kthread_should_stop ( ) )
break ;
/* Do we have new PDT entries? */
switch ( pdt_type ) {
case PDT_PAT_NEW :
ret = get_info_pat_new ( ) ;
break ;
case PDT_PAT_CELL :
ret = get_info_pat_cell ( ) ;
break ;
default :
ret = pdc_mem_pdt_info ( & pdt_status ) ;
break ;
}
if ( ret ! = PDC_OK ) {
pr_warn ( " PDT: unexpected failure %d \n " , ret ) ;
return - EINVAL ;
}
/* if no new PDT entries, just wait again */
num = pdt_status . pdt_entries - old_num_entries ;
if ( num < = 0 )
continue ;
/* decrease poll interval in case we found memory errors */
if ( pdt_status . pdt_entries & &
pdt_poll_interval = = PDT_POLL_INTERVAL_DEFAULT )
pdt_poll_interval = PDT_POLL_INTERVAL_SHORT ;
/* limit entries to get */
if ( num > MAX_PDT_ENTRIES ) {
num = MAX_PDT_ENTRIES ;
pdt_status . pdt_entries = old_num_entries + num ;
}
/* get new entries */
switch ( pdt_type ) {
2017-07-25 21:12:25 +03:00
# ifdef CONFIG_64BIT
2017-08-04 20:23:53 +03:00
case PDT_PAT_CELL :
if ( pdt_status . pdt_entries > MAX_PDT_ENTRIES ) {
pr_crit ( " PDT: too many entries. \n " ) ;
return - ENOMEM ;
}
ret = pdc_pat_mem_read_cell_pdt ( & pat_pret , pdt_entry ,
MAX_PDT_ENTRIES ) ;
bad_mem_ptr = & pdt_entry [ old_num_entries ] ;
break ;
case PDT_PAT_NEW :
ret = pdc_pat_mem_read_pd_pdt ( & pat_pret ,
pdt_entry ,
num * sizeof ( unsigned long ) ,
old_num_entries * sizeof ( unsigned long ) ) ;
bad_mem_ptr = & pdt_entry [ 0 ] ;
break ;
2017-07-25 21:12:25 +03:00
# endif
2017-08-04 20:23:53 +03:00
default :
ret = pdc_mem_pdt_read_entries ( & pdt_read_ret ,
pdt_entry ) ;
bad_mem_ptr = & pdt_entry [ old_num_entries ] ;
break ;
}
2017-07-25 21:12:25 +03:00
2017-08-04 20:23:53 +03:00
/* report and mark memory broken */
while ( num - - ) {
unsigned long pde = * bad_mem_ptr + + ;
2017-05-11 23:24:15 +03:00
2017-08-04 20:23:53 +03:00
report_mem_err ( pde ) ;
# ifdef CONFIG_MEMORY_FAILURE
if ( ( pde & PDT_ADDR_PERM_ERR ) | |
( ( pde & PDT_ADDR_SINGLE_ERR ) = = 0 ) )
2017-07-10 02:14:01 +03:00
memory_failure ( pde > > PAGE_SHIFT , 0 ) ;
2017-08-04 20:23:53 +03:00
else
soft_offline_page (
pfn_to_page ( pde > > PAGE_SHIFT ) , 0 ) ;
# else
pr_crit ( " PDT: memory error at 0x%lx ignored. \n "
" Rebuild kernel with CONFIG_MEMORY_FAILURE=y "
" for real handling. \n " ,
pde & PDT_ADDR_PHYS_MASK ) ;
# endif
}
2017-05-11 23:24:15 +03:00
}
2017-08-04 20:23:53 +03:00
return 0 ;
2017-05-11 23:24:15 +03:00
}
2017-08-04 20:23:53 +03:00
static int __init pdt_initcall ( void )
{
struct task_struct * kpdtd_task ;
if ( pdt_type = = PDT_NONE )
return - ENODEV ;
kpdtd_task = kthread_create ( pdt_mainloop , NULL , " kpdtd " ) ;
if ( IS_ERR ( kpdtd_task ) )
return PTR_ERR ( kpdtd_task ) ;
wake_up_process ( kpdtd_task ) ;
return 0 ;
}
late_initcall ( pdt_initcall ) ;