ipl_tools: support clear attribute for FCP and CCW re-IPL

This patch adds support for the "clear" sysfs attribute for re-IPL, if
available. This attribute allows to control whether the memory should
be cleared on re-IPL.

Signed-off-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Acked-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Gerald Schaefer
2020-02-20 16:47:31 +01:00
committed by Jan Höppner
parent f742ed73e1
commit 4753340e79
3 changed files with 52 additions and 1 deletions

View File

@@ -60,6 +60,7 @@ static const char *const usage_chreipl =
"Options for ccw target:\n"
" -d, --device <DEVICE> Device number of the CCW IPL device\n"
" -L, --loadparm <PARM> Loadparm specification\n"
" -c, --clear 0|1 Control if memory is cleared on re-IPL\n"
"\n"
"Options for fcp target:\n"
" -d, --device <DEVICE> Device number of the adapter of the FCP IPL device\n"
@@ -67,6 +68,7 @@ static const char *const usage_chreipl =
" -w --wwpn <WWPN> World Wide Port Name of the FCP IPL device\n"
" -b, --bootprog <BPROG> Bootprog specification\n"
" -L, --loadparm <PARM> Loadparm specification\n"
" -c, --clear 0|1 Control if memory is cleared on re-IPL\n"
"\n"
"Options for nss target:\n"
" -n, --name <NAME> Identifier of the NSS\n"
@@ -96,6 +98,7 @@ static struct locals {
int target_type_set;
int target_type_auto_mode;
enum reipl_type reipl_type; /* CCW, FCP, NSS */
int reipl_clear;
} l;
static void __noreturn print_usage_chreipl_exit(void)
@@ -460,6 +463,16 @@ static void set_target_type_auto(const char *arg)
}
}
static void set_reipl_clear(const char *arg)
{
if (arg[0] == '1')
l.reipl_clear = 1;
else if (arg[0] == '0')
l.reipl_clear = 0;
else
ERR_EXIT("re-IPL clear argument must be either 1 or 0");
}
static void parse_chreipl_options(int argc, char *argv[])
{
int opt, idx;
@@ -474,9 +487,10 @@ static void parse_chreipl_options(int argc, char *argv[])
{ "bootparms", required_argument, NULL, 'p' },
{ "force", no_argument, NULL, 'f' },
{ "version", no_argument, NULL, 'v' },
{ "clear", required_argument, NULL, 'c' },
{ NULL, 0, NULL, 0 }
};
static const char optstr[] = "hcd:vw:l:fL:b:n:p:";
static const char optstr[] = "hd:vw:l:fL:b:n:p:c:";
/* dont run without any argument */
if (argc == 1)
@@ -493,6 +507,8 @@ static void parse_chreipl_options(int argc, char *argv[])
else
set_target_type_auto(argv[1]);
l.reipl_clear = -1;
while ((opt = getopt_long(argc, argv, optstr, long_opts, &idx)) != -1) {
switch (opt) {
case 'h':
@@ -521,6 +537,9 @@ static void parse_chreipl_options(int argc, char *argv[])
case 'f':
l.force_set = 1;
break;
case 'c':
set_reipl_clear(optarg);
break;
case 'v':
print_version_exit();
default:
@@ -600,6 +619,11 @@ static void chreipl_ccw(void)
strlen(l.bootparms), BOOTPARMS_CCW_MAX);
}
if (l.reipl_clear >= 0) {
check_exists("reipl/ccw/clear", "CCW re-IPL clear attribute");
write_str(l.reipl_clear ? "1" : "0", "reipl/ccw/clear");
}
/*
* On old systems that use CCW reipl loadparm cannot be set
*/
@@ -627,6 +651,12 @@ static void chreipl_fcp(void)
ERR_EXIT("Maximum boot parameter length exceeded (%zu/%u)",
strlen(l.bootparms), BOOTPARMS_FCP_MAX);
}
if (l.reipl_clear >= 0) {
check_exists("reipl/fcp/clear", "FCP re-IPL clear attribute");
write_str(l.reipl_clear ? "1" : "0", "reipl/fcp/clear");
}
/*
* On old systems the FCP reipl loadparm cannot be set
*/

View File

@@ -59,6 +59,7 @@ void print_fcp(int show_ipl, int dump)
char *path_loadparm = show_ipl ? "/sys/firmware/ipl/loadparm" :
"/sys/firmware/reipl/fcp/loadparm";
char loadparm[9], loadparm_path[PATH_MAX];
char *path_reipl_clear = "/sys/firmware/reipl/fcp/clear";
if (dump)
printf("%-12s fcp_dump\n", get_ipl_banner(show_ipl));
@@ -79,6 +80,8 @@ void print_fcp(int show_ipl, int dump)
}
if (access(path_bootparms, R_OK) == 0)
print_fw_str("Bootparms: \"%s\"\n", dir, "scp_data");
if (!show_ipl && access(path_reipl_clear, R_OK) == 0)
print_fw_str("clear: %s\n", dir, "clear");
}
void print_ccw(int show_ipl)
@@ -89,6 +92,7 @@ void print_ccw(int show_ipl)
"/sys/firmware/reipl/ccw/loadparm";
char *path_bootparms = show_ipl ? "/sys/firmware/ipl/parm" :
"/sys/firmware/reipl/ccw/parm";
char *path_reipl_clear = "/sys/firmware/reipl/ccw/clear";
printf("%-12s ccw\n", get_ipl_banner(show_ipl));
print_fw_str("Device: %s\n", dir, "device");
@@ -101,6 +105,8 @@ void print_ccw(int show_ipl)
}
if (access(path_bootparms, R_OK) == 0)
print_fw_str("Bootparms: \"%s\"\n", dir, "parm");
if (!show_ipl && access(path_reipl_clear, R_OK) == 0)
print_fw_str("clear: %s\n", dir, "clear");
}
static void parse_lsreipl_options(int argc, char *argv[])

View File

@@ -132,6 +132,14 @@ the same as 0.0.5000).
Specifies an entry in the
.BR zipl (8)
boot menu. If this option is omitted, the default menu entry is used.
.TP
.BR "\-c" " or " "\-\-clear"
Specify whether memory should be cleared on re-IPL. Possible values are 0 to
disable and 1 to enable memory clearing on re-IPL.
Memory clearing is supported if the "clear" attribute is present in
/sys/firmware/reipl/ccw/.
.PP
\fBExamples:\fP
.br
@@ -176,6 +184,13 @@ configuration that is defined by the
boot menu. Instead it can be used to control higher level boot loaders
like GRUB. For more details refer to distribution specific documentation.
.TP
.BR "\-c" " or " "\-\-clear"
Specify whether memory should be cleared on re-IPL. Possible values are 0 to
disable and 1 to enable memory clearing on re-IPL.
Memory clearing is supported if the "clear" attribute is present in
/sys/firmware/reipl/fcp/.
.PP
\fBExamples:\fP
.br