2017-11-24 17:00:32 +03:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2006-09-20 17:58:49 +04:00
|
|
|
/*
|
|
|
|
* ipl/reipl/dump support for Linux on s390.
|
|
|
|
*
|
2012-07-20 13:15:04 +04:00
|
|
|
* Copyright IBM Corp. 2005, 2012
|
2006-09-20 17:58:49 +04:00
|
|
|
* Author(s): Michael Holzheu <holzheu@de.ibm.com>
|
|
|
|
* Heiko Carstens <heiko.carstens@de.ibm.com>
|
|
|
|
* Volker Sameske <sameske@de.ibm.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
2017-02-09 23:20:23 +03:00
|
|
|
#include <linux/export.h>
|
|
|
|
#include <linux/init.h>
|
2006-09-20 17:58:49 +04:00
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/delay.h>
|
2021-07-01 04:54:59 +03:00
|
|
|
#include <linux/panic_notifier.h>
|
2006-09-20 17:58:49 +04:00
|
|
|
#include <linux/reboot.h>
|
2006-12-04 17:39:58 +03:00
|
|
|
#include <linux/ctype.h>
|
2008-07-14 11:59:17 +04:00
|
|
|
#include <linux/fs.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 11:04:11 +03:00
|
|
|
#include <linux/gfp.h>
|
2011-10-30 18:16:40 +04:00
|
|
|
#include <linux/crash_dump.h>
|
2012-03-11 19:59:32 +04:00
|
|
|
#include <linux/debug_locks.h>
|
2015-08-20 18:28:44 +03:00
|
|
|
#include <asm/diag.h>
|
2007-02-21 12:55:21 +03:00
|
|
|
#include <asm/ipl.h>
|
2006-09-20 17:58:49 +04:00
|
|
|
#include <asm/smp.h>
|
|
|
|
#include <asm/setup.h>
|
|
|
|
#include <asm/cpcmd.h>
|
2006-12-04 17:39:58 +03:00
|
|
|
#include <asm/ebcdic.h>
|
2007-02-05 23:18:37 +03:00
|
|
|
#include <asm/sclp.h>
|
2009-03-26 17:24:45 +03:00
|
|
|
#include <asm/checksum.h>
|
2012-03-11 19:59:32 +04:00
|
|
|
#include <asm/debug.h>
|
2012-03-11 19:59:34 +04:00
|
|
|
#include <asm/os_info.h>
|
2018-05-15 14:28:53 +03:00
|
|
|
#include <asm/sections.h>
|
|
|
|
#include <asm/boot_data.h>
|
2011-10-30 18:17:13 +04:00
|
|
|
#include "entry.h"
|
2006-09-20 17:58:49 +04:00
|
|
|
|
|
|
|
#define IPL_PARM_BLOCK_VERSION 0
|
2006-12-04 17:39:58 +03:00
|
|
|
|
2007-04-27 18:01:49 +04:00
|
|
|
#define IPL_UNKNOWN_STR "unknown"
|
|
|
|
#define IPL_CCW_STR "ccw"
|
|
|
|
#define IPL_FCP_STR "fcp"
|
|
|
|
#define IPL_FCP_DUMP_STR "fcp_dump"
|
2020-03-02 22:03:37 +03:00
|
|
|
#define IPL_NVME_STR "nvme"
|
2020-03-17 16:23:41 +03:00
|
|
|
#define IPL_NVME_DUMP_STR "nvme_dump"
|
2007-04-27 18:01:49 +04:00
|
|
|
#define IPL_NSS_STR "nss"
|
2007-02-21 12:55:37 +03:00
|
|
|
|
2008-01-26 16:11:11 +03:00
|
|
|
#define DUMP_CCW_STR "ccw"
|
|
|
|
#define DUMP_FCP_STR "fcp"
|
2020-03-17 16:23:41 +03:00
|
|
|
#define DUMP_NVME_STR "nvme"
|
2008-01-26 16:11:11 +03:00
|
|
|
#define DUMP_NONE_STR "none"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Four shutdown trigger types are supported:
|
|
|
|
* - panic
|
|
|
|
* - halt
|
|
|
|
* - power off
|
|
|
|
* - reipl
|
2011-08-03 18:44:19 +04:00
|
|
|
* - restart
|
2008-01-26 16:11:11 +03:00
|
|
|
*/
|
|
|
|
#define ON_PANIC_STR "on_panic"
|
|
|
|
#define ON_HALT_STR "on_halt"
|
|
|
|
#define ON_POFF_STR "on_poff"
|
|
|
|
#define ON_REIPL_STR "on_reboot"
|
2011-08-03 18:44:19 +04:00
|
|
|
#define ON_RESTART_STR "on_restart"
|
2008-01-26 16:11:11 +03:00
|
|
|
|
|
|
|
struct shutdown_action;
|
|
|
|
struct shutdown_trigger {
|
|
|
|
char *name;
|
|
|
|
struct shutdown_action *action;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
2009-03-26 17:23:43 +03:00
|
|
|
* The following shutdown action types are supported:
|
2008-01-26 16:11:11 +03:00
|
|
|
*/
|
|
|
|
#define SHUTDOWN_ACTION_IPL_STR "ipl"
|
|
|
|
#define SHUTDOWN_ACTION_REIPL_STR "reipl"
|
|
|
|
#define SHUTDOWN_ACTION_DUMP_STR "dump"
|
|
|
|
#define SHUTDOWN_ACTION_VMCMD_STR "vmcmd"
|
|
|
|
#define SHUTDOWN_ACTION_STOP_STR "stop"
|
2009-03-26 17:23:43 +03:00
|
|
|
#define SHUTDOWN_ACTION_DUMP_REIPL_STR "dump_reipl"
|
2008-01-26 16:11:11 +03:00
|
|
|
|
|
|
|
struct shutdown_action {
|
|
|
|
char *name;
|
|
|
|
void (*fn) (struct shutdown_trigger *trigger);
|
|
|
|
int (*init) (void);
|
2009-07-07 18:37:07 +04:00
|
|
|
int init_rc;
|
2008-01-26 16:11:11 +03:00
|
|
|
};
|
|
|
|
|
2006-09-20 17:58:49 +04:00
|
|
|
static char *ipl_type_str(enum ipl_type type)
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case IPL_TYPE_CCW:
|
|
|
|
return IPL_CCW_STR;
|
|
|
|
case IPL_TYPE_FCP:
|
|
|
|
return IPL_FCP_STR;
|
2007-04-27 18:01:49 +04:00
|
|
|
case IPL_TYPE_FCP_DUMP:
|
|
|
|
return IPL_FCP_DUMP_STR;
|
2007-02-05 23:18:24 +03:00
|
|
|
case IPL_TYPE_NSS:
|
|
|
|
return IPL_NSS_STR;
|
2020-03-02 22:03:37 +03:00
|
|
|
case IPL_TYPE_NVME:
|
|
|
|
return IPL_NVME_STR;
|
2020-03-17 16:23:41 +03:00
|
|
|
case IPL_TYPE_NVME_DUMP:
|
|
|
|
return IPL_NVME_DUMP_STR;
|
2006-09-20 17:58:49 +04:00
|
|
|
case IPL_TYPE_UNKNOWN:
|
|
|
|
default:
|
|
|
|
return IPL_UNKNOWN_STR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-27 18:01:49 +04:00
|
|
|
enum dump_type {
|
|
|
|
DUMP_TYPE_NONE = 1,
|
|
|
|
DUMP_TYPE_CCW = 2,
|
|
|
|
DUMP_TYPE_FCP = 4,
|
2020-03-17 16:23:41 +03:00
|
|
|
DUMP_TYPE_NVME = 8,
|
2007-04-27 18:01:49 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static char *dump_type_str(enum dump_type type)
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case DUMP_TYPE_NONE:
|
|
|
|
return DUMP_NONE_STR;
|
|
|
|
case DUMP_TYPE_CCW:
|
|
|
|
return DUMP_CCW_STR;
|
|
|
|
case DUMP_TYPE_FCP:
|
|
|
|
return DUMP_FCP_STR;
|
2020-03-17 16:23:41 +03:00
|
|
|
case DUMP_TYPE_NVME:
|
|
|
|
return DUMP_NVME_STR;
|
2007-04-27 18:01:49 +04:00
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-01 20:10:51 +03:00
|
|
|
int __bootdata_preserved(ipl_block_valid);
|
|
|
|
struct ipl_parameter_block __bootdata_preserved(ipl_block);
|
2019-02-21 16:23:04 +03:00
|
|
|
int __bootdata_preserved(ipl_secure_flag);
|
|
|
|
|
|
|
|
unsigned long __bootdata_preserved(ipl_cert_list_addr);
|
|
|
|
unsigned long __bootdata_preserved(ipl_cert_list_size);
|
|
|
|
|
|
|
|
unsigned long __bootdata(early_ipl_comp_list_addr);
|
|
|
|
unsigned long __bootdata(early_ipl_comp_list_size);
|
2008-07-14 11:59:09 +04:00
|
|
|
|
2006-09-20 17:58:49 +04:00
|
|
|
static int reipl_capabilities = IPL_TYPE_UNKNOWN;
|
2007-02-05 23:18:24 +03:00
|
|
|
|
2006-09-20 17:58:49 +04:00
|
|
|
static enum ipl_type reipl_type = IPL_TYPE_UNKNOWN;
|
|
|
|
static struct ipl_parameter_block *reipl_block_fcp;
|
2020-03-03 22:11:19 +03:00
|
|
|
static struct ipl_parameter_block *reipl_block_nvme;
|
2006-09-20 17:58:49 +04:00
|
|
|
static struct ipl_parameter_block *reipl_block_ccw;
|
2008-07-14 11:59:09 +04:00
|
|
|
static struct ipl_parameter_block *reipl_block_nss;
|
2009-03-26 17:23:43 +03:00
|
|
|
static struct ipl_parameter_block *reipl_block_actual;
|
2007-02-05 23:18:24 +03:00
|
|
|
|
2007-04-27 18:01:49 +04:00
|
|
|
static int dump_capabilities = DUMP_TYPE_NONE;
|
|
|
|
static enum dump_type dump_type = DUMP_TYPE_NONE;
|
2006-09-20 17:58:49 +04:00
|
|
|
static struct ipl_parameter_block *dump_block_fcp;
|
2020-03-17 16:23:41 +03:00
|
|
|
static struct ipl_parameter_block *dump_block_nvme;
|
2006-09-20 17:58:49 +04:00
|
|
|
static struct ipl_parameter_block *dump_block_ccw;
|
|
|
|
|
2007-07-10 13:24:09 +04:00
|
|
|
static struct sclp_ipl_info sclp_ipl_info;
|
|
|
|
|
2020-06-23 20:10:08 +03:00
|
|
|
static bool reipl_nvme_clear;
|
2020-02-20 18:22:30 +03:00
|
|
|
static bool reipl_fcp_clear;
|
|
|
|
static bool reipl_ccw_clear;
|
|
|
|
|
2015-08-20 18:28:44 +03:00
|
|
|
static inline int __diag308(unsigned long subcode, void *addr)
|
2006-09-20 17:58:49 +04:00
|
|
|
{
|
2021-06-14 23:32:21 +03:00
|
|
|
union register_pair r1;
|
2006-09-20 17:58:49 +04:00
|
|
|
|
2021-06-14 23:32:21 +03:00
|
|
|
r1.even = (unsigned long) addr;
|
|
|
|
r1.odd = 0;
|
2006-09-28 18:56:43 +04:00
|
|
|
asm volatile(
|
2021-06-14 23:32:21 +03:00
|
|
|
" diag %[r1],%[subcode],0x308\n"
|
2016-06-10 10:57:05 +03:00
|
|
|
"0: nopr %%r7\n"
|
2006-09-28 18:56:43 +04:00
|
|
|
EX_TABLE(0b,0b)
|
2021-06-14 23:32:21 +03:00
|
|
|
: [r1] "+&d" (r1.pair)
|
|
|
|
: [subcode] "d" (subcode)
|
|
|
|
: "cc", "memory");
|
|
|
|
return r1.odd;
|
2006-09-20 17:58:49 +04:00
|
|
|
}
|
2015-08-20 18:28:44 +03:00
|
|
|
|
|
|
|
int diag308(unsigned long subcode, void *addr)
|
|
|
|
{
|
|
|
|
diag_stat_inc(DIAG_STAT_X308);
|
|
|
|
return __diag308(subcode, addr);
|
|
|
|
}
|
2007-04-27 18:01:49 +04:00
|
|
|
EXPORT_SYMBOL_GPL(diag308);
|
2006-09-20 17:58:49 +04:00
|
|
|
|
|
|
|
/* SYSFS */
|
|
|
|
|
2015-03-17 12:36:14 +03:00
|
|
|
#define IPL_ATTR_SHOW_FN(_prefix, _name, _format, args...) \
|
2007-11-03 00:17:00 +03:00
|
|
|
static ssize_t sys_##_prefix##_##_name##_show(struct kobject *kobj, \
|
|
|
|
struct kobj_attribute *attr, \
|
2006-09-20 17:58:49 +04:00
|
|
|
char *page) \
|
|
|
|
{ \
|
2020-05-09 11:56:07 +03:00
|
|
|
return scnprintf(page, PAGE_SIZE, _format, ##args); \
|
2015-03-17 12:36:14 +03:00
|
|
|
}
|
|
|
|
|
2015-06-29 19:39:54 +03:00
|
|
|
#define IPL_ATTR_CCW_STORE_FN(_prefix, _name, _ipl_blk) \
|
|
|
|
static ssize_t sys_##_prefix##_##_name##_store(struct kobject *kobj, \
|
|
|
|
struct kobj_attribute *attr, \
|
|
|
|
const char *buf, size_t len) \
|
|
|
|
{ \
|
|
|
|
unsigned long long ssid, devno; \
|
|
|
|
\
|
|
|
|
if (sscanf(buf, "0.%llx.%llx\n", &ssid, &devno) != 2) \
|
|
|
|
return -EINVAL; \
|
|
|
|
\
|
|
|
|
if (ssid > __MAX_SSID || devno > __MAX_SUBCHANNEL) \
|
|
|
|
return -EINVAL; \
|
|
|
|
\
|
|
|
|
_ipl_blk.ssid = ssid; \
|
|
|
|
_ipl_blk.devno = devno; \
|
|
|
|
return len; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define DEFINE_IPL_CCW_ATTR_RW(_prefix, _name, _ipl_blk) \
|
|
|
|
IPL_ATTR_SHOW_FN(_prefix, _name, "0.%x.%04x\n", \
|
|
|
|
_ipl_blk.ssid, _ipl_blk.devno); \
|
|
|
|
IPL_ATTR_CCW_STORE_FN(_prefix, _name, _ipl_blk); \
|
|
|
|
static struct kobj_attribute sys_##_prefix##_##_name##_attr = \
|
|
|
|
__ATTR(_name, (S_IRUGO | S_IWUSR), \
|
|
|
|
sys_##_prefix##_##_name##_show, \
|
|
|
|
sys_##_prefix##_##_name##_store) \
|
|
|
|
|
2015-03-17 12:36:14 +03:00
|
|
|
#define DEFINE_IPL_ATTR_RO(_prefix, _name, _format, _value) \
|
|
|
|
IPL_ATTR_SHOW_FN(_prefix, _name, _format, _value) \
|
2007-11-03 00:17:00 +03:00
|
|
|
static struct kobj_attribute sys_##_prefix##_##_name##_attr = \
|
2015-03-17 12:36:14 +03:00
|
|
|
__ATTR(_name, S_IRUGO, sys_##_prefix##_##_name##_show, NULL)
|
2006-09-20 17:58:49 +04:00
|
|
|
|
|
|
|
#define DEFINE_IPL_ATTR_RW(_prefix, _name, _fmt_out, _fmt_in, _value) \
|
2015-03-17 12:36:14 +03:00
|
|
|
IPL_ATTR_SHOW_FN(_prefix, _name, _fmt_out, (unsigned long long) _value) \
|
2007-11-03 00:17:00 +03:00
|
|
|
static ssize_t sys_##_prefix##_##_name##_store(struct kobject *kobj, \
|
|
|
|
struct kobj_attribute *attr, \
|
2006-09-20 17:58:49 +04:00
|
|
|
const char *buf, size_t len) \
|
|
|
|
{ \
|
|
|
|
unsigned long long value; \
|
|
|
|
if (sscanf(buf, _fmt_in, &value) != 1) \
|
|
|
|
return -EINVAL; \
|
|
|
|
_value = value; \
|
|
|
|
return len; \
|
|
|
|
} \
|
2007-11-03 00:17:00 +03:00
|
|
|
static struct kobj_attribute sys_##_prefix##_##_name##_attr = \
|
2006-09-20 17:58:49 +04:00
|
|
|
__ATTR(_name,(S_IRUGO | S_IWUSR), \
|
|
|
|
sys_##_prefix##_##_name##_show, \
|
2015-03-17 12:36:14 +03:00
|
|
|
sys_##_prefix##_##_name##_store)
|
2006-09-20 17:58:49 +04:00
|
|
|
|
2007-02-05 23:18:24 +03:00
|
|
|
#define DEFINE_IPL_ATTR_STR_RW(_prefix, _name, _fmt_out, _fmt_in, _value)\
|
2015-03-17 12:36:14 +03:00
|
|
|
IPL_ATTR_SHOW_FN(_prefix, _name, _fmt_out, _value) \
|
2007-11-03 00:17:00 +03:00
|
|
|
static ssize_t sys_##_prefix##_##_name##_store(struct kobject *kobj, \
|
|
|
|
struct kobj_attribute *attr, \
|
2007-02-05 23:18:24 +03:00
|
|
|
const char *buf, size_t len) \
|
|
|
|
{ \
|
2008-01-26 16:11:11 +03:00
|
|
|
strncpy(_value, buf, sizeof(_value) - 1); \
|
2009-12-18 19:43:27 +03:00
|
|
|
strim(_value); \
|
2007-02-05 23:18:24 +03:00
|
|
|
return len; \
|
|
|
|
} \
|
2007-11-03 00:17:00 +03:00
|
|
|
static struct kobj_attribute sys_##_prefix##_##_name##_attr = \
|
2007-02-05 23:18:24 +03:00
|
|
|
__ATTR(_name,(S_IRUGO | S_IWUSR), \
|
|
|
|
sys_##_prefix##_##_name##_show, \
|
2015-03-17 12:36:14 +03:00
|
|
|
sys_##_prefix##_##_name##_store)
|
2007-02-05 23:18:24 +03:00
|
|
|
|
2006-09-20 17:58:49 +04:00
|
|
|
/*
|
|
|
|
* ipl section
|
|
|
|
*/
|
|
|
|
|
2007-04-27 18:01:49 +04:00
|
|
|
static __init enum ipl_type get_ipl_type(void)
|
2006-09-20 17:58:49 +04:00
|
|
|
{
|
2018-04-03 17:03:08 +03:00
|
|
|
if (!ipl_block_valid)
|
2006-09-20 17:58:49 +04:00
|
|
|
return IPL_TYPE_UNKNOWN;
|
2018-04-03 17:03:08 +03:00
|
|
|
|
2019-02-20 16:26:51 +03:00
|
|
|
switch (ipl_block.pb0_hdr.pbt) {
|
|
|
|
case IPL_PBT_CCW:
|
2006-09-20 17:58:49 +04:00
|
|
|
return IPL_TYPE_CCW;
|
2019-02-20 16:26:51 +03:00
|
|
|
case IPL_PBT_FCP:
|
|
|
|
if (ipl_block.fcp.opt == IPL_PB0_FCP_OPT_DUMP)
|
2018-04-03 17:03:08 +03:00
|
|
|
return IPL_TYPE_FCP_DUMP;
|
|
|
|
else
|
|
|
|
return IPL_TYPE_FCP;
|
2020-03-02 22:03:37 +03:00
|
|
|
case IPL_PBT_NVME:
|
2020-03-17 16:23:41 +03:00
|
|
|
if (ipl_block.nvme.opt == IPL_PB0_NVME_OPT_DUMP)
|
|
|
|
return IPL_TYPE_NVME_DUMP;
|
|
|
|
else
|
|
|
|
return IPL_TYPE_NVME;
|
2018-04-03 17:03:08 +03:00
|
|
|
}
|
|
|
|
return IPL_TYPE_UNKNOWN;
|
2006-09-20 17:58:49 +04:00
|
|
|
}
|
|
|
|
|
2007-04-27 18:01:49 +04:00
|
|
|
struct ipl_info ipl_info;
|
|
|
|
EXPORT_SYMBOL_GPL(ipl_info);
|
|
|
|
|
2007-11-03 00:17:00 +03:00
|
|
|
static ssize_t ipl_type_show(struct kobject *kobj, struct kobj_attribute *attr,
|
|
|
|
char *page)
|
2006-09-20 17:58:49 +04:00
|
|
|
{
|
2007-04-27 18:01:49 +04:00
|
|
|
return sprintf(page, "%s\n", ipl_type_str(ipl_info.type));
|
2006-09-20 17:58:49 +04:00
|
|
|
}
|
|
|
|
|
2007-11-03 00:17:00 +03:00
|
|
|
static struct kobj_attribute sys_ipl_type_attr = __ATTR_RO(ipl_type);
|
2006-09-20 17:58:49 +04:00
|
|
|
|
2019-02-21 16:23:04 +03:00
|
|
|
static ssize_t ipl_secure_show(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr, char *page)
|
|
|
|
{
|
|
|
|
return sprintf(page, "%i\n", !!ipl_secure_flag);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct kobj_attribute sys_ipl_secure_attr =
|
|
|
|
__ATTR(secure, 0444, ipl_secure_show, NULL);
|
|
|
|
|
2019-04-08 15:24:08 +03:00
|
|
|
static ssize_t ipl_has_secure_show(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr, char *page)
|
|
|
|
{
|
2019-06-28 18:38:05 +03:00
|
|
|
return sprintf(page, "%i\n", !!sclp.has_sipl);
|
2019-04-08 15:24:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct kobj_attribute sys_ipl_has_secure_attr =
|
|
|
|
__ATTR(has_secure, 0444, ipl_has_secure_show, NULL);
|
|
|
|
|
2008-07-14 11:59:09 +04:00
|
|
|
static ssize_t ipl_vm_parm_show(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr, char *page)
|
|
|
|
{
|
|
|
|
char parm[DIAG308_VMPARM_SIZE + 1] = {};
|
|
|
|
|
2019-02-20 16:26:51 +03:00
|
|
|
if (ipl_block_valid && (ipl_block.pb0_hdr.pbt == IPL_PBT_CCW))
|
2018-05-15 14:28:53 +03:00
|
|
|
ipl_block_get_ascii_vmparm(parm, sizeof(parm), &ipl_block);
|
2008-07-14 11:59:09 +04:00
|
|
|
return sprintf(page, "%s\n", parm);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct kobj_attribute sys_ipl_vm_parm_attr =
|
|
|
|
__ATTR(parm, S_IRUGO, ipl_vm_parm_show, NULL);
|
|
|
|
|
2007-11-03 00:17:00 +03:00
|
|
|
static ssize_t sys_ipl_device_show(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr, char *page)
|
2006-09-20 17:58:49 +04:00
|
|
|
{
|
2007-04-27 18:01:49 +04:00
|
|
|
switch (ipl_info.type) {
|
2006-09-20 17:58:49 +04:00
|
|
|
case IPL_TYPE_CCW:
|
2019-02-20 16:08:26 +03:00
|
|
|
return sprintf(page, "0.%x.%04x\n", ipl_block.ccw.ssid,
|
|
|
|
ipl_block.ccw.devno);
|
2006-09-20 17:58:49 +04:00
|
|
|
case IPL_TYPE_FCP:
|
2007-04-27 18:01:49 +04:00
|
|
|
case IPL_TYPE_FCP_DUMP:
|
2019-02-20 16:08:26 +03:00
|
|
|
return sprintf(page, "0.0.%04x\n", ipl_block.fcp.devno);
|
2020-03-02 22:03:37 +03:00
|
|
|
case IPL_TYPE_NVME:
|
2020-03-17 16:23:41 +03:00
|
|
|
case IPL_TYPE_NVME_DUMP:
|
2020-03-02 22:03:37 +03:00
|
|
|
return sprintf(page, "%08ux\n", ipl_block.nvme.fid);
|
2006-09-20 17:58:49 +04:00
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-03 00:17:00 +03:00
|
|
|
static struct kobj_attribute sys_ipl_device_attr =
|
2006-09-20 17:58:49 +04:00
|
|
|
__ATTR(device, S_IRUGO, sys_ipl_device_show, NULL);
|
|
|
|
|
2010-05-13 05:28:57 +04:00
|
|
|
static ssize_t ipl_parameter_read(struct file *filp, struct kobject *kobj,
|
|
|
|
struct bin_attribute *attr, char *buf,
|
|
|
|
loff_t off, size_t count)
|
2006-09-20 17:58:49 +04:00
|
|
|
{
|
2018-04-03 17:02:40 +03:00
|
|
|
return memory_read_from_buffer(buf, count, &off, &ipl_block,
|
|
|
|
ipl_block.hdr.len);
|
2006-09-20 17:58:49 +04:00
|
|
|
}
|
2015-03-17 12:25:16 +03:00
|
|
|
static struct bin_attribute ipl_parameter_attr =
|
|
|
|
__BIN_ATTR(binary_parameter, S_IRUGO, ipl_parameter_read, NULL,
|
|
|
|
PAGE_SIZE);
|
2006-09-20 17:58:49 +04:00
|
|
|
|
2010-05-13 05:28:57 +04:00
|
|
|
static ssize_t ipl_scp_data_read(struct file *filp, struct kobject *kobj,
|
|
|
|
struct bin_attribute *attr, char *buf,
|
|
|
|
loff_t off, size_t count)
|
2006-09-20 17:58:49 +04:00
|
|
|
{
|
2019-02-20 16:08:26 +03:00
|
|
|
unsigned int size = ipl_block.fcp.scp_data_len;
|
|
|
|
void *scp_data = &ipl_block.fcp.scp_data;
|
2006-09-20 17:58:49 +04:00
|
|
|
|
2008-07-14 11:59:17 +04:00
|
|
|
return memory_read_from_buffer(buf, count, &off, scp_data, size);
|
2006-09-20 17:58:49 +04:00
|
|
|
}
|
2020-03-02 22:03:37 +03:00
|
|
|
|
|
|
|
static ssize_t ipl_nvme_scp_data_read(struct file *filp, struct kobject *kobj,
|
|
|
|
struct bin_attribute *attr, char *buf,
|
|
|
|
loff_t off, size_t count)
|
|
|
|
{
|
|
|
|
unsigned int size = ipl_block.nvme.scp_data_len;
|
|
|
|
void *scp_data = &ipl_block.nvme.scp_data;
|
|
|
|
|
|
|
|
return memory_read_from_buffer(buf, count, &off, scp_data, size);
|
|
|
|
}
|
|
|
|
|
2015-03-17 12:25:16 +03:00
|
|
|
static struct bin_attribute ipl_scp_data_attr =
|
|
|
|
__BIN_ATTR(scp_data, S_IRUGO, ipl_scp_data_read, NULL, PAGE_SIZE);
|
2006-09-20 17:58:49 +04:00
|
|
|
|
2020-03-02 22:03:37 +03:00
|
|
|
static struct bin_attribute ipl_nvme_scp_data_attr =
|
|
|
|
__BIN_ATTR(scp_data, S_IRUGO, ipl_nvme_scp_data_read, NULL, PAGE_SIZE);
|
|
|
|
|
2015-03-17 12:25:16 +03:00
|
|
|
static struct bin_attribute *ipl_fcp_bin_attrs[] = {
|
|
|
|
&ipl_parameter_attr,
|
|
|
|
&ipl_scp_data_attr,
|
|
|
|
NULL,
|
2006-09-20 17:58:49 +04:00
|
|
|
};
|
|
|
|
|
2020-03-02 22:03:37 +03:00
|
|
|
static struct bin_attribute *ipl_nvme_bin_attrs[] = {
|
|
|
|
&ipl_parameter_attr,
|
|
|
|
&ipl_nvme_scp_data_attr,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
2006-09-20 17:58:49 +04:00
|
|
|
/* FCP ipl device attributes */
|
|
|
|
|
2018-04-03 17:02:40 +03:00
|
|
|
DEFINE_IPL_ATTR_RO(ipl_fcp, wwpn, "0x%016llx\n",
|
2019-02-20 16:08:26 +03:00
|
|
|
(unsigned long long)ipl_block.fcp.wwpn);
|
2018-04-03 17:02:40 +03:00
|
|
|
DEFINE_IPL_ATTR_RO(ipl_fcp, lun, "0x%016llx\n",
|
2019-02-20 16:08:26 +03:00
|
|
|
(unsigned long long)ipl_block.fcp.lun);
|
2018-04-03 17:02:40 +03:00
|
|
|
DEFINE_IPL_ATTR_RO(ipl_fcp, bootprog, "%lld\n",
|
2019-02-20 16:08:26 +03:00
|
|
|
(unsigned long long)ipl_block.fcp.bootprog);
|
2018-04-03 17:02:40 +03:00
|
|
|
DEFINE_IPL_ATTR_RO(ipl_fcp, br_lba, "%lld\n",
|
2019-02-20 16:08:26 +03:00
|
|
|
(unsigned long long)ipl_block.fcp.br_lba);
|
2006-09-20 17:58:49 +04:00
|
|
|
|
2020-03-02 22:03:37 +03:00
|
|
|
/* NVMe ipl device attributes */
|
|
|
|
DEFINE_IPL_ATTR_RO(ipl_nvme, fid, "0x%08llx\n",
|
|
|
|
(unsigned long long)ipl_block.nvme.fid);
|
|
|
|
DEFINE_IPL_ATTR_RO(ipl_nvme, nsid, "0x%08llx\n",
|
|
|
|
(unsigned long long)ipl_block.nvme.nsid);
|
|
|
|
DEFINE_IPL_ATTR_RO(ipl_nvme, bootprog, "%lld\n",
|
|
|
|
(unsigned long long)ipl_block.nvme.bootprog);
|
|
|
|
DEFINE_IPL_ATTR_RO(ipl_nvme, br_lba, "%lld\n",
|
|
|
|
(unsigned long long)ipl_block.nvme.br_lba);
|
|
|
|
|
2007-11-03 00:17:00 +03:00
|
|
|
static ssize_t ipl_ccw_loadparm_show(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr, char *page)
|
2006-12-04 17:39:58 +03:00
|
|
|
{
|
|
|
|
char loadparm[LOADPARM_LEN + 1] = {};
|
|
|
|
|
2007-07-10 13:24:09 +04:00
|
|
|
if (!sclp_ipl_info.is_valid)
|
2006-12-04 17:39:58 +03:00
|
|
|
return sprintf(page, "#unknown#\n");
|
2007-07-10 13:24:09 +04:00
|
|
|
memcpy(loadparm, &sclp_ipl_info.loadparm, LOADPARM_LEN);
|
2006-12-04 17:39:58 +03:00
|
|
|
EBCASC(loadparm, LOADPARM_LEN);
|
2009-12-18 19:43:27 +03:00
|
|
|
strim(loadparm);
|
2006-12-04 17:39:58 +03:00
|
|
|
return sprintf(page, "%s\n", loadparm);
|
|
|
|
}
|
|
|
|
|
2007-11-03 00:17:00 +03:00
|
|
|
static struct kobj_attribute sys_ipl_ccw_loadparm_attr =
|
2006-12-04 17:39:58 +03:00
|
|
|
__ATTR(loadparm, 0444, ipl_ccw_loadparm_show, NULL);
|
|
|
|
|
2014-08-26 19:51:08 +04:00
|
|
|
static struct attribute *ipl_fcp_attrs[] = {
|
|
|
|
&sys_ipl_type_attr.attr,
|
|
|
|
&sys_ipl_device_attr.attr,
|
|
|
|
&sys_ipl_fcp_wwpn_attr.attr,
|
|
|
|
&sys_ipl_fcp_lun_attr.attr,
|
|
|
|
&sys_ipl_fcp_bootprog_attr.attr,
|
|
|
|
&sys_ipl_fcp_br_lba_attr.attr,
|
|
|
|
&sys_ipl_ccw_loadparm_attr.attr,
|
2019-02-21 16:23:04 +03:00
|
|
|
&sys_ipl_secure_attr.attr,
|
2019-04-08 15:24:08 +03:00
|
|
|
&sys_ipl_has_secure_attr.attr,
|
2014-08-26 19:51:08 +04:00
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct attribute_group ipl_fcp_attr_group = {
|
|
|
|
.attrs = ipl_fcp_attrs,
|
2015-03-17 12:25:16 +03:00
|
|
|
.bin_attrs = ipl_fcp_bin_attrs,
|
2014-08-26 19:51:08 +04:00
|
|
|
};
|
|
|
|
|
2020-03-02 22:03:37 +03:00
|
|
|
static struct attribute *ipl_nvme_attrs[] = {
|
|
|
|
&sys_ipl_type_attr.attr,
|
|
|
|
&sys_ipl_nvme_fid_attr.attr,
|
|
|
|
&sys_ipl_nvme_nsid_attr.attr,
|
|
|
|
&sys_ipl_nvme_bootprog_attr.attr,
|
|
|
|
&sys_ipl_nvme_br_lba_attr.attr,
|
|
|
|
&sys_ipl_ccw_loadparm_attr.attr,
|
|
|
|
&sys_ipl_secure_attr.attr,
|
|
|
|
&sys_ipl_has_secure_attr.attr,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct attribute_group ipl_nvme_attr_group = {
|
|
|
|
.attrs = ipl_nvme_attrs,
|
|
|
|
.bin_attrs = ipl_nvme_bin_attrs,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-08-26 19:51:08 +04:00
|
|
|
/* CCW ipl device attributes */
|
|
|
|
|
2008-07-14 11:59:09 +04:00
|
|
|
static struct attribute *ipl_ccw_attrs_vm[] = {
|
|
|
|
&sys_ipl_type_attr.attr,
|
|
|
|
&sys_ipl_device_attr.attr,
|
|
|
|
&sys_ipl_ccw_loadparm_attr.attr,
|
|
|
|
&sys_ipl_vm_parm_attr.attr,
|
2019-02-21 16:23:04 +03:00
|
|
|
&sys_ipl_secure_attr.attr,
|
2019-04-08 15:24:08 +03:00
|
|
|
&sys_ipl_has_secure_attr.attr,
|
2008-07-14 11:59:09 +04:00
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct attribute *ipl_ccw_attrs_lpar[] = {
|
2006-09-20 17:58:49 +04:00
|
|
|
&sys_ipl_type_attr.attr,
|
|
|
|
&sys_ipl_device_attr.attr,
|
2006-12-04 17:39:58 +03:00
|
|
|
&sys_ipl_ccw_loadparm_attr.attr,
|
2019-02-21 16:23:04 +03:00
|
|
|
&sys_ipl_secure_attr.attr,
|
2019-04-08 15:24:08 +03:00
|
|
|
&sys_ipl_has_secure_attr.attr,
|
2006-09-20 17:58:49 +04:00
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
2008-07-14 11:59:09 +04:00
|
|
|
static struct attribute_group ipl_ccw_attr_group_vm = {
|
|
|
|
.attrs = ipl_ccw_attrs_vm,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct attribute_group ipl_ccw_attr_group_lpar = {
|
|
|
|
.attrs = ipl_ccw_attrs_lpar
|
2006-09-20 17:58:49 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/* UNKNOWN ipl device attributes */
|
|
|
|
|
|
|
|
static struct attribute *ipl_unknown_attrs[] = {
|
|
|
|
&sys_ipl_type_attr.attr,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct attribute_group ipl_unknown_attr_group = {
|
|
|
|
.attrs = ipl_unknown_attrs,
|
|
|
|
};
|
|
|
|
|
2007-11-03 00:17:00 +03:00
|
|
|
static struct kset *ipl_kset;
|
2006-09-20 17:58:49 +04:00
|
|
|
|
2010-02-27 00:37:34 +03:00
|
|
|
static void __ipl_run(void *unused)
|
2008-01-26 16:11:11 +03:00
|
|
|
{
|
2018-01-16 09:11:45 +03:00
|
|
|
__bpon();
|
2016-06-11 12:24:27 +03:00
|
|
|
diag308(DIAG308_LOAD_CLEAR, NULL);
|
2008-01-26 16:11:11 +03:00
|
|
|
}
|
|
|
|
|
2010-02-27 00:37:34 +03:00
|
|
|
static void ipl_run(struct shutdown_trigger *trigger)
|
|
|
|
{
|
2012-03-11 19:59:26 +04:00
|
|
|
smp_call_ipl_cpu(__ipl_run, NULL);
|
2010-02-27 00:37:34 +03:00
|
|
|
}
|
|
|
|
|
2008-02-05 18:50:40 +03:00
|
|
|
static int __init ipl_init(void)
|
2008-01-26 16:11:11 +03:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
ipl_kset = kset_create_and_add("ipl", NULL, firmware_kobj);
|
|
|
|
if (!ipl_kset) {
|
|
|
|
rc = -ENOMEM;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
switch (ipl_info.type) {
|
|
|
|
case IPL_TYPE_CCW:
|
2008-07-14 11:59:09 +04:00
|
|
|
if (MACHINE_IS_VM)
|
|
|
|
rc = sysfs_create_group(&ipl_kset->kobj,
|
|
|
|
&ipl_ccw_attr_group_vm);
|
|
|
|
else
|
|
|
|
rc = sysfs_create_group(&ipl_kset->kobj,
|
|
|
|
&ipl_ccw_attr_group_lpar);
|
2008-01-26 16:11:11 +03:00
|
|
|
break;
|
|
|
|
case IPL_TYPE_FCP:
|
|
|
|
case IPL_TYPE_FCP_DUMP:
|
2015-03-17 12:25:16 +03:00
|
|
|
rc = sysfs_create_group(&ipl_kset->kobj, &ipl_fcp_attr_group);
|
2008-01-26 16:11:11 +03:00
|
|
|
break;
|
2020-03-02 22:03:37 +03:00
|
|
|
case IPL_TYPE_NVME:
|
2020-03-17 16:23:41 +03:00
|
|
|
case IPL_TYPE_NVME_DUMP:
|
2020-03-02 22:03:37 +03:00
|
|
|
rc = sysfs_create_group(&ipl_kset->kobj, &ipl_nvme_attr_group);
|
|
|
|
break;
|
2008-01-26 16:11:11 +03:00
|
|
|
default:
|
|
|
|
rc = sysfs_create_group(&ipl_kset->kobj,
|
|
|
|
&ipl_unknown_attr_group);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
out:
|
|
|
|
if (rc)
|
|
|
|
panic("ipl_init failed: rc = %i\n", rc);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-02-05 18:50:40 +03:00
|
|
|
static struct shutdown_action __refdata ipl_action = {
|
|
|
|
.name = SHUTDOWN_ACTION_IPL_STR,
|
|
|
|
.fn = ipl_run,
|
|
|
|
.init = ipl_init,
|
|
|
|
};
|
2008-01-26 16:11:11 +03:00
|
|
|
|
2006-09-20 17:58:49 +04:00
|
|
|
/*
|
2008-01-26 16:11:11 +03:00
|
|
|
* reipl shutdown action: Reboot Linux on shutdown.
|
2006-09-20 17:58:49 +04:00
|
|
|
*/
|
|
|
|
|
2008-07-14 11:59:09 +04:00
|
|
|
/* VM IPL PARM attributes */
|
|
|
|
static ssize_t reipl_generic_vmparm_show(struct ipl_parameter_block *ipb,
|
|
|
|
char *page)
|
|
|
|
{
|
|
|
|
char vmparm[DIAG308_VMPARM_SIZE + 1] = {};
|
|
|
|
|
2018-05-15 14:28:53 +03:00
|
|
|
ipl_block_get_ascii_vmparm(vmparm, sizeof(vmparm), ipb);
|
2008-07-14 11:59:09 +04:00
|
|
|
return sprintf(page, "%s\n", vmparm);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t reipl_generic_vmparm_store(struct ipl_parameter_block *ipb,
|
|
|
|
size_t vmparm_max,
|
|
|
|
const char *buf, size_t len)
|
|
|
|
{
|
|
|
|
int i, ip_len;
|
|
|
|
|
|
|
|
/* ignore trailing newline */
|
|
|
|
ip_len = len;
|
|
|
|
if ((len > 0) && (buf[len - 1] == '\n'))
|
|
|
|
ip_len--;
|
|
|
|
|
|
|
|
if (ip_len > vmparm_max)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* parm is used to store kernel options, check for common chars */
|
|
|
|
for (i = 0; i < ip_len; i++)
|
|
|
|
if (!(isalnum(buf[i]) || isascii(buf[i]) || isprint(buf[i])))
|
|
|
|
return -EINVAL;
|
|
|
|
|
2019-02-20 16:08:26 +03:00
|
|
|
memset(ipb->ccw.vm_parm, 0, DIAG308_VMPARM_SIZE);
|
|
|
|
ipb->ccw.vm_parm_len = ip_len;
|
2008-07-14 11:59:09 +04:00
|
|
|
if (ip_len > 0) {
|
2019-02-20 16:26:51 +03:00
|
|
|
ipb->ccw.vm_flags |= IPL_PB0_CCW_VM_FLAG_VP;
|
2019-02-20 16:08:26 +03:00
|
|
|
memcpy(ipb->ccw.vm_parm, buf, ip_len);
|
|
|
|
ASCEBC(ipb->ccw.vm_parm, ip_len);
|
2008-07-14 11:59:09 +04:00
|
|
|
} else {
|
2019-02-20 16:26:51 +03:00
|
|
|
ipb->ccw.vm_flags &= ~IPL_PB0_CCW_VM_FLAG_VP;
|
2008-07-14 11:59:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* NSS wrapper */
|
|
|
|
static ssize_t reipl_nss_vmparm_show(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr, char *page)
|
|
|
|
{
|
|
|
|
return reipl_generic_vmparm_show(reipl_block_nss, page);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t reipl_nss_vmparm_store(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr,
|
|
|
|
const char *buf, size_t len)
|
|
|
|
{
|
|
|
|
return reipl_generic_vmparm_store(reipl_block_nss, 56, buf, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* CCW wrapper */
|
|
|
|
static ssize_t reipl_ccw_vmparm_show(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr, char *page)
|
|
|
|
{
|
|
|
|
return reipl_generic_vmparm_show(reipl_block_ccw, page);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t reipl_ccw_vmparm_store(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr,
|
|
|
|
const char *buf, size_t len)
|
|
|
|
{
|
|
|
|
return reipl_generic_vmparm_store(reipl_block_ccw, 64, buf, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct kobj_attribute sys_reipl_nss_vmparm_attr =
|
|
|
|
__ATTR(parm, S_IRUGO | S_IWUSR, reipl_nss_vmparm_show,
|
|
|
|
reipl_nss_vmparm_store);
|
|
|
|
static struct kobj_attribute sys_reipl_ccw_vmparm_attr =
|
|
|
|
__ATTR(parm, S_IRUGO | S_IWUSR, reipl_ccw_vmparm_show,
|
|
|
|
reipl_ccw_vmparm_store);
|
|
|
|
|
2006-09-20 17:58:49 +04:00
|
|
|
/* FCP reipl device attributes */
|
|
|
|
|
2010-05-13 05:28:57 +04:00
|
|
|
static ssize_t reipl_fcp_scpdata_read(struct file *filp, struct kobject *kobj,
|
2009-09-11 12:28:40 +04:00
|
|
|
struct bin_attribute *attr,
|
|
|
|
char *buf, loff_t off, size_t count)
|
|
|
|
{
|
2019-02-20 16:08:26 +03:00
|
|
|
size_t size = reipl_block_fcp->fcp.scp_data_len;
|
|
|
|
void *scp_data = reipl_block_fcp->fcp.scp_data;
|
2009-09-11 12:28:40 +04:00
|
|
|
|
|
|
|
return memory_read_from_buffer(buf, count, &off, scp_data, size);
|
|
|
|
}
|
|
|
|
|
2010-05-13 05:28:57 +04:00
|
|
|
static ssize_t reipl_fcp_scpdata_write(struct file *filp, struct kobject *kobj,
|
2009-09-11 12:28:40 +04:00
|
|
|
struct bin_attribute *attr,
|
|
|
|
char *buf, loff_t off, size_t count)
|
|
|
|
{
|
2015-11-06 11:58:06 +03:00
|
|
|
size_t scpdata_len = count;
|
2009-09-11 12:28:40 +04:00
|
|
|
size_t padding;
|
|
|
|
|
|
|
|
|
2015-11-06 11:58:06 +03:00
|
|
|
if (off)
|
|
|
|
return -EINVAL;
|
2009-09-11 12:28:40 +04:00
|
|
|
|
2019-02-20 16:08:26 +03:00
|
|
|
memcpy(reipl_block_fcp->fcp.scp_data, buf, count);
|
2009-09-11 12:28:40 +04:00
|
|
|
if (scpdata_len % 8) {
|
|
|
|
padding = 8 - (scpdata_len % 8);
|
2019-02-20 16:08:26 +03:00
|
|
|
memset(reipl_block_fcp->fcp.scp_data + scpdata_len,
|
2009-09-11 12:28:40 +04:00
|
|
|
0, padding);
|
|
|
|
scpdata_len += padding;
|
|
|
|
}
|
|
|
|
|
2019-02-20 16:26:51 +03:00
|
|
|
reipl_block_fcp->hdr.len = IPL_BP_FCP_LEN + scpdata_len;
|
|
|
|
reipl_block_fcp->fcp.len = IPL_BP0_FCP_LEN + scpdata_len;
|
2019-02-20 16:08:26 +03:00
|
|
|
reipl_block_fcp->fcp.scp_data_len = scpdata_len;
|
2009-09-11 12:28:40 +04:00
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
2015-03-17 12:25:16 +03:00
|
|
|
static struct bin_attribute sys_reipl_fcp_scp_data_attr =
|
|
|
|
__BIN_ATTR(scp_data, (S_IRUGO | S_IWUSR), reipl_fcp_scpdata_read,
|
2015-11-06 11:58:06 +03:00
|
|
|
reipl_fcp_scpdata_write, DIAG308_SCPDATA_SIZE);
|
2009-09-11 12:28:40 +04:00
|
|
|
|
2015-03-17 12:25:16 +03:00
|
|
|
static struct bin_attribute *reipl_fcp_bin_attrs[] = {
|
|
|
|
&sys_reipl_fcp_scp_data_attr,
|
|
|
|
NULL,
|
2009-09-11 12:28:40 +04:00
|
|
|
};
|
|
|
|
|
2013-06-21 15:21:30 +04:00
|
|
|
DEFINE_IPL_ATTR_RW(reipl_fcp, wwpn, "0x%016llx\n", "%llx\n",
|
2019-02-20 16:08:26 +03:00
|
|
|
reipl_block_fcp->fcp.wwpn);
|
2013-06-21 15:21:30 +04:00
|
|
|
DEFINE_IPL_ATTR_RW(reipl_fcp, lun, "0x%016llx\n", "%llx\n",
|
2019-02-20 16:08:26 +03:00
|
|
|
reipl_block_fcp->fcp.lun);
|
2006-09-20 17:58:49 +04:00
|
|
|
DEFINE_IPL_ATTR_RW(reipl_fcp, bootprog, "%lld\n", "%lld\n",
|
2019-02-20 16:08:26 +03:00
|
|
|
reipl_block_fcp->fcp.bootprog);
|
2006-09-20 17:58:49 +04:00
|
|
|
DEFINE_IPL_ATTR_RW(reipl_fcp, br_lba, "%lld\n", "%lld\n",
|
2019-02-20 16:08:26 +03:00
|
|
|
reipl_block_fcp->fcp.br_lba);
|
2006-09-20 17:58:49 +04:00
|
|
|
DEFINE_IPL_ATTR_RW(reipl_fcp, device, "0.0.%04llx\n", "0.0.%llx\n",
|
2019-02-20 16:08:26 +03:00
|
|
|
reipl_block_fcp->fcp.devno);
|
2006-09-20 17:58:49 +04:00
|
|
|
|
2008-07-14 11:59:09 +04:00
|
|
|
static void reipl_get_ascii_loadparm(char *loadparm,
|
|
|
|
struct ipl_parameter_block *ibp)
|
2006-12-04 17:39:58 +03:00
|
|
|
{
|
2019-02-20 16:26:51 +03:00
|
|
|
memcpy(loadparm, ibp->common.loadparm, LOADPARM_LEN);
|
2006-12-04 17:39:58 +03:00
|
|
|
EBCASC(loadparm, LOADPARM_LEN);
|
|
|
|
loadparm[LOADPARM_LEN] = 0;
|
2009-12-18 19:43:27 +03:00
|
|
|
strim(loadparm);
|
2006-12-04 17:39:58 +03:00
|
|
|
}
|
|
|
|
|
2008-07-14 11:59:09 +04:00
|
|
|
static ssize_t reipl_generic_loadparm_show(struct ipl_parameter_block *ipb,
|
|
|
|
char *page)
|
2006-12-04 17:39:58 +03:00
|
|
|
{
|
|
|
|
char buf[LOADPARM_LEN + 1];
|
|
|
|
|
2008-07-14 11:59:09 +04:00
|
|
|
reipl_get_ascii_loadparm(buf, ipb);
|
2006-12-04 17:39:58 +03:00
|
|
|
return sprintf(page, "%s\n", buf);
|
|
|
|
}
|
|
|
|
|
2008-07-14 11:59:09 +04:00
|
|
|
static ssize_t reipl_generic_loadparm_store(struct ipl_parameter_block *ipb,
|
|
|
|
const char *buf, size_t len)
|
2006-12-04 17:39:58 +03:00
|
|
|
{
|
|
|
|
int i, lp_len;
|
|
|
|
|
|
|
|
/* ignore trailing newline */
|
|
|
|
lp_len = len;
|
|
|
|
if ((len > 0) && (buf[len - 1] == '\n'))
|
|
|
|
lp_len--;
|
|
|
|
/* loadparm can have max 8 characters and must not start with a blank */
|
|
|
|
if ((lp_len > LOADPARM_LEN) || ((lp_len > 0) && (buf[0] == ' ')))
|
|
|
|
return -EINVAL;
|
|
|
|
/* loadparm can only contain "a-z,A-Z,0-9,SP,." */
|
|
|
|
for (i = 0; i < lp_len; i++) {
|
|
|
|
if (isalpha(buf[i]) || isdigit(buf[i]) || (buf[i] == ' ') ||
|
|
|
|
(buf[i] == '.'))
|
|
|
|
continue;
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
/* initialize loadparm with blanks */
|
2019-02-20 16:26:51 +03:00
|
|
|
memset(ipb->common.loadparm, ' ', LOADPARM_LEN);
|
2006-12-04 17:39:58 +03:00
|
|
|
/* copy and convert to ebcdic */
|
2019-02-20 16:26:51 +03:00
|
|
|
memcpy(ipb->common.loadparm, buf, lp_len);
|
|
|
|
ASCEBC(ipb->common.loadparm, LOADPARM_LEN);
|
|
|
|
ipb->common.flags |= IPL_PB0_FLAG_LOADPARM;
|
2006-12-04 17:39:58 +03:00
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
2014-08-26 19:51:08 +04:00
|
|
|
/* FCP wrapper */
|
|
|
|
static ssize_t reipl_fcp_loadparm_show(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr, char *page)
|
|
|
|
{
|
|
|
|
return reipl_generic_loadparm_show(reipl_block_fcp, page);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t reipl_fcp_loadparm_store(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr,
|
|
|
|
const char *buf, size_t len)
|
|
|
|
{
|
|
|
|
return reipl_generic_loadparm_store(reipl_block_fcp, buf, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct kobj_attribute sys_reipl_fcp_loadparm_attr =
|
|
|
|
__ATTR(loadparm, S_IRUGO | S_IWUSR, reipl_fcp_loadparm_show,
|
|
|
|
reipl_fcp_loadparm_store);
|
|
|
|
|
2020-02-20 18:22:30 +03:00
|
|
|
static ssize_t reipl_fcp_clear_show(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr, char *page)
|
|
|
|
{
|
|
|
|
return sprintf(page, "%u\n", reipl_fcp_clear);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t reipl_fcp_clear_store(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr,
|
|
|
|
const char *buf, size_t len)
|
|
|
|
{
|
|
|
|
if (strtobool(buf, &reipl_fcp_clear) < 0)
|
|
|
|
return -EINVAL;
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
2014-08-26 19:51:08 +04:00
|
|
|
static struct attribute *reipl_fcp_attrs[] = {
|
|
|
|
&sys_reipl_fcp_device_attr.attr,
|
|
|
|
&sys_reipl_fcp_wwpn_attr.attr,
|
|
|
|
&sys_reipl_fcp_lun_attr.attr,
|
|
|
|
&sys_reipl_fcp_bootprog_attr.attr,
|
|
|
|
&sys_reipl_fcp_br_lba_attr.attr,
|
|
|
|
&sys_reipl_fcp_loadparm_attr.attr,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct attribute_group reipl_fcp_attr_group = {
|
|
|
|
.attrs = reipl_fcp_attrs,
|
2015-03-17 12:25:16 +03:00
|
|
|
.bin_attrs = reipl_fcp_bin_attrs,
|
2014-08-26 19:51:08 +04:00
|
|
|
};
|
|
|
|
|
2020-02-20 18:22:30 +03:00
|
|
|
static struct kobj_attribute sys_reipl_fcp_clear_attr =
|
|
|
|
__ATTR(clear, 0644, reipl_fcp_clear_show, reipl_fcp_clear_store);
|
|
|
|
|
2020-03-03 22:11:19 +03:00
|
|
|
/* NVME reipl device attributes */
|
|
|
|
|
|
|
|
static ssize_t reipl_nvme_scpdata_read(struct file *filp, struct kobject *kobj,
|
|
|
|
struct bin_attribute *attr,
|
|
|
|
char *buf, loff_t off, size_t count)
|
|
|
|
{
|
|
|
|
size_t size = reipl_block_nvme->nvme.scp_data_len;
|
|
|
|
void *scp_data = reipl_block_nvme->nvme.scp_data;
|
|
|
|
|
|
|
|
return memory_read_from_buffer(buf, count, &off, scp_data, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t reipl_nvme_scpdata_write(struct file *filp, struct kobject *kobj,
|
|
|
|
struct bin_attribute *attr,
|
|
|
|
char *buf, loff_t off, size_t count)
|
|
|
|
{
|
|
|
|
size_t scpdata_len = count;
|
|
|
|
size_t padding;
|
|
|
|
|
|
|
|
if (off)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
memcpy(reipl_block_nvme->nvme.scp_data, buf, count);
|
|
|
|
if (scpdata_len % 8) {
|
|
|
|
padding = 8 - (scpdata_len % 8);
|
|
|
|
memset(reipl_block_nvme->nvme.scp_data + scpdata_len,
|
|
|
|
0, padding);
|
|
|
|
scpdata_len += padding;
|
|
|
|
}
|
|
|
|
|
|
|
|
reipl_block_nvme->hdr.len = IPL_BP_FCP_LEN + scpdata_len;
|
|
|
|
reipl_block_nvme->nvme.len = IPL_BP0_FCP_LEN + scpdata_len;
|
|
|
|
reipl_block_nvme->nvme.scp_data_len = scpdata_len;
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct bin_attribute sys_reipl_nvme_scp_data_attr =
|
|
|
|
__BIN_ATTR(scp_data, (S_IRUGO | S_IWUSR), reipl_nvme_scpdata_read,
|
|
|
|
reipl_nvme_scpdata_write, DIAG308_SCPDATA_SIZE);
|
|
|
|
|
|
|
|
static struct bin_attribute *reipl_nvme_bin_attrs[] = {
|
|
|
|
&sys_reipl_nvme_scp_data_attr,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
DEFINE_IPL_ATTR_RW(reipl_nvme, fid, "0x%08llx\n", "%llx\n",
|
|
|
|
reipl_block_nvme->nvme.fid);
|
|
|
|
DEFINE_IPL_ATTR_RW(reipl_nvme, nsid, "0x%08llx\n", "%llx\n",
|
|
|
|
reipl_block_nvme->nvme.nsid);
|
|
|
|
DEFINE_IPL_ATTR_RW(reipl_nvme, bootprog, "%lld\n", "%lld\n",
|
|
|
|
reipl_block_nvme->nvme.bootprog);
|
|
|
|
DEFINE_IPL_ATTR_RW(reipl_nvme, br_lba, "%lld\n", "%lld\n",
|
|
|
|
reipl_block_nvme->nvme.br_lba);
|
|
|
|
|
|
|
|
/* nvme wrapper */
|
|
|
|
static ssize_t reipl_nvme_loadparm_show(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr, char *page)
|
|
|
|
{
|
|
|
|
return reipl_generic_loadparm_show(reipl_block_nvme, page);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t reipl_nvme_loadparm_store(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr,
|
|
|
|
const char *buf, size_t len)
|
|
|
|
{
|
|
|
|
return reipl_generic_loadparm_store(reipl_block_nvme, buf, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct kobj_attribute sys_reipl_nvme_loadparm_attr =
|
|
|
|
__ATTR(loadparm, S_IRUGO | S_IWUSR, reipl_nvme_loadparm_show,
|
|
|
|
reipl_nvme_loadparm_store);
|
|
|
|
|
|
|
|
static struct attribute *reipl_nvme_attrs[] = {
|
|
|
|
&sys_reipl_nvme_fid_attr.attr,
|
|
|
|
&sys_reipl_nvme_nsid_attr.attr,
|
|
|
|
&sys_reipl_nvme_bootprog_attr.attr,
|
|
|
|
&sys_reipl_nvme_br_lba_attr.attr,
|
|
|
|
&sys_reipl_nvme_loadparm_attr.attr,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct attribute_group reipl_nvme_attr_group = {
|
|
|
|
.attrs = reipl_nvme_attrs,
|
|
|
|
.bin_attrs = reipl_nvme_bin_attrs
|
|
|
|
};
|
|
|
|
|
2020-06-23 20:10:08 +03:00
|
|
|
static ssize_t reipl_nvme_clear_show(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr, char *page)
|
|
|
|
{
|
|
|
|
return sprintf(page, "%u\n", reipl_nvme_clear);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t reipl_nvme_clear_store(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr,
|
|
|
|
const char *buf, size_t len)
|
|
|
|
{
|
|
|
|
if (strtobool(buf, &reipl_nvme_clear) < 0)
|
|
|
|
return -EINVAL;
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct kobj_attribute sys_reipl_nvme_clear_attr =
|
|
|
|
__ATTR(clear, 0644, reipl_nvme_clear_show, reipl_nvme_clear_store);
|
|
|
|
|
2014-08-26 19:51:08 +04:00
|
|
|
/* CCW reipl device attributes */
|
2019-02-20 16:08:26 +03:00
|
|
|
DEFINE_IPL_CCW_ATTR_RW(reipl_ccw, device, reipl_block_ccw->ccw);
|
2014-08-26 19:51:08 +04:00
|
|
|
|
2008-07-14 11:59:09 +04:00
|
|
|
/* NSS wrapper */
|
|
|
|
static ssize_t reipl_nss_loadparm_show(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr, char *page)
|
|
|
|
{
|
|
|
|
return reipl_generic_loadparm_show(reipl_block_nss, page);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t reipl_nss_loadparm_store(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr,
|
|
|
|
const char *buf, size_t len)
|
|
|
|
{
|
|
|
|
return reipl_generic_loadparm_store(reipl_block_nss, buf, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* CCW wrapper */
|
|
|
|
static ssize_t reipl_ccw_loadparm_show(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr, char *page)
|
|
|
|
{
|
|
|
|
return reipl_generic_loadparm_show(reipl_block_ccw, page);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t reipl_ccw_loadparm_store(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr,
|
|
|
|
const char *buf, size_t len)
|
|
|
|
{
|
|
|
|
return reipl_generic_loadparm_store(reipl_block_ccw, buf, len);
|
|
|
|
}
|
|
|
|
|
2007-11-03 00:17:00 +03:00
|
|
|
static struct kobj_attribute sys_reipl_ccw_loadparm_attr =
|
2008-07-14 11:59:09 +04:00
|
|
|
__ATTR(loadparm, S_IRUGO | S_IWUSR, reipl_ccw_loadparm_show,
|
|
|
|
reipl_ccw_loadparm_store);
|
|
|
|
|
2020-02-20 18:22:30 +03:00
|
|
|
static ssize_t reipl_ccw_clear_show(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr, char *page)
|
|
|
|
{
|
|
|
|
return sprintf(page, "%u\n", reipl_ccw_clear);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t reipl_ccw_clear_store(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr,
|
|
|
|
const char *buf, size_t len)
|
|
|
|
{
|
|
|
|
if (strtobool(buf, &reipl_ccw_clear) < 0)
|
|
|
|
return -EINVAL;
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct kobj_attribute sys_reipl_ccw_clear_attr =
|
|
|
|
__ATTR(clear, 0644, reipl_ccw_clear_show, reipl_ccw_clear_store);
|
|
|
|
|
2008-07-14 11:59:09 +04:00
|
|
|
static struct attribute *reipl_ccw_attrs_vm[] = {
|
|
|
|
&sys_reipl_ccw_device_attr.attr,
|
|
|
|
&sys_reipl_ccw_loadparm_attr.attr,
|
|
|
|
&sys_reipl_ccw_vmparm_attr.attr,
|
2020-02-20 18:22:30 +03:00
|
|
|
&sys_reipl_ccw_clear_attr.attr,
|
2008-07-14 11:59:09 +04:00
|
|
|
NULL,
|
|
|
|
};
|
2006-12-04 17:39:58 +03:00
|
|
|
|
2008-07-14 11:59:09 +04:00
|
|
|
static struct attribute *reipl_ccw_attrs_lpar[] = {
|
2006-09-20 17:58:49 +04:00
|
|
|
&sys_reipl_ccw_device_attr.attr,
|
2006-12-04 17:39:58 +03:00
|
|
|
&sys_reipl_ccw_loadparm_attr.attr,
|
2020-02-20 18:22:30 +03:00
|
|
|
&sys_reipl_ccw_clear_attr.attr,
|
2006-09-20 17:58:49 +04:00
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
2008-07-14 11:59:09 +04:00
|
|
|
static struct attribute_group reipl_ccw_attr_group_vm = {
|
2006-09-20 17:58:49 +04:00
|
|
|
.name = IPL_CCW_STR,
|
2008-07-14 11:59:09 +04:00
|
|
|
.attrs = reipl_ccw_attrs_vm,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct attribute_group reipl_ccw_attr_group_lpar = {
|
|
|
|
.name = IPL_CCW_STR,
|
|
|
|
.attrs = reipl_ccw_attrs_lpar,
|
2006-09-20 17:58:49 +04:00
|
|
|
};
|
|
|
|
|
2007-02-05 23:18:24 +03:00
|
|
|
|
|
|
|
/* NSS reipl device attributes */
|
2008-07-14 11:59:09 +04:00
|
|
|
static void reipl_get_ascii_nss_name(char *dst,
|
|
|
|
struct ipl_parameter_block *ipb)
|
|
|
|
{
|
2019-02-20 16:08:26 +03:00
|
|
|
memcpy(dst, ipb->ccw.nss_name, NSS_NAME_SIZE);
|
2008-07-14 11:59:09 +04:00
|
|
|
EBCASC(dst, NSS_NAME_SIZE);
|
|
|
|
dst[NSS_NAME_SIZE] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t reipl_nss_name_show(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr, char *page)
|
|
|
|
{
|
|
|
|
char nss_name[NSS_NAME_SIZE + 1] = {};
|
|
|
|
|
|
|
|
reipl_get_ascii_nss_name(nss_name, reipl_block_nss);
|
|
|
|
return sprintf(page, "%s\n", nss_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t reipl_nss_name_store(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr,
|
|
|
|
const char *buf, size_t len)
|
|
|
|
{
|
|
|
|
int nss_len;
|
|
|
|
|
|
|
|
/* ignore trailing newline */
|
|
|
|
nss_len = len;
|
|
|
|
if ((len > 0) && (buf[len - 1] == '\n'))
|
|
|
|
nss_len--;
|
2007-02-05 23:18:24 +03:00
|
|
|
|
2008-07-14 11:59:09 +04:00
|
|
|
if (nss_len > NSS_NAME_SIZE)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2019-02-20 16:08:26 +03:00
|
|
|
memset(reipl_block_nss->ccw.nss_name, 0x40, NSS_NAME_SIZE);
|
2008-07-14 11:59:09 +04:00
|
|
|
if (nss_len > 0) {
|
2019-02-20 16:26:51 +03:00
|
|
|
reipl_block_nss->ccw.vm_flags |= IPL_PB0_CCW_VM_FLAG_NSS;
|
2019-02-20 16:08:26 +03:00
|
|
|
memcpy(reipl_block_nss->ccw.nss_name, buf, nss_len);
|
|
|
|
ASCEBC(reipl_block_nss->ccw.nss_name, nss_len);
|
|
|
|
EBC_TOUPPER(reipl_block_nss->ccw.nss_name, nss_len);
|
2008-07-14 11:59:09 +04:00
|
|
|
} else {
|
2019-02-20 16:26:51 +03:00
|
|
|
reipl_block_nss->ccw.vm_flags &= ~IPL_PB0_CCW_VM_FLAG_NSS;
|
2008-07-14 11:59:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct kobj_attribute sys_reipl_nss_name_attr =
|
|
|
|
__ATTR(name, S_IRUGO | S_IWUSR, reipl_nss_name_show,
|
|
|
|
reipl_nss_name_store);
|
|
|
|
|
|
|
|
static struct kobj_attribute sys_reipl_nss_loadparm_attr =
|
|
|
|
__ATTR(loadparm, S_IRUGO | S_IWUSR, reipl_nss_loadparm_show,
|
|
|
|
reipl_nss_loadparm_store);
|
2007-02-05 23:18:24 +03:00
|
|
|
|
|
|
|
static struct attribute *reipl_nss_attrs[] = {
|
|
|
|
&sys_reipl_nss_name_attr.attr,
|
2008-07-14 11:59:09 +04:00
|
|
|
&sys_reipl_nss_loadparm_attr.attr,
|
|
|
|
&sys_reipl_nss_vmparm_attr.attr,
|
2007-02-05 23:18:24 +03:00
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct attribute_group reipl_nss_attr_group = {
|
|
|
|
.name = IPL_NSS_STR,
|
|
|
|
.attrs = reipl_nss_attrs,
|
|
|
|
};
|
|
|
|
|
2018-04-04 15:42:41 +03:00
|
|
|
void set_os_info_reipl_block(void)
|
2012-03-11 19:59:34 +04:00
|
|
|
{
|
|
|
|
os_info_entry_add(OS_INFO_REIPL_BLOCK, reipl_block_actual,
|
2018-04-04 15:42:41 +03:00
|
|
|
reipl_block_actual->hdr.len);
|
2012-03-11 19:59:34 +04:00
|
|
|
}
|
|
|
|
|
2006-09-20 17:58:49 +04:00
|
|
|
/* reipl type */
|
|
|
|
|
|
|
|
static int reipl_set_type(enum ipl_type type)
|
|
|
|
{
|
|
|
|
if (!(reipl_capabilities & type))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
switch(type) {
|
|
|
|
case IPL_TYPE_CCW:
|
2018-04-04 15:42:41 +03:00
|
|
|
reipl_block_actual = reipl_block_ccw;
|
2006-09-20 17:58:49 +04:00
|
|
|
break;
|
|
|
|
case IPL_TYPE_FCP:
|
2018-04-04 15:42:41 +03:00
|
|
|
reipl_block_actual = reipl_block_fcp;
|
2007-04-27 18:01:49 +04:00
|
|
|
break;
|
2020-03-03 22:11:19 +03:00
|
|
|
case IPL_TYPE_NVME:
|
|
|
|
reipl_block_actual = reipl_block_nvme;
|
|
|
|
break;
|
2007-02-05 23:18:24 +03:00
|
|
|
case IPL_TYPE_NSS:
|
2018-04-04 15:42:41 +03:00
|
|
|
reipl_block_actual = reipl_block_nss;
|
2007-04-27 18:01:49 +04:00
|
|
|
break;
|
2006-09-20 17:58:49 +04:00
|
|
|
default:
|
2018-04-04 17:05:16 +03:00
|
|
|
break;
|
2006-09-20 17:58:49 +04:00
|
|
|
}
|
|
|
|
reipl_type = type;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-11-03 00:17:00 +03:00
|
|
|
static ssize_t reipl_type_show(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr, char *page)
|
2006-09-20 17:58:49 +04:00
|
|
|
{
|
|
|
|
return sprintf(page, "%s\n", ipl_type_str(reipl_type));
|
|
|
|
}
|
|
|
|
|
2007-11-03 00:17:00 +03:00
|
|
|
static ssize_t reipl_type_store(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr,
|
|
|
|
const char *buf, size_t len)
|
2006-09-20 17:58:49 +04:00
|
|
|
{
|
|
|
|
int rc = -EINVAL;
|
|
|
|
|
|
|
|
if (strncmp(buf, IPL_CCW_STR, strlen(IPL_CCW_STR)) == 0)
|
|
|
|
rc = reipl_set_type(IPL_TYPE_CCW);
|
|
|
|
else if (strncmp(buf, IPL_FCP_STR, strlen(IPL_FCP_STR)) == 0)
|
|
|
|
rc = reipl_set_type(IPL_TYPE_FCP);
|
2020-03-03 22:11:19 +03:00
|
|
|
else if (strncmp(buf, IPL_NVME_STR, strlen(IPL_NVME_STR)) == 0)
|
|
|
|
rc = reipl_set_type(IPL_TYPE_NVME);
|
2007-02-05 23:18:24 +03:00
|
|
|
else if (strncmp(buf, IPL_NSS_STR, strlen(IPL_NSS_STR)) == 0)
|
|
|
|
rc = reipl_set_type(IPL_TYPE_NSS);
|
2006-09-20 17:58:49 +04:00
|
|
|
return (rc != 0) ? rc : len;
|
|
|
|
}
|
|
|
|
|
2007-11-03 00:17:00 +03:00
|
|
|
static struct kobj_attribute reipl_type_attr =
|
2008-01-26 16:11:11 +03:00
|
|
|
__ATTR(reipl_type, 0644, reipl_type_show, reipl_type_store);
|
2006-09-20 17:58:49 +04:00
|
|
|
|
2007-11-03 00:17:00 +03:00
|
|
|
static struct kset *reipl_kset;
|
2009-09-11 12:28:40 +04:00
|
|
|
static struct kset *reipl_fcp_kset;
|
2020-03-03 22:11:19 +03:00
|
|
|
static struct kset *reipl_nvme_kset;
|
2006-09-20 17:58:49 +04:00
|
|
|
|
2010-02-27 00:37:34 +03:00
|
|
|
static void __reipl_run(void *unused)
|
2006-09-20 17:58:49 +04:00
|
|
|
{
|
2018-04-04 17:05:16 +03:00
|
|
|
switch (reipl_type) {
|
|
|
|
case IPL_TYPE_CCW:
|
2006-09-20 17:58:49 +04:00
|
|
|
diag308(DIAG308_SET, reipl_block_ccw);
|
2020-02-20 18:22:30 +03:00
|
|
|
if (reipl_ccw_clear)
|
|
|
|
diag308(DIAG308_LOAD_CLEAR, NULL);
|
|
|
|
else
|
|
|
|
diag308(DIAG308_LOAD_NORMAL_DUMP, NULL);
|
2006-09-20 17:58:49 +04:00
|
|
|
break;
|
2018-04-04 17:05:16 +03:00
|
|
|
case IPL_TYPE_FCP:
|
2006-09-20 17:58:49 +04:00
|
|
|
diag308(DIAG308_SET, reipl_block_fcp);
|
2020-02-20 18:22:30 +03:00
|
|
|
if (reipl_fcp_clear)
|
|
|
|
diag308(DIAG308_LOAD_CLEAR, NULL);
|
|
|
|
else
|
|
|
|
diag308(DIAG308_LOAD_NORMAL, NULL);
|
2006-09-20 17:58:49 +04:00
|
|
|
break;
|
2020-03-03 22:11:19 +03:00
|
|
|
case IPL_TYPE_NVME:
|
|
|
|
diag308(DIAG308_SET, reipl_block_nvme);
|
2020-06-23 20:10:08 +03:00
|
|
|
if (reipl_nvme_clear)
|
|
|
|
diag308(DIAG308_LOAD_CLEAR, NULL);
|
|
|
|
else
|
|
|
|
diag308(DIAG308_LOAD_NORMAL, NULL);
|
2020-03-03 22:11:19 +03:00
|
|
|
break;
|
2018-04-04 17:05:16 +03:00
|
|
|
case IPL_TYPE_NSS:
|
2008-07-14 11:59:09 +04:00
|
|
|
diag308(DIAG308_SET, reipl_block_nss);
|
2016-06-11 12:24:27 +03:00
|
|
|
diag308(DIAG308_LOAD_CLEAR, NULL);
|
2008-07-14 11:59:09 +04:00
|
|
|
break;
|
2018-04-04 17:05:16 +03:00
|
|
|
case IPL_TYPE_UNKNOWN:
|
2016-06-11 12:24:27 +03:00
|
|
|
diag308(DIAG308_LOAD_CLEAR, NULL);
|
2006-09-20 17:58:49 +04:00
|
|
|
break;
|
2018-04-04 17:05:16 +03:00
|
|
|
case IPL_TYPE_FCP_DUMP:
|
2020-03-17 16:23:41 +03:00
|
|
|
case IPL_TYPE_NVME_DUMP:
|
2007-04-27 18:01:49 +04:00
|
|
|
break;
|
2006-09-20 17:58:49 +04:00
|
|
|
}
|
2019-04-30 13:33:45 +03:00
|
|
|
disabled_wait();
|
2006-09-20 17:58:49 +04:00
|
|
|
}
|
|
|
|
|
2010-02-27 00:37:34 +03:00
|
|
|
static void reipl_run(struct shutdown_trigger *trigger)
|
|
|
|
{
|
2012-03-11 19:59:26 +04:00
|
|
|
smp_call_ipl_cpu(__reipl_run, NULL);
|
2010-02-27 00:37:34 +03:00
|
|
|
}
|
|
|
|
|
2008-07-14 11:59:09 +04:00
|
|
|
static void reipl_block_ccw_init(struct ipl_parameter_block *ipb)
|
2006-09-20 17:58:49 +04:00
|
|
|
{
|
2019-02-20 16:26:51 +03:00
|
|
|
ipb->hdr.len = IPL_BP_CCW_LEN;
|
2008-07-14 11:59:09 +04:00
|
|
|
ipb->hdr.version = IPL_PARM_BLOCK_VERSION;
|
2019-02-20 16:26:51 +03:00
|
|
|
ipb->pb0_hdr.len = IPL_BP0_CCW_LEN;
|
|
|
|
ipb->pb0_hdr.pbt = IPL_PBT_CCW;
|
2008-07-14 11:59:09 +04:00
|
|
|
}
|
2006-09-20 17:58:49 +04:00
|
|
|
|
2008-07-14 11:59:09 +04:00
|
|
|
static void reipl_block_ccw_fill_parms(struct ipl_parameter_block *ipb)
|
|
|
|
{
|
|
|
|
/* LOADPARM */
|
|
|
|
/* check if read scp info worked and set loadparm */
|
|
|
|
if (sclp_ipl_info.is_valid)
|
2019-02-20 16:26:51 +03:00
|
|
|
memcpy(ipb->ccw.loadparm, &sclp_ipl_info.loadparm, LOADPARM_LEN);
|
2008-07-14 11:59:09 +04:00
|
|
|
else
|
|
|
|
/* read scp info failed: set empty loadparm (EBCDIC blanks) */
|
2019-02-20 16:26:51 +03:00
|
|
|
memset(ipb->ccw.loadparm, 0x40, LOADPARM_LEN);
|
|
|
|
ipb->ccw.flags = IPL_PB0_FLAG_LOADPARM;
|
2008-07-14 11:59:09 +04:00
|
|
|
|
|
|
|
/* VM PARM */
|
2018-04-03 17:03:14 +03:00
|
|
|
if (MACHINE_IS_VM && ipl_block_valid &&
|
2019-02-20 16:26:51 +03:00
|
|
|
(ipl_block.ccw.vm_flags & IPL_PB0_CCW_VM_FLAG_VP)) {
|
2008-07-14 11:59:09 +04:00
|
|
|
|
2019-02-20 16:26:51 +03:00
|
|
|
ipb->ccw.vm_flags |= IPL_PB0_CCW_VM_FLAG_VP;
|
2019-02-20 16:08:26 +03:00
|
|
|
ipb->ccw.vm_parm_len = ipl_block.ccw.vm_parm_len;
|
|
|
|
memcpy(ipb->ccw.vm_parm,
|
|
|
|
ipl_block.ccw.vm_parm, DIAG308_VMPARM_SIZE);
|
2008-07-14 11:59:09 +04:00
|
|
|
}
|
2006-09-20 17:58:49 +04:00
|
|
|
}
|
|
|
|
|
2008-01-26 16:11:11 +03:00
|
|
|
static int __init reipl_nss_init(void)
|
2006-09-20 17:58:49 +04:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
2008-01-26 16:11:11 +03:00
|
|
|
if (!MACHINE_IS_VM)
|
|
|
|
return 0;
|
2008-07-14 11:59:09 +04:00
|
|
|
|
|
|
|
reipl_block_nss = (void *) get_zeroed_page(GFP_KERNEL);
|
|
|
|
if (!reipl_block_nss)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2008-01-26 16:11:11 +03:00
|
|
|
rc = sysfs_create_group(&reipl_kset->kobj, &reipl_nss_attr_group);
|
2007-02-05 23:18:24 +03:00
|
|
|
if (rc)
|
|
|
|
return rc;
|
2008-07-14 11:59:09 +04:00
|
|
|
|
|
|
|
reipl_block_ccw_init(reipl_block_nss);
|
2007-02-05 23:18:24 +03:00
|
|
|
reipl_capabilities |= IPL_TYPE_NSS;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-09-20 17:58:49 +04:00
|
|
|
static int __init reipl_ccw_init(void)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
reipl_block_ccw = (void *) get_zeroed_page(GFP_KERNEL);
|
|
|
|
if (!reipl_block_ccw)
|
|
|
|
return -ENOMEM;
|
2008-07-14 11:59:09 +04:00
|
|
|
|
2018-04-03 17:03:32 +03:00
|
|
|
rc = sysfs_create_group(&reipl_kset->kobj,
|
|
|
|
MACHINE_IS_VM ? &reipl_ccw_attr_group_vm
|
|
|
|
: &reipl_ccw_attr_group_lpar);
|
2008-07-14 11:59:09 +04:00
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
reipl_block_ccw_init(reipl_block_ccw);
|
|
|
|
if (ipl_info.type == IPL_TYPE_CCW) {
|
2019-02-20 16:08:26 +03:00
|
|
|
reipl_block_ccw->ccw.ssid = ipl_block.ccw.ssid;
|
|
|
|
reipl_block_ccw->ccw.devno = ipl_block.ccw.devno;
|
2008-07-14 11:59:09 +04:00
|
|
|
reipl_block_ccw_fill_parms(reipl_block_ccw);
|
|
|
|
}
|
|
|
|
|
2006-09-20 17:58:49 +04:00
|
|
|
reipl_capabilities |= IPL_TYPE_CCW;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __init reipl_fcp_init(void)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
reipl_block_fcp = (void *) get_zeroed_page(GFP_KERNEL);
|
|
|
|
if (!reipl_block_fcp)
|
|
|
|
return -ENOMEM;
|
2009-09-11 12:28:40 +04:00
|
|
|
|
|
|
|
/* sysfs: create fcp kset for mixing attr group and bin attrs */
|
|
|
|
reipl_fcp_kset = kset_create_and_add(IPL_FCP_STR, NULL,
|
|
|
|
&reipl_kset->kobj);
|
2011-08-24 19:15:11 +04:00
|
|
|
if (!reipl_fcp_kset) {
|
2009-09-11 12:28:40 +04:00
|
|
|
free_page((unsigned long) reipl_block_fcp);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = sysfs_create_group(&reipl_fcp_kset->kobj, &reipl_fcp_attr_group);
|
2020-02-20 18:22:30 +03:00
|
|
|
if (rc)
|
|
|
|
goto out1;
|
|
|
|
|
|
|
|
if (test_facility(141)) {
|
|
|
|
rc = sysfs_create_file(&reipl_fcp_kset->kobj,
|
|
|
|
&sys_reipl_fcp_clear_attr.attr);
|
|
|
|
if (rc)
|
|
|
|
goto out2;
|
2020-06-23 20:10:08 +03:00
|
|
|
} else {
|
2020-02-20 18:22:30 +03:00
|
|
|
reipl_fcp_clear = true;
|
2020-06-23 20:10:08 +03:00
|
|
|
}
|
2009-09-11 12:28:40 +04:00
|
|
|
|
2014-08-26 19:51:08 +04:00
|
|
|
if (ipl_info.type == IPL_TYPE_FCP) {
|
2018-04-03 17:02:40 +03:00
|
|
|
memcpy(reipl_block_fcp, &ipl_block, sizeof(ipl_block));
|
2014-08-26 19:51:08 +04:00
|
|
|
/*
|
|
|
|
* Fix loadparm: There are systems where the (SCSI) LOADPARM
|
|
|
|
* is invalid in the SCSI IPL parameter block, so take it
|
|
|
|
* always from sclp_ipl_info.
|
|
|
|
*/
|
2019-02-20 16:26:51 +03:00
|
|
|
memcpy(reipl_block_fcp->fcp.loadparm, sclp_ipl_info.loadparm,
|
2014-08-26 19:51:08 +04:00
|
|
|
LOADPARM_LEN);
|
|
|
|
} else {
|
2019-02-20 16:26:51 +03:00
|
|
|
reipl_block_fcp->hdr.len = IPL_BP_FCP_LEN;
|
2006-09-20 17:58:49 +04:00
|
|
|
reipl_block_fcp->hdr.version = IPL_PARM_BLOCK_VERSION;
|
2019-02-20 16:26:51 +03:00
|
|
|
reipl_block_fcp->fcp.len = IPL_BP0_FCP_LEN;
|
|
|
|
reipl_block_fcp->fcp.pbt = IPL_PBT_FCP;
|
|
|
|
reipl_block_fcp->fcp.opt = IPL_PB0_FCP_OPT_IPL;
|
2006-09-20 17:58:49 +04:00
|
|
|
}
|
|
|
|
reipl_capabilities |= IPL_TYPE_FCP;
|
|
|
|
return 0;
|
2020-02-20 18:22:30 +03:00
|
|
|
|
|
|
|
out2:
|
|
|
|
sysfs_remove_group(&reipl_fcp_kset->kobj, &reipl_fcp_attr_group);
|
|
|
|
out1:
|
|
|
|
kset_unregister(reipl_fcp_kset);
|
|
|
|
free_page((unsigned long) reipl_block_fcp);
|
|
|
|
return rc;
|
2006-09-20 17:58:49 +04:00
|
|
|
}
|
|
|
|
|
2020-03-03 22:11:19 +03:00
|
|
|
static int __init reipl_nvme_init(void)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
reipl_block_nvme = (void *) get_zeroed_page(GFP_KERNEL);
|
|
|
|
if (!reipl_block_nvme)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
/* sysfs: create kset for mixing attr group and bin attrs */
|
|
|
|
reipl_nvme_kset = kset_create_and_add(IPL_NVME_STR, NULL,
|
|
|
|
&reipl_kset->kobj);
|
|
|
|
if (!reipl_nvme_kset) {
|
|
|
|
free_page((unsigned long) reipl_block_nvme);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = sysfs_create_group(&reipl_nvme_kset->kobj, &reipl_nvme_attr_group);
|
2020-06-23 20:10:08 +03:00
|
|
|
if (rc)
|
|
|
|
goto out1;
|
|
|
|
|
|
|
|
if (test_facility(141)) {
|
|
|
|
rc = sysfs_create_file(&reipl_nvme_kset->kobj,
|
|
|
|
&sys_reipl_nvme_clear_attr.attr);
|
|
|
|
if (rc)
|
|
|
|
goto out2;
|
|
|
|
} else {
|
|
|
|
reipl_nvme_clear = true;
|
2020-03-03 22:11:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ipl_info.type == IPL_TYPE_NVME) {
|
|
|
|
memcpy(reipl_block_nvme, &ipl_block, sizeof(ipl_block));
|
|
|
|
/*
|
|
|
|
* Fix loadparm: There are systems where the (SCSI) LOADPARM
|
|
|
|
* is invalid in the IPL parameter block, so take it
|
|
|
|
* always from sclp_ipl_info.
|
|
|
|
*/
|
|
|
|
memcpy(reipl_block_nvme->nvme.loadparm, sclp_ipl_info.loadparm,
|
|
|
|
LOADPARM_LEN);
|
|
|
|
} else {
|
|
|
|
reipl_block_nvme->hdr.len = IPL_BP_NVME_LEN;
|
|
|
|
reipl_block_nvme->hdr.version = IPL_PARM_BLOCK_VERSION;
|
|
|
|
reipl_block_nvme->nvme.len = IPL_BP0_NVME_LEN;
|
|
|
|
reipl_block_nvme->nvme.pbt = IPL_PBT_NVME;
|
|
|
|
reipl_block_nvme->nvme.opt = IPL_PB0_NVME_OPT_IPL;
|
|
|
|
}
|
|
|
|
reipl_capabilities |= IPL_TYPE_NVME;
|
|
|
|
return 0;
|
2020-06-23 20:10:08 +03:00
|
|
|
|
|
|
|
out2:
|
|
|
|
sysfs_remove_group(&reipl_nvme_kset->kobj, &reipl_nvme_attr_group);
|
|
|
|
out1:
|
|
|
|
kset_unregister(reipl_nvme_kset);
|
|
|
|
free_page((unsigned long) reipl_block_nvme);
|
|
|
|
return rc;
|
2020-03-03 22:11:19 +03:00
|
|
|
}
|
|
|
|
|
2012-03-11 19:59:34 +04:00
|
|
|
static int __init reipl_type_init(void)
|
|
|
|
{
|
|
|
|
enum ipl_type reipl_type = ipl_info.type;
|
|
|
|
struct ipl_parameter_block *reipl_block;
|
|
|
|
unsigned long size;
|
|
|
|
|
|
|
|
reipl_block = os_info_old_entry(OS_INFO_REIPL_BLOCK, &size);
|
|
|
|
if (!reipl_block)
|
|
|
|
goto out;
|
|
|
|
/*
|
|
|
|
* If we have an OS info reipl block, this will be used
|
|
|
|
*/
|
2019-02-20 16:26:51 +03:00
|
|
|
if (reipl_block->pb0_hdr.pbt == IPL_PBT_FCP) {
|
2012-03-11 19:59:34 +04:00
|
|
|
memcpy(reipl_block_fcp, reipl_block, size);
|
|
|
|
reipl_type = IPL_TYPE_FCP;
|
2020-03-03 22:11:19 +03:00
|
|
|
} else if (reipl_block->pb0_hdr.pbt == IPL_PBT_NVME) {
|
|
|
|
memcpy(reipl_block_nvme, reipl_block, size);
|
|
|
|
reipl_type = IPL_TYPE_NVME;
|
2019-02-20 16:26:51 +03:00
|
|
|
} else if (reipl_block->pb0_hdr.pbt == IPL_PBT_CCW) {
|
2012-03-11 19:59:34 +04:00
|
|
|
memcpy(reipl_block_ccw, reipl_block, size);
|
|
|
|
reipl_type = IPL_TYPE_CCW;
|
|
|
|
}
|
|
|
|
out:
|
|
|
|
return reipl_set_type(reipl_type);
|
|
|
|
}
|
|
|
|
|
2008-02-05 18:50:40 +03:00
|
|
|
static int __init reipl_init(void)
|
2006-09-20 17:58:49 +04:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
2007-11-06 00:16:15 +03:00
|
|
|
reipl_kset = kset_create_and_add("reipl", NULL, firmware_kobj);
|
2007-11-03 00:17:00 +03:00
|
|
|
if (!reipl_kset)
|
|
|
|
return -ENOMEM;
|
|
|
|
rc = sysfs_create_file(&reipl_kset->kobj, &reipl_type_attr.attr);
|
2006-09-20 17:58:49 +04:00
|
|
|
if (rc) {
|
2007-11-03 00:17:00 +03:00
|
|
|
kset_unregister(reipl_kset);
|
2006-09-20 17:58:49 +04:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
rc = reipl_ccw_init();
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
rc = reipl_fcp_init();
|
2020-03-03 22:11:19 +03:00
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
rc = reipl_nvme_init();
|
2007-02-05 23:18:24 +03:00
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
rc = reipl_nss_init();
|
2006-09-20 17:58:49 +04:00
|
|
|
if (rc)
|
|
|
|
return rc;
|
2012-03-11 19:59:34 +04:00
|
|
|
return reipl_type_init();
|
2006-09-20 17:58:49 +04:00
|
|
|
}
|
|
|
|
|
2008-02-05 18:50:40 +03:00
|
|
|
static struct shutdown_action __refdata reipl_action = {
|
|
|
|
.name = SHUTDOWN_ACTION_REIPL_STR,
|
|
|
|
.fn = reipl_run,
|
|
|
|
.init = reipl_init,
|
|
|
|
};
|
2008-01-26 16:11:11 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* dump shutdown action: Dump Linux on shutdown.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* FCP dump device attributes */
|
|
|
|
|
2013-06-21 15:21:30 +04:00
|
|
|
DEFINE_IPL_ATTR_RW(dump_fcp, wwpn, "0x%016llx\n", "%llx\n",
|
2019-02-20 16:08:26 +03:00
|
|
|
dump_block_fcp->fcp.wwpn);
|
2013-06-21 15:21:30 +04:00
|
|
|
DEFINE_IPL_ATTR_RW(dump_fcp, lun, "0x%016llx\n", "%llx\n",
|
2019-02-20 16:08:26 +03:00
|
|
|
dump_block_fcp->fcp.lun);
|
2008-01-26 16:11:11 +03:00
|
|
|
DEFINE_IPL_ATTR_RW(dump_fcp, bootprog, "%lld\n", "%lld\n",
|
2019-02-20 16:08:26 +03:00
|
|
|
dump_block_fcp->fcp.bootprog);
|
2008-01-26 16:11:11 +03:00
|
|
|
DEFINE_IPL_ATTR_RW(dump_fcp, br_lba, "%lld\n", "%lld\n",
|
2019-02-20 16:08:26 +03:00
|
|
|
dump_block_fcp->fcp.br_lba);
|
2008-01-26 16:11:11 +03:00
|
|
|
DEFINE_IPL_ATTR_RW(dump_fcp, device, "0.0.%04llx\n", "0.0.%llx\n",
|
2019-02-20 16:08:26 +03:00
|
|
|
dump_block_fcp->fcp.devno);
|
2008-01-26 16:11:11 +03:00
|
|
|
|
|
|
|
static struct attribute *dump_fcp_attrs[] = {
|
|
|
|
&sys_dump_fcp_device_attr.attr,
|
|
|
|
&sys_dump_fcp_wwpn_attr.attr,
|
|
|
|
&sys_dump_fcp_lun_attr.attr,
|
|
|
|
&sys_dump_fcp_bootprog_attr.attr,
|
|
|
|
&sys_dump_fcp_br_lba_attr.attr,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct attribute_group dump_fcp_attr_group = {
|
|
|
|
.name = IPL_FCP_STR,
|
|
|
|
.attrs = dump_fcp_attrs,
|
|
|
|
};
|
|
|
|
|
2020-03-17 16:23:41 +03:00
|
|
|
/* NVME dump device attributes */
|
|
|
|
DEFINE_IPL_ATTR_RW(dump_nvme, fid, "0x%08llx\n", "%llx\n",
|
|
|
|
dump_block_nvme->nvme.fid);
|
|
|
|
DEFINE_IPL_ATTR_RW(dump_nvme, nsid, "0x%08llx\n", "%llx\n",
|
|
|
|
dump_block_nvme->nvme.nsid);
|
|
|
|
DEFINE_IPL_ATTR_RW(dump_nvme, bootprog, "%lld\n", "%llx\n",
|
|
|
|
dump_block_nvme->nvme.bootprog);
|
|
|
|
DEFINE_IPL_ATTR_RW(dump_nvme, br_lba, "%lld\n", "%llx\n",
|
|
|
|
dump_block_nvme->nvme.br_lba);
|
|
|
|
|
|
|
|
static struct attribute *dump_nvme_attrs[] = {
|
|
|
|
&sys_dump_nvme_fid_attr.attr,
|
|
|
|
&sys_dump_nvme_nsid_attr.attr,
|
|
|
|
&sys_dump_nvme_bootprog_attr.attr,
|
|
|
|
&sys_dump_nvme_br_lba_attr.attr,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct attribute_group dump_nvme_attr_group = {
|
|
|
|
.name = IPL_NVME_STR,
|
|
|
|
.attrs = dump_nvme_attrs,
|
|
|
|
};
|
|
|
|
|
2008-01-26 16:11:11 +03:00
|
|
|
/* CCW dump device attributes */
|
2019-02-20 16:08:26 +03:00
|
|
|
DEFINE_IPL_CCW_ATTR_RW(dump_ccw, device, dump_block_ccw->ccw);
|
2008-01-26 16:11:11 +03:00
|
|
|
|
|
|
|
static struct attribute *dump_ccw_attrs[] = {
|
|
|
|
&sys_dump_ccw_device_attr.attr,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct attribute_group dump_ccw_attr_group = {
|
|
|
|
.name = IPL_CCW_STR,
|
|
|
|
.attrs = dump_ccw_attrs,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* dump type */
|
|
|
|
|
|
|
|
static int dump_set_type(enum dump_type type)
|
|
|
|
{
|
|
|
|
if (!(dump_capabilities & type))
|
|
|
|
return -EINVAL;
|
|
|
|
dump_type = type;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t dump_type_show(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr, char *page)
|
|
|
|
{
|
|
|
|
return sprintf(page, "%s\n", dump_type_str(dump_type));
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t dump_type_store(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr,
|
|
|
|
const char *buf, size_t len)
|
|
|
|
{
|
|
|
|
int rc = -EINVAL;
|
|
|
|
|
|
|
|
if (strncmp(buf, DUMP_NONE_STR, strlen(DUMP_NONE_STR)) == 0)
|
|
|
|
rc = dump_set_type(DUMP_TYPE_NONE);
|
|
|
|
else if (strncmp(buf, DUMP_CCW_STR, strlen(DUMP_CCW_STR)) == 0)
|
|
|
|
rc = dump_set_type(DUMP_TYPE_CCW);
|
|
|
|
else if (strncmp(buf, DUMP_FCP_STR, strlen(DUMP_FCP_STR)) == 0)
|
|
|
|
rc = dump_set_type(DUMP_TYPE_FCP);
|
2020-03-17 16:23:41 +03:00
|
|
|
else if (strncmp(buf, DUMP_NVME_STR, strlen(DUMP_NVME_STR)) == 0)
|
|
|
|
rc = dump_set_type(DUMP_TYPE_NVME);
|
2008-01-26 16:11:11 +03:00
|
|
|
return (rc != 0) ? rc : len;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct kobj_attribute dump_type_attr =
|
|
|
|
__ATTR(dump_type, 0644, dump_type_show, dump_type_store);
|
|
|
|
|
|
|
|
static struct kset *dump_kset;
|
|
|
|
|
2013-01-21 21:35:15 +04:00
|
|
|
static void diag308_dump(void *dump_block)
|
|
|
|
{
|
|
|
|
diag308(DIAG308_SET, dump_block);
|
|
|
|
while (1) {
|
2016-06-11 12:24:27 +03:00
|
|
|
if (diag308(DIAG308_LOAD_NORMAL_DUMP, NULL) != 0x302)
|
2013-01-21 21:35:15 +04:00
|
|
|
break;
|
2020-12-14 23:44:39 +03:00
|
|
|
udelay(USEC_PER_SEC);
|
2013-01-21 21:35:15 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-27 00:37:34 +03:00
|
|
|
static void __dump_run(void *unused)
|
2008-01-26 16:11:11 +03:00
|
|
|
{
|
2018-04-04 17:05:16 +03:00
|
|
|
switch (dump_type) {
|
|
|
|
case DUMP_TYPE_CCW:
|
2013-01-21 21:35:15 +04:00
|
|
|
diag308_dump(dump_block_ccw);
|
2008-01-26 16:11:11 +03:00
|
|
|
break;
|
2018-04-04 17:05:16 +03:00
|
|
|
case DUMP_TYPE_FCP:
|
2013-01-21 21:35:15 +04:00
|
|
|
diag308_dump(dump_block_fcp);
|
2008-01-26 16:11:11 +03:00
|
|
|
break;
|
2020-03-17 16:23:41 +03:00
|
|
|
case DUMP_TYPE_NVME:
|
|
|
|
diag308_dump(dump_block_nvme);
|
|
|
|
break;
|
2010-02-27 00:37:34 +03:00
|
|
|
default:
|
|
|
|
break;
|
2008-01-26 16:11:11 +03:00
|
|
|
}
|
2010-02-27 00:37:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void dump_run(struct shutdown_trigger *trigger)
|
|
|
|
{
|
2018-04-04 17:05:16 +03:00
|
|
|
if (dump_type == DUMP_TYPE_NONE)
|
2010-02-27 00:37:34 +03:00
|
|
|
return;
|
|
|
|
smp_send_stop();
|
2012-03-11 19:59:26 +04:00
|
|
|
smp_call_ipl_cpu(__dump_run, NULL);
|
2008-01-26 16:11:11 +03:00
|
|
|
}
|
|
|
|
|
2006-09-20 17:58:49 +04:00
|
|
|
static int __init dump_ccw_init(void)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
dump_block_ccw = (void *) get_zeroed_page(GFP_KERNEL);
|
|
|
|
if (!dump_block_ccw)
|
|
|
|
return -ENOMEM;
|
2007-11-03 00:17:00 +03:00
|
|
|
rc = sysfs_create_group(&dump_kset->kobj, &dump_ccw_attr_group);
|
2006-09-20 17:58:49 +04:00
|
|
|
if (rc) {
|
|
|
|
free_page((unsigned long)dump_block_ccw);
|
|
|
|
return rc;
|
|
|
|
}
|
2019-02-20 16:26:51 +03:00
|
|
|
dump_block_ccw->hdr.len = IPL_BP_CCW_LEN;
|
2006-09-20 17:58:49 +04:00
|
|
|
dump_block_ccw->hdr.version = IPL_PARM_BLOCK_VERSION;
|
2019-02-20 16:26:51 +03:00
|
|
|
dump_block_ccw->ccw.len = IPL_BP0_CCW_LEN;
|
|
|
|
dump_block_ccw->ccw.pbt = IPL_PBT_CCW;
|
2007-04-27 18:01:49 +04:00
|
|
|
dump_capabilities |= DUMP_TYPE_CCW;
|
2006-09-20 17:58:49 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __init dump_fcp_init(void)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
2007-07-10 13:24:09 +04:00
|
|
|
if (!sclp_ipl_info.has_dump)
|
2006-09-20 17:58:49 +04:00
|
|
|
return 0; /* LDIPL DUMP is not installed */
|
|
|
|
dump_block_fcp = (void *) get_zeroed_page(GFP_KERNEL);
|
|
|
|
if (!dump_block_fcp)
|
|
|
|
return -ENOMEM;
|
2007-11-03 00:17:00 +03:00
|
|
|
rc = sysfs_create_group(&dump_kset->kobj, &dump_fcp_attr_group);
|
2006-09-20 17:58:49 +04:00
|
|
|
if (rc) {
|
|
|
|
free_page((unsigned long)dump_block_fcp);
|
|
|
|
return rc;
|
|
|
|
}
|
2019-02-20 16:26:51 +03:00
|
|
|
dump_block_fcp->hdr.len = IPL_BP_FCP_LEN;
|
2006-09-20 17:58:49 +04:00
|
|
|
dump_block_fcp->hdr.version = IPL_PARM_BLOCK_VERSION;
|
2019-02-20 16:26:51 +03:00
|
|
|
dump_block_fcp->fcp.len = IPL_BP0_FCP_LEN;
|
|
|
|
dump_block_fcp->fcp.pbt = IPL_PBT_FCP;
|
|
|
|
dump_block_fcp->fcp.opt = IPL_PB0_FCP_OPT_DUMP;
|
2007-04-27 18:01:49 +04:00
|
|
|
dump_capabilities |= DUMP_TYPE_FCP;
|
2006-09-20 17:58:49 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-03-17 16:23:41 +03:00
|
|
|
static int __init dump_nvme_init(void)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (!sclp_ipl_info.has_dump)
|
|
|
|
return 0; /* LDIPL DUMP is not installed */
|
|
|
|
dump_block_nvme = (void *) get_zeroed_page(GFP_KERNEL);
|
|
|
|
if (!dump_block_nvme)
|
|
|
|
return -ENOMEM;
|
|
|
|
rc = sysfs_create_group(&dump_kset->kobj, &dump_nvme_attr_group);
|
|
|
|
if (rc) {
|
|
|
|
free_page((unsigned long)dump_block_nvme);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
dump_block_nvme->hdr.len = IPL_BP_NVME_LEN;
|
|
|
|
dump_block_nvme->hdr.version = IPL_PARM_BLOCK_VERSION;
|
|
|
|
dump_block_nvme->fcp.len = IPL_BP0_NVME_LEN;
|
|
|
|
dump_block_nvme->fcp.pbt = IPL_PBT_NVME;
|
|
|
|
dump_block_nvme->fcp.opt = IPL_PB0_NVME_OPT_DUMP;
|
|
|
|
dump_capabilities |= DUMP_TYPE_NVME;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-02-05 18:50:40 +03:00
|
|
|
static int __init dump_init(void)
|
2006-09-20 17:58:49 +04:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
2007-11-06 00:16:15 +03:00
|
|
|
dump_kset = kset_create_and_add("dump", NULL, firmware_kobj);
|
2007-11-03 00:17:00 +03:00
|
|
|
if (!dump_kset)
|
|
|
|
return -ENOMEM;
|
2008-01-26 16:11:11 +03:00
|
|
|
rc = sysfs_create_file(&dump_kset->kobj, &dump_type_attr.attr);
|
2006-09-20 17:58:49 +04:00
|
|
|
if (rc) {
|
2007-11-03 00:17:00 +03:00
|
|
|
kset_unregister(dump_kset);
|
2006-09-20 17:58:49 +04:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
rc = dump_ccw_init();
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
rc = dump_fcp_init();
|
2020-03-17 16:23:41 +03:00
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
rc = dump_nvme_init();
|
2006-09-20 17:58:49 +04:00
|
|
|
if (rc)
|
|
|
|
return rc;
|
2007-04-27 18:01:49 +04:00
|
|
|
dump_set_type(DUMP_TYPE_NONE);
|
2006-09-20 17:58:49 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-02-05 18:50:40 +03:00
|
|
|
static struct shutdown_action __refdata dump_action = {
|
|
|
|
.name = SHUTDOWN_ACTION_DUMP_STR,
|
|
|
|
.fn = dump_run,
|
|
|
|
.init = dump_init,
|
|
|
|
};
|
2008-01-26 16:11:11 +03:00
|
|
|
|
2009-03-26 17:23:43 +03:00
|
|
|
static void dump_reipl_run(struct shutdown_trigger *trigger)
|
|
|
|
{
|
2012-06-27 16:43:31 +04:00
|
|
|
unsigned long ipib = (unsigned long) reipl_block_actual;
|
2012-06-05 11:59:52 +04:00
|
|
|
unsigned int csum;
|
|
|
|
|
2016-12-20 18:08:05 +03:00
|
|
|
csum = (__force unsigned int)
|
|
|
|
csum_partial(reipl_block_actual, reipl_block_actual->hdr.len, 0);
|
2022-03-17 17:03:03 +03:00
|
|
|
put_abs_lowcore(ipib, ipib);
|
|
|
|
put_abs_lowcore(ipib_checksum, csum);
|
2009-03-26 17:23:43 +03:00
|
|
|
dump_run(trigger);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct shutdown_action __refdata dump_reipl_action = {
|
|
|
|
.name = SHUTDOWN_ACTION_DUMP_REIPL_STR,
|
|
|
|
.fn = dump_reipl_run,
|
|
|
|
};
|
|
|
|
|
2008-01-26 16:11:11 +03:00
|
|
|
/*
|
|
|
|
* vmcmd shutdown action: Trigger vm command on shutdown.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static char vmcmd_on_reboot[128];
|
|
|
|
static char vmcmd_on_panic[128];
|
|
|
|
static char vmcmd_on_halt[128];
|
|
|
|
static char vmcmd_on_poff[128];
|
2011-08-03 18:44:19 +04:00
|
|
|
static char vmcmd_on_restart[128];
|
2008-01-26 16:11:11 +03:00
|
|
|
|
|
|
|
DEFINE_IPL_ATTR_STR_RW(vmcmd, on_reboot, "%s\n", "%s\n", vmcmd_on_reboot);
|
|
|
|
DEFINE_IPL_ATTR_STR_RW(vmcmd, on_panic, "%s\n", "%s\n", vmcmd_on_panic);
|
|
|
|
DEFINE_IPL_ATTR_STR_RW(vmcmd, on_halt, "%s\n", "%s\n", vmcmd_on_halt);
|
|
|
|
DEFINE_IPL_ATTR_STR_RW(vmcmd, on_poff, "%s\n", "%s\n", vmcmd_on_poff);
|
2011-08-03 18:44:19 +04:00
|
|
|
DEFINE_IPL_ATTR_STR_RW(vmcmd, on_restart, "%s\n", "%s\n", vmcmd_on_restart);
|
2008-01-26 16:11:11 +03:00
|
|
|
|
|
|
|
static struct attribute *vmcmd_attrs[] = {
|
|
|
|
&sys_vmcmd_on_reboot_attr.attr,
|
|
|
|
&sys_vmcmd_on_panic_attr.attr,
|
|
|
|
&sys_vmcmd_on_halt_attr.attr,
|
|
|
|
&sys_vmcmd_on_poff_attr.attr,
|
2011-08-03 18:44:19 +04:00
|
|
|
&sys_vmcmd_on_restart_attr.attr,
|
2008-01-26 16:11:11 +03:00
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct attribute_group vmcmd_attr_group = {
|
|
|
|
.attrs = vmcmd_attrs,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct kset *vmcmd_kset;
|
|
|
|
|
|
|
|
static void vmcmd_run(struct shutdown_trigger *trigger)
|
2006-09-20 17:58:49 +04:00
|
|
|
{
|
2012-07-24 20:43:02 +04:00
|
|
|
char *cmd;
|
2008-01-26 16:11:11 +03:00
|
|
|
|
|
|
|
if (strcmp(trigger->name, ON_REIPL_STR) == 0)
|
|
|
|
cmd = vmcmd_on_reboot;
|
|
|
|
else if (strcmp(trigger->name, ON_PANIC_STR) == 0)
|
|
|
|
cmd = vmcmd_on_panic;
|
|
|
|
else if (strcmp(trigger->name, ON_HALT_STR) == 0)
|
|
|
|
cmd = vmcmd_on_halt;
|
|
|
|
else if (strcmp(trigger->name, ON_POFF_STR) == 0)
|
|
|
|
cmd = vmcmd_on_poff;
|
2011-08-03 18:44:19 +04:00
|
|
|
else if (strcmp(trigger->name, ON_RESTART_STR) == 0)
|
|
|
|
cmd = vmcmd_on_restart;
|
2008-01-26 16:11:11 +03:00
|
|
|
else
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (strlen(cmd) == 0)
|
|
|
|
return;
|
2012-07-24 20:43:02 +04:00
|
|
|
__cpcmd(cmd, NULL, 0, NULL);
|
2008-01-26 16:11:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static int vmcmd_init(void)
|
|
|
|
{
|
|
|
|
if (!MACHINE_IS_VM)
|
2010-02-27 00:37:41 +03:00
|
|
|
return -EOPNOTSUPP;
|
2008-01-26 16:11:11 +03:00
|
|
|
vmcmd_kset = kset_create_and_add("vmcmd", NULL, firmware_kobj);
|
|
|
|
if (!vmcmd_kset)
|
|
|
|
return -ENOMEM;
|
|
|
|
return sysfs_create_group(&vmcmd_kset->kobj, &vmcmd_attr_group);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct shutdown_action vmcmd_action = {SHUTDOWN_ACTION_VMCMD_STR,
|
|
|
|
vmcmd_run, vmcmd_init};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* stop shutdown action: Stop Linux on shutdown.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void stop_run(struct shutdown_trigger *trigger)
|
|
|
|
{
|
2011-08-24 19:15:12 +04:00
|
|
|
if (strcmp(trigger->name, ON_PANIC_STR) == 0 ||
|
|
|
|
strcmp(trigger->name, ON_RESTART_STR) == 0)
|
2019-04-30 13:33:45 +03:00
|
|
|
disabled_wait();
|
2012-03-11 19:59:26 +04:00
|
|
|
smp_stop_cpu();
|
2008-01-26 16:11:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct shutdown_action stop_action = {SHUTDOWN_ACTION_STOP_STR,
|
|
|
|
stop_run, NULL};
|
|
|
|
|
|
|
|
/* action list */
|
|
|
|
|
|
|
|
static struct shutdown_action *shutdown_actions_list[] = {
|
2009-03-26 17:23:43 +03:00
|
|
|
&ipl_action, &reipl_action, &dump_reipl_action, &dump_action,
|
|
|
|
&vmcmd_action, &stop_action};
|
2008-01-26 16:11:11 +03:00
|
|
|
#define SHUTDOWN_ACTIONS_COUNT (sizeof(shutdown_actions_list) / sizeof(void *))
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Trigger section
|
|
|
|
*/
|
|
|
|
|
|
|
|
static struct kset *shutdown_actions_kset;
|
|
|
|
|
|
|
|
static int set_trigger(const char *buf, struct shutdown_trigger *trigger,
|
|
|
|
size_t len)
|
|
|
|
{
|
|
|
|
int i;
|
2009-03-26 17:23:43 +03:00
|
|
|
|
2008-01-26 16:11:11 +03:00
|
|
|
for (i = 0; i < SHUTDOWN_ACTIONS_COUNT; i++) {
|
2009-03-26 17:23:43 +03:00
|
|
|
if (sysfs_streq(buf, shutdown_actions_list[i]->name)) {
|
2009-07-07 18:37:07 +04:00
|
|
|
if (shutdown_actions_list[i]->init_rc) {
|
|
|
|
return shutdown_actions_list[i]->init_rc;
|
|
|
|
} else {
|
|
|
|
trigger->action = shutdown_actions_list[i];
|
|
|
|
return len;
|
|
|
|
}
|
2008-01-26 16:11:11 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* on reipl */
|
|
|
|
|
|
|
|
static struct shutdown_trigger on_reboot_trigger = {ON_REIPL_STR,
|
|
|
|
&reipl_action};
|
|
|
|
|
|
|
|
static ssize_t on_reboot_show(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr, char *page)
|
|
|
|
{
|
|
|
|
return sprintf(page, "%s\n", on_reboot_trigger.action->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t on_reboot_store(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr,
|
|
|
|
const char *buf, size_t len)
|
|
|
|
{
|
|
|
|
return set_trigger(buf, &on_reboot_trigger, len);
|
|
|
|
}
|
2015-03-17 12:28:46 +03:00
|
|
|
static struct kobj_attribute on_reboot_attr = __ATTR_RW(on_reboot);
|
2008-01-26 16:11:11 +03:00
|
|
|
|
|
|
|
static void do_machine_restart(char *__unused)
|
|
|
|
{
|
|
|
|
smp_send_stop();
|
|
|
|
on_reboot_trigger.action->fn(&on_reboot_trigger);
|
|
|
|
reipl_run(NULL);
|
|
|
|
}
|
|
|
|
void (*_machine_restart)(char *command) = do_machine_restart;
|
|
|
|
|
|
|
|
/* on panic */
|
|
|
|
|
|
|
|
static struct shutdown_trigger on_panic_trigger = {ON_PANIC_STR, &stop_action};
|
|
|
|
|
|
|
|
static ssize_t on_panic_show(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr, char *page)
|
|
|
|
{
|
|
|
|
return sprintf(page, "%s\n", on_panic_trigger.action->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t on_panic_store(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr,
|
|
|
|
const char *buf, size_t len)
|
|
|
|
{
|
|
|
|
return set_trigger(buf, &on_panic_trigger, len);
|
|
|
|
}
|
2015-03-17 12:28:46 +03:00
|
|
|
static struct kobj_attribute on_panic_attr = __ATTR_RW(on_panic);
|
2008-01-26 16:11:11 +03:00
|
|
|
|
|
|
|
static void do_panic(void)
|
|
|
|
{
|
2012-03-11 19:59:32 +04:00
|
|
|
lgr_info_log();
|
2008-01-26 16:11:11 +03:00
|
|
|
on_panic_trigger.action->fn(&on_panic_trigger);
|
|
|
|
stop_run(&on_panic_trigger);
|
|
|
|
}
|
|
|
|
|
2011-08-03 18:44:19 +04:00
|
|
|
/* on restart */
|
|
|
|
|
|
|
|
static struct shutdown_trigger on_restart_trigger = {ON_RESTART_STR,
|
2011-08-24 19:15:12 +04:00
|
|
|
&stop_action};
|
2011-08-03 18:44:19 +04:00
|
|
|
|
|
|
|
static ssize_t on_restart_show(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr, char *page)
|
|
|
|
{
|
|
|
|
return sprintf(page, "%s\n", on_restart_trigger.action->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t on_restart_store(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr,
|
|
|
|
const char *buf, size_t len)
|
|
|
|
{
|
|
|
|
return set_trigger(buf, &on_restart_trigger, len);
|
|
|
|
}
|
2015-03-17 12:28:46 +03:00
|
|
|
static struct kobj_attribute on_restart_attr = __ATTR_RW(on_restart);
|
2011-08-03 18:44:19 +04:00
|
|
|
|
2012-03-11 19:59:26 +04:00
|
|
|
static void __do_restart(void *ignore)
|
2011-08-03 18:44:19 +04:00
|
|
|
{
|
|
|
|
smp_send_stop();
|
2011-10-30 18:16:40 +04:00
|
|
|
#ifdef CONFIG_CRASH_DUMP
|
|
|
|
crash_kexec(NULL);
|
|
|
|
#endif
|
2011-08-03 18:44:19 +04:00
|
|
|
on_restart_trigger.action->fn(&on_restart_trigger);
|
|
|
|
stop_run(&on_restart_trigger);
|
|
|
|
}
|
|
|
|
|
2021-04-06 18:38:11 +03:00
|
|
|
void do_restart(void *arg)
|
2012-03-11 19:59:26 +04:00
|
|
|
{
|
2012-03-11 19:59:32 +04:00
|
|
|
tracing_off();
|
|
|
|
debug_locks_off();
|
|
|
|
lgr_info_log();
|
2021-04-06 18:38:11 +03:00
|
|
|
smp_call_online_cpu(__do_restart, arg);
|
2012-03-11 19:59:26 +04:00
|
|
|
}
|
|
|
|
|
2008-01-26 16:11:11 +03:00
|
|
|
/* on halt */
|
|
|
|
|
|
|
|
static struct shutdown_trigger on_halt_trigger = {ON_HALT_STR, &stop_action};
|
|
|
|
|
|
|
|
static ssize_t on_halt_show(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr, char *page)
|
|
|
|
{
|
|
|
|
return sprintf(page, "%s\n", on_halt_trigger.action->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t on_halt_store(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr,
|
|
|
|
const char *buf, size_t len)
|
|
|
|
{
|
|
|
|
return set_trigger(buf, &on_halt_trigger, len);
|
|
|
|
}
|
2015-03-17 12:28:46 +03:00
|
|
|
static struct kobj_attribute on_halt_attr = __ATTR_RW(on_halt);
|
2008-01-26 16:11:11 +03:00
|
|
|
|
|
|
|
static void do_machine_halt(void)
|
|
|
|
{
|
|
|
|
smp_send_stop();
|
|
|
|
on_halt_trigger.action->fn(&on_halt_trigger);
|
|
|
|
stop_run(&on_halt_trigger);
|
|
|
|
}
|
|
|
|
void (*_machine_halt)(void) = do_machine_halt;
|
|
|
|
|
|
|
|
/* on power off */
|
|
|
|
|
|
|
|
static struct shutdown_trigger on_poff_trigger = {ON_POFF_STR, &stop_action};
|
|
|
|
|
|
|
|
static ssize_t on_poff_show(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr, char *page)
|
|
|
|
{
|
|
|
|
return sprintf(page, "%s\n", on_poff_trigger.action->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t on_poff_store(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr,
|
|
|
|
const char *buf, size_t len)
|
|
|
|
{
|
|
|
|
return set_trigger(buf, &on_poff_trigger, len);
|
|
|
|
}
|
2015-03-17 12:28:46 +03:00
|
|
|
static struct kobj_attribute on_poff_attr = __ATTR_RW(on_poff);
|
2008-01-26 16:11:11 +03:00
|
|
|
|
|
|
|
static void do_machine_power_off(void)
|
|
|
|
{
|
|
|
|
smp_send_stop();
|
|
|
|
on_poff_trigger.action->fn(&on_poff_trigger);
|
|
|
|
stop_run(&on_poff_trigger);
|
|
|
|
}
|
|
|
|
void (*_machine_power_off)(void) = do_machine_power_off;
|
|
|
|
|
2015-03-17 12:28:46 +03:00
|
|
|
static struct attribute *shutdown_action_attrs[] = {
|
|
|
|
&on_restart_attr.attr,
|
|
|
|
&on_reboot_attr.attr,
|
|
|
|
&on_panic_attr.attr,
|
|
|
|
&on_halt_attr.attr,
|
|
|
|
&on_poff_attr.attr,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct attribute_group shutdown_action_attr_group = {
|
|
|
|
.attrs = shutdown_action_attrs,
|
|
|
|
};
|
|
|
|
|
2008-01-26 16:11:11 +03:00
|
|
|
static void __init shutdown_triggers_init(void)
|
|
|
|
{
|
2007-11-03 00:17:00 +03:00
|
|
|
shutdown_actions_kset = kset_create_and_add("shutdown_actions", NULL,
|
2007-11-06 00:16:15 +03:00
|
|
|
firmware_kobj);
|
2007-11-03 00:17:00 +03:00
|
|
|
if (!shutdown_actions_kset)
|
2008-01-26 16:11:11 +03:00
|
|
|
goto fail;
|
2015-03-17 12:28:46 +03:00
|
|
|
if (sysfs_create_group(&shutdown_actions_kset->kobj,
|
|
|
|
&shutdown_action_attr_group))
|
2011-08-03 18:44:19 +04:00
|
|
|
goto fail;
|
2008-01-26 16:11:11 +03:00
|
|
|
return;
|
|
|
|
fail:
|
|
|
|
panic("shutdown_triggers_init failed\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __init shutdown_actions_init(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < SHUTDOWN_ACTIONS_COUNT; i++) {
|
|
|
|
if (!shutdown_actions_list[i]->init)
|
|
|
|
continue;
|
2009-07-07 18:37:07 +04:00
|
|
|
shutdown_actions_list[i]->init_rc =
|
|
|
|
shutdown_actions_list[i]->init();
|
2006-09-20 17:58:49 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __init s390_ipl_init(void)
|
|
|
|
{
|
2014-08-26 19:51:08 +04:00
|
|
|
char str[8] = {0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40};
|
|
|
|
|
2017-01-24 17:58:52 +03:00
|
|
|
sclp_early_get_ipl_info(&sclp_ipl_info);
|
2014-08-26 19:51:08 +04:00
|
|
|
/*
|
|
|
|
* Fix loadparm: There are systems where the (SCSI) LOADPARM
|
|
|
|
* returned by read SCP info is invalid (contains EBCDIC blanks)
|
|
|
|
* when the system has been booted via diag308. In that case we use
|
|
|
|
* the value from diag308, if available.
|
|
|
|
*
|
|
|
|
* There are also systems where diag308 store does not work in
|
|
|
|
* case the system is booted from HMC. Fortunately in this case
|
|
|
|
* READ SCP info provides the correct value.
|
|
|
|
*/
|
2018-04-03 17:03:14 +03:00
|
|
|
if (memcmp(sclp_ipl_info.loadparm, str, sizeof(str)) == 0 && ipl_block_valid)
|
2019-02-20 16:26:51 +03:00
|
|
|
memcpy(sclp_ipl_info.loadparm, ipl_block.ccw.loadparm, LOADPARM_LEN);
|
2008-01-26 16:11:11 +03:00
|
|
|
shutdown_actions_init();
|
|
|
|
shutdown_triggers_init();
|
2006-09-20 17:58:49 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
__initcall(s390_ipl_init);
|
2006-12-04 17:40:26 +03:00
|
|
|
|
2008-01-26 16:11:11 +03:00
|
|
|
static void __init strncpy_skip_quote(char *dst, char *src, int n)
|
|
|
|
{
|
|
|
|
int sx, dx;
|
|
|
|
|
|
|
|
dx = 0;
|
|
|
|
for (sx = 0; src[sx] != 0; sx++) {
|
|
|
|
if (src[sx] == '"')
|
|
|
|
continue;
|
|
|
|
dst[dx++] = src[sx];
|
|
|
|
if (dx >= n)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __init vmcmd_on_reboot_setup(char *str)
|
|
|
|
{
|
|
|
|
if (!MACHINE_IS_VM)
|
|
|
|
return 1;
|
|
|
|
strncpy_skip_quote(vmcmd_on_reboot, str, 127);
|
|
|
|
vmcmd_on_reboot[127] = 0;
|
|
|
|
on_reboot_trigger.action = &vmcmd_action;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
__setup("vmreboot=", vmcmd_on_reboot_setup);
|
|
|
|
|
|
|
|
static int __init vmcmd_on_panic_setup(char *str)
|
|
|
|
{
|
|
|
|
if (!MACHINE_IS_VM)
|
|
|
|
return 1;
|
|
|
|
strncpy_skip_quote(vmcmd_on_panic, str, 127);
|
|
|
|
vmcmd_on_panic[127] = 0;
|
|
|
|
on_panic_trigger.action = &vmcmd_action;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
__setup("vmpanic=", vmcmd_on_panic_setup);
|
|
|
|
|
|
|
|
static int __init vmcmd_on_halt_setup(char *str)
|
|
|
|
{
|
|
|
|
if (!MACHINE_IS_VM)
|
|
|
|
return 1;
|
|
|
|
strncpy_skip_quote(vmcmd_on_halt, str, 127);
|
|
|
|
vmcmd_on_halt[127] = 0;
|
|
|
|
on_halt_trigger.action = &vmcmd_action;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
__setup("vmhalt=", vmcmd_on_halt_setup);
|
|
|
|
|
|
|
|
static int __init vmcmd_on_poff_setup(char *str)
|
|
|
|
{
|
|
|
|
if (!MACHINE_IS_VM)
|
|
|
|
return 1;
|
|
|
|
strncpy_skip_quote(vmcmd_on_poff, str, 127);
|
|
|
|
vmcmd_on_poff[127] = 0;
|
|
|
|
on_poff_trigger.action = &vmcmd_action;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
__setup("vmpoff=", vmcmd_on_poff_setup);
|
|
|
|
|
|
|
|
static int on_panic_notify(struct notifier_block *self,
|
|
|
|
unsigned long event, void *data)
|
|
|
|
{
|
|
|
|
do_panic();
|
|
|
|
return NOTIFY_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct notifier_block on_panic_nb = {
|
|
|
|
.notifier_call = on_panic_notify,
|
2009-03-26 17:24:55 +03:00
|
|
|
.priority = INT_MIN,
|
2008-01-26 16:11:11 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
void __init setup_ipl(void)
|
|
|
|
{
|
2018-04-03 17:02:40 +03:00
|
|
|
BUILD_BUG_ON(sizeof(struct ipl_parameter_block) != PAGE_SIZE);
|
|
|
|
|
2008-01-26 16:11:11 +03:00
|
|
|
ipl_info.type = get_ipl_type();
|
|
|
|
switch (ipl_info.type) {
|
|
|
|
case IPL_TYPE_CCW:
|
2019-02-20 16:08:26 +03:00
|
|
|
ipl_info.data.ccw.dev_id.ssid = ipl_block.ccw.ssid;
|
|
|
|
ipl_info.data.ccw.dev_id.devno = ipl_block.ccw.devno;
|
2008-01-26 16:11:11 +03:00
|
|
|
break;
|
|
|
|
case IPL_TYPE_FCP:
|
|
|
|
case IPL_TYPE_FCP_DUMP:
|
2015-06-29 19:39:54 +03:00
|
|
|
ipl_info.data.fcp.dev_id.ssid = 0;
|
2019-02-20 16:08:26 +03:00
|
|
|
ipl_info.data.fcp.dev_id.devno = ipl_block.fcp.devno;
|
|
|
|
ipl_info.data.fcp.wwpn = ipl_block.fcp.wwpn;
|
|
|
|
ipl_info.data.fcp.lun = ipl_block.fcp.lun;
|
2008-01-26 16:11:11 +03:00
|
|
|
break;
|
2020-03-02 22:03:37 +03:00
|
|
|
case IPL_TYPE_NVME:
|
2020-03-17 16:23:41 +03:00
|
|
|
case IPL_TYPE_NVME_DUMP:
|
2020-03-02 22:03:37 +03:00
|
|
|
ipl_info.data.nvme.fid = ipl_block.nvme.fid;
|
|
|
|
ipl_info.data.nvme.nsid = ipl_block.nvme.nsid;
|
|
|
|
break;
|
2008-01-26 16:11:11 +03:00
|
|
|
case IPL_TYPE_NSS:
|
|
|
|
case IPL_TYPE_UNKNOWN:
|
|
|
|
/* We have no info to copy */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
atomic_notifier_chain_register(&panic_notifier_list, &on_panic_nb);
|
|
|
|
}
|
|
|
|
|
2015-10-29 12:28:26 +03:00
|
|
|
void s390_reset_system(void)
|
2006-12-04 17:40:26 +03:00
|
|
|
{
|
|
|
|
/* Disable prefixing */
|
|
|
|
set_prefix(0);
|
|
|
|
|
|
|
|
/* Disable lowcore protection */
|
2018-04-03 17:03:32 +03:00
|
|
|
__ctl_clear_bit(0, 28);
|
2021-08-04 14:40:31 +03:00
|
|
|
diag_amode31_ops.diag308_reset();
|
2006-12-04 17:40:26 +03:00
|
|
|
}
|
2019-02-25 19:23:39 +03:00
|
|
|
|
|
|
|
#ifdef CONFIG_KEXEC_FILE
|
|
|
|
|
|
|
|
int ipl_report_add_component(struct ipl_report *report, struct kexec_buf *kbuf,
|
|
|
|
unsigned char flags, unsigned short cert)
|
|
|
|
{
|
|
|
|
struct ipl_report_component *comp;
|
|
|
|
|
|
|
|
comp = vzalloc(sizeof(*comp));
|
|
|
|
if (!comp)
|
|
|
|
return -ENOMEM;
|
|
|
|
list_add_tail(&comp->list, &report->components);
|
|
|
|
|
|
|
|
comp->entry.addr = kbuf->mem;
|
|
|
|
comp->entry.len = kbuf->memsz;
|
|
|
|
comp->entry.flags = flags;
|
|
|
|
comp->entry.certificate_index = cert;
|
|
|
|
|
|
|
|
report->size += sizeof(comp->entry);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ipl_report_add_certificate(struct ipl_report *report, void *key,
|
|
|
|
unsigned long addr, unsigned long len)
|
|
|
|
{
|
|
|
|
struct ipl_report_certificate *cert;
|
|
|
|
|
|
|
|
cert = vzalloc(sizeof(*cert));
|
|
|
|
if (!cert)
|
|
|
|
return -ENOMEM;
|
|
|
|
list_add_tail(&cert->list, &report->certificates);
|
|
|
|
|
|
|
|
cert->entry.addr = addr;
|
|
|
|
cert->entry.len = len;
|
|
|
|
cert->key = key;
|
|
|
|
|
|
|
|
report->size += sizeof(cert->entry);
|
|
|
|
report->size += cert->entry.len;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ipl_report *ipl_report_init(struct ipl_parameter_block *ipib)
|
|
|
|
{
|
|
|
|
struct ipl_report *report;
|
|
|
|
|
|
|
|
report = vzalloc(sizeof(*report));
|
|
|
|
if (!report)
|
|
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
|
|
|
|
report->ipib = ipib;
|
|
|
|
INIT_LIST_HEAD(&report->components);
|
|
|
|
INIT_LIST_HEAD(&report->certificates);
|
|
|
|
|
|
|
|
report->size = ALIGN(ipib->hdr.len, 8);
|
|
|
|
report->size += sizeof(struct ipl_rl_hdr);
|
|
|
|
report->size += sizeof(struct ipl_rb_components);
|
|
|
|
report->size += sizeof(struct ipl_rb_certificates);
|
|
|
|
|
|
|
|
return report;
|
|
|
|
}
|
|
|
|
|
|
|
|
void *ipl_report_finish(struct ipl_report *report)
|
|
|
|
{
|
|
|
|
struct ipl_report_certificate *cert;
|
|
|
|
struct ipl_report_component *comp;
|
|
|
|
struct ipl_rb_certificates *certs;
|
|
|
|
struct ipl_parameter_block *ipib;
|
|
|
|
struct ipl_rb_components *comps;
|
|
|
|
struct ipl_rl_hdr *rl_hdr;
|
|
|
|
void *buf, *ptr;
|
|
|
|
|
|
|
|
buf = vzalloc(report->size);
|
|
|
|
if (!buf)
|
2021-11-16 13:06:38 +03:00
|
|
|
goto out;
|
2019-02-25 19:23:39 +03:00
|
|
|
ptr = buf;
|
|
|
|
|
|
|
|
memcpy(ptr, report->ipib, report->ipib->hdr.len);
|
|
|
|
ipib = ptr;
|
|
|
|
if (ipl_secure_flag)
|
|
|
|
ipib->hdr.flags |= IPL_PL_FLAG_SIPL;
|
|
|
|
ipib->hdr.flags |= IPL_PL_FLAG_IPLSR;
|
|
|
|
ptr += report->ipib->hdr.len;
|
|
|
|
ptr = PTR_ALIGN(ptr, 8);
|
|
|
|
|
|
|
|
rl_hdr = ptr;
|
|
|
|
ptr += sizeof(*rl_hdr);
|
|
|
|
|
|
|
|
comps = ptr;
|
|
|
|
comps->rbt = IPL_RBT_COMPONENTS;
|
|
|
|
ptr += sizeof(*comps);
|
|
|
|
list_for_each_entry(comp, &report->components, list) {
|
|
|
|
memcpy(ptr, &comp->entry, sizeof(comp->entry));
|
|
|
|
ptr += sizeof(comp->entry);
|
|
|
|
}
|
|
|
|
comps->len = ptr - (void *)comps;
|
|
|
|
|
|
|
|
certs = ptr;
|
|
|
|
certs->rbt = IPL_RBT_CERTIFICATES;
|
|
|
|
ptr += sizeof(*certs);
|
|
|
|
list_for_each_entry(cert, &report->certificates, list) {
|
|
|
|
memcpy(ptr, &cert->entry, sizeof(cert->entry));
|
|
|
|
ptr += sizeof(cert->entry);
|
|
|
|
}
|
|
|
|
certs->len = ptr - (void *)certs;
|
|
|
|
rl_hdr->len = ptr - (void *)rl_hdr;
|
|
|
|
|
|
|
|
list_for_each_entry(cert, &report->certificates, list) {
|
|
|
|
memcpy(ptr, cert->key, cert->entry.len);
|
|
|
|
ptr += cert->entry.len;
|
|
|
|
}
|
|
|
|
|
|
|
|
BUG_ON(ptr > buf + report->size);
|
2021-11-16 13:06:38 +03:00
|
|
|
out:
|
2019-02-25 19:23:39 +03:00
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ipl_report_free(struct ipl_report *report)
|
|
|
|
{
|
|
|
|
struct ipl_report_component *comp, *ncomp;
|
|
|
|
struct ipl_report_certificate *cert, *ncert;
|
|
|
|
|
|
|
|
list_for_each_entry_safe(comp, ncomp, &report->components, list)
|
|
|
|
vfree(comp);
|
|
|
|
|
|
|
|
list_for_each_entry_safe(cert, ncert, &report->certificates, list)
|
|
|
|
vfree(cert);
|
|
|
|
|
|
|
|
vfree(report);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|