From 0ecf18b66da54f152f385cc2716ca6598ee3dc9d Mon Sep 17 00:00:00 2001 From: Gerald Schaefer Date: Tue, 23 Jun 2020 19:08:50 +0200 Subject: [PATCH] ipl_tools: support clear attribute for nvme re-IPL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch adds support for the "clear" sysfs attribute for nvme re-IPL, if available. This attribute allows to control whether the memory should be cleared on re-IPL. Signed-off-by: Gerald Schaefer Reviewed-by: Jan Höppner Signed-off-by: Jan Höppner --- ipl_tools/cmd_chreipl.c | 6 ++++++ ipl_tools/cmd_lsreipl.c | 3 +++ ipl_tools/man/chreipl.8 | 7 +++++++ 3 files changed, 16 insertions(+) diff --git a/ipl_tools/cmd_chreipl.c b/ipl_tools/cmd_chreipl.c index a296f91a..f58a7d60 100644 --- a/ipl_tools/cmd_chreipl.c +++ b/ipl_tools/cmd_chreipl.c @@ -79,6 +79,7 @@ static const char *const usage_chreipl = " -s --nsid Namespace ID of NVME IPL device (decimal, default 1)\n" " -b, --bootprog Bootprog specification\n" " -L, --loadparm Loadparm specification\n" +" -c, --clear 0|1 Control if memory is cleared on re-IPL\n" "\n" "Options for nss target:\n" " -n, --name Identifier of the NSS\n" @@ -794,6 +795,11 @@ static void chreipl_nvme(void) strlen(l.bootparms), BOOTPARMS_FCP_MAX); } + if (l.reipl_clear >= 0) { + check_exists("reipl/nvme/clear", "NVME re-IPL clear attribute"); + write_str(l.reipl_clear ? "1" : "0", "reipl/nvme/clear"); + } + write_str_optional(l.loadparm, "reipl/nvme/loadparm", l.loadparm_set, "loadparm"); write_str_optional(l.bootparms, "reipl/nvme/scp_data", l.bootparms_set, diff --git a/ipl_tools/cmd_lsreipl.c b/ipl_tools/cmd_lsreipl.c index af9b9bca..b006896c 100644 --- a/ipl_tools/cmd_lsreipl.c +++ b/ipl_tools/cmd_lsreipl.c @@ -92,6 +92,7 @@ void print_nvme(int show_ipl, int dump) char *path_loadparm = show_ipl ? "/sys/firmware/ipl/loadparm" : "/sys/firmware/reipl/nvme/loadparm"; char loadparm[9], loadparm_path[PATH_MAX]; + char *path_reipl_clear = "/sys/firmware/reipl/nvme/clear"; if (dump) printf("%-12s nvme_dump\n", get_ipl_banner(show_ipl)); @@ -111,6 +112,8 @@ void print_nvme(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) diff --git a/ipl_tools/man/chreipl.8 b/ipl_tools/man/chreipl.8 index e6ffc16c..ad147c1e 100644 --- a/ipl_tools/man/chreipl.8 +++ b/ipl_tools/man/chreipl.8 @@ -238,6 +238,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/nvme/. + .PP \fBExamples:\fP .br