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 21:07:57 +07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2005-04-17 05:20:36 +07:00
|
|
|
/*
|
|
|
|
* Author(s)......: Carsten Otte <cotte@de.ibm.com>
|
|
|
|
* Rob M van der Heij <rvdheij@nl.ibm.com>
|
|
|
|
* Steven Shultz <shultzss@us.ibm.com>
|
|
|
|
* Bugreports.to..: <Linux390@de.ibm.com>
|
2012-07-20 16:15:04 +07:00
|
|
|
* Copyright IBM Corp. 2002, 2004
|
2005-04-17 05:20:36 +07:00
|
|
|
*/
|
|
|
|
|
2008-12-25 19:39:45 +07:00
|
|
|
#define KMSG_COMPONENT "extmem"
|
|
|
|
#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/string.h>
|
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/slab.h>
|
2017-02-10 03:20:24 +07:00
|
|
|
#include <linux/export.h>
|
2018-10-31 05:09:49 +07:00
|
|
|
#include <linux/memblock.h>
|
2006-12-04 21:40:38 +07:00
|
|
|
#include <linux/ctype.h>
|
2007-02-06 03:17:11 +07:00
|
|
|
#include <linux/ioport.h>
|
2015-08-20 22:28:44 +07:00
|
|
|
#include <asm/diag.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <asm/page.h>
|
2006-12-08 21:56:07 +07:00
|
|
|
#include <asm/pgtable.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <asm/ebcdic.h>
|
|
|
|
#include <asm/errno.h>
|
|
|
|
#include <asm/extmem.h>
|
|
|
|
#include <asm/cpcmd.h>
|
2006-12-04 21:40:38 +07:00
|
|
|
#include <asm/setup.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
#define DCSS_PURGESEG 0x08
|
2008-10-11 02:33:21 +07:00
|
|
|
#define DCSS_LOADSHRX 0x20
|
|
|
|
#define DCSS_LOADNSRX 0x24
|
|
|
|
#define DCSS_FINDSEGX 0x2c
|
|
|
|
#define DCSS_SEGEXTX 0x38
|
2005-04-17 05:20:36 +07:00
|
|
|
#define DCSS_FINDSEGA 0x0c
|
|
|
|
|
|
|
|
struct qrange {
|
2008-10-11 02:33:21 +07:00
|
|
|
unsigned long start; /* last byte type */
|
|
|
|
unsigned long end; /* last byte reserved */
|
2005-04-17 05:20:36 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct qout64 {
|
2008-10-11 02:33:21 +07:00
|
|
|
unsigned long segstart;
|
|
|
|
unsigned long segend;
|
|
|
|
int segcnt;
|
|
|
|
int segrcnt;
|
|
|
|
struct qrange range[6];
|
|
|
|
};
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
struct qin64 {
|
|
|
|
char qopcode;
|
|
|
|
char rsrv1[3];
|
|
|
|
char qrcode;
|
|
|
|
char rsrv2[3];
|
|
|
|
char qname[8];
|
|
|
|
unsigned int qoutptr;
|
|
|
|
short int qoutlen;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct dcss_segment {
|
|
|
|
struct list_head list;
|
|
|
|
char dcss_name[8];
|
2018-06-17 05:30:43 +07:00
|
|
|
char res_name[16];
|
2005-04-17 05:20:36 +07:00
|
|
|
unsigned long start_addr;
|
|
|
|
unsigned long end;
|
|
|
|
atomic_t ref_count;
|
|
|
|
int do_nonshared;
|
|
|
|
unsigned int vm_segtype;
|
|
|
|
struct qrange range[6];
|
|
|
|
int segcnt;
|
2007-02-06 03:17:11 +07:00
|
|
|
struct resource *res;
|
2005-04-17 05:20:36 +07:00
|
|
|
};
|
|
|
|
|
2006-12-04 21:40:51 +07:00
|
|
|
static DEFINE_MUTEX(dcss_lock);
|
2008-01-26 20:11:13 +07:00
|
|
|
static LIST_HEAD(dcss_list);
|
2005-04-17 05:20:36 +07:00
|
|
|
static char *segtype_string[] = { "SW", "EW", "SR", "ER", "SN", "EN", "SC",
|
|
|
|
"EW/EN-MIXED" };
|
2019-02-21 21:34:21 +07:00
|
|
|
static int loadshr_scode = DCSS_LOADSHRX;
|
|
|
|
static int loadnsr_scode = DCSS_LOADNSRX;
|
|
|
|
static int purgeseg_scode = DCSS_PURGESEG;
|
|
|
|
static int segext_scode = DCSS_SEGEXTX;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Create the 8 bytes, ebcdic VM segment name from
|
|
|
|
* an ascii name.
|
|
|
|
*/
|
2007-02-06 03:18:53 +07:00
|
|
|
static void
|
2005-04-17 05:20:36 +07:00
|
|
|
dcss_mkname(char *name, char *dcss_name)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 8; i++) {
|
|
|
|
if (name[i] == '\0')
|
|
|
|
break;
|
|
|
|
dcss_name[i] = toupper(name[i]);
|
2017-01-02 14:51:02 +07:00
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
for (; i < 8; i++)
|
|
|
|
dcss_name[i] = ' ';
|
|
|
|
ASCEBC(dcss_name, 8);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* search all segments in dcss_list, and return the one
|
|
|
|
* namend *name. If not found, return NULL.
|
|
|
|
*/
|
|
|
|
static struct dcss_segment *
|
|
|
|
segment_by_name (char *name)
|
|
|
|
{
|
|
|
|
char dcss_name[9];
|
|
|
|
struct list_head *l;
|
|
|
|
struct dcss_segment *tmp, *retval = NULL;
|
|
|
|
|
2006-12-04 21:40:51 +07:00
|
|
|
BUG_ON(!mutex_is_locked(&dcss_lock));
|
2005-04-17 05:20:36 +07:00
|
|
|
dcss_mkname (name, dcss_name);
|
|
|
|
list_for_each (l, &dcss_list) {
|
|
|
|
tmp = list_entry (l, struct dcss_segment, list);
|
|
|
|
if (memcmp(tmp->dcss_name, dcss_name, 8) == 0) {
|
|
|
|
retval = tmp;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Perform a function on a dcss segment.
|
|
|
|
*/
|
|
|
|
static inline int
|
2008-10-11 02:33:21 +07:00
|
|
|
dcss_diag(int *func, void *parameter,
|
2005-04-17 05:20:36 +07:00
|
|
|
unsigned long *ret1, unsigned long *ret2)
|
|
|
|
{
|
|
|
|
unsigned long rx, ry;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
rx = (unsigned long) parameter;
|
2008-10-11 02:33:21 +07:00
|
|
|
ry = (unsigned long) *func;
|
|
|
|
|
2015-08-20 22:28:44 +07:00
|
|
|
diag_stat_inc(DIAG_STAT_X064);
|
2019-02-21 21:34:21 +07:00
|
|
|
asm volatile(
|
|
|
|
" diag %0,%1,0x64\n"
|
|
|
|
" ipm %2\n"
|
|
|
|
" srl %2,28\n"
|
|
|
|
: "+d" (rx), "+d" (ry), "=d" (rc) : : "cc");
|
2005-04-17 05:20:36 +07:00
|
|
|
*ret1 = rx;
|
|
|
|
*ret2 = ry;
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
dcss_diag_translate_rc (int vm_rc) {
|
|
|
|
if (vm_rc == 44)
|
|
|
|
return -ENOENT;
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* do a diag to get info about a segment.
|
|
|
|
* fills start_address, end and vm_segtype fields
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
query_segment_type (struct dcss_segment *seg)
|
|
|
|
{
|
|
|
|
unsigned long dummy, vmrc;
|
2010-06-08 23:58:09 +07:00
|
|
|
int diag_cc, rc, i;
|
|
|
|
struct qout64 *qout;
|
|
|
|
struct qin64 *qin;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2010-06-08 23:58:09 +07:00
|
|
|
qin = kmalloc(sizeof(*qin), GFP_KERNEL | GFP_DMA);
|
|
|
|
qout = kmalloc(sizeof(*qout), GFP_KERNEL | GFP_DMA);
|
2005-04-17 05:20:36 +07:00
|
|
|
if ((qin == NULL) || (qout == NULL)) {
|
|
|
|
rc = -ENOMEM;
|
|
|
|
goto out_free;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* initialize diag input parameters */
|
|
|
|
qin->qopcode = DCSS_FINDSEGA;
|
|
|
|
qin->qoutptr = (unsigned long) qout;
|
|
|
|
qin->qoutlen = sizeof(struct qout64);
|
|
|
|
memcpy (qin->qname, seg->dcss_name, 8);
|
|
|
|
|
2008-10-11 02:33:21 +07:00
|
|
|
diag_cc = dcss_diag(&segext_scode, qin, &dummy, &vmrc);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-10-11 02:33:21 +07:00
|
|
|
if (diag_cc < 0) {
|
|
|
|
rc = diag_cc;
|
|
|
|
goto out_free;
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
if (diag_cc > 1) {
|
2016-03-04 11:49:57 +07:00
|
|
|
pr_warn("Querying a DCSS type failed with rc=%ld\n", vmrc);
|
2005-04-17 05:20:36 +07:00
|
|
|
rc = dcss_diag_translate_rc (vmrc);
|
|
|
|
goto out_free;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (qout->segcnt > 6) {
|
2010-02-27 04:37:41 +07:00
|
|
|
rc = -EOPNOTSUPP;
|
2005-04-17 05:20:36 +07:00
|
|
|
goto out_free;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (qout->segcnt == 1) {
|
|
|
|
seg->vm_segtype = qout->range[0].start & 0xff;
|
|
|
|
} else {
|
|
|
|
/* multi-part segment. only one type supported here:
|
|
|
|
- all parts are contiguous
|
|
|
|
- all parts are either EW or EN type
|
|
|
|
- maximum 6 parts allowed */
|
|
|
|
unsigned long start = qout->segstart >> PAGE_SHIFT;
|
|
|
|
for (i=0; i<qout->segcnt; i++) {
|
|
|
|
if (((qout->range[i].start & 0xff) != SEG_TYPE_EW) &&
|
|
|
|
((qout->range[i].start & 0xff) != SEG_TYPE_EN)) {
|
2010-02-27 04:37:41 +07:00
|
|
|
rc = -EOPNOTSUPP;
|
2005-04-17 05:20:36 +07:00
|
|
|
goto out_free;
|
|
|
|
}
|
|
|
|
if (start != qout->range[i].start >> PAGE_SHIFT) {
|
2010-02-27 04:37:41 +07:00
|
|
|
rc = -EOPNOTSUPP;
|
2005-04-17 05:20:36 +07:00
|
|
|
goto out_free;
|
|
|
|
}
|
|
|
|
start = (qout->range[i].end >> PAGE_SHIFT) + 1;
|
|
|
|
}
|
|
|
|
seg->vm_segtype = SEG_TYPE_EWEN;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* analyze diag output and update seg */
|
|
|
|
seg->start_addr = qout->segstart;
|
|
|
|
seg->end = qout->segend;
|
|
|
|
|
|
|
|
memcpy (seg->range, qout->range, 6*sizeof(struct qrange));
|
|
|
|
seg->segcnt = qout->segcnt;
|
|
|
|
|
|
|
|
rc = 0;
|
|
|
|
|
|
|
|
out_free:
|
2005-11-07 16:01:35 +07:00
|
|
|
kfree(qin);
|
|
|
|
kfree(qout);
|
2005-04-17 05:20:36 +07:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* get info about a segment
|
|
|
|
* possible return values:
|
|
|
|
* -ENOSYS : we are not running on VM
|
|
|
|
* -EIO : could not perform query diagnose
|
|
|
|
* -ENOENT : no such segment
|
2010-02-27 04:37:41 +07:00
|
|
|
* -EOPNOTSUPP: multi-part segment cannot be used with linux
|
2005-04-17 05:20:36 +07:00
|
|
|
* -ENOMEM : out of memory
|
|
|
|
* 0 .. 6 : type of segment as defined in include/asm-s390/extmem.h
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
segment_type (char* name)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
struct dcss_segment seg;
|
|
|
|
|
|
|
|
if (!MACHINE_IS_VM)
|
|
|
|
return -ENOSYS;
|
|
|
|
|
|
|
|
dcss_mkname(name, seg.dcss_name);
|
|
|
|
rc = query_segment_type (&seg);
|
|
|
|
if (rc < 0)
|
|
|
|
return rc;
|
|
|
|
return seg.vm_segtype;
|
|
|
|
}
|
|
|
|
|
2008-10-11 02:33:21 +07:00
|
|
|
/*
|
|
|
|
* check if segment collides with other segments that are currently loaded
|
|
|
|
* returns 1 if this is the case, 0 if no collision was found
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
segment_overlaps_others (struct dcss_segment *seg)
|
|
|
|
{
|
|
|
|
struct list_head *l;
|
|
|
|
struct dcss_segment *tmp;
|
|
|
|
|
|
|
|
BUG_ON(!mutex_is_locked(&dcss_lock));
|
|
|
|
list_for_each(l, &dcss_list) {
|
|
|
|
tmp = list_entry(l, struct dcss_segment, list);
|
|
|
|
if ((tmp->start_addr >> 20) > (seg->end >> 20))
|
|
|
|
continue;
|
|
|
|
if ((tmp->end >> 20) < (seg->start_addr >> 20))
|
|
|
|
continue;
|
|
|
|
if (seg == tmp)
|
|
|
|
continue;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/*
|
|
|
|
* real segment loading function, called from segment_load
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
__segment_load (char *name, int do_nonshared, unsigned long *addr, unsigned long *end)
|
|
|
|
{
|
2008-10-11 02:33:21 +07:00
|
|
|
unsigned long start_addr, end_addr, dummy;
|
2010-06-08 23:58:09 +07:00
|
|
|
struct dcss_segment *seg;
|
|
|
|
int rc, diag_cc;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2011-05-23 15:24:29 +07:00
|
|
|
start_addr = end_addr = 0;
|
2010-06-08 23:58:09 +07:00
|
|
|
seg = kmalloc(sizeof(*seg), GFP_KERNEL | GFP_DMA);
|
2005-04-17 05:20:36 +07:00
|
|
|
if (seg == NULL) {
|
|
|
|
rc = -ENOMEM;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
dcss_mkname (name, seg->dcss_name);
|
|
|
|
rc = query_segment_type (seg);
|
|
|
|
if (rc < 0)
|
|
|
|
goto out_free;
|
2006-12-08 21:56:07 +07:00
|
|
|
|
2019-02-21 21:34:21 +07:00
|
|
|
if (segment_overlaps_others(seg)) {
|
|
|
|
rc = -EBUSY;
|
|
|
|
goto out_free;
|
2008-10-11 02:33:21 +07:00
|
|
|
}
|
|
|
|
|
2008-04-30 18:38:47 +07:00
|
|
|
rc = vmem_add_mapping(seg->start_addr, seg->end - seg->start_addr + 1);
|
2006-12-08 21:56:07 +07:00
|
|
|
|
2008-04-17 12:46:31 +07:00
|
|
|
if (rc)
|
2005-04-17 05:20:36 +07:00
|
|
|
goto out_free;
|
2006-12-08 21:56:07 +07:00
|
|
|
|
2007-02-06 03:17:11 +07:00
|
|
|
seg->res = kzalloc(sizeof(struct resource), GFP_KERNEL);
|
|
|
|
if (seg->res == NULL) {
|
|
|
|
rc = -ENOMEM;
|
|
|
|
goto out_shared;
|
|
|
|
}
|
|
|
|
seg->res->flags = IORESOURCE_BUSY | IORESOURCE_MEM;
|
|
|
|
seg->res->start = seg->start_addr;
|
|
|
|
seg->res->end = seg->end;
|
|
|
|
memcpy(&seg->res_name, seg->dcss_name, 8);
|
|
|
|
EBCASC(seg->res_name, 8);
|
|
|
|
seg->res_name[8] = '\0';
|
2018-06-17 05:30:43 +07:00
|
|
|
strlcat(seg->res_name, " (DCSS)", sizeof(seg->res_name));
|
2007-02-06 03:17:11 +07:00
|
|
|
seg->res->name = seg->res_name;
|
|
|
|
rc = seg->vm_segtype;
|
|
|
|
if (rc == SEG_TYPE_SC ||
|
|
|
|
((rc == SEG_TYPE_SR || rc == SEG_TYPE_ER) && !do_nonshared))
|
|
|
|
seg->res->flags |= IORESOURCE_READONLY;
|
|
|
|
if (request_resource(&iomem_resource, seg->res)) {
|
|
|
|
rc = -EBUSY;
|
|
|
|
kfree(seg->res);
|
|
|
|
goto out_shared;
|
|
|
|
}
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
if (do_nonshared)
|
2008-10-11 02:33:21 +07:00
|
|
|
diag_cc = dcss_diag(&loadnsr_scode, seg->dcss_name,
|
|
|
|
&start_addr, &end_addr);
|
2005-04-17 05:20:36 +07:00
|
|
|
else
|
2008-10-11 02:33:21 +07:00
|
|
|
diag_cc = dcss_diag(&loadshr_scode, seg->dcss_name,
|
|
|
|
&start_addr, &end_addr);
|
|
|
|
if (diag_cc < 0) {
|
|
|
|
dcss_diag(&purgeseg_scode, seg->dcss_name,
|
|
|
|
&dummy, &dummy);
|
|
|
|
rc = diag_cc;
|
|
|
|
goto out_resource;
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
if (diag_cc > 1) {
|
2016-03-04 11:49:57 +07:00
|
|
|
pr_warn("Loading DCSS %s failed with rc=%ld\n", name, end_addr);
|
2008-10-11 02:33:21 +07:00
|
|
|
rc = dcss_diag_translate_rc(end_addr);
|
|
|
|
dcss_diag(&purgeseg_scode, seg->dcss_name,
|
|
|
|
&dummy, &dummy);
|
2007-02-06 03:17:11 +07:00
|
|
|
goto out_resource;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2008-10-11 02:33:21 +07:00
|
|
|
seg->start_addr = start_addr;
|
|
|
|
seg->end = end_addr;
|
2005-04-17 05:20:36 +07:00
|
|
|
seg->do_nonshared = do_nonshared;
|
|
|
|
atomic_set(&seg->ref_count, 1);
|
|
|
|
list_add(&seg->list, &dcss_list);
|
|
|
|
*addr = seg->start_addr;
|
|
|
|
*end = seg->end;
|
|
|
|
if (do_nonshared)
|
2019-02-21 21:36:31 +07:00
|
|
|
pr_info("DCSS %s of range %px to %px and type %s loaded as "
|
2008-12-25 19:39:45 +07:00
|
|
|
"exclusive-writable\n", name, (void*) seg->start_addr,
|
|
|
|
(void*) seg->end, segtype_string[seg->vm_segtype]);
|
2007-02-06 03:17:11 +07:00
|
|
|
else {
|
2019-02-21 21:36:31 +07:00
|
|
|
pr_info("DCSS %s of range %px to %px and type %s loaded in "
|
2008-12-25 19:39:45 +07:00
|
|
|
"shared access mode\n", name, (void*) seg->start_addr,
|
|
|
|
(void*) seg->end, segtype_string[seg->vm_segtype]);
|
2007-02-06 03:17:11 +07:00
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
goto out;
|
2007-02-06 03:17:11 +07:00
|
|
|
out_resource:
|
|
|
|
release_resource(seg->res);
|
|
|
|
kfree(seg->res);
|
2006-12-08 21:56:07 +07:00
|
|
|
out_shared:
|
2008-04-30 18:38:47 +07:00
|
|
|
vmem_remove_mapping(seg->start_addr, seg->end - seg->start_addr + 1);
|
2005-04-17 05:20:36 +07:00
|
|
|
out_free:
|
2005-11-07 16:01:35 +07:00
|
|
|
kfree(seg);
|
2005-04-17 05:20:36 +07:00
|
|
|
out:
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* this function loads a DCSS segment
|
|
|
|
* name : name of the DCSS
|
|
|
|
* do_nonshared : 0 indicates that the dcss should be shared with other linux images
|
|
|
|
* 1 indicates that the dcss should be exclusive for this linux image
|
|
|
|
* addr : will be filled with start address of the segment
|
|
|
|
* end : will be filled with end address of the segment
|
|
|
|
* return values:
|
|
|
|
* -ENOSYS : we are not running on VM
|
|
|
|
* -EIO : could not perform query or load diagnose
|
|
|
|
* -ENOENT : no such segment
|
2010-02-27 04:37:41 +07:00
|
|
|
* -EOPNOTSUPP: multi-part segment cannot be used with linux
|
2005-04-17 05:20:36 +07:00
|
|
|
* -ENOSPC : segment cannot be used (overlaps with storage)
|
|
|
|
* -EBUSY : segment can temporarily not be used (overlaps with dcss)
|
|
|
|
* -ERANGE : segment cannot be used (exceeds kernel mapping range)
|
|
|
|
* -EPERM : segment is currently loaded with incompatible permissions
|
|
|
|
* -ENOMEM : out of memory
|
|
|
|
* 0 .. 6 : type of segment as defined in include/asm-s390/extmem.h
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
segment_load (char *name, int do_nonshared, unsigned long *addr,
|
|
|
|
unsigned long *end)
|
|
|
|
{
|
|
|
|
struct dcss_segment *seg;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (!MACHINE_IS_VM)
|
|
|
|
return -ENOSYS;
|
|
|
|
|
2006-12-04 21:40:51 +07:00
|
|
|
mutex_lock(&dcss_lock);
|
2005-04-17 05:20:36 +07:00
|
|
|
seg = segment_by_name (name);
|
|
|
|
if (seg == NULL)
|
|
|
|
rc = __segment_load (name, do_nonshared, addr, end);
|
|
|
|
else {
|
|
|
|
if (do_nonshared == seg->do_nonshared) {
|
|
|
|
atomic_inc(&seg->ref_count);
|
|
|
|
*addr = seg->start_addr;
|
|
|
|
*end = seg->end;
|
|
|
|
rc = seg->vm_segtype;
|
|
|
|
} else {
|
|
|
|
*addr = *end = 0;
|
|
|
|
rc = -EPERM;
|
|
|
|
}
|
|
|
|
}
|
2006-12-04 21:40:51 +07:00
|
|
|
mutex_unlock(&dcss_lock);
|
2005-04-17 05:20:36 +07:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* this function modifies the shared state of a DCSS segment. note that
|
|
|
|
* name : name of the DCSS
|
|
|
|
* do_nonshared : 0 indicates that the dcss should be shared with other linux images
|
|
|
|
* 1 indicates that the dcss should be exclusive for this linux image
|
|
|
|
* return values:
|
|
|
|
* -EIO : could not perform load diagnose (segment gone!)
|
|
|
|
* -ENOENT : no such segment (segment gone!)
|
|
|
|
* -EAGAIN : segment is in use by other exploiters, try later
|
|
|
|
* -EINVAL : no segment with the given name is currently loaded - name invalid
|
2007-02-06 03:17:11 +07:00
|
|
|
* -EBUSY : segment can temporarily not be used (overlaps with dcss)
|
2005-04-17 05:20:36 +07:00
|
|
|
* 0 : operation succeeded
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
segment_modify_shared (char *name, int do_nonshared)
|
|
|
|
{
|
|
|
|
struct dcss_segment *seg;
|
2008-10-11 02:33:21 +07:00
|
|
|
unsigned long start_addr, end_addr, dummy;
|
|
|
|
int rc, diag_cc;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2011-05-23 15:24:29 +07:00
|
|
|
start_addr = end_addr = 0;
|
2006-12-04 21:40:51 +07:00
|
|
|
mutex_lock(&dcss_lock);
|
2005-04-17 05:20:36 +07:00
|
|
|
seg = segment_by_name (name);
|
|
|
|
if (seg == NULL) {
|
|
|
|
rc = -EINVAL;
|
|
|
|
goto out_unlock;
|
|
|
|
}
|
|
|
|
if (do_nonshared == seg->do_nonshared) {
|
2008-12-25 19:39:45 +07:00
|
|
|
pr_info("DCSS %s is already in the requested access "
|
|
|
|
"mode\n", name);
|
2005-04-17 05:20:36 +07:00
|
|
|
rc = 0;
|
|
|
|
goto out_unlock;
|
|
|
|
}
|
|
|
|
if (atomic_read (&seg->ref_count) != 1) {
|
2016-03-04 11:49:57 +07:00
|
|
|
pr_warn("DCSS %s is in use and cannot be reloaded\n", name);
|
2005-04-17 05:20:36 +07:00
|
|
|
rc = -EAGAIN;
|
|
|
|
goto out_unlock;
|
|
|
|
}
|
2007-02-06 03:17:11 +07:00
|
|
|
release_resource(seg->res);
|
2008-10-11 02:33:21 +07:00
|
|
|
if (do_nonshared)
|
2007-02-06 03:17:11 +07:00
|
|
|
seg->res->flags &= ~IORESOURCE_READONLY;
|
2008-10-11 02:33:21 +07:00
|
|
|
else
|
2007-02-06 03:17:11 +07:00
|
|
|
if (seg->vm_segtype == SEG_TYPE_SR ||
|
|
|
|
seg->vm_segtype == SEG_TYPE_ER)
|
|
|
|
seg->res->flags |= IORESOURCE_READONLY;
|
2008-10-11 02:33:21 +07:00
|
|
|
|
2007-02-06 03:17:11 +07:00
|
|
|
if (request_resource(&iomem_resource, seg->res)) {
|
2016-03-04 11:49:57 +07:00
|
|
|
pr_warn("DCSS %s overlaps with used memory resources and cannot be reloaded\n",
|
|
|
|
name);
|
2007-02-06 03:17:11 +07:00
|
|
|
rc = -EBUSY;
|
|
|
|
kfree(seg->res);
|
2008-10-11 02:33:21 +07:00
|
|
|
goto out_del_mem;
|
|
|
|
}
|
|
|
|
|
|
|
|
dcss_diag(&purgeseg_scode, seg->dcss_name, &dummy, &dummy);
|
|
|
|
if (do_nonshared)
|
|
|
|
diag_cc = dcss_diag(&loadnsr_scode, seg->dcss_name,
|
|
|
|
&start_addr, &end_addr);
|
|
|
|
else
|
|
|
|
diag_cc = dcss_diag(&loadshr_scode, seg->dcss_name,
|
|
|
|
&start_addr, &end_addr);
|
|
|
|
if (diag_cc < 0) {
|
|
|
|
rc = diag_cc;
|
|
|
|
goto out_del_res;
|
2007-02-06 03:17:11 +07:00
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
if (diag_cc > 1) {
|
2016-03-04 11:49:57 +07:00
|
|
|
pr_warn("Reloading DCSS %s failed with rc=%ld\n",
|
|
|
|
name, end_addr);
|
2008-10-11 02:33:21 +07:00
|
|
|
rc = dcss_diag_translate_rc(end_addr);
|
|
|
|
goto out_del_res;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2008-10-11 02:33:21 +07:00
|
|
|
seg->start_addr = start_addr;
|
|
|
|
seg->end = end_addr;
|
2005-04-17 05:20:36 +07:00
|
|
|
seg->do_nonshared = do_nonshared;
|
|
|
|
rc = 0;
|
|
|
|
goto out_unlock;
|
2008-10-11 02:33:21 +07:00
|
|
|
out_del_res:
|
|
|
|
release_resource(seg->res);
|
|
|
|
kfree(seg->res);
|
|
|
|
out_del_mem:
|
2008-04-30 18:38:47 +07:00
|
|
|
vmem_remove_mapping(seg->start_addr, seg->end - seg->start_addr + 1);
|
2005-04-17 05:20:36 +07:00
|
|
|
list_del(&seg->list);
|
2008-10-11 02:33:21 +07:00
|
|
|
dcss_diag(&purgeseg_scode, seg->dcss_name, &dummy, &dummy);
|
2005-11-07 16:01:35 +07:00
|
|
|
kfree(seg);
|
2005-04-17 05:20:36 +07:00
|
|
|
out_unlock:
|
2006-12-04 21:40:51 +07:00
|
|
|
mutex_unlock(&dcss_lock);
|
2005-04-17 05:20:36 +07:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Decrease the use count of a DCSS segment and remove
|
|
|
|
* it from the address space if nobody is using it
|
|
|
|
* any longer.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
segment_unload(char *name)
|
|
|
|
{
|
|
|
|
unsigned long dummy;
|
|
|
|
struct dcss_segment *seg;
|
|
|
|
|
|
|
|
if (!MACHINE_IS_VM)
|
|
|
|
return;
|
|
|
|
|
2006-12-04 21:40:51 +07:00
|
|
|
mutex_lock(&dcss_lock);
|
2005-04-17 05:20:36 +07:00
|
|
|
seg = segment_by_name (name);
|
|
|
|
if (seg == NULL) {
|
2008-12-25 19:39:45 +07:00
|
|
|
pr_err("Unloading unknown DCSS %s failed\n", name);
|
2005-04-17 05:20:36 +07:00
|
|
|
goto out_unlock;
|
|
|
|
}
|
2006-12-08 21:56:07 +07:00
|
|
|
if (atomic_dec_return(&seg->ref_count) != 0)
|
|
|
|
goto out_unlock;
|
2007-02-06 03:17:11 +07:00
|
|
|
release_resource(seg->res);
|
|
|
|
kfree(seg->res);
|
2008-04-30 18:38:47 +07:00
|
|
|
vmem_remove_mapping(seg->start_addr, seg->end - seg->start_addr + 1);
|
2006-12-08 21:56:07 +07:00
|
|
|
list_del(&seg->list);
|
2008-10-11 02:33:21 +07:00
|
|
|
dcss_diag(&purgeseg_scode, seg->dcss_name, &dummy, &dummy);
|
2006-12-08 21:56:07 +07:00
|
|
|
kfree(seg);
|
2005-04-17 05:20:36 +07:00
|
|
|
out_unlock:
|
2006-12-04 21:40:51 +07:00
|
|
|
mutex_unlock(&dcss_lock);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* save segment content permanently
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
segment_save(char *name)
|
|
|
|
{
|
|
|
|
struct dcss_segment *seg;
|
|
|
|
char cmd1[160];
|
|
|
|
char cmd2[80];
|
2006-04-28 08:40:22 +07:00
|
|
|
int i, response;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
if (!MACHINE_IS_VM)
|
|
|
|
return;
|
|
|
|
|
2006-12-04 21:40:51 +07:00
|
|
|
mutex_lock(&dcss_lock);
|
2005-04-17 05:20:36 +07:00
|
|
|
seg = segment_by_name (name);
|
|
|
|
|
|
|
|
if (seg == NULL) {
|
2008-12-25 19:39:45 +07:00
|
|
|
pr_err("Saving unknown DCSS %s failed\n", name);
|
2006-12-04 21:40:20 +07:00
|
|
|
goto out;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(cmd1, "DEFSEG %s", name);
|
|
|
|
for (i=0; i<seg->segcnt; i++) {
|
2008-10-11 02:33:21 +07:00
|
|
|
sprintf(cmd1+strlen(cmd1), " %lX-%lX %s",
|
2005-04-17 05:20:36 +07:00
|
|
|
seg->range[i].start >> PAGE_SHIFT,
|
|
|
|
seg->range[i].end >> PAGE_SHIFT,
|
|
|
|
segtype_string[seg->range[i].start & 0xff]);
|
|
|
|
}
|
|
|
|
sprintf(cmd2, "SAVESEG %s", name);
|
2006-04-28 08:40:22 +07:00
|
|
|
response = 0;
|
|
|
|
cpcmd(cmd1, NULL, 0, &response);
|
|
|
|
if (response) {
|
2008-12-25 19:39:45 +07:00
|
|
|
pr_err("Saving a DCSS failed with DEFSEG response code "
|
|
|
|
"%i\n", response);
|
2006-04-28 08:40:22 +07:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
cpcmd(cmd2, NULL, 0, &response);
|
|
|
|
if (response) {
|
2008-12-25 19:39:45 +07:00
|
|
|
pr_err("Saving a DCSS failed with SAVESEG response code "
|
|
|
|
"%i\n", response);
|
2006-04-28 08:40:22 +07:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
out:
|
2006-12-04 21:40:51 +07:00
|
|
|
mutex_unlock(&dcss_lock);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2008-04-17 12:46:31 +07:00
|
|
|
/*
|
|
|
|
* print appropriate error message for segment_load()/segment_type()
|
|
|
|
* return code
|
|
|
|
*/
|
|
|
|
void segment_warning(int rc, char *seg_name)
|
|
|
|
{
|
|
|
|
switch (rc) {
|
|
|
|
case -ENOENT:
|
2008-12-25 19:39:45 +07:00
|
|
|
pr_err("DCSS %s cannot be loaded or queried\n", seg_name);
|
2008-04-17 12:46:31 +07:00
|
|
|
break;
|
|
|
|
case -ENOSYS:
|
2008-12-25 19:39:45 +07:00
|
|
|
pr_err("DCSS %s cannot be loaded or queried without "
|
|
|
|
"z/VM\n", seg_name);
|
2008-04-17 12:46:31 +07:00
|
|
|
break;
|
|
|
|
case -EIO:
|
2008-12-25 19:39:45 +07:00
|
|
|
pr_err("Loading or querying DCSS %s resulted in a "
|
|
|
|
"hardware error\n", seg_name);
|
2008-04-17 12:46:31 +07:00
|
|
|
break;
|
2010-02-27 04:37:41 +07:00
|
|
|
case -EOPNOTSUPP:
|
2008-12-25 19:39:45 +07:00
|
|
|
pr_err("DCSS %s has multiple page ranges and cannot be "
|
|
|
|
"loaded or queried\n", seg_name);
|
2008-04-17 12:46:31 +07:00
|
|
|
break;
|
|
|
|
case -ENOSPC:
|
2008-12-25 19:39:45 +07:00
|
|
|
pr_err("DCSS %s overlaps with used storage and cannot "
|
|
|
|
"be loaded\n", seg_name);
|
2008-04-17 12:46:31 +07:00
|
|
|
break;
|
|
|
|
case -EBUSY:
|
2008-12-25 19:39:45 +07:00
|
|
|
pr_err("%s needs used memory resources and cannot be "
|
|
|
|
"loaded or queried\n", seg_name);
|
2008-04-17 12:46:31 +07:00
|
|
|
break;
|
|
|
|
case -EPERM:
|
2008-12-25 19:39:45 +07:00
|
|
|
pr_err("DCSS %s is already loaded in a different access "
|
|
|
|
"mode\n", seg_name);
|
2008-04-17 12:46:31 +07:00
|
|
|
break;
|
|
|
|
case -ENOMEM:
|
2008-12-25 19:39:45 +07:00
|
|
|
pr_err("There is not enough memory to load or query "
|
|
|
|
"DCSS %s\n", seg_name);
|
2008-04-17 12:46:31 +07:00
|
|
|
break;
|
|
|
|
case -ERANGE:
|
2008-12-25 19:39:45 +07:00
|
|
|
pr_err("DCSS %s exceeds the kernel mapping range (%lu) "
|
|
|
|
"and cannot be loaded\n", seg_name, VMEM_MAX_PHYS);
|
2008-04-17 12:46:31 +07:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
EXPORT_SYMBOL(segment_load);
|
|
|
|
EXPORT_SYMBOL(segment_unload);
|
|
|
|
EXPORT_SYMBOL(segment_save);
|
|
|
|
EXPORT_SYMBOL(segment_type);
|
|
|
|
EXPORT_SYMBOL(segment_modify_shared);
|
2008-04-17 12:46:31 +07:00
|
|
|
EXPORT_SYMBOL(segment_warning);
|