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 15:07:57 +01:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2016-04-29 23:25:41 +10:00
|
|
|
#ifndef _ASM_POWERPC_BOOK3S_32_MMU_HASH_H_
|
|
|
|
#define _ASM_POWERPC_BOOK3S_32_MMU_HASH_H_
|
2018-11-29 14:07:01 +00:00
|
|
|
|
2007-06-13 14:52:54 +10:00
|
|
|
/*
|
|
|
|
* 32-bit hash table MMU support
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* BATs
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Block size masks */
|
|
|
|
#define BL_128K 0x000
|
|
|
|
#define BL_256K 0x001
|
|
|
|
#define BL_512K 0x003
|
|
|
|
#define BL_1M 0x007
|
|
|
|
#define BL_2M 0x00F
|
|
|
|
#define BL_4M 0x01F
|
|
|
|
#define BL_8M 0x03F
|
|
|
|
#define BL_16M 0x07F
|
|
|
|
#define BL_32M 0x0FF
|
|
|
|
#define BL_64M 0x1FF
|
|
|
|
#define BL_128M 0x3FF
|
|
|
|
#define BL_256M 0x7FF
|
|
|
|
|
|
|
|
/* BAT Access Protection */
|
|
|
|
#define BPP_XX 0x00 /* No access */
|
|
|
|
#define BPP_RX 0x01 /* Read only */
|
|
|
|
#define BPP_RW 0x02 /* Read/write */
|
|
|
|
|
|
|
|
#ifndef __ASSEMBLY__
|
2008-06-14 09:41:42 +10:00
|
|
|
/* Contort a phys_addr_t into the right format/bits for a BAT */
|
|
|
|
#ifdef CONFIG_PHYS_64BIT
|
|
|
|
#define BAT_PHYS_ADDR(x) ((u32)((x & 0x00000000fffe0000ULL) | \
|
|
|
|
((x & 0x0000000e00000000ULL) >> 24) | \
|
|
|
|
((x & 0x0000000100000000ULL) >> 30)))
|
2018-12-03 17:40:25 +00:00
|
|
|
#define PHYS_BAT_ADDR(x) (((u64)(x) & 0x00000000fffe0000ULL) | \
|
|
|
|
(((u64)(x) << 24) & 0x0000000e00000000ULL) | \
|
|
|
|
(((u64)(x) << 30) & 0x0000000100000000ULL))
|
2008-06-14 09:41:42 +10:00
|
|
|
#else
|
|
|
|
#define BAT_PHYS_ADDR(x) (x)
|
2018-12-03 17:40:25 +00:00
|
|
|
#define PHYS_BAT_ADDR(x) ((x) & 0xfffe0000)
|
2008-06-14 09:41:42 +10:00
|
|
|
#endif
|
|
|
|
|
2007-06-13 14:52:56 +10:00
|
|
|
struct ppc_bat {
|
2008-06-14 09:41:43 +10:00
|
|
|
u32 batu;
|
|
|
|
u32 batl;
|
2007-06-13 14:52:56 +10:00
|
|
|
};
|
2007-06-13 14:52:54 +10:00
|
|
|
#endif /* !__ASSEMBLY__ */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Hash table
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Values for PP (assumes Ks=0, Kp=1) */
|
|
|
|
#define PP_RWXX 0 /* Supervisor read/write, User none */
|
|
|
|
#define PP_RWRX 1 /* Supervisor read/write, User read */
|
|
|
|
#define PP_RWRW 2 /* Supervisor read/write, User read/write */
|
|
|
|
#define PP_RXRX 3 /* Supervisor read, User read */
|
|
|
|
|
2019-03-11 08:30:35 +00:00
|
|
|
/* Values for Segment Registers */
|
|
|
|
#define SR_NX 0x10000000 /* No Execute */
|
2019-03-11 08:30:36 +00:00
|
|
|
#define SR_KP 0x20000000 /* User key */
|
|
|
|
#define SR_KS 0x40000000 /* Supervisor key */
|
2019-03-11 08:30:35 +00:00
|
|
|
|
powerpc/32s: Do kuep_lock() and kuep_unlock() in assembly
When interrupt and syscall entries where converted to C, KUEP locking
and unlocking was also converted. It improved performance by unrolling
the loop, and allowed easily implementing boot time deactivation of
KUEP.
However, null_syscall selftest shows that KUEP is still heavy
(361 cycles with KUEP, 212 cycles without).
A way to improve more is to group 'mtsr's together, instead of
repeating 'addi' + 'mtsr' several times.
In order to do that, more registers need to be available. In C, GCC
will always be able to provide the requested number of registers, but
at the cost of saving some data on the stack, which is counter
performant here.
So let's do it in assembly, when we have full control of which
register can be used. It also has the advantage of locking earlier
and unlocking later and it helps GCC generating less tricky code.
The only drawback is to make boot time deactivation less straight
forward and require 'hand' instruction patching.
Group 'mtsr's by 4.
With this change, null_syscall selftest reports 336 cycles. Without
the change it was 361 cycles, that's a 7% reduction.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/115cb279e9b9948dfd93a065e047081c59e3a2a6.1634627931.git.christophe.leroy@csgroup.eu
2021-10-19 09:29:17 +02:00
|
|
|
#ifdef __ASSEMBLY__
|
|
|
|
|
|
|
|
#include <asm/asm-offsets.h>
|
|
|
|
|
|
|
|
.macro uus_addi sr reg1 reg2 imm
|
|
|
|
.if NUM_USER_SEGMENTS > \sr
|
|
|
|
addi \reg1,\reg2,\imm
|
|
|
|
.endif
|
|
|
|
.endm
|
|
|
|
|
|
|
|
.macro uus_mtsr sr reg1
|
|
|
|
.if NUM_USER_SEGMENTS > \sr
|
|
|
|
mtsr \sr, \reg1
|
|
|
|
.endif
|
|
|
|
.endm
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This isync() shouldn't be necessary as the kernel is not excepted to run
|
|
|
|
* any instruction in userspace soon after the update of segments and 'rfi'
|
|
|
|
* instruction is used to return to userspace, but hash based cores
|
|
|
|
* (at least G3) seem to exhibit a random behaviour when the 'isync' is not
|
|
|
|
* there. 603 cores don't have this behaviour so don't do the 'isync' as it
|
|
|
|
* saves several CPU cycles.
|
|
|
|
*/
|
|
|
|
.macro uus_isync
|
|
|
|
#ifdef CONFIG_PPC_BOOK3S_604
|
|
|
|
BEGIN_MMU_FTR_SECTION
|
|
|
|
isync
|
|
|
|
END_MMU_FTR_SECTION_IFSET(MMU_FTR_HPTE_TABLE)
|
|
|
|
#endif
|
|
|
|
.endm
|
|
|
|
|
|
|
|
.macro update_user_segments_by_4 tmp1 tmp2 tmp3 tmp4
|
|
|
|
uus_addi 1, \tmp2, \tmp1, 0x111
|
|
|
|
uus_addi 2, \tmp3, \tmp1, 0x222
|
|
|
|
uus_addi 3, \tmp4, \tmp1, 0x333
|
|
|
|
|
|
|
|
uus_mtsr 0, \tmp1
|
|
|
|
uus_mtsr 1, \tmp2
|
|
|
|
uus_mtsr 2, \tmp3
|
|
|
|
uus_mtsr 3, \tmp4
|
|
|
|
|
|
|
|
uus_addi 4, \tmp1, \tmp1, 0x444
|
|
|
|
uus_addi 5, \tmp2, \tmp2, 0x444
|
|
|
|
uus_addi 6, \tmp3, \tmp3, 0x444
|
|
|
|
uus_addi 7, \tmp4, \tmp4, 0x444
|
|
|
|
|
|
|
|
uus_mtsr 4, \tmp1
|
|
|
|
uus_mtsr 5, \tmp2
|
|
|
|
uus_mtsr 6, \tmp3
|
|
|
|
uus_mtsr 7, \tmp4
|
|
|
|
|
|
|
|
uus_addi 8, \tmp1, \tmp1, 0x444
|
|
|
|
uus_addi 9, \tmp2, \tmp2, 0x444
|
|
|
|
uus_addi 10, \tmp3, \tmp3, 0x444
|
|
|
|
uus_addi 11, \tmp4, \tmp4, 0x444
|
|
|
|
|
|
|
|
uus_mtsr 8, \tmp1
|
|
|
|
uus_mtsr 9, \tmp2
|
|
|
|
uus_mtsr 10, \tmp3
|
|
|
|
uus_mtsr 11, \tmp4
|
|
|
|
|
|
|
|
uus_addi 12, \tmp1, \tmp1, 0x444
|
|
|
|
uus_addi 13, \tmp2, \tmp2, 0x444
|
|
|
|
uus_addi 14, \tmp3, \tmp3, 0x444
|
|
|
|
uus_addi 15, \tmp4, \tmp4, 0x444
|
|
|
|
|
|
|
|
uus_mtsr 12, \tmp1
|
|
|
|
uus_mtsr 13, \tmp2
|
|
|
|
uus_mtsr 14, \tmp3
|
|
|
|
uus_mtsr 15, \tmp4
|
|
|
|
|
|
|
|
uus_isync
|
|
|
|
.endm
|
|
|
|
|
|
|
|
#else
|
2007-06-13 14:52:54 +10:00
|
|
|
|
2021-06-03 08:41:38 +00:00
|
|
|
/*
|
|
|
|
* This macro defines the mapping from contexts to VSIDs (virtual
|
|
|
|
* segment IDs). We use a skew on both the context and the high 4 bits
|
|
|
|
* of the 32-bit virtual address (the "effective segment ID") in order
|
|
|
|
* to spread out the entries in the MMU hash table. Note, if this
|
|
|
|
* function is changed then hash functions will have to be
|
|
|
|
* changed to correspond.
|
|
|
|
*/
|
|
|
|
#define CTX_TO_VSID(c, id) ((((c) * (897 * 16)) + (id * 0x111)) & 0xffffff)
|
|
|
|
|
2009-08-24 06:15:36 +00:00
|
|
|
/*
|
|
|
|
* Hardware Page Table Entry
|
|
|
|
* Note that the xpn and x bitfields are used only by processors that
|
|
|
|
* support extended addressing; otherwise, those bits are reserved.
|
|
|
|
*/
|
2007-06-13 14:52:56 +10:00
|
|
|
struct hash_pte {
|
2007-06-13 14:52:54 +10:00
|
|
|
unsigned long v:1; /* Entry is valid */
|
|
|
|
unsigned long vsid:24; /* Virtual segment identifier */
|
|
|
|
unsigned long h:1; /* Hash algorithm indicator */
|
|
|
|
unsigned long api:6; /* Abbreviated page index */
|
|
|
|
unsigned long rpn:20; /* Real (physical) page number */
|
2009-08-24 06:15:36 +00:00
|
|
|
unsigned long xpn:3; /* Real page number bits 0-2, optional */
|
2007-06-13 14:52:54 +10:00
|
|
|
unsigned long r:1; /* Referenced */
|
|
|
|
unsigned long c:1; /* Changed */
|
|
|
|
unsigned long w:1; /* Write-thru cache mode */
|
|
|
|
unsigned long i:1; /* Cache inhibited */
|
|
|
|
unsigned long m:1; /* Memory coherence */
|
|
|
|
unsigned long g:1; /* Guarded */
|
2009-08-24 06:15:36 +00:00
|
|
|
unsigned long x:1; /* Real page number bit 3, optional */
|
2007-06-13 14:52:54 +10:00
|
|
|
unsigned long pp:2; /* Page protection */
|
2007-06-13 14:52:56 +10:00
|
|
|
};
|
2007-06-13 14:52:54 +10:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
unsigned long id;
|
2021-10-19 09:29:18 +02:00
|
|
|
unsigned long sr0;
|
2020-09-27 09:16:29 +00:00
|
|
|
void __user *vdso;
|
2007-06-13 14:52:54 +10:00
|
|
|
} mm_context_t;
|
|
|
|
|
2021-10-19 09:29:18 +02:00
|
|
|
#ifdef CONFIG_PPC_KUEP
|
|
|
|
#define INIT_MM_CONTEXT(mm) .context.sr0 = SR_NX
|
|
|
|
#endif
|
|
|
|
|
2019-02-21 19:08:48 +00:00
|
|
|
void update_bats(void);
|
2021-01-25 17:53:38 +08:00
|
|
|
static inline void cleanup_cpu_mmu_context(void) { }
|
2019-02-21 19:08:48 +00:00
|
|
|
|
2018-11-09 17:33:24 +00:00
|
|
|
/* patch sites */
|
|
|
|
extern s32 patch__hash_page_A0, patch__hash_page_A1, patch__hash_page_A2;
|
|
|
|
extern s32 patch__hash_page_B, patch__hash_page_C;
|
|
|
|
extern s32 patch__flush_hash_A0, patch__flush_hash_A1, patch__flush_hash_A2;
|
|
|
|
extern s32 patch__flush_hash_B;
|
|
|
|
|
2021-06-03 08:41:37 +00:00
|
|
|
#include <asm/reg.h>
|
|
|
|
#include <asm/task_size_32.h>
|
|
|
|
|
2021-06-03 08:41:40 +00:00
|
|
|
static __always_inline void update_user_segment(u32 n, u32 val)
|
|
|
|
{
|
|
|
|
if (n << 28 < TASK_SIZE)
|
|
|
|
mtsr(val + n * 0x111, n << 28);
|
|
|
|
}
|
2021-06-03 08:41:37 +00:00
|
|
|
|
|
|
|
static __always_inline void update_user_segments(u32 val)
|
|
|
|
{
|
2021-06-03 08:41:40 +00:00
|
|
|
val &= 0xf0ffffff;
|
|
|
|
|
|
|
|
update_user_segment(0, val);
|
|
|
|
update_user_segment(1, val);
|
|
|
|
update_user_segment(2, val);
|
|
|
|
update_user_segment(3, val);
|
|
|
|
update_user_segment(4, val);
|
|
|
|
update_user_segment(5, val);
|
|
|
|
update_user_segment(6, val);
|
|
|
|
update_user_segment(7, val);
|
|
|
|
update_user_segment(8, val);
|
|
|
|
update_user_segment(9, val);
|
|
|
|
update_user_segment(10, val);
|
|
|
|
update_user_segment(11, val);
|
|
|
|
update_user_segment(12, val);
|
|
|
|
update_user_segment(13, val);
|
|
|
|
update_user_segment(14, val);
|
|
|
|
update_user_segment(15, val);
|
2021-06-03 08:41:37 +00:00
|
|
|
}
|
|
|
|
|
2022-01-10 15:29:25 +00:00
|
|
|
int __init find_free_bat(void);
|
|
|
|
unsigned int bat_block_size(unsigned long base, unsigned long top);
|
2007-06-13 14:52:54 +10:00
|
|
|
#endif /* !__ASSEMBLY__ */
|
|
|
|
|
2009-07-23 23:15:47 +00:00
|
|
|
/* We happily ignore the smaller BATs on 601, we don't actually use
|
|
|
|
* those definitions on hash32 at the moment anyway
|
|
|
|
*/
|
|
|
|
#define mmu_virtual_psize MMU_PAGE_4K
|
|
|
|
#define mmu_linear_psize MMU_PAGE_256M
|
|
|
|
|
2016-04-29 23:25:41 +10:00
|
|
|
#endif /* _ASM_POWERPC_BOOK3S_32_MMU_HASH_H_ */
|