From 2b511aa2b962c5b6f86ea98ef41a40803b72d6eb Mon Sep 17 00:00:00 2001 From: Sven Schnelle Date: Mon, 13 Feb 2023 10:28:17 +0100 Subject: [PATCH] zipl/dump: move dump parmline processing and verification MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The current code has different paths to construct the kernel parameters depending on whether it's a dump kernel or a normal kernel. This would require adding special handling to get_common_component(), because for normal kernels the parmline is already set, contrary to dump kernels, where the command line is constructed later. To make the code simpler and fix a bug where the default command line no longer works, move the dump command line processing to an earlier stage. Also rename the old function to make the function name match what it is actually doing. Fixes: 5fb64345486f ("zipl: add get_common_components() and finalize_common_address_data()") Signed-off-by: Sven Schnelle Reviewed-by: Stefan Haberland Signed-off-by: Jan Höppner --- zipl/src/bootmap.c | 36 ++++-------------------------------- zipl/src/job.c | 3 +++ 2 files changed, 7 insertions(+), 32 deletions(-) diff --git a/zipl/src/bootmap.c b/zipl/src/bootmap.c index 900dea56..2751d16c 100644 --- a/zipl/src/bootmap.c +++ b/zipl/src/bootmap.c @@ -953,30 +953,10 @@ static int add_segment_program(struct install_set *bis, #define DUMP_PARAM_MAX_LEN 896 -static char * -create_dump_parmline(const char* parmline, const char* root_dev, - uint64_t mem, int max_cpus) -{ - char* result; - - result = misc_malloc(DUMP_PARAM_MAX_LEN); - if (!result) - return NULL; - snprintf(result, DUMP_PARAM_MAX_LEN, "%s%sroot=%s dump_mem=%lld " - "possible_cpus=%d cgroup_disable=memory ", - parmline ? parmline : "", parmline ? " " : "", root_dev, - (unsigned long long) mem, max_cpus); - result[DUMP_PARAM_MAX_LEN - 1] = 0; - return result; -} - - static int -get_dump_parmline(char *partition, char *parameters, - struct disk_info *target_info, - struct job_target_data *target, char **result) +check_dump_device_late(char *partition, struct disk_info *target_info, + struct job_target_data *target) { - char* buffer; struct disk_info* info; int rc; @@ -999,15 +979,7 @@ get_dump_parmline(char *partition, char *parameters, disk_free_info(info); return -1; } - if (is_ngdump_enabled(partition, target)) - buffer = misc_strdup(parameters); - else - buffer = create_dump_parmline(parameters, "/dev/ram0", - info->partnum, 1); disk_free_info(info); - if (buffer == NULL) - return -1; - *result = buffer; return 0; } @@ -1025,10 +997,10 @@ static int add_dump_program(struct install_set *bis, struct job_dump_data *dump, ipl.common = dump->common; /* Get file system dump parmline */ - rc = get_dump_parmline(dump->device, dump->common.parmline, - bis->info, target, &ipl.common.parmline); + rc = check_dump_device_late(dump->device, bis->info, target); if (rc) return rc; + ipl.common.parmline = dump->common.parmline; ipl.common.parm_addr = dump->common.parm_addr; return add_ipl_program(bis, NULL, false, NULL, &ipl, program, verbose, 1, type, target, SECURE_BOOT_DISABLED, diff --git a/zipl/src/job.c b/zipl/src/job.c index b5bf5b20..1eccc44f 100644 --- a/zipl/src/job.c +++ b/zipl/src/job.c @@ -30,6 +30,8 @@ #include "zipl.h" #include "envblk.h" +#define DEFAULT_DUMP_PARMLINE "root=/dev/ram0 possible_cpus=1 cgroup_disable=memory" + const char *blsdir; /* Command line options */ @@ -891,6 +893,7 @@ check_job_dump_images(struct job_dump_data* dump, char* name) dump->common.ramdisk_addr = UNSPECIFIED_ADDRESS; } + dump->common.parmline = misc_strdup(DEFAULT_DUMP_PARMLINE); dump->common.parm_addr = UNSPECIFIED_ADDRESS; return finalize_common_address_data(&dump->common, name); }