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-06-27 17:58:02 +00:00
|
|
|
#ifndef ASM_KVM_CACHE_REGS_H
|
|
|
|
#define ASM_KVM_CACHE_REGS_H
|
|
|
|
|
2018-12-03 21:52:54 +00:00
|
|
|
#include <linux/kvm_host.h>
|
|
|
|
|
2010-01-21 13:31:51 +00:00
|
|
|
#define KVM_POSSIBLE_CR0_GUEST_BITS X86_CR0_TS
|
|
|
|
#define KVM_POSSIBLE_CR4_GUEST_BITS \
|
|
|
|
(X86_CR4_PVI | X86_CR4_DE | X86_CR4_PCE | X86_CR4_OSFXSR \
|
2020-09-30 04:16:59 +00:00
|
|
|
| X86_CR4_OSXMMEXCPT | X86_CR4_PGE | X86_CR4_TSD | X86_CR4_FSGSBASE)
|
2010-01-21 13:31:51 +00:00
|
|
|
|
2019-04-30 17:36:17 +00:00
|
|
|
#define BUILD_KVM_GPR_ACCESSORS(lname, uname) \
|
|
|
|
static __always_inline unsigned long kvm_##lname##_read(struct kvm_vcpu *vcpu)\
|
|
|
|
{ \
|
|
|
|
return vcpu->arch.regs[VCPU_REGS_##uname]; \
|
|
|
|
} \
|
|
|
|
static __always_inline void kvm_##lname##_write(struct kvm_vcpu *vcpu, \
|
|
|
|
unsigned long val) \
|
|
|
|
{ \
|
|
|
|
vcpu->arch.regs[VCPU_REGS_##uname] = val; \
|
|
|
|
}
|
|
|
|
BUILD_KVM_GPR_ACCESSORS(rax, RAX)
|
|
|
|
BUILD_KVM_GPR_ACCESSORS(rbx, RBX)
|
|
|
|
BUILD_KVM_GPR_ACCESSORS(rcx, RCX)
|
|
|
|
BUILD_KVM_GPR_ACCESSORS(rdx, RDX)
|
|
|
|
BUILD_KVM_GPR_ACCESSORS(rbp, RBP)
|
|
|
|
BUILD_KVM_GPR_ACCESSORS(rsi, RSI)
|
|
|
|
BUILD_KVM_GPR_ACCESSORS(rdi, RDI)
|
|
|
|
#ifdef CONFIG_X86_64
|
|
|
|
BUILD_KVM_GPR_ACCESSORS(r8, R8)
|
|
|
|
BUILD_KVM_GPR_ACCESSORS(r9, R9)
|
|
|
|
BUILD_KVM_GPR_ACCESSORS(r10, R10)
|
|
|
|
BUILD_KVM_GPR_ACCESSORS(r11, R11)
|
|
|
|
BUILD_KVM_GPR_ACCESSORS(r12, R12)
|
|
|
|
BUILD_KVM_GPR_ACCESSORS(r13, R13)
|
|
|
|
BUILD_KVM_GPR_ACCESSORS(r14, R14)
|
|
|
|
BUILD_KVM_GPR_ACCESSORS(r15, R15)
|
|
|
|
#endif
|
|
|
|
|
2021-01-22 23:50:48 +00:00
|
|
|
static inline bool kvm_register_is_available(struct kvm_vcpu *vcpu,
|
|
|
|
enum kvm_reg reg)
|
|
|
|
{
|
|
|
|
return test_bit(reg, (unsigned long *)&vcpu->arch.regs_avail);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool kvm_register_is_dirty(struct kvm_vcpu *vcpu,
|
|
|
|
enum kvm_reg reg)
|
|
|
|
{
|
|
|
|
return test_bit(reg, (unsigned long *)&vcpu->arch.regs_dirty);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void kvm_register_mark_available(struct kvm_vcpu *vcpu,
|
|
|
|
enum kvm_reg reg)
|
|
|
|
{
|
|
|
|
__set_bit(reg, (unsigned long *)&vcpu->arch.regs_avail);
|
|
|
|
}
|
|
|
|
|
2021-06-07 09:02:01 +00:00
|
|
|
static inline void kvm_register_clear_available(struct kvm_vcpu *vcpu,
|
|
|
|
enum kvm_reg reg)
|
|
|
|
{
|
|
|
|
__clear_bit(reg, (unsigned long *)&vcpu->arch.regs_avail);
|
|
|
|
__clear_bit(reg, (unsigned long *)&vcpu->arch.regs_dirty);
|
|
|
|
}
|
|
|
|
|
2021-01-22 23:50:48 +00:00
|
|
|
static inline void kvm_register_mark_dirty(struct kvm_vcpu *vcpu,
|
|
|
|
enum kvm_reg reg)
|
|
|
|
{
|
|
|
|
__set_bit(reg, (unsigned long *)&vcpu->arch.regs_avail);
|
|
|
|
__set_bit(reg, (unsigned long *)&vcpu->arch.regs_dirty);
|
|
|
|
}
|
|
|
|
|
2021-04-22 02:21:28 +00:00
|
|
|
/*
|
|
|
|
* The "raw" register helpers are only for cases where the full 64 bits of a
|
|
|
|
* register are read/written irrespective of current vCPU mode. In other words,
|
|
|
|
* odds are good you shouldn't be using the raw variants.
|
|
|
|
*/
|
|
|
|
static inline unsigned long kvm_register_read_raw(struct kvm_vcpu *vcpu, int reg)
|
2008-06-27 17:58:02 +00:00
|
|
|
{
|
2019-09-27 21:45:20 +00:00
|
|
|
if (WARN_ON_ONCE((unsigned int)reg >= NR_VCPU_REGS))
|
|
|
|
return 0;
|
|
|
|
|
2019-09-27 21:45:22 +00:00
|
|
|
if (!kvm_register_is_available(vcpu, reg))
|
2021-01-15 03:27:56 +00:00
|
|
|
static_call(kvm_x86_cache_reg)(vcpu, reg);
|
2008-06-27 17:58:02 +00:00
|
|
|
|
|
|
|
return vcpu->arch.regs[reg];
|
|
|
|
}
|
|
|
|
|
2021-04-22 02:21:28 +00:00
|
|
|
static inline void kvm_register_write_raw(struct kvm_vcpu *vcpu, int reg,
|
|
|
|
unsigned long val)
|
2008-06-27 17:58:02 +00:00
|
|
|
{
|
2019-09-27 21:45:20 +00:00
|
|
|
if (WARN_ON_ONCE((unsigned int)reg >= NR_VCPU_REGS))
|
|
|
|
return;
|
|
|
|
|
2008-06-27 17:58:02 +00:00
|
|
|
vcpu->arch.regs[reg] = val;
|
2019-09-27 21:45:22 +00:00
|
|
|
kvm_register_mark_dirty(vcpu, reg);
|
2008-06-27 17:58:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline unsigned long kvm_rip_read(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
2021-04-22 02:21:28 +00:00
|
|
|
return kvm_register_read_raw(vcpu, VCPU_REGS_RIP);
|
2008-06-27 17:58:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void kvm_rip_write(struct kvm_vcpu *vcpu, unsigned long val)
|
|
|
|
{
|
2021-04-22 02:21:28 +00:00
|
|
|
kvm_register_write_raw(vcpu, VCPU_REGS_RIP, val);
|
2008-06-27 17:58:02 +00:00
|
|
|
}
|
|
|
|
|
2019-04-30 20:07:26 +00:00
|
|
|
static inline unsigned long kvm_rsp_read(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
2021-04-22 02:21:28 +00:00
|
|
|
return kvm_register_read_raw(vcpu, VCPU_REGS_RSP);
|
2019-04-30 20:07:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void kvm_rsp_write(struct kvm_vcpu *vcpu, unsigned long val)
|
|
|
|
{
|
2021-04-22 02:21:28 +00:00
|
|
|
kvm_register_write_raw(vcpu, VCPU_REGS_RSP, val);
|
2019-04-30 20:07:26 +00:00
|
|
|
}
|
|
|
|
|
2009-05-31 19:58:47 +00:00
|
|
|
static inline u64 kvm_pdptr_read(struct kvm_vcpu *vcpu, int index)
|
|
|
|
{
|
2010-05-04 10:00:55 +00:00
|
|
|
might_sleep(); /* on svm */
|
|
|
|
|
2019-09-27 21:45:22 +00:00
|
|
|
if (!kvm_register_is_available(vcpu, VCPU_EXREG_PDPTR))
|
2021-01-15 03:27:56 +00:00
|
|
|
static_call(kvm_x86_cache_reg)(vcpu, VCPU_EXREG_PDPTR);
|
2009-05-31 19:58:47 +00:00
|
|
|
|
2010-09-10 15:30:57 +00:00
|
|
|
return vcpu->arch.walk_mmu->pdptrs[index];
|
2009-05-31 19:58:47 +00:00
|
|
|
}
|
|
|
|
|
2021-06-07 09:02:02 +00:00
|
|
|
static inline void kvm_pdptr_write(struct kvm_vcpu *vcpu, int index, u64 value)
|
|
|
|
{
|
|
|
|
vcpu->arch.walk_mmu->pdptrs[index] = value;
|
|
|
|
}
|
|
|
|
|
2009-12-29 16:07:30 +00:00
|
|
|
static inline ulong kvm_read_cr0_bits(struct kvm_vcpu *vcpu, ulong mask)
|
|
|
|
{
|
2010-01-21 13:31:51 +00:00
|
|
|
ulong tmask = mask & KVM_POSSIBLE_CR0_GUEST_BITS;
|
2020-05-02 04:32:31 +00:00
|
|
|
if ((tmask & vcpu->arch.cr0_guest_owned_bits) &&
|
|
|
|
!kvm_register_is_available(vcpu, VCPU_EXREG_CR0))
|
2021-01-15 03:27:56 +00:00
|
|
|
static_call(kvm_x86_cache_reg)(vcpu, VCPU_EXREG_CR0);
|
2009-12-29 16:07:30 +00:00
|
|
|
return vcpu->arch.cr0 & mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline ulong kvm_read_cr0(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
|
|
|
return kvm_read_cr0_bits(vcpu, ~0UL);
|
|
|
|
}
|
|
|
|
|
2009-12-07 10:16:48 +00:00
|
|
|
static inline ulong kvm_read_cr4_bits(struct kvm_vcpu *vcpu, ulong mask)
|
|
|
|
{
|
2010-01-21 13:31:51 +00:00
|
|
|
ulong tmask = mask & KVM_POSSIBLE_CR4_GUEST_BITS;
|
2020-05-02 04:32:30 +00:00
|
|
|
if ((tmask & vcpu->arch.cr4_guest_owned_bits) &&
|
|
|
|
!kvm_register_is_available(vcpu, VCPU_EXREG_CR4))
|
2021-01-15 03:27:56 +00:00
|
|
|
static_call(kvm_x86_cache_reg)(vcpu, VCPU_EXREG_CR4);
|
2009-12-07 10:16:48 +00:00
|
|
|
return vcpu->arch.cr4 & mask;
|
|
|
|
}
|
|
|
|
|
2010-12-05 15:30:00 +00:00
|
|
|
static inline ulong kvm_read_cr3(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
2019-09-27 21:45:22 +00:00
|
|
|
if (!kvm_register_is_available(vcpu, VCPU_EXREG_CR3))
|
2021-01-15 03:27:56 +00:00
|
|
|
static_call(kvm_x86_cache_reg)(vcpu, VCPU_EXREG_CR3);
|
2010-12-05 15:30:00 +00:00
|
|
|
return vcpu->arch.cr3;
|
|
|
|
}
|
|
|
|
|
2009-12-07 10:16:48 +00:00
|
|
|
static inline ulong kvm_read_cr4(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
|
|
|
return kvm_read_cr4_bits(vcpu, ~0UL);
|
|
|
|
}
|
|
|
|
|
2010-06-10 03:27:12 +00:00
|
|
|
static inline u64 kvm_read_edx_eax(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
2019-04-30 17:36:17 +00:00
|
|
|
return (kvm_rax_read(vcpu) & -1u)
|
|
|
|
| ((u64)(kvm_rdx_read(vcpu) & -1u) << 32);
|
2010-06-10 03:27:12 +00:00
|
|
|
}
|
|
|
|
|
2010-11-29 16:51:47 +00:00
|
|
|
static inline void enter_guest_mode(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
|
|
|
vcpu->arch.hflags |= HF_GUEST_MASK;
|
2021-06-09 18:03:39 +00:00
|
|
|
vcpu->stat.guest_mode = 1;
|
2010-11-29 16:51:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void leave_guest_mode(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
|
|
|
vcpu->arch.hflags &= ~HF_GUEST_MASK;
|
KVM: nVMX: Do not load EOI-exitmap while running L2
When L1 IOAPIC redirection-table is written, a request of
KVM_REQ_SCAN_IOAPIC is set on all vCPUs. This is done such that
all vCPUs will now recalc their IOAPIC handled vectors and load
it to their EOI-exitmap.
However, it could be that one of the vCPUs is currently running
L2. In this case, load_eoi_exitmap() will be called which would
write to vmcs02->eoi_exit_bitmap, which is wrong because
vmcs02->eoi_exit_bitmap should always be equal to
vmcs12->eoi_exit_bitmap. Furthermore, at this point
KVM_REQ_SCAN_IOAPIC was already consumed and therefore we will
never update vmcs01->eoi_exit_bitmap. This could lead to remote_irr
of some IOAPIC level-triggered entry to remain set forever.
Fix this issue by delaying the load of EOI-exitmap to when vCPU
is running L1.
One may wonder why not just delay entire KVM_REQ_SCAN_IOAPIC
processing to when vCPU is running L1. This is done in order to handle
correctly the case where LAPIC & IO-APIC of L1 is pass-throughed into
L2. In this case, vmcs12->virtual_interrupt_delivery should be 0. In
current nVMX implementation, that results in
vmcs02->virtual_interrupt_delivery to also be 0. Thus,
vmcs02->eoi_exit_bitmap is not used. Therefore, every L2 EOI cause
a #VMExit into L0 (either on MSR_WRITE to x2APIC MSR or
APIC_ACCESS/APIC_WRITE/EPT_MISCONFIG to APIC MMIO page).
In order for such L2 EOI to be broadcasted, if needed, from LAPIC
to IO-APIC, vcpu->arch.ioapic_handled_vectors must be updated
while L2 is running. Therefore, patch makes sure to delay only the
loading of EOI-exitmap but not the update of
vcpu->arch.ioapic_handled_vectors.
Reviewed-by: Arbel Moshe <arbel.moshe@oracle.com>
Reviewed-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>
Signed-off-by: Liran Alon <liran.alon@oracle.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2018-03-21 00:50:31 +00:00
|
|
|
|
|
|
|
if (vcpu->arch.load_eoi_exitmap_pending) {
|
|
|
|
vcpu->arch.load_eoi_exitmap_pending = false;
|
|
|
|
kvm_make_request(KVM_REQ_LOAD_EOI_EXITMAP, vcpu);
|
|
|
|
}
|
2021-06-09 18:03:39 +00:00
|
|
|
|
|
|
|
vcpu->stat.guest_mode = 0;
|
2010-11-29 16:51:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool is_guest_mode(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
|
|
|
return vcpu->arch.hflags & HF_GUEST_MASK;
|
|
|
|
}
|
|
|
|
|
2015-04-01 13:06:40 +00:00
|
|
|
static inline bool is_smm(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
|
|
|
return vcpu->arch.hflags & HF_SMM_MASK;
|
|
|
|
}
|
|
|
|
|
2008-06-27 17:58:02 +00:00
|
|
|
#endif
|