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 */
|
2005-04-17 05:20:36 +07:00
|
|
|
#ifndef _LINUX_HIGHMEM_H
|
|
|
|
#define _LINUX_HIGHMEM_H
|
|
|
|
|
|
|
|
#include <linux/fs.h>
|
2010-08-10 07:18:32 +07:00
|
|
|
#include <linux/kernel.h>
|
2011-11-24 08:12:59 +07:00
|
|
|
#include <linux/bug.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <linux/mm.h>
|
2006-12-07 11:32:21 +07:00
|
|
|
#include <linux/uaccess.h>
|
2010-11-12 05:05:10 +07:00
|
|
|
#include <linux/hardirq.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
#include <asm/cacheflush.h>
|
|
|
|
|
2006-03-26 16:36:57 +07:00
|
|
|
#ifndef ARCH_HAS_FLUSH_ANON_PAGE
|
2006-12-31 05:24:19 +07:00
|
|
|
static inline void flush_anon_page(struct vm_area_struct *vma, struct page *page, unsigned long vmaddr)
|
2006-03-26 16:36:57 +07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-03-26 16:36:59 +07:00
|
|
|
#ifndef ARCH_HAS_FLUSH_KERNEL_DCACHE_PAGE
|
|
|
|
static inline void flush_kernel_dcache_page(struct page *page)
|
|
|
|
{
|
|
|
|
}
|
2010-01-26 00:42:20 +07:00
|
|
|
static inline void flush_kernel_vmap_range(void *vaddr, int size)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
static inline void invalidate_kernel_vmap_range(void *vaddr, int size)
|
|
|
|
{
|
|
|
|
}
|
2006-03-26 16:36:59 +07:00
|
|
|
#endif
|
|
|
|
|
2009-04-02 11:38:49 +07:00
|
|
|
#include <asm/kmap_types.h>
|
|
|
|
|
|
|
|
#ifdef CONFIG_HIGHMEM
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <asm/highmem.h>
|
|
|
|
|
|
|
|
/* declarations for linux/mm/highmem.c */
|
|
|
|
unsigned int nr_free_highpages(void);
|
2018-12-28 15:34:29 +07:00
|
|
|
extern atomic_long_t _totalhigh_pages;
|
|
|
|
static inline unsigned long totalhigh_pages(void)
|
|
|
|
{
|
|
|
|
return (unsigned long)atomic_long_read(&_totalhigh_pages);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void totalhigh_pages_inc(void)
|
|
|
|
{
|
|
|
|
atomic_long_inc(&_totalhigh_pages);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void totalhigh_pages_dec(void)
|
|
|
|
{
|
|
|
|
atomic_long_dec(&_totalhigh_pages);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void totalhigh_pages_add(long count)
|
|
|
|
{
|
|
|
|
atomic_long_add(count, &_totalhigh_pages);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void totalhigh_pages_set(long val)
|
|
|
|
{
|
|
|
|
atomic_long_set(&_totalhigh_pages, val);
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-05-03 00:27:15 +07:00
|
|
|
void kmap_flush_unused(void);
|
|
|
|
|
2012-08-01 06:45:02 +07:00
|
|
|
struct page *kmap_to_page(void *addr);
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
#else /* CONFIG_HIGHMEM */
|
|
|
|
|
|
|
|
static inline unsigned int nr_free_highpages(void) { return 0; }
|
|
|
|
|
2012-08-01 06:45:02 +07:00
|
|
|
static inline struct page *kmap_to_page(void *addr)
|
|
|
|
{
|
|
|
|
return virt_to_page(addr);
|
|
|
|
}
|
|
|
|
|
2018-12-28 15:34:29 +07:00
|
|
|
static inline unsigned long totalhigh_pages(void) { return 0UL; }
|
2006-09-26 13:31:11 +07:00
|
|
|
|
2006-09-26 13:30:55 +07:00
|
|
|
#ifndef ARCH_HAS_KMAP
|
2005-04-17 05:20:36 +07:00
|
|
|
static inline void *kmap(struct page *page)
|
|
|
|
{
|
|
|
|
might_sleep();
|
|
|
|
return page_address(page);
|
|
|
|
}
|
|
|
|
|
2009-06-17 05:32:45 +07:00
|
|
|
static inline void kunmap(struct page *page)
|
|
|
|
{
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2011-11-26 09:53:39 +07:00
|
|
|
static inline void *kmap_atomic(struct page *page)
|
2007-05-02 03:33:07 +07:00
|
|
|
{
|
2015-05-11 22:52:09 +07:00
|
|
|
preempt_disable();
|
2007-05-02 03:33:07 +07:00
|
|
|
pagefault_disable();
|
|
|
|
return page_address(page);
|
|
|
|
}
|
2011-11-26 09:53:39 +07:00
|
|
|
#define kmap_atomic_prot(page, prot) kmap_atomic(page)
|
2007-05-02 03:33:07 +07:00
|
|
|
|
2010-10-27 04:21:51 +07:00
|
|
|
static inline void __kunmap_atomic(void *addr)
|
2010-08-10 07:19:03 +07:00
|
|
|
{
|
|
|
|
pagefault_enable();
|
2015-05-11 22:52:09 +07:00
|
|
|
preempt_enable();
|
2010-08-10 07:19:03 +07:00
|
|
|
}
|
|
|
|
|
2010-10-27 04:21:51 +07:00
|
|
|
#define kmap_atomic_pfn(pfn) kmap_atomic(pfn_to_page(pfn))
|
2007-05-03 00:27:15 +07:00
|
|
|
|
|
|
|
#define kmap_flush_unused() do {} while(0)
|
2006-09-26 13:30:55 +07:00
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
#endif /* CONFIG_HIGHMEM */
|
|
|
|
|
2010-10-28 05:32:57 +07:00
|
|
|
#if defined(CONFIG_HIGHMEM) || defined(CONFIG_X86_32)
|
|
|
|
|
|
|
|
DECLARE_PER_CPU(int, __kmap_atomic_idx);
|
|
|
|
|
|
|
|
static inline int kmap_atomic_idx_push(void)
|
|
|
|
{
|
2010-12-07 00:40:03 +07:00
|
|
|
int idx = __this_cpu_inc_return(__kmap_atomic_idx) - 1;
|
|
|
|
|
2010-10-28 05:32:57 +07:00
|
|
|
#ifdef CONFIG_DEBUG_HIGHMEM
|
|
|
|
WARN_ON_ONCE(in_irq() && !irqs_disabled());
|
2014-08-07 06:08:18 +07:00
|
|
|
BUG_ON(idx >= KM_TYPE_NR);
|
2010-10-28 05:32:57 +07:00
|
|
|
#endif
|
|
|
|
return idx;
|
|
|
|
}
|
|
|
|
|
2010-10-28 05:32:58 +07:00
|
|
|
static inline int kmap_atomic_idx(void)
|
|
|
|
{
|
2010-12-07 00:40:03 +07:00
|
|
|
return __this_cpu_read(__kmap_atomic_idx) - 1;
|
2010-10-28 05:32:58 +07:00
|
|
|
}
|
|
|
|
|
2010-12-07 00:40:03 +07:00
|
|
|
static inline void kmap_atomic_idx_pop(void)
|
2010-10-28 05:32:57 +07:00
|
|
|
{
|
|
|
|
#ifdef CONFIG_DEBUG_HIGHMEM
|
2010-12-07 00:40:03 +07:00
|
|
|
int idx = __this_cpu_dec_return(__kmap_atomic_idx);
|
|
|
|
|
2010-10-28 05:32:57 +07:00
|
|
|
BUG_ON(idx < 0);
|
2010-12-07 00:40:03 +07:00
|
|
|
#else
|
|
|
|
__this_cpu_dec(__kmap_atomic_idx);
|
2010-10-28 05:32:57 +07:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2010-10-27 04:21:51 +07:00
|
|
|
/*
|
|
|
|
* Prevent people trying to call kunmap_atomic() as if it were kunmap()
|
|
|
|
* kunmap_atomic() should get the return value of kmap_atomic, not the page.
|
|
|
|
*/
|
2012-06-22 22:17:53 +07:00
|
|
|
#define kunmap_atomic(addr) \
|
2011-11-25 21:08:45 +07:00
|
|
|
do { \
|
|
|
|
BUILD_BUG_ON(__same_type((addr), struct page *)); \
|
|
|
|
__kunmap_atomic(addr); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/* when CONFIG_HIGHMEM is not set these will be plain clear/copy_page */
|
2008-11-27 18:13:58 +07:00
|
|
|
#ifndef clear_user_highpage
|
2005-04-17 05:20:36 +07:00
|
|
|
static inline void clear_user_highpage(struct page *page, unsigned long vaddr)
|
|
|
|
{
|
2011-11-25 22:14:14 +07:00
|
|
|
void *addr = kmap_atomic(page);
|
2005-04-17 05:20:36 +07:00
|
|
|
clear_user_page(addr, vaddr, page);
|
2011-11-25 22:14:14 +07:00
|
|
|
kunmap_atomic(addr);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2008-11-27 18:13:58 +07:00
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
#ifndef __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE
|
2007-07-17 18:03:05 +07:00
|
|
|
/**
|
|
|
|
* __alloc_zeroed_user_highpage - Allocate a zeroed HIGHMEM page for a VMA with caller-specified movable GFP flags
|
|
|
|
* @movableflags: The GFP flags related to the pages future ability to move like __GFP_MOVABLE
|
|
|
|
* @vma: The VMA the page is to be allocated for
|
|
|
|
* @vaddr: The virtual address the page will be inserted into
|
|
|
|
*
|
|
|
|
* This function will allocate a page for a VMA but the caller is expected
|
|
|
|
* to specify via movableflags whether the page will be movable in the
|
|
|
|
* future or not
|
|
|
|
*
|
|
|
|
* An architecture may override this function by defining
|
|
|
|
* __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE and providing their own
|
|
|
|
* implementation.
|
|
|
|
*/
|
2005-04-17 05:20:36 +07:00
|
|
|
static inline struct page *
|
2007-07-17 18:03:05 +07:00
|
|
|
__alloc_zeroed_user_highpage(gfp_t movableflags,
|
|
|
|
struct vm_area_struct *vma,
|
|
|
|
unsigned long vaddr)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2007-07-17 18:03:05 +07:00
|
|
|
struct page *page = alloc_page_vma(GFP_HIGHUSER | movableflags,
|
|
|
|
vma, vaddr);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
if (page)
|
|
|
|
clear_user_highpage(page, vaddr);
|
|
|
|
|
|
|
|
return page;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-07-17 18:03:05 +07:00
|
|
|
/**
|
|
|
|
* alloc_zeroed_user_highpage_movable - Allocate a zeroed HIGHMEM page for a VMA that the caller knows can move
|
|
|
|
* @vma: The VMA the page is to be allocated for
|
|
|
|
* @vaddr: The virtual address the page will be inserted into
|
|
|
|
*
|
|
|
|
* This function will allocate a page for a VMA that the caller knows will
|
|
|
|
* be able to migrate in the future using move_pages() or reclaimed
|
|
|
|
*/
|
|
|
|
static inline struct page *
|
|
|
|
alloc_zeroed_user_highpage_movable(struct vm_area_struct *vma,
|
|
|
|
unsigned long vaddr)
|
|
|
|
{
|
|
|
|
return __alloc_zeroed_user_highpage(__GFP_MOVABLE, vma, vaddr);
|
|
|
|
}
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
static inline void clear_highpage(struct page *page)
|
|
|
|
{
|
2011-11-25 22:14:14 +07:00
|
|
|
void *kaddr = kmap_atomic(page);
|
2005-04-17 05:20:36 +07:00
|
|
|
clear_page(kaddr);
|
2011-11-25 22:14:14 +07:00
|
|
|
kunmap_atomic(kaddr);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2008-02-05 13:28:29 +07:00
|
|
|
static inline void zero_user_segments(struct page *page,
|
|
|
|
unsigned start1, unsigned end1,
|
|
|
|
unsigned start2, unsigned end2)
|
|
|
|
{
|
2011-11-25 22:14:14 +07:00
|
|
|
void *kaddr = kmap_atomic(page);
|
2008-02-05 13:28:29 +07:00
|
|
|
|
|
|
|
BUG_ON(end1 > PAGE_SIZE || end2 > PAGE_SIZE);
|
|
|
|
|
|
|
|
if (end1 > start1)
|
|
|
|
memset(kaddr + start1, 0, end1 - start1);
|
|
|
|
|
|
|
|
if (end2 > start2)
|
|
|
|
memset(kaddr + start2, 0, end2 - start2);
|
|
|
|
|
2011-11-25 22:14:14 +07:00
|
|
|
kunmap_atomic(kaddr);
|
2008-02-05 13:28:29 +07:00
|
|
|
flush_dcache_page(page);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void zero_user_segment(struct page *page,
|
|
|
|
unsigned start, unsigned end)
|
|
|
|
{
|
|
|
|
zero_user_segments(page, start, end, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void zero_user(struct page *page,
|
|
|
|
unsigned start, unsigned size)
|
|
|
|
{
|
|
|
|
zero_user_segments(page, start, start + size, 0, 0);
|
|
|
|
}
|
2007-05-09 16:35:07 +07:00
|
|
|
|
2006-12-13 00:14:54 +07:00
|
|
|
#ifndef __HAVE_ARCH_COPY_USER_HIGHPAGE
|
|
|
|
|
2006-12-13 00:14:55 +07:00
|
|
|
static inline void copy_user_highpage(struct page *to, struct page *from,
|
|
|
|
unsigned long vaddr, struct vm_area_struct *vma)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
char *vfrom, *vto;
|
|
|
|
|
2011-11-25 22:14:14 +07:00
|
|
|
vfrom = kmap_atomic(from);
|
|
|
|
vto = kmap_atomic(to);
|
2005-04-17 05:20:36 +07:00
|
|
|
copy_user_page(vto, vfrom, vaddr, to);
|
2011-11-25 22:14:14 +07:00
|
|
|
kunmap_atomic(vto);
|
|
|
|
kunmap_atomic(vfrom);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2006-12-13 00:14:54 +07:00
|
|
|
#endif
|
|
|
|
|
2018-02-22 00:15:51 +07:00
|
|
|
#ifndef __HAVE_ARCH_COPY_HIGHPAGE
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
static inline void copy_highpage(struct page *to, struct page *from)
|
|
|
|
{
|
|
|
|
char *vfrom, *vto;
|
|
|
|
|
2011-11-25 22:14:14 +07:00
|
|
|
vfrom = kmap_atomic(from);
|
|
|
|
vto = kmap_atomic(to);
|
2005-04-17 05:20:36 +07:00
|
|
|
copy_page(vto, vfrom);
|
2011-11-25 22:14:14 +07:00
|
|
|
kunmap_atomic(vto);
|
|
|
|
kunmap_atomic(vfrom);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2018-02-22 00:15:51 +07:00
|
|
|
#endif
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
#endif /* _LINUX_HIGHMEM_H */
|