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 22:07:57 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2006-06-23 17:05:06 +08:00
|
|
|
/*
|
|
|
|
* Hypervisor filesystem for Linux on s390. Diag 204 and 224
|
|
|
|
* implementation.
|
|
|
|
*
|
2008-12-25 20:39:39 +08:00
|
|
|
* Copyright IBM Corp. 2006, 2008
|
2006-06-23 17:05:06 +08:00
|
|
|
* Author(s): Michael Holzheu <holzheu@de.ibm.com>
|
|
|
|
*/
|
|
|
|
|
2008-12-25 20:39:39 +08:00
|
|
|
#define KMSG_COMPONENT "hypfs"
|
|
|
|
#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
|
|
|
|
|
2006-06-23 17:05:06 +08:00
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/errno.h>
|
2009-04-01 01:16:02 +08:00
|
|
|
#include <linux/slab.h>
|
2006-06-23 17:05:06 +08:00
|
|
|
#include <linux/string.h>
|
|
|
|
#include <linux/vmalloc.h>
|
2010-05-17 16:00:20 +08:00
|
|
|
#include <linux/mm.h>
|
2015-08-20 23:28:44 +08:00
|
|
|
#include <asm/diag.h>
|
2006-06-23 17:05:06 +08:00
|
|
|
#include <asm/ebcdic.h>
|
|
|
|
#include "hypfs.h"
|
|
|
|
|
|
|
|
#define TMP_SIZE 64 /* size of temporary buffers */
|
|
|
|
|
2010-05-17 16:00:20 +08:00
|
|
|
#define DBFS_D204_HDR_VERSION 0
|
|
|
|
|
2006-06-23 17:05:06 +08:00
|
|
|
static char *diag224_cpu_names; /* diag 224 name table */
|
|
|
|
static enum diag204_sc diag204_store_sc; /* used subcode for store */
|
|
|
|
static enum diag204_format diag204_info_type; /* used diag 204 data format */
|
|
|
|
|
|
|
|
static void *diag204_buf; /* 4K aligned buffer for diag204 data */
|
|
|
|
static void *diag204_buf_vmalloc; /* vmalloc pointer for diag204 data */
|
|
|
|
static int diag204_buf_pages; /* number of pages for diag204 data */
|
|
|
|
|
2010-05-17 16:00:20 +08:00
|
|
|
static struct dentry *dbfs_d204_file;
|
|
|
|
|
2006-06-23 17:05:06 +08:00
|
|
|
/*
|
2016-02-04 17:24:52 +08:00
|
|
|
* DIAG 204 member access functions.
|
2006-06-23 17:05:06 +08:00
|
|
|
*
|
|
|
|
* Since we have two different diag 204 data formats for old and new s390
|
|
|
|
* machines, we do not access the structs directly, but use getter functions for
|
|
|
|
* each struct member instead. This should make the code more readable.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Time information block */
|
|
|
|
|
|
|
|
static inline int info_blk_hdr__size(enum diag204_format type)
|
|
|
|
{
|
2016-02-04 17:24:52 +08:00
|
|
|
if (type == DIAG204_INFO_SIMPLE)
|
|
|
|
return sizeof(struct diag204_info_blk_hdr);
|
|
|
|
else /* DIAG204_INFO_EXT */
|
|
|
|
return sizeof(struct diag204_x_info_blk_hdr);
|
2006-06-23 17:05:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline __u8 info_blk_hdr__npar(enum diag204_format type, void *hdr)
|
|
|
|
{
|
2016-02-04 17:24:52 +08:00
|
|
|
if (type == DIAG204_INFO_SIMPLE)
|
|
|
|
return ((struct diag204_info_blk_hdr *)hdr)->npar;
|
|
|
|
else /* DIAG204_INFO_EXT */
|
|
|
|
return ((struct diag204_x_info_blk_hdr *)hdr)->npar;
|
2006-06-23 17:05:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline __u8 info_blk_hdr__flags(enum diag204_format type, void *hdr)
|
|
|
|
{
|
2016-02-04 17:24:52 +08:00
|
|
|
if (type == DIAG204_INFO_SIMPLE)
|
|
|
|
return ((struct diag204_info_blk_hdr *)hdr)->flags;
|
|
|
|
else /* DIAG204_INFO_EXT */
|
|
|
|
return ((struct diag204_x_info_blk_hdr *)hdr)->flags;
|
2006-06-23 17:05:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline __u16 info_blk_hdr__pcpus(enum diag204_format type, void *hdr)
|
|
|
|
{
|
2016-02-04 17:24:52 +08:00
|
|
|
if (type == DIAG204_INFO_SIMPLE)
|
|
|
|
return ((struct diag204_info_blk_hdr *)hdr)->phys_cpus;
|
|
|
|
else /* DIAG204_INFO_EXT */
|
|
|
|
return ((struct diag204_x_info_blk_hdr *)hdr)->phys_cpus;
|
2006-06-23 17:05:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Partition header */
|
|
|
|
|
|
|
|
static inline int part_hdr__size(enum diag204_format type)
|
|
|
|
{
|
2016-02-04 17:24:52 +08:00
|
|
|
if (type == DIAG204_INFO_SIMPLE)
|
|
|
|
return sizeof(struct diag204_part_hdr);
|
|
|
|
else /* DIAG204_INFO_EXT */
|
|
|
|
return sizeof(struct diag204_x_part_hdr);
|
2006-06-23 17:05:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline __u8 part_hdr__rcpus(enum diag204_format type, void *hdr)
|
|
|
|
{
|
2016-02-04 17:24:52 +08:00
|
|
|
if (type == DIAG204_INFO_SIMPLE)
|
|
|
|
return ((struct diag204_part_hdr *)hdr)->cpus;
|
|
|
|
else /* DIAG204_INFO_EXT */
|
|
|
|
return ((struct diag204_x_part_hdr *)hdr)->rcpus;
|
2006-06-23 17:05:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void part_hdr__part_name(enum diag204_format type, void *hdr,
|
|
|
|
char *name)
|
|
|
|
{
|
2016-02-04 17:24:52 +08:00
|
|
|
if (type == DIAG204_INFO_SIMPLE)
|
|
|
|
memcpy(name, ((struct diag204_part_hdr *)hdr)->part_name,
|
|
|
|
DIAG204_LPAR_NAME_LEN);
|
|
|
|
else /* DIAG204_INFO_EXT */
|
|
|
|
memcpy(name, ((struct diag204_x_part_hdr *)hdr)->part_name,
|
|
|
|
DIAG204_LPAR_NAME_LEN);
|
|
|
|
EBCASC(name, DIAG204_LPAR_NAME_LEN);
|
|
|
|
name[DIAG204_LPAR_NAME_LEN] = 0;
|
2009-12-19 00:43:27 +08:00
|
|
|
strim(name);
|
2006-06-23 17:05:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* CPU info block */
|
|
|
|
|
|
|
|
static inline int cpu_info__size(enum diag204_format type)
|
|
|
|
{
|
2016-02-04 17:24:52 +08:00
|
|
|
if (type == DIAG204_INFO_SIMPLE)
|
|
|
|
return sizeof(struct diag204_cpu_info);
|
|
|
|
else /* DIAG204_INFO_EXT */
|
|
|
|
return sizeof(struct diag204_x_cpu_info);
|
2006-06-23 17:05:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline __u8 cpu_info__ctidx(enum diag204_format type, void *hdr)
|
|
|
|
{
|
2016-02-04 17:24:52 +08:00
|
|
|
if (type == DIAG204_INFO_SIMPLE)
|
|
|
|
return ((struct diag204_cpu_info *)hdr)->ctidx;
|
|
|
|
else /* DIAG204_INFO_EXT */
|
|
|
|
return ((struct diag204_x_cpu_info *)hdr)->ctidx;
|
2006-06-23 17:05:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline __u16 cpu_info__cpu_addr(enum diag204_format type, void *hdr)
|
|
|
|
{
|
2016-02-04 17:24:52 +08:00
|
|
|
if (type == DIAG204_INFO_SIMPLE)
|
|
|
|
return ((struct diag204_cpu_info *)hdr)->cpu_addr;
|
|
|
|
else /* DIAG204_INFO_EXT */
|
|
|
|
return ((struct diag204_x_cpu_info *)hdr)->cpu_addr;
|
2006-06-23 17:05:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline __u64 cpu_info__acc_time(enum diag204_format type, void *hdr)
|
|
|
|
{
|
2016-02-04 17:24:52 +08:00
|
|
|
if (type == DIAG204_INFO_SIMPLE)
|
|
|
|
return ((struct diag204_cpu_info *)hdr)->acc_time;
|
|
|
|
else /* DIAG204_INFO_EXT */
|
|
|
|
return ((struct diag204_x_cpu_info *)hdr)->acc_time;
|
2006-06-23 17:05:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline __u64 cpu_info__lp_time(enum diag204_format type, void *hdr)
|
|
|
|
{
|
2016-02-04 17:24:52 +08:00
|
|
|
if (type == DIAG204_INFO_SIMPLE)
|
|
|
|
return ((struct diag204_cpu_info *)hdr)->lp_time;
|
|
|
|
else /* DIAG204_INFO_EXT */
|
|
|
|
return ((struct diag204_x_cpu_info *)hdr)->lp_time;
|
2006-06-23 17:05:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline __u64 cpu_info__online_time(enum diag204_format type, void *hdr)
|
|
|
|
{
|
2016-02-04 17:24:52 +08:00
|
|
|
if (type == DIAG204_INFO_SIMPLE)
|
2006-06-23 17:05:06 +08:00
|
|
|
return 0; /* online_time not available in simple info */
|
2016-02-04 17:24:52 +08:00
|
|
|
else /* DIAG204_INFO_EXT */
|
|
|
|
return ((struct diag204_x_cpu_info *)hdr)->online_time;
|
2006-06-23 17:05:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Physical header */
|
|
|
|
|
|
|
|
static inline int phys_hdr__size(enum diag204_format type)
|
|
|
|
{
|
2016-02-04 17:24:52 +08:00
|
|
|
if (type == DIAG204_INFO_SIMPLE)
|
|
|
|
return sizeof(struct diag204_phys_hdr);
|
|
|
|
else /* DIAG204_INFO_EXT */
|
|
|
|
return sizeof(struct diag204_x_phys_hdr);
|
2006-06-23 17:05:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline __u8 phys_hdr__cpus(enum diag204_format type, void *hdr)
|
|
|
|
{
|
2016-02-04 17:24:52 +08:00
|
|
|
if (type == DIAG204_INFO_SIMPLE)
|
|
|
|
return ((struct diag204_phys_hdr *)hdr)->cpus;
|
|
|
|
else /* DIAG204_INFO_EXT */
|
|
|
|
return ((struct diag204_x_phys_hdr *)hdr)->cpus;
|
2006-06-23 17:05:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Physical CPU info block */
|
|
|
|
|
|
|
|
static inline int phys_cpu__size(enum diag204_format type)
|
|
|
|
{
|
2016-02-04 17:24:52 +08:00
|
|
|
if (type == DIAG204_INFO_SIMPLE)
|
|
|
|
return sizeof(struct diag204_phys_cpu);
|
|
|
|
else /* DIAG204_INFO_EXT */
|
|
|
|
return sizeof(struct diag204_x_phys_cpu);
|
2006-06-23 17:05:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline __u16 phys_cpu__cpu_addr(enum diag204_format type, void *hdr)
|
|
|
|
{
|
2016-02-04 17:24:52 +08:00
|
|
|
if (type == DIAG204_INFO_SIMPLE)
|
|
|
|
return ((struct diag204_phys_cpu *)hdr)->cpu_addr;
|
|
|
|
else /* DIAG204_INFO_EXT */
|
|
|
|
return ((struct diag204_x_phys_cpu *)hdr)->cpu_addr;
|
2006-06-23 17:05:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline __u64 phys_cpu__mgm_time(enum diag204_format type, void *hdr)
|
|
|
|
{
|
2016-02-04 17:24:52 +08:00
|
|
|
if (type == DIAG204_INFO_SIMPLE)
|
|
|
|
return ((struct diag204_phys_cpu *)hdr)->mgm_time;
|
|
|
|
else /* DIAG204_INFO_EXT */
|
|
|
|
return ((struct diag204_x_phys_cpu *)hdr)->mgm_time;
|
2006-06-23 17:05:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline __u64 phys_cpu__ctidx(enum diag204_format type, void *hdr)
|
|
|
|
{
|
2016-02-04 17:24:52 +08:00
|
|
|
if (type == DIAG204_INFO_SIMPLE)
|
|
|
|
return ((struct diag204_phys_cpu *)hdr)->ctidx;
|
|
|
|
else /* DIAG204_INFO_EXT */
|
|
|
|
return ((struct diag204_x_phys_cpu *)hdr)->ctidx;
|
2006-06-23 17:05:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Diagnose 204 functions */
|
|
|
|
/*
|
|
|
|
* For the old diag subcode 4 with simple data format we have to use real
|
|
|
|
* memory. If we use subcode 6 or 7 with extended data format, we can (and
|
|
|
|
* should) use vmalloc, since we need a lot of memory in that case. Currently
|
|
|
|
* up to 93 pages!
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void diag204_free_buffer(void)
|
|
|
|
{
|
|
|
|
if (!diag204_buf)
|
|
|
|
return;
|
|
|
|
if (diag204_buf_vmalloc) {
|
|
|
|
vfree(diag204_buf_vmalloc);
|
|
|
|
diag204_buf_vmalloc = NULL;
|
|
|
|
} else {
|
|
|
|
free_pages((unsigned long) diag204_buf, 0);
|
|
|
|
}
|
|
|
|
diag204_buf = NULL;
|
|
|
|
}
|
|
|
|
|
2010-05-17 16:00:20 +08:00
|
|
|
static void *page_align_ptr(void *ptr)
|
|
|
|
{
|
|
|
|
return (void *) PAGE_ALIGN((unsigned long) ptr);
|
|
|
|
}
|
|
|
|
|
2006-06-23 17:05:06 +08:00
|
|
|
static void *diag204_alloc_vbuf(int pages)
|
|
|
|
{
|
|
|
|
/* The buffer has to be page aligned! */
|
treewide: Use array_size() in vmalloc()
The vmalloc() function has no 2-factor argument form, so multiplication
factors need to be wrapped in array_size(). This patch replaces cases of:
vmalloc(a * b)
with:
vmalloc(array_size(a, b))
as well as handling cases of:
vmalloc(a * b * c)
with:
vmalloc(array3_size(a, b, c))
This does, however, attempt to ignore constant size factors like:
vmalloc(4 * 1024)
though any constants defined via macros get caught up in the conversion.
Any factors with a sizeof() of "unsigned char", "char", and "u8" were
dropped, since they're redundant.
The Coccinelle script used for this was:
// Fix redundant parens around sizeof().
@@
type TYPE;
expression THING, E;
@@
(
vmalloc(
- (sizeof(TYPE)) * E
+ sizeof(TYPE) * E
, ...)
|
vmalloc(
- (sizeof(THING)) * E
+ sizeof(THING) * E
, ...)
)
// Drop single-byte sizes and redundant parens.
@@
expression COUNT;
typedef u8;
typedef __u8;
@@
(
vmalloc(
- sizeof(u8) * (COUNT)
+ COUNT
, ...)
|
vmalloc(
- sizeof(__u8) * (COUNT)
+ COUNT
, ...)
|
vmalloc(
- sizeof(char) * (COUNT)
+ COUNT
, ...)
|
vmalloc(
- sizeof(unsigned char) * (COUNT)
+ COUNT
, ...)
|
vmalloc(
- sizeof(u8) * COUNT
+ COUNT
, ...)
|
vmalloc(
- sizeof(__u8) * COUNT
+ COUNT
, ...)
|
vmalloc(
- sizeof(char) * COUNT
+ COUNT
, ...)
|
vmalloc(
- sizeof(unsigned char) * COUNT
+ COUNT
, ...)
)
// 2-factor product with sizeof(type/expression) and identifier or constant.
@@
type TYPE;
expression THING;
identifier COUNT_ID;
constant COUNT_CONST;
@@
(
vmalloc(
- sizeof(TYPE) * (COUNT_ID)
+ array_size(COUNT_ID, sizeof(TYPE))
, ...)
|
vmalloc(
- sizeof(TYPE) * COUNT_ID
+ array_size(COUNT_ID, sizeof(TYPE))
, ...)
|
vmalloc(
- sizeof(TYPE) * (COUNT_CONST)
+ array_size(COUNT_CONST, sizeof(TYPE))
, ...)
|
vmalloc(
- sizeof(TYPE) * COUNT_CONST
+ array_size(COUNT_CONST, sizeof(TYPE))
, ...)
|
vmalloc(
- sizeof(THING) * (COUNT_ID)
+ array_size(COUNT_ID, sizeof(THING))
, ...)
|
vmalloc(
- sizeof(THING) * COUNT_ID
+ array_size(COUNT_ID, sizeof(THING))
, ...)
|
vmalloc(
- sizeof(THING) * (COUNT_CONST)
+ array_size(COUNT_CONST, sizeof(THING))
, ...)
|
vmalloc(
- sizeof(THING) * COUNT_CONST
+ array_size(COUNT_CONST, sizeof(THING))
, ...)
)
// 2-factor product, only identifiers.
@@
identifier SIZE, COUNT;
@@
vmalloc(
- SIZE * COUNT
+ array_size(COUNT, SIZE)
, ...)
// 3-factor product with 1 sizeof(type) or sizeof(expression), with
// redundant parens removed.
@@
expression THING;
identifier STRIDE, COUNT;
type TYPE;
@@
(
vmalloc(
- sizeof(TYPE) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
vmalloc(
- sizeof(TYPE) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
vmalloc(
- sizeof(TYPE) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
vmalloc(
- sizeof(TYPE) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
vmalloc(
- sizeof(THING) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
vmalloc(
- sizeof(THING) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
vmalloc(
- sizeof(THING) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
vmalloc(
- sizeof(THING) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
)
// 3-factor product with 2 sizeof(variable), with redundant parens removed.
@@
expression THING1, THING2;
identifier COUNT;
type TYPE1, TYPE2;
@@
(
vmalloc(
- sizeof(TYPE1) * sizeof(TYPE2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
vmalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
vmalloc(
- sizeof(THING1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
vmalloc(
- sizeof(THING1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
vmalloc(
- sizeof(TYPE1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
|
vmalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
)
// 3-factor product, only identifiers, with redundant parens removed.
@@
identifier STRIDE, SIZE, COUNT;
@@
(
vmalloc(
- (COUNT) * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
vmalloc(
- COUNT * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
vmalloc(
- COUNT * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
vmalloc(
- (COUNT) * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
vmalloc(
- COUNT * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
vmalloc(
- (COUNT) * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
vmalloc(
- (COUNT) * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
vmalloc(
- COUNT * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
)
// Any remaining multi-factor products, first at least 3-factor products
// when they're not all constants...
@@
expression E1, E2, E3;
constant C1, C2, C3;
@@
(
vmalloc(C1 * C2 * C3, ...)
|
vmalloc(
- E1 * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
)
// And then all remaining 2 factors products when they're not all constants.
@@
expression E1, E2;
constant C1, C2;
@@
(
vmalloc(C1 * C2, ...)
|
vmalloc(
- E1 * E2
+ array_size(E1, E2)
, ...)
)
Signed-off-by: Kees Cook <keescook@chromium.org>
2018-06-13 05:27:11 +08:00
|
|
|
diag204_buf_vmalloc = vmalloc(array_size(PAGE_SIZE, (pages + 1)));
|
2006-06-23 17:05:06 +08:00
|
|
|
if (!diag204_buf_vmalloc)
|
|
|
|
return ERR_PTR(-ENOMEM);
|
2010-05-17 16:00:20 +08:00
|
|
|
diag204_buf = page_align_ptr(diag204_buf_vmalloc);
|
2006-06-23 17:05:06 +08:00
|
|
|
diag204_buf_pages = pages;
|
|
|
|
return diag204_buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *diag204_alloc_rbuf(void)
|
|
|
|
{
|
|
|
|
diag204_buf = (void*)__get_free_pages(GFP_KERNEL,0);
|
2006-12-16 00:18:10 +08:00
|
|
|
if (!diag204_buf)
|
2006-06-23 17:05:06 +08:00
|
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
diag204_buf_pages = 1;
|
|
|
|
return diag204_buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *diag204_get_buffer(enum diag204_format fmt, int *pages)
|
|
|
|
{
|
|
|
|
if (diag204_buf) {
|
|
|
|
*pages = diag204_buf_pages;
|
|
|
|
return diag204_buf;
|
|
|
|
}
|
2016-02-04 17:24:52 +08:00
|
|
|
if (fmt == DIAG204_INFO_SIMPLE) {
|
2006-06-23 17:05:06 +08:00
|
|
|
*pages = 1;
|
|
|
|
return diag204_alloc_rbuf();
|
2016-02-04 17:24:52 +08:00
|
|
|
} else {/* DIAG204_INFO_EXT */
|
|
|
|
*pages = diag204((unsigned long)DIAG204_SUBC_RSI |
|
|
|
|
(unsigned long)DIAG204_INFO_EXT, 0, NULL);
|
2006-06-23 17:05:06 +08:00
|
|
|
if (*pages <= 0)
|
|
|
|
return ERR_PTR(-ENOSYS);
|
|
|
|
else
|
|
|
|
return diag204_alloc_vbuf(*pages);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* diag204_probe() has to find out, which type of diagnose 204 implementation
|
|
|
|
* we have on our machine. Currently there are three possible scanarios:
|
|
|
|
* - subcode 4 + simple data format (only one page)
|
|
|
|
* - subcode 4-6 + extended data format
|
|
|
|
* - subcode 4-7 + extended data format
|
|
|
|
*
|
|
|
|
* Subcode 5 is used to retrieve the size of the data, provided by subcodes
|
|
|
|
* 6 and 7. Subcode 7 basically has the same function as subcode 6. In addition
|
|
|
|
* to subcode 6 it provides also information about secondary cpus.
|
|
|
|
* In order to get as much information as possible, we first try
|
|
|
|
* subcode 7, then 6 and if both fail, we use subcode 4.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int diag204_probe(void)
|
|
|
|
{
|
|
|
|
void *buf;
|
|
|
|
int pages, rc;
|
|
|
|
|
2016-02-04 17:24:52 +08:00
|
|
|
buf = diag204_get_buffer(DIAG204_INFO_EXT, &pages);
|
2006-06-23 17:05:06 +08:00
|
|
|
if (!IS_ERR(buf)) {
|
2016-02-04 17:24:52 +08:00
|
|
|
if (diag204((unsigned long)DIAG204_SUBC_STIB7 |
|
|
|
|
(unsigned long)DIAG204_INFO_EXT, pages, buf) >= 0) {
|
|
|
|
diag204_store_sc = DIAG204_SUBC_STIB7;
|
|
|
|
diag204_info_type = DIAG204_INFO_EXT;
|
2006-06-23 17:05:06 +08:00
|
|
|
goto out;
|
|
|
|
}
|
2016-02-04 17:24:52 +08:00
|
|
|
if (diag204((unsigned long)DIAG204_SUBC_STIB6 |
|
|
|
|
(unsigned long)DIAG204_INFO_EXT, pages, buf) >= 0) {
|
|
|
|
diag204_store_sc = DIAG204_SUBC_STIB6;
|
|
|
|
diag204_info_type = DIAG204_INFO_EXT;
|
2006-06-23 17:05:06 +08:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
diag204_free_buffer();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* subcodes 6 and 7 failed, now try subcode 4 */
|
|
|
|
|
2016-02-04 17:24:52 +08:00
|
|
|
buf = diag204_get_buffer(DIAG204_INFO_SIMPLE, &pages);
|
2006-06-23 17:05:06 +08:00
|
|
|
if (IS_ERR(buf)) {
|
|
|
|
rc = PTR_ERR(buf);
|
|
|
|
goto fail_alloc;
|
|
|
|
}
|
2016-02-04 17:24:52 +08:00
|
|
|
if (diag204((unsigned long)DIAG204_SUBC_STIB4 |
|
|
|
|
(unsigned long)DIAG204_INFO_SIMPLE, pages, buf) >= 0) {
|
|
|
|
diag204_store_sc = DIAG204_SUBC_STIB4;
|
|
|
|
diag204_info_type = DIAG204_INFO_SIMPLE;
|
2006-06-23 17:05:06 +08:00
|
|
|
goto out;
|
|
|
|
} else {
|
|
|
|
rc = -ENOSYS;
|
|
|
|
goto fail_store;
|
|
|
|
}
|
|
|
|
out:
|
|
|
|
rc = 0;
|
|
|
|
fail_store:
|
|
|
|
diag204_free_buffer();
|
|
|
|
fail_alloc:
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2010-05-17 16:00:20 +08:00
|
|
|
static int diag204_do_store(void *buf, int pages)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
rc = diag204((unsigned long) diag204_store_sc |
|
|
|
|
(unsigned long) diag204_info_type, pages, buf);
|
|
|
|
return rc < 0 ? -ENOSYS : 0;
|
|
|
|
}
|
|
|
|
|
2006-06-23 17:05:06 +08:00
|
|
|
static void *diag204_store(void)
|
|
|
|
{
|
|
|
|
void *buf;
|
2010-05-17 16:00:20 +08:00
|
|
|
int pages, rc;
|
2006-06-23 17:05:06 +08:00
|
|
|
|
|
|
|
buf = diag204_get_buffer(diag204_info_type, &pages);
|
|
|
|
if (IS_ERR(buf))
|
|
|
|
goto out;
|
2010-05-17 16:00:20 +08:00
|
|
|
rc = diag204_do_store(buf, pages);
|
|
|
|
if (rc)
|
|
|
|
return ERR_PTR(rc);
|
2006-06-23 17:05:06 +08:00
|
|
|
out:
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Diagnose 224 functions */
|
|
|
|
|
|
|
|
static int diag224_get_name_table(void)
|
|
|
|
{
|
|
|
|
/* memory must be below 2GB */
|
2016-10-25 22:24:28 +08:00
|
|
|
diag224_cpu_names = (char *) __get_free_page(GFP_KERNEL | GFP_DMA);
|
2006-06-23 17:05:06 +08:00
|
|
|
if (!diag224_cpu_names)
|
|
|
|
return -ENOMEM;
|
2007-05-31 23:38:01 +08:00
|
|
|
if (diag224(diag224_cpu_names)) {
|
2016-10-25 22:24:28 +08:00
|
|
|
free_page((unsigned long) diag224_cpu_names);
|
2010-02-27 05:37:41 +08:00
|
|
|
return -EOPNOTSUPP;
|
2007-05-31 23:38:01 +08:00
|
|
|
}
|
2006-06-23 17:05:06 +08:00
|
|
|
EBCASC(diag224_cpu_names + 16, (*diag224_cpu_names + 1) * 16);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void diag224_delete_name_table(void)
|
|
|
|
{
|
2016-10-25 22:24:28 +08:00
|
|
|
free_page((unsigned long) diag224_cpu_names);
|
2006-06-23 17:05:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int diag224_idx2name(int index, char *name)
|
|
|
|
{
|
2016-02-04 17:24:52 +08:00
|
|
|
memcpy(name, diag224_cpu_names + ((index + 1) * DIAG204_CPU_NAME_LEN),
|
|
|
|
DIAG204_CPU_NAME_LEN);
|
|
|
|
name[DIAG204_CPU_NAME_LEN] = 0;
|
2009-12-19 00:43:27 +08:00
|
|
|
strim(name);
|
2006-06-23 17:05:06 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-05-17 16:00:20 +08:00
|
|
|
struct dbfs_d204_hdr {
|
|
|
|
u64 len; /* Length of d204 buffer without header */
|
|
|
|
u16 version; /* Version of header */
|
|
|
|
u8 sc; /* Used subcode */
|
|
|
|
char reserved[53];
|
|
|
|
} __attribute__ ((packed));
|
|
|
|
|
|
|
|
struct dbfs_d204 {
|
|
|
|
struct dbfs_d204_hdr hdr; /* 64 byte header */
|
|
|
|
char buf[]; /* d204 buffer */
|
|
|
|
} __attribute__ ((packed));
|
|
|
|
|
2011-01-05 19:47:43 +08:00
|
|
|
static int dbfs_d204_create(void **data, void **data_free_ptr, size_t *size)
|
2010-05-17 16:00:20 +08:00
|
|
|
{
|
|
|
|
struct dbfs_d204 *d204;
|
|
|
|
int rc, buf_size;
|
2011-01-05 19:47:43 +08:00
|
|
|
void *base;
|
2010-05-17 16:00:20 +08:00
|
|
|
|
|
|
|
buf_size = PAGE_SIZE * (diag204_buf_pages + 1) + sizeof(d204->hdr);
|
2011-05-29 01:36:21 +08:00
|
|
|
base = vzalloc(buf_size);
|
2011-01-05 19:47:43 +08:00
|
|
|
if (!base)
|
|
|
|
return -ENOMEM;
|
|
|
|
d204 = page_align_ptr(base + sizeof(d204->hdr)) - sizeof(d204->hdr);
|
|
|
|
rc = diag204_do_store(d204->buf, diag204_buf_pages);
|
|
|
|
if (rc) {
|
|
|
|
vfree(base);
|
|
|
|
return rc;
|
2010-05-17 16:00:20 +08:00
|
|
|
}
|
|
|
|
d204->hdr.version = DBFS_D204_HDR_VERSION;
|
|
|
|
d204->hdr.len = PAGE_SIZE * diag204_buf_pages;
|
|
|
|
d204->hdr.sc = diag204_store_sc;
|
2011-01-05 19:47:43 +08:00
|
|
|
*data = d204;
|
|
|
|
*data_free_ptr = base;
|
|
|
|
*size = d204->hdr.len + sizeof(struct dbfs_d204_hdr);
|
2010-05-17 16:00:20 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-01-05 19:47:43 +08:00
|
|
|
static struct hypfs_dbfs_file dbfs_file_d204 = {
|
|
|
|
.name = "diag_204",
|
|
|
|
.data_create = dbfs_d204_create,
|
|
|
|
.data_free = vfree,
|
2010-05-17 16:00:20 +08:00
|
|
|
};
|
|
|
|
|
2006-06-23 17:05:06 +08:00
|
|
|
__init int hypfs_diag_init(void)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (diag204_probe()) {
|
2008-12-25 20:39:39 +08:00
|
|
|
pr_err("The hardware system does not support hypfs\n");
|
2006-06-23 17:05:06 +08:00
|
|
|
return -ENODATA;
|
|
|
|
}
|
2016-02-04 17:24:52 +08:00
|
|
|
if (diag204_info_type == DIAG204_INFO_EXT) {
|
2011-01-05 19:47:43 +08:00
|
|
|
rc = hypfs_dbfs_create_file(&dbfs_file_d204);
|
2010-05-17 16:00:20 +08:00
|
|
|
if (rc)
|
2010-10-29 22:50:39 +08:00
|
|
|
return rc;
|
2010-05-17 16:00:20 +08:00
|
|
|
}
|
2010-10-29 22:50:39 +08:00
|
|
|
if (MACHINE_IS_LPAR) {
|
|
|
|
rc = diag224_get_name_table();
|
|
|
|
if (rc) {
|
|
|
|
pr_err("The hardware system does not provide all "
|
|
|
|
"functions required by hypfs\n");
|
|
|
|
debugfs_remove(dbfs_d204_file);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
2006-06-23 17:05:06 +08:00
|
|
|
}
|
|
|
|
|
2006-09-20 21:59:12 +08:00
|
|
|
void hypfs_diag_exit(void)
|
2006-06-23 17:05:06 +08:00
|
|
|
{
|
2010-05-17 16:00:20 +08:00
|
|
|
debugfs_remove(dbfs_d204_file);
|
2006-06-23 17:05:06 +08:00
|
|
|
diag224_delete_name_table();
|
|
|
|
diag204_free_buffer();
|
2011-01-05 19:47:43 +08:00
|
|
|
hypfs_dbfs_remove_file(&dbfs_file_d204);
|
2006-06-23 17:05:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Functions to create the directory structure
|
|
|
|
* *******************************************
|
|
|
|
*/
|
|
|
|
|
2013-07-19 21:10:21 +08:00
|
|
|
static int hypfs_create_cpu_files(struct dentry *cpus_dir, void *cpu_info)
|
2006-06-23 17:05:06 +08:00
|
|
|
{
|
|
|
|
struct dentry *cpu_dir;
|
|
|
|
char buffer[TMP_SIZE];
|
|
|
|
void *rc;
|
|
|
|
|
|
|
|
snprintf(buffer, TMP_SIZE, "%d", cpu_info__cpu_addr(diag204_info_type,
|
|
|
|
cpu_info));
|
2013-07-19 22:05:21 +08:00
|
|
|
cpu_dir = hypfs_mkdir(cpus_dir, buffer);
|
|
|
|
rc = hypfs_create_u64(cpu_dir, "mgmtime",
|
2006-06-23 17:05:06 +08:00
|
|
|
cpu_info__acc_time(diag204_info_type, cpu_info) -
|
|
|
|
cpu_info__lp_time(diag204_info_type, cpu_info));
|
|
|
|
if (IS_ERR(rc))
|
|
|
|
return PTR_ERR(rc);
|
2013-07-19 22:05:21 +08:00
|
|
|
rc = hypfs_create_u64(cpu_dir, "cputime",
|
2006-06-23 17:05:06 +08:00
|
|
|
cpu_info__lp_time(diag204_info_type, cpu_info));
|
|
|
|
if (IS_ERR(rc))
|
|
|
|
return PTR_ERR(rc);
|
2016-02-04 17:24:52 +08:00
|
|
|
if (diag204_info_type == DIAG204_INFO_EXT) {
|
2013-07-19 22:05:21 +08:00
|
|
|
rc = hypfs_create_u64(cpu_dir, "onlinetime",
|
2006-06-23 17:05:06 +08:00
|
|
|
cpu_info__online_time(diag204_info_type,
|
|
|
|
cpu_info));
|
|
|
|
if (IS_ERR(rc))
|
|
|
|
return PTR_ERR(rc);
|
|
|
|
}
|
|
|
|
diag224_idx2name(cpu_info__ctidx(diag204_info_type, cpu_info), buffer);
|
2013-07-19 22:05:21 +08:00
|
|
|
rc = hypfs_create_str(cpu_dir, "type", buffer);
|
2018-07-19 13:08:30 +08:00
|
|
|
return PTR_ERR_OR_ZERO(rc);
|
2006-06-23 17:05:06 +08:00
|
|
|
}
|
|
|
|
|
2013-07-19 21:10:21 +08:00
|
|
|
static void *hypfs_create_lpar_files(struct dentry *systems_dir, void *part_hdr)
|
2006-06-23 17:05:06 +08:00
|
|
|
{
|
|
|
|
struct dentry *cpus_dir;
|
|
|
|
struct dentry *lpar_dir;
|
2016-02-04 17:24:52 +08:00
|
|
|
char lpar_name[DIAG204_LPAR_NAME_LEN + 1];
|
2006-06-23 17:05:06 +08:00
|
|
|
void *cpu_info;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
part_hdr__part_name(diag204_info_type, part_hdr, lpar_name);
|
2016-02-04 17:24:52 +08:00
|
|
|
lpar_name[DIAG204_LPAR_NAME_LEN] = 0;
|
2013-07-19 22:05:21 +08:00
|
|
|
lpar_dir = hypfs_mkdir(systems_dir, lpar_name);
|
2006-06-23 17:05:06 +08:00
|
|
|
if (IS_ERR(lpar_dir))
|
|
|
|
return lpar_dir;
|
2013-07-19 22:05:21 +08:00
|
|
|
cpus_dir = hypfs_mkdir(lpar_dir, "cpus");
|
2006-06-23 17:05:06 +08:00
|
|
|
if (IS_ERR(cpus_dir))
|
|
|
|
return cpus_dir;
|
|
|
|
cpu_info = part_hdr + part_hdr__size(diag204_info_type);
|
|
|
|
for (i = 0; i < part_hdr__rcpus(diag204_info_type, part_hdr); i++) {
|
|
|
|
int rc;
|
2013-07-19 21:10:21 +08:00
|
|
|
rc = hypfs_create_cpu_files(cpus_dir, cpu_info);
|
2006-06-23 17:05:06 +08:00
|
|
|
if (rc)
|
|
|
|
return ERR_PTR(rc);
|
|
|
|
cpu_info += cpu_info__size(diag204_info_type);
|
|
|
|
}
|
|
|
|
return cpu_info;
|
|
|
|
}
|
|
|
|
|
2013-07-19 21:10:21 +08:00
|
|
|
static int hypfs_create_phys_cpu_files(struct dentry *cpus_dir, void *cpu_info)
|
2006-06-23 17:05:06 +08:00
|
|
|
{
|
|
|
|
struct dentry *cpu_dir;
|
|
|
|
char buffer[TMP_SIZE];
|
|
|
|
void *rc;
|
|
|
|
|
|
|
|
snprintf(buffer, TMP_SIZE, "%i", phys_cpu__cpu_addr(diag204_info_type,
|
|
|
|
cpu_info));
|
2013-07-19 22:05:21 +08:00
|
|
|
cpu_dir = hypfs_mkdir(cpus_dir, buffer);
|
2006-06-23 17:05:06 +08:00
|
|
|
if (IS_ERR(cpu_dir))
|
|
|
|
return PTR_ERR(cpu_dir);
|
2013-07-19 22:05:21 +08:00
|
|
|
rc = hypfs_create_u64(cpu_dir, "mgmtime",
|
2006-06-23 17:05:06 +08:00
|
|
|
phys_cpu__mgm_time(diag204_info_type, cpu_info));
|
|
|
|
if (IS_ERR(rc))
|
|
|
|
return PTR_ERR(rc);
|
|
|
|
diag224_idx2name(phys_cpu__ctidx(diag204_info_type, cpu_info), buffer);
|
2013-07-19 22:05:21 +08:00
|
|
|
rc = hypfs_create_str(cpu_dir, "type", buffer);
|
2018-07-19 13:08:30 +08:00
|
|
|
return PTR_ERR_OR_ZERO(rc);
|
2006-06-23 17:05:06 +08:00
|
|
|
}
|
|
|
|
|
2013-07-19 21:10:21 +08:00
|
|
|
static void *hypfs_create_phys_files(struct dentry *parent_dir, void *phys_hdr)
|
2006-06-23 17:05:06 +08:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
void *cpu_info;
|
|
|
|
struct dentry *cpus_dir;
|
|
|
|
|
2013-07-19 22:05:21 +08:00
|
|
|
cpus_dir = hypfs_mkdir(parent_dir, "cpus");
|
2006-06-23 17:05:06 +08:00
|
|
|
if (IS_ERR(cpus_dir))
|
|
|
|
return cpus_dir;
|
|
|
|
cpu_info = phys_hdr + phys_hdr__size(diag204_info_type);
|
|
|
|
for (i = 0; i < phys_hdr__cpus(diag204_info_type, phys_hdr); i++) {
|
|
|
|
int rc;
|
2013-07-19 21:10:21 +08:00
|
|
|
rc = hypfs_create_phys_cpu_files(cpus_dir, cpu_info);
|
2006-06-23 17:05:06 +08:00
|
|
|
if (rc)
|
|
|
|
return ERR_PTR(rc);
|
|
|
|
cpu_info += phys_cpu__size(diag204_info_type);
|
|
|
|
}
|
|
|
|
return cpu_info;
|
|
|
|
}
|
|
|
|
|
2013-07-19 21:10:21 +08:00
|
|
|
int hypfs_diag_create_files(struct dentry *root)
|
2006-06-23 17:05:06 +08:00
|
|
|
{
|
|
|
|
struct dentry *systems_dir, *hyp_dir;
|
|
|
|
void *time_hdr, *part_hdr;
|
|
|
|
int i, rc;
|
|
|
|
void *buffer, *ptr;
|
|
|
|
|
|
|
|
buffer = diag204_store();
|
|
|
|
if (IS_ERR(buffer))
|
|
|
|
return PTR_ERR(buffer);
|
|
|
|
|
2013-07-19 22:05:21 +08:00
|
|
|
systems_dir = hypfs_mkdir(root, "systems");
|
2006-06-23 17:05:06 +08:00
|
|
|
if (IS_ERR(systems_dir)) {
|
|
|
|
rc = PTR_ERR(systems_dir);
|
|
|
|
goto err_out;
|
|
|
|
}
|
|
|
|
time_hdr = (struct x_info_blk_hdr *)buffer;
|
|
|
|
part_hdr = time_hdr + info_blk_hdr__size(diag204_info_type);
|
|
|
|
for (i = 0; i < info_blk_hdr__npar(diag204_info_type, time_hdr); i++) {
|
2013-07-19 21:10:21 +08:00
|
|
|
part_hdr = hypfs_create_lpar_files(systems_dir, part_hdr);
|
2006-06-23 17:05:06 +08:00
|
|
|
if (IS_ERR(part_hdr)) {
|
|
|
|
rc = PTR_ERR(part_hdr);
|
|
|
|
goto err_out;
|
|
|
|
}
|
|
|
|
}
|
2016-02-04 17:24:52 +08:00
|
|
|
if (info_blk_hdr__flags(diag204_info_type, time_hdr) &
|
|
|
|
DIAG204_LPAR_PHYS_FLG) {
|
2013-07-19 21:10:21 +08:00
|
|
|
ptr = hypfs_create_phys_files(root, part_hdr);
|
2006-06-23 17:05:06 +08:00
|
|
|
if (IS_ERR(ptr)) {
|
|
|
|
rc = PTR_ERR(ptr);
|
|
|
|
goto err_out;
|
|
|
|
}
|
|
|
|
}
|
2013-07-19 22:05:21 +08:00
|
|
|
hyp_dir = hypfs_mkdir(root, "hyp");
|
2006-06-23 17:05:06 +08:00
|
|
|
if (IS_ERR(hyp_dir)) {
|
|
|
|
rc = PTR_ERR(hyp_dir);
|
|
|
|
goto err_out;
|
|
|
|
}
|
2013-07-19 22:05:21 +08:00
|
|
|
ptr = hypfs_create_str(hyp_dir, "type", "LPAR Hypervisor");
|
2006-06-23 17:05:06 +08:00
|
|
|
if (IS_ERR(ptr)) {
|
|
|
|
rc = PTR_ERR(ptr);
|
|
|
|
goto err_out;
|
|
|
|
}
|
|
|
|
rc = 0;
|
|
|
|
|
|
|
|
err_out:
|
|
|
|
return rc;
|
|
|
|
}
|