mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-25 04:11:44 +07:00
b24413180f
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>
402 lines
10 KiB
C
402 lines
10 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*---------------------------------------------------------------------------+
|
|
| get_address.c |
|
|
| |
|
|
| Get the effective address from an FPU instruction. |
|
|
| |
|
|
| Copyright (C) 1992,1993,1994,1997 |
|
|
| W. Metzenthen, 22 Parker St, Ormond, Vic 3163, |
|
|
| Australia. E-mail billm@suburbia.net |
|
|
| |
|
|
| |
|
|
+---------------------------------------------------------------------------*/
|
|
|
|
/*---------------------------------------------------------------------------+
|
|
| Note: |
|
|
| The file contains code which accesses user memory. |
|
|
| Emulator static data may change when user memory is accessed, due to |
|
|
| other processes using the emulator while swapping is in progress. |
|
|
+---------------------------------------------------------------------------*/
|
|
|
|
#include <linux/stddef.h>
|
|
|
|
#include <linux/uaccess.h>
|
|
#include <asm/vm86.h>
|
|
|
|
#include "fpu_system.h"
|
|
#include "exception.h"
|
|
#include "fpu_emu.h"
|
|
|
|
#define FPU_WRITE_BIT 0x10
|
|
|
|
static int reg_offset[] = {
|
|
offsetof(struct pt_regs, ax),
|
|
offsetof(struct pt_regs, cx),
|
|
offsetof(struct pt_regs, dx),
|
|
offsetof(struct pt_regs, bx),
|
|
offsetof(struct pt_regs, sp),
|
|
offsetof(struct pt_regs, bp),
|
|
offsetof(struct pt_regs, si),
|
|
offsetof(struct pt_regs, di)
|
|
};
|
|
|
|
#define REG_(x) (*(long *)(reg_offset[(x)] + (u_char *)FPU_info->regs))
|
|
|
|
static int reg_offset_vm86[] = {
|
|
offsetof(struct pt_regs, cs),
|
|
offsetof(struct kernel_vm86_regs, ds),
|
|
offsetof(struct kernel_vm86_regs, es),
|
|
offsetof(struct kernel_vm86_regs, fs),
|
|
offsetof(struct kernel_vm86_regs, gs),
|
|
offsetof(struct pt_regs, ss),
|
|
offsetof(struct kernel_vm86_regs, ds)
|
|
};
|
|
|
|
#define VM86_REG_(x) (*(unsigned short *) \
|
|
(reg_offset_vm86[((unsigned)x)] + (u_char *)FPU_info->regs))
|
|
|
|
static int reg_offset_pm[] = {
|
|
offsetof(struct pt_regs, cs),
|
|
offsetof(struct pt_regs, ds),
|
|
offsetof(struct pt_regs, es),
|
|
offsetof(struct pt_regs, fs),
|
|
offsetof(struct pt_regs, ds), /* dummy, not saved on stack */
|
|
offsetof(struct pt_regs, ss),
|
|
offsetof(struct pt_regs, ds)
|
|
};
|
|
|
|
#define PM_REG_(x) (*(unsigned short *) \
|
|
(reg_offset_pm[((unsigned)x)] + (u_char *)FPU_info->regs))
|
|
|
|
/* Decode the SIB byte. This function assumes mod != 0 */
|
|
static int sib(int mod, unsigned long *fpu_eip)
|
|
{
|
|
u_char ss, index, base;
|
|
long offset;
|
|
|
|
RE_ENTRANT_CHECK_OFF;
|
|
FPU_code_access_ok(1);
|
|
FPU_get_user(base, (u_char __user *) (*fpu_eip)); /* The SIB byte */
|
|
RE_ENTRANT_CHECK_ON;
|
|
(*fpu_eip)++;
|
|
ss = base >> 6;
|
|
index = (base >> 3) & 7;
|
|
base &= 7;
|
|
|
|
if ((mod == 0) && (base == 5))
|
|
offset = 0; /* No base register */
|
|
else
|
|
offset = REG_(base);
|
|
|
|
if (index == 4) {
|
|
/* No index register */
|
|
/* A non-zero ss is illegal */
|
|
if (ss)
|
|
EXCEPTION(EX_Invalid);
|
|
} else {
|
|
offset += (REG_(index)) << ss;
|
|
}
|
|
|
|
if (mod == 1) {
|
|
/* 8 bit signed displacement */
|
|
long displacement;
|
|
RE_ENTRANT_CHECK_OFF;
|
|
FPU_code_access_ok(1);
|
|
FPU_get_user(displacement, (signed char __user *)(*fpu_eip));
|
|
offset += displacement;
|
|
RE_ENTRANT_CHECK_ON;
|
|
(*fpu_eip)++;
|
|
} else if (mod == 2 || base == 5) { /* The second condition also has mod==0 */
|
|
/* 32 bit displacement */
|
|
long displacement;
|
|
RE_ENTRANT_CHECK_OFF;
|
|
FPU_code_access_ok(4);
|
|
FPU_get_user(displacement, (long __user *)(*fpu_eip));
|
|
offset += displacement;
|
|
RE_ENTRANT_CHECK_ON;
|
|
(*fpu_eip) += 4;
|
|
}
|
|
|
|
return offset;
|
|
}
|
|
|
|
static unsigned long vm86_segment(u_char segment, struct address *addr)
|
|
{
|
|
segment--;
|
|
#ifdef PARANOID
|
|
if (segment > PREFIX_SS_) {
|
|
EXCEPTION(EX_INTERNAL | 0x130);
|
|
math_abort(FPU_info, SIGSEGV);
|
|
}
|
|
#endif /* PARANOID */
|
|
addr->selector = VM86_REG_(segment);
|
|
return (unsigned long)VM86_REG_(segment) << 4;
|
|
}
|
|
|
|
/* This should work for 16 and 32 bit protected mode. */
|
|
static long pm_address(u_char FPU_modrm, u_char segment,
|
|
struct address *addr, long offset)
|
|
{
|
|
struct desc_struct descriptor;
|
|
unsigned long base_address, limit, address, seg_top;
|
|
|
|
segment--;
|
|
|
|
#ifdef PARANOID
|
|
/* segment is unsigned, so this also detects if segment was 0: */
|
|
if (segment > PREFIX_SS_) {
|
|
EXCEPTION(EX_INTERNAL | 0x132);
|
|
math_abort(FPU_info, SIGSEGV);
|
|
}
|
|
#endif /* PARANOID */
|
|
|
|
switch (segment) {
|
|
case PREFIX_GS_ - 1:
|
|
/* user gs handling can be lazy, use special accessors */
|
|
addr->selector = get_user_gs(FPU_info->regs);
|
|
break;
|
|
default:
|
|
addr->selector = PM_REG_(segment);
|
|
}
|
|
|
|
descriptor = FPU_get_ldt_descriptor(addr->selector);
|
|
base_address = seg_get_base(&descriptor);
|
|
address = base_address + offset;
|
|
limit = seg_get_limit(&descriptor) + 1;
|
|
limit *= seg_get_granularity(&descriptor);
|
|
limit += base_address - 1;
|
|
if (limit < base_address)
|
|
limit = 0xffffffff;
|
|
|
|
if (seg_expands_down(&descriptor)) {
|
|
if (descriptor.g) {
|
|
seg_top = 0xffffffff;
|
|
} else {
|
|
seg_top = base_address + (1 << 20);
|
|
if (seg_top < base_address)
|
|
seg_top = 0xffffffff;
|
|
}
|
|
access_limit =
|
|
(address <= limit) || (address >= seg_top) ? 0 :
|
|
((seg_top - address) >= 255 ? 255 : seg_top - address);
|
|
} else {
|
|
access_limit =
|
|
(address > limit) || (address < base_address) ? 0 :
|
|
((limit - address) >= 254 ? 255 : limit - address + 1);
|
|
}
|
|
if (seg_execute_only(&descriptor) ||
|
|
(!seg_writable(&descriptor) && (FPU_modrm & FPU_WRITE_BIT))) {
|
|
access_limit = 0;
|
|
}
|
|
return address;
|
|
}
|
|
|
|
/*
|
|
MOD R/M byte: MOD == 3 has a special use for the FPU
|
|
SIB byte used iff R/M = 100b
|
|
|
|
7 6 5 4 3 2 1 0
|
|
..... ......... .........
|
|
MOD OPCODE(2) R/M
|
|
|
|
SIB byte
|
|
|
|
7 6 5 4 3 2 1 0
|
|
..... ......... .........
|
|
SS INDEX BASE
|
|
|
|
*/
|
|
|
|
void __user *FPU_get_address(u_char FPU_modrm, unsigned long *fpu_eip,
|
|
struct address *addr, fpu_addr_modes addr_modes)
|
|
{
|
|
u_char mod;
|
|
unsigned rm = FPU_modrm & 7;
|
|
long *cpu_reg_ptr;
|
|
int address = 0; /* Initialized just to stop compiler warnings. */
|
|
|
|
/* Memory accessed via the cs selector is write protected
|
|
in `non-segmented' 32 bit protected mode. */
|
|
if (!addr_modes.default_mode && (FPU_modrm & FPU_WRITE_BIT)
|
|
&& (addr_modes.override.segment == PREFIX_CS_)) {
|
|
math_abort(FPU_info, SIGSEGV);
|
|
}
|
|
|
|
addr->selector = FPU_DS; /* Default, for 32 bit non-segmented mode. */
|
|
|
|
mod = (FPU_modrm >> 6) & 3;
|
|
|
|
if (rm == 4 && mod != 3) {
|
|
address = sib(mod, fpu_eip);
|
|
} else {
|
|
cpu_reg_ptr = ®_(rm);
|
|
switch (mod) {
|
|
case 0:
|
|
if (rm == 5) {
|
|
/* Special case: disp32 */
|
|
RE_ENTRANT_CHECK_OFF;
|
|
FPU_code_access_ok(4);
|
|
FPU_get_user(address,
|
|
(unsigned long __user
|
|
*)(*fpu_eip));
|
|
(*fpu_eip) += 4;
|
|
RE_ENTRANT_CHECK_ON;
|
|
addr->offset = address;
|
|
return (void __user *)address;
|
|
} else {
|
|
address = *cpu_reg_ptr; /* Just return the contents
|
|
of the cpu register */
|
|
addr->offset = address;
|
|
return (void __user *)address;
|
|
}
|
|
case 1:
|
|
/* 8 bit signed displacement */
|
|
RE_ENTRANT_CHECK_OFF;
|
|
FPU_code_access_ok(1);
|
|
FPU_get_user(address, (signed char __user *)(*fpu_eip));
|
|
RE_ENTRANT_CHECK_ON;
|
|
(*fpu_eip)++;
|
|
break;
|
|
case 2:
|
|
/* 32 bit displacement */
|
|
RE_ENTRANT_CHECK_OFF;
|
|
FPU_code_access_ok(4);
|
|
FPU_get_user(address, (long __user *)(*fpu_eip));
|
|
(*fpu_eip) += 4;
|
|
RE_ENTRANT_CHECK_ON;
|
|
break;
|
|
case 3:
|
|
/* Not legal for the FPU */
|
|
EXCEPTION(EX_Invalid);
|
|
}
|
|
address += *cpu_reg_ptr;
|
|
}
|
|
|
|
addr->offset = address;
|
|
|
|
switch (addr_modes.default_mode) {
|
|
case 0:
|
|
break;
|
|
case VM86:
|
|
address += vm86_segment(addr_modes.override.segment, addr);
|
|
break;
|
|
case PM16:
|
|
case SEG32:
|
|
address = pm_address(FPU_modrm, addr_modes.override.segment,
|
|
addr, address);
|
|
break;
|
|
default:
|
|
EXCEPTION(EX_INTERNAL | 0x133);
|
|
}
|
|
|
|
return (void __user *)address;
|
|
}
|
|
|
|
void __user *FPU_get_address_16(u_char FPU_modrm, unsigned long *fpu_eip,
|
|
struct address *addr, fpu_addr_modes addr_modes)
|
|
{
|
|
u_char mod;
|
|
unsigned rm = FPU_modrm & 7;
|
|
int address = 0; /* Default used for mod == 0 */
|
|
|
|
/* Memory accessed via the cs selector is write protected
|
|
in `non-segmented' 32 bit protected mode. */
|
|
if (!addr_modes.default_mode && (FPU_modrm & FPU_WRITE_BIT)
|
|
&& (addr_modes.override.segment == PREFIX_CS_)) {
|
|
math_abort(FPU_info, SIGSEGV);
|
|
}
|
|
|
|
addr->selector = FPU_DS; /* Default, for 32 bit non-segmented mode. */
|
|
|
|
mod = (FPU_modrm >> 6) & 3;
|
|
|
|
switch (mod) {
|
|
case 0:
|
|
if (rm == 6) {
|
|
/* Special case: disp16 */
|
|
RE_ENTRANT_CHECK_OFF;
|
|
FPU_code_access_ok(2);
|
|
FPU_get_user(address,
|
|
(unsigned short __user *)(*fpu_eip));
|
|
(*fpu_eip) += 2;
|
|
RE_ENTRANT_CHECK_ON;
|
|
goto add_segment;
|
|
}
|
|
break;
|
|
case 1:
|
|
/* 8 bit signed displacement */
|
|
RE_ENTRANT_CHECK_OFF;
|
|
FPU_code_access_ok(1);
|
|
FPU_get_user(address, (signed char __user *)(*fpu_eip));
|
|
RE_ENTRANT_CHECK_ON;
|
|
(*fpu_eip)++;
|
|
break;
|
|
case 2:
|
|
/* 16 bit displacement */
|
|
RE_ENTRANT_CHECK_OFF;
|
|
FPU_code_access_ok(2);
|
|
FPU_get_user(address, (unsigned short __user *)(*fpu_eip));
|
|
(*fpu_eip) += 2;
|
|
RE_ENTRANT_CHECK_ON;
|
|
break;
|
|
case 3:
|
|
/* Not legal for the FPU */
|
|
EXCEPTION(EX_Invalid);
|
|
break;
|
|
}
|
|
switch (rm) {
|
|
case 0:
|
|
address += FPU_info->regs->bx + FPU_info->regs->si;
|
|
break;
|
|
case 1:
|
|
address += FPU_info->regs->bx + FPU_info->regs->di;
|
|
break;
|
|
case 2:
|
|
address += FPU_info->regs->bp + FPU_info->regs->si;
|
|
if (addr_modes.override.segment == PREFIX_DEFAULT)
|
|
addr_modes.override.segment = PREFIX_SS_;
|
|
break;
|
|
case 3:
|
|
address += FPU_info->regs->bp + FPU_info->regs->di;
|
|
if (addr_modes.override.segment == PREFIX_DEFAULT)
|
|
addr_modes.override.segment = PREFIX_SS_;
|
|
break;
|
|
case 4:
|
|
address += FPU_info->regs->si;
|
|
break;
|
|
case 5:
|
|
address += FPU_info->regs->di;
|
|
break;
|
|
case 6:
|
|
address += FPU_info->regs->bp;
|
|
if (addr_modes.override.segment == PREFIX_DEFAULT)
|
|
addr_modes.override.segment = PREFIX_SS_;
|
|
break;
|
|
case 7:
|
|
address += FPU_info->regs->bx;
|
|
break;
|
|
}
|
|
|
|
add_segment:
|
|
address &= 0xffff;
|
|
|
|
addr->offset = address;
|
|
|
|
switch (addr_modes.default_mode) {
|
|
case 0:
|
|
break;
|
|
case VM86:
|
|
address += vm86_segment(addr_modes.override.segment, addr);
|
|
break;
|
|
case PM16:
|
|
case SEG32:
|
|
address = pm_address(FPU_modrm, addr_modes.override.segment,
|
|
addr, address);
|
|
break;
|
|
default:
|
|
EXCEPTION(EX_INTERNAL | 0x131);
|
|
}
|
|
|
|
return (void __user *)address;
|
|
}
|