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 14:07:57 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2008-01-30 12:31:51 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 1994 Linus Torvalds
|
|
|
|
*
|
|
|
|
* Pentium III FXSR, SSE support
|
|
|
|
* General FPU state handling cleanups
|
|
|
|
* Gareth Hughes <gareth@valinux.com>, May 2000
|
|
|
|
* x86-64 work by Andi Kleen 2002
|
|
|
|
*/
|
|
|
|
|
2015-04-24 00:46:00 +00:00
|
|
|
#ifndef _ASM_X86_FPU_API_H
|
|
|
|
#define _ASM_X86_FPU_API_H
|
2019-04-03 16:41:52 +00:00
|
|
|
#include <linux/bottom_half.h>
|
2008-01-30 12:31:51 +00:00
|
|
|
|
2021-10-15 01:16:12 +00:00
|
|
|
#include <asm/fpu/types.h>
|
|
|
|
|
2012-09-20 18:01:49 +00:00
|
|
|
/*
|
2018-11-29 15:02:10 +00:00
|
|
|
* Use kernel_fpu_begin/end() if you intend to use FPU in kernel context. It
|
|
|
|
* disables preemption so be careful if you intend to use it for long periods
|
|
|
|
* of time.
|
2021-01-21 05:09:48 +00:00
|
|
|
* If you intend to use the FPU in irq/softirq you need to check first with
|
2018-11-29 15:02:10 +00:00
|
|
|
* irq_fpu_usable() if it is possible.
|
2012-09-20 18:01:49 +00:00
|
|
|
*/
|
2021-01-21 05:09:48 +00:00
|
|
|
|
|
|
|
/* Kernel FPU states to initialize in kernel_fpu_begin_mask() */
|
|
|
|
#define KFPU_387 _BITUL(0) /* 387 state will be initialized */
|
|
|
|
#define KFPU_MXCSR _BITUL(1) /* MXCSR will be initialized */
|
|
|
|
|
|
|
|
extern void kernel_fpu_begin_mask(unsigned int kfpu_mask);
|
2015-04-26 10:07:18 +00:00
|
|
|
extern void kernel_fpu_end(void);
|
2015-04-26 14:56:05 +00:00
|
|
|
extern bool irq_fpu_usable(void);
|
2019-04-03 16:41:52 +00:00
|
|
|
extern void fpregs_mark_activate(void);
|
2008-01-30 12:31:51 +00:00
|
|
|
|
2021-01-21 05:09:48 +00:00
|
|
|
/* Code that is unaware of kernel_fpu_begin_mask() can use this */
|
|
|
|
static inline void kernel_fpu_begin(void)
|
|
|
|
{
|
2021-01-21 05:09:51 +00:00
|
|
|
#ifdef CONFIG_X86_64
|
|
|
|
/*
|
|
|
|
* Any 64-bit code that uses 387 instructions must explicitly request
|
|
|
|
* KFPU_387.
|
|
|
|
*/
|
|
|
|
kernel_fpu_begin_mask(KFPU_MXCSR);
|
|
|
|
#else
|
|
|
|
/*
|
|
|
|
* 32-bit kernel code may use 387 operations as well as SSE2, etc,
|
|
|
|
* as long as it checks that the CPU has the required capability.
|
|
|
|
*/
|
2021-01-21 05:09:48 +00:00
|
|
|
kernel_fpu_begin_mask(KFPU_387 | KFPU_MXCSR);
|
2021-01-21 05:09:51 +00:00
|
|
|
#endif
|
2021-01-21 05:09:48 +00:00
|
|
|
}
|
|
|
|
|
2019-04-03 16:41:52 +00:00
|
|
|
/*
|
|
|
|
* Use fpregs_lock() while editing CPU's FPU registers or fpu->state.
|
|
|
|
* A context switch will (and softirq might) save CPU's FPU registers to
|
|
|
|
* fpu->state and set TIF_NEED_FPU_LOAD leaving CPU's FPU registers in
|
|
|
|
* a random state.
|
2020-10-27 10:09:50 +00:00
|
|
|
*
|
|
|
|
* local_bh_disable() protects against both preemption and soft interrupts
|
|
|
|
* on !RT kernels.
|
2020-10-27 10:09:51 +00:00
|
|
|
*
|
|
|
|
* On RT kernels local_bh_disable() is not sufficient because it only
|
|
|
|
* serializes soft interrupt related sections via a local lock, but stays
|
|
|
|
* preemptible. Disabling preemption is the right choice here as bottom
|
|
|
|
* half processing is always in thread context on RT kernels so it
|
|
|
|
* implicitly prevents bottom half processing as well.
|
|
|
|
*
|
|
|
|
* Disabling preemption also serializes against kernel_fpu_begin().
|
2019-04-03 16:41:52 +00:00
|
|
|
*/
|
2019-04-03 16:41:38 +00:00
|
|
|
static inline void fpregs_lock(void)
|
|
|
|
{
|
2020-10-27 10:09:51 +00:00
|
|
|
if (!IS_ENABLED(CONFIG_PREEMPT_RT))
|
|
|
|
local_bh_disable();
|
|
|
|
else
|
|
|
|
preempt_disable();
|
2019-04-03 16:41:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void fpregs_unlock(void)
|
|
|
|
{
|
2020-10-27 10:09:51 +00:00
|
|
|
if (!IS_ENABLED(CONFIG_PREEMPT_RT))
|
|
|
|
local_bh_enable();
|
|
|
|
else
|
|
|
|
preempt_enable();
|
2019-04-03 16:41:38 +00:00
|
|
|
}
|
|
|
|
|
2019-04-03 16:41:52 +00:00
|
|
|
#ifdef CONFIG_X86_DEBUG_FPU
|
|
|
|
extern void fpregs_assert_state_consistent(void);
|
|
|
|
#else
|
|
|
|
static inline void fpregs_assert_state_consistent(void) { }
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Load the task FPU state before returning to userspace.
|
|
|
|
*/
|
|
|
|
extern void switch_fpu_return(void);
|
|
|
|
|
2015-04-28 06:51:17 +00:00
|
|
|
/*
|
|
|
|
* Query the presence of one or more xfeatures. Works on any legacy CPU as well.
|
|
|
|
*
|
|
|
|
* If 'feature_name' is set then put a human-readable description of
|
|
|
|
* the feature there as well - this can be used to print error (or success)
|
|
|
|
* messages.
|
|
|
|
*/
|
|
|
|
extern int cpu_has_xfeatures(u64 xfeatures_mask, const char **feature_name);
|
|
|
|
|
2020-09-15 16:30:13 +00:00
|
|
|
/*
|
|
|
|
* Tasks that are not using SVA have mm->pasid set to zero to note that they
|
|
|
|
* will not have the valid bit set in MSR_IA32_PASID while they are running.
|
|
|
|
*/
|
|
|
|
#define PASID_DISABLED 0
|
|
|
|
|
|
|
|
static inline void update_pasid(void) { }
|
x86/cpufeatures: Force disable X86_FEATURE_ENQCMD and remove update_pasid()
While digesting the XSAVE-related horrors which got introduced with
the supervisor/user split, the recent addition of ENQCMD-related
functionality got on the radar and turned out to be similarly broken.
update_pasid(), which is only required when X86_FEATURE_ENQCMD is
available, is invoked from two places:
1) From switch_to() for the incoming task
2) Via a SMP function call from the IOMMU/SMV code
#1 is half-ways correct as it hacks around the brokenness of get_xsave_addr()
by enforcing the state to be 'present', but all the conditionals in that
code are completely pointless for that.
Also the invocation is just useless overhead because at that point
it's guaranteed that TIF_NEED_FPU_LOAD is set on the incoming task
and all of this can be handled at return to user space.
#2 is broken beyond repair. The comment in the code claims that it is safe
to invoke this in an IPI, but that's just wishful thinking.
FPU state of a running task is protected by fregs_lock() which is
nothing else than a local_bh_disable(). As BH-disabled regions run
usually with interrupts enabled the IPI can hit a code section which
modifies FPU state and there is absolutely no guarantee that any of the
assumptions which are made for the IPI case is true.
Also the IPI is sent to all CPUs in mm_cpumask(mm), but the IPI is
invoked with a NULL pointer argument, so it can hit a completely
unrelated task and unconditionally force an update for nothing.
Worse, it can hit a kernel thread which operates on a user space
address space and set a random PASID for it.
The offending commit does not cleanly revert, but it's sufficient to
force disable X86_FEATURE_ENQCMD and to remove the broken update_pasid()
code to make this dysfunctional all over the place. Anything more
complex would require more surgery and none of the related functions
outside of the x86 core code are blatantly wrong, so removing those
would be overkill.
As nothing enables the PASID bit in the IA32_XSS MSR yet, which is
required to make this actually work, this cannot result in a regression
except for related out of tree train-wrecks, but they are broken already
today.
Fixes: 20f0afd1fb3d ("x86/mmu: Allocate/free a PASID")
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-by: Andy Lutomirski <luto@kernel.org>
Cc: stable@vger.kernel.org
Link: https://lkml.kernel.org/r/87mtsd6gr9.ffs@nanos.tec.linutronix.de
2021-05-29 09:17:30 +00:00
|
|
|
|
2021-10-15 01:16:12 +00:00
|
|
|
/* fpstate-related functions which are exported to KVM */
|
|
|
|
extern void fpu_init_fpstate_user(struct fpu *fpu);
|
|
|
|
|
|
|
|
/* KVM specific functions */
|
|
|
|
extern void fpu_swap_kvm_fpu(struct fpu *save, struct fpu *rstor, u64 restore_mask);
|
|
|
|
|
2015-04-24 00:46:00 +00:00
|
|
|
#endif /* _ASM_X86_FPU_API_H */
|