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>
459 lines
13 KiB
C
459 lines
13 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* User address space access functions.
|
|
* The non-inlined parts of asm-cris/uaccess.h are here.
|
|
*
|
|
* Copyright (C) 2000, 2003 Axis Communications AB.
|
|
*
|
|
* Written by Hans-Peter Nilsson.
|
|
* Pieces used from memcpy, originally by Kenny Ranerup long time ago.
|
|
*/
|
|
|
|
#include <linux/uaccess.h>
|
|
|
|
/* Asm:s have been tweaked (within the domain of correctness) to give
|
|
satisfactory results for "gcc version 3.2.1 Axis release R53/1.53-v32".
|
|
|
|
Check regularly...
|
|
|
|
Note that for CRISv32, the PC saved at a bus-fault is the address
|
|
*at* the faulting instruction, with a special case for instructions
|
|
in delay slots: then it's the address of the branch. Note also that
|
|
in contrast to v10, a postincrement in the instruction is *not*
|
|
performed at a bus-fault; the register is seen having the original
|
|
value in fault handlers. */
|
|
|
|
|
|
/* Copy to userspace. This is based on the memcpy used for
|
|
kernel-to-kernel copying; see "string.c". */
|
|
|
|
unsigned long __copy_user(void __user *pdst, const void *psrc, unsigned long pn)
|
|
{
|
|
/* We want the parameters put in special registers.
|
|
Make sure the compiler is able to make something useful of this.
|
|
As it is now: r10 -> r13; r11 -> r11 (nop); r12 -> r12 (nop).
|
|
|
|
FIXME: Comment for old gcc version. Check.
|
|
If gcc was alright, it really would need no temporaries, and no
|
|
stack space to save stuff on. */
|
|
|
|
register char *dst __asm__ ("r13") = pdst;
|
|
register const char *src __asm__ ("r11") = psrc;
|
|
register int n __asm__ ("r12") = pn;
|
|
register int retn __asm__ ("r10") = 0;
|
|
|
|
|
|
/* When src is aligned but not dst, this makes a few extra needless
|
|
cycles. I believe it would take as many to check that the
|
|
re-alignment was unnecessary. */
|
|
if (((unsigned long) dst & 3) != 0
|
|
/* Don't align if we wouldn't copy more than a few bytes; so we
|
|
don't have to check further for overflows. */
|
|
&& n >= 3)
|
|
{
|
|
if ((unsigned long) dst & 1)
|
|
{
|
|
__asm_copy_to_user_1 (dst, src, retn);
|
|
n--;
|
|
}
|
|
|
|
if ((unsigned long) dst & 2)
|
|
{
|
|
__asm_copy_to_user_2 (dst, src, retn);
|
|
n -= 2;
|
|
}
|
|
}
|
|
|
|
/* Movem is dirt cheap. The overheap is low enough to always use the
|
|
minimum possible block size as the threshold. */
|
|
if (n >= 44)
|
|
{
|
|
/* For large copies we use 'movem'. */
|
|
|
|
/* It is not optimal to tell the compiler about clobbering any
|
|
registers; that will move the saving/restoring of those registers
|
|
to the function prologue/epilogue, and make non-movem sizes
|
|
suboptimal. */
|
|
__asm__ volatile ("\
|
|
;; Check that the register asm declaration got right. \n\
|
|
;; The GCC manual explicitly says TRT will happen. \n\
|
|
.ifnc %0%1%2%3,$r13$r11$r12$r10 \n\
|
|
.err \n\
|
|
.endif \n\
|
|
\n\
|
|
;; Save the registers we'll use in the movem process \n\
|
|
;; on the stack. \n\
|
|
subq 11*4,$sp \n\
|
|
movem $r10,[$sp] \n\
|
|
\n\
|
|
;; Now we've got this: \n\
|
|
;; r11 - src \n\
|
|
;; r13 - dst \n\
|
|
;; r12 - n \n\
|
|
\n\
|
|
;; Update n for the first loop \n\
|
|
subq 44,$r12 \n\
|
|
0: \n\
|
|
movem [$r11+],$r10 \n\
|
|
subq 44,$r12 \n\
|
|
1: bge 0b \n\
|
|
movem $r10,[$r13+] \n\
|
|
3: \n\
|
|
addq 44,$r12 ;; compensate for last loop underflowing n \n\
|
|
\n\
|
|
;; Restore registers from stack \n\
|
|
movem [$sp+],$r10 \n\
|
|
2: \n\
|
|
.section .fixup,\"ax\" \n\
|
|
4: \n\
|
|
; When failing on any of the 1..44 bytes in a chunk, we adjust back the \n\
|
|
; source pointer and just drop through to the by-16 and by-4 loops to \n\
|
|
; get the correct number of failing bytes. This necessarily means a \n\
|
|
; few extra exceptions, but invalid user pointers shouldn't happen in \n\
|
|
; time-critical code anyway. \n\
|
|
jump 3b \n\
|
|
subq 44,$r11 \n\
|
|
\n\
|
|
.previous \n\
|
|
.section __ex_table,\"a\" \n\
|
|
.dword 1b,4b \n\
|
|
.previous"
|
|
|
|
/* Outputs */ : "=r" (dst), "=r" (src), "=r" (n), "=r" (retn)
|
|
/* Inputs */ : "0" (dst), "1" (src), "2" (n), "3" (retn));
|
|
|
|
}
|
|
|
|
while (n >= 16)
|
|
{
|
|
__asm_copy_to_user_16 (dst, src, retn);
|
|
n -= 16;
|
|
}
|
|
|
|
/* Having a separate by-four loops cuts down on cache footprint.
|
|
FIXME: Test with and without; increasing switch to be 0..15. */
|
|
while (n >= 4)
|
|
{
|
|
__asm_copy_to_user_4 (dst, src, retn);
|
|
n -= 4;
|
|
}
|
|
|
|
switch (n)
|
|
{
|
|
case 0:
|
|
break;
|
|
case 1:
|
|
__asm_copy_to_user_1 (dst, src, retn);
|
|
break;
|
|
case 2:
|
|
__asm_copy_to_user_2 (dst, src, retn);
|
|
break;
|
|
case 3:
|
|
__asm_copy_to_user_3 (dst, src, retn);
|
|
break;
|
|
}
|
|
|
|
return retn;
|
|
}
|
|
EXPORT_SYMBOL(__copy_user);
|
|
|
|
/* Copy from user to kernel. The return-value is the number of bytes that were
|
|
inaccessible. */
|
|
unsigned long __copy_user_in(void *pdst, const void __user *psrc,
|
|
unsigned long pn)
|
|
{
|
|
/* We want the parameters put in special registers.
|
|
Make sure the compiler is able to make something useful of this.
|
|
As it is now: r10 -> r13; r11 -> r11 (nop); r12 -> r12 (nop).
|
|
|
|
FIXME: Comment for old gcc version. Check.
|
|
If gcc was alright, it really would need no temporaries, and no
|
|
stack space to save stuff on. */
|
|
|
|
register char *dst __asm__ ("r13") = pdst;
|
|
register const char *src __asm__ ("r11") = psrc;
|
|
register int n __asm__ ("r12") = pn;
|
|
register int retn __asm__ ("r10") = 0;
|
|
|
|
/* The best reason to align src is that we then know that a read-fault
|
|
was for aligned bytes; there's no 1..3 remaining good bytes to
|
|
pickle. */
|
|
if (((unsigned long) src & 3) != 0)
|
|
{
|
|
if (((unsigned long) src & 1) && n != 0)
|
|
{
|
|
__asm_copy_from_user_1 (dst, src, retn);
|
|
n--;
|
|
if (retn != 0)
|
|
goto exception;
|
|
}
|
|
|
|
if (((unsigned long) src & 2) && n >= 2)
|
|
{
|
|
__asm_copy_from_user_2 (dst, src, retn);
|
|
n -= 2;
|
|
if (retn != 0)
|
|
goto exception;
|
|
}
|
|
|
|
}
|
|
|
|
/* Movem is dirt cheap. The overheap is low enough to always use the
|
|
minimum possible block size as the threshold. */
|
|
if (n >= 44)
|
|
{
|
|
/* It is not optimal to tell the compiler about clobbering any
|
|
registers; that will move the saving/restoring of those registers
|
|
to the function prologue/epilogue, and make non-movem sizes
|
|
suboptimal. */
|
|
__asm__ volatile ("\
|
|
.ifnc %0%1%2%3,$r13$r11$r12$r10 \n\
|
|
.err \n\
|
|
.endif \n\
|
|
\n\
|
|
;; Save the registers we'll use in the movem process \n\
|
|
;; on the stack. \n\
|
|
subq 11*4,$sp \n\
|
|
movem $r10,[$sp] \n\
|
|
\n\
|
|
;; Now we've got this: \n\
|
|
;; r11 - src \n\
|
|
;; r13 - dst \n\
|
|
;; r12 - n \n\
|
|
\n\
|
|
;; Update n for the first loop \n\
|
|
subq 44,$r12 \n\
|
|
0: \n\
|
|
movem [$r11+],$r10 \n\
|
|
\n\
|
|
subq 44,$r12 \n\
|
|
bge 0b \n\
|
|
movem $r10,[$r13+] \n\
|
|
\n\
|
|
4: \n\
|
|
addq 44,$r12 ;; compensate for last loop underflowing n \n\
|
|
\n\
|
|
;; Restore registers from stack \n\
|
|
movem [$sp+],$r10 \n\
|
|
.section .fixup,\"ax\" \n\
|
|
\n\
|
|
;; Do not jump back into the loop if we fail. For some uses, we get a \n\
|
|
;; page fault somewhere on the line. Without checking for page limits, \n\
|
|
;; we don't know where, but we need to copy accurately and keep an \n\
|
|
;; accurate count; not just clear the whole line. To do that, we fall \n\
|
|
;; down in the code below, proceeding with smaller amounts. It should \n\
|
|
;; be kept in mind that we have to cater to code like what at one time \n\
|
|
;; was in fs/super.c: \n\
|
|
;; i = size - copy_from_user((void *)page, data, size); \n\
|
|
;; which would cause repeated faults while clearing the remainder of \n\
|
|
;; the SIZE bytes at PAGE after the first fault. \n\
|
|
;; A caveat here is that we must not fall through from a failing page \n\
|
|
;; to a valid page. \n\
|
|
\n\
|
|
3: \n\
|
|
jump 4b ;; Fall through, pretending the fault didn't happen. \n\
|
|
nop \n\
|
|
\n\
|
|
.previous \n\
|
|
.section __ex_table,\"a\" \n\
|
|
.dword 0b,3b \n\
|
|
.previous"
|
|
|
|
/* Outputs */ : "=r" (dst), "=r" (src), "=r" (n), "=r" (retn)
|
|
/* Inputs */ : "0" (dst), "1" (src), "2" (n), "3" (retn));
|
|
}
|
|
|
|
/* Either we directly start copying here, using dword copying in a loop,
|
|
or we copy as much as possible with 'movem' and then the last block
|
|
(<44 bytes) is copied here. This will work since 'movem' will have
|
|
updated src, dst and n. (Except with failing src.)
|
|
|
|
Since we want to keep src accurate, we can't use
|
|
__asm_copy_from_user_N with N != (1, 2, 4); it updates dst and
|
|
retn, but not src (by design; it's value is ignored elsewhere). */
|
|
|
|
while (n >= 4)
|
|
{
|
|
__asm_copy_from_user_4 (dst, src, retn);
|
|
n -= 4;
|
|
|
|
if (retn)
|
|
goto exception;
|
|
}
|
|
|
|
/* If we get here, there were no memory read faults. */
|
|
switch (n)
|
|
{
|
|
/* These copies are at least "naturally aligned" (so we don't have
|
|
to check each byte), due to the src alignment code before the
|
|
movem loop. The *_3 case *will* get the correct count for retn. */
|
|
case 0:
|
|
/* This case deliberately left in (if you have doubts check the
|
|
generated assembly code). */
|
|
break;
|
|
case 1:
|
|
__asm_copy_from_user_1 (dst, src, retn);
|
|
break;
|
|
case 2:
|
|
__asm_copy_from_user_2 (dst, src, retn);
|
|
break;
|
|
case 3:
|
|
__asm_copy_from_user_3 (dst, src, retn);
|
|
break;
|
|
}
|
|
|
|
/* If we get here, retn correctly reflects the number of failing
|
|
bytes. */
|
|
return retn;
|
|
|
|
exception:
|
|
return retn + n;
|
|
}
|
|
EXPORT_SYMBOL(__copy_user_in);
|
|
|
|
/* Zero userspace. */
|
|
unsigned long __do_clear_user(void __user *pto, unsigned long pn)
|
|
{
|
|
/* We want the parameters put in special registers.
|
|
Make sure the compiler is able to make something useful of this.
|
|
As it is now: r10 -> r13; r11 -> r11 (nop); r12 -> r12 (nop).
|
|
|
|
FIXME: Comment for old gcc version. Check.
|
|
If gcc was alright, it really would need no temporaries, and no
|
|
stack space to save stuff on. */
|
|
|
|
register char *dst __asm__ ("r13") = pto;
|
|
register int n __asm__ ("r12") = pn;
|
|
register int retn __asm__ ("r10") = 0;
|
|
|
|
|
|
if (((unsigned long) dst & 3) != 0
|
|
/* Don't align if we wouldn't copy more than a few bytes. */
|
|
&& n >= 3)
|
|
{
|
|
if ((unsigned long) dst & 1)
|
|
{
|
|
__asm_clear_1 (dst, retn);
|
|
n--;
|
|
}
|
|
|
|
if ((unsigned long) dst & 2)
|
|
{
|
|
__asm_clear_2 (dst, retn);
|
|
n -= 2;
|
|
}
|
|
}
|
|
|
|
/* Decide which copying method to use.
|
|
FIXME: This number is from the "ordinary" kernel memset. */
|
|
if (n >= 48)
|
|
{
|
|
/* For large clears we use 'movem' */
|
|
|
|
/* It is not optimal to tell the compiler about clobbering any
|
|
call-saved registers; that will move the saving/restoring of
|
|
those registers to the function prologue/epilogue, and make
|
|
non-movem sizes suboptimal.
|
|
|
|
This method is not foolproof; it assumes that the "asm reg"
|
|
declarations at the beginning of the function really are used
|
|
here (beware: they may be moved to temporary registers).
|
|
This way, we do not have to save/move the registers around into
|
|
temporaries; we can safely use them straight away.
|
|
|
|
If you want to check that the allocation was right; then
|
|
check the equalities in the first comment. It should say
|
|
something like "r13=r13, r11=r11, r12=r12". */
|
|
__asm__ volatile ("\
|
|
.ifnc %0%1%2,$r13$r12$r10 \n\
|
|
.err \n\
|
|
.endif \n\
|
|
\n\
|
|
;; Save the registers we'll clobber in the movem process \n\
|
|
;; on the stack. Don't mention them to gcc, it will only be \n\
|
|
;; upset. \n\
|
|
subq 11*4,$sp \n\
|
|
movem $r10,[$sp] \n\
|
|
\n\
|
|
clear.d $r0 \n\
|
|
clear.d $r1 \n\
|
|
clear.d $r2 \n\
|
|
clear.d $r3 \n\
|
|
clear.d $r4 \n\
|
|
clear.d $r5 \n\
|
|
clear.d $r6 \n\
|
|
clear.d $r7 \n\
|
|
clear.d $r8 \n\
|
|
clear.d $r9 \n\
|
|
clear.d $r10 \n\
|
|
clear.d $r11 \n\
|
|
\n\
|
|
;; Now we've got this: \n\
|
|
;; r13 - dst \n\
|
|
;; r12 - n \n\
|
|
\n\
|
|
;; Update n for the first loop \n\
|
|
subq 12*4,$r12 \n\
|
|
0: \n\
|
|
subq 12*4,$r12 \n\
|
|
1: \n\
|
|
bge 0b \n\
|
|
movem $r11,[$r13+] \n\
|
|
\n\
|
|
addq 12*4,$r12 ;; compensate for last loop underflowing n \n\
|
|
\n\
|
|
;; Restore registers from stack \n\
|
|
movem [$sp+],$r10 \n\
|
|
2: \n\
|
|
.section .fixup,\"ax\" \n\
|
|
3: \n\
|
|
movem [$sp],$r10 \n\
|
|
addq 12*4,$r10 \n\
|
|
addq 12*4,$r13 \n\
|
|
movem $r10,[$sp] \n\
|
|
jump 0b \n\
|
|
clear.d $r10 \n\
|
|
\n\
|
|
.previous \n\
|
|
.section __ex_table,\"a\" \n\
|
|
.dword 1b,3b \n\
|
|
.previous"
|
|
|
|
/* Outputs */ : "=r" (dst), "=r" (n), "=r" (retn)
|
|
/* Inputs */ : "0" (dst), "1" (n), "2" (retn)
|
|
/* Clobber */ : "r11");
|
|
}
|
|
|
|
while (n >= 16)
|
|
{
|
|
__asm_clear_16 (dst, retn);
|
|
n -= 16;
|
|
}
|
|
|
|
/* Having a separate by-four loops cuts down on cache footprint.
|
|
FIXME: Test with and without; increasing switch to be 0..15. */
|
|
while (n >= 4)
|
|
{
|
|
__asm_clear_4 (dst, retn);
|
|
n -= 4;
|
|
}
|
|
|
|
switch (n)
|
|
{
|
|
case 0:
|
|
break;
|
|
case 1:
|
|
__asm_clear_1 (dst, retn);
|
|
break;
|
|
case 2:
|
|
__asm_clear_2 (dst, retn);
|
|
break;
|
|
case 3:
|
|
__asm_clear_3 (dst, retn);
|
|
break;
|
|
}
|
|
|
|
return retn;
|
|
}
|
|
EXPORT_SYMBOL(__do_clear_user);
|