From 7503d88b3bdcafa31fa9fbdbce0d3298edda9e2b Mon Sep 17 00:00:00 2001 From: Marc Hartmayer Date: Tue, 28 Sep 2021 08:48:39 +0000 Subject: [PATCH] genprotimg/boot: add extended kernel command line support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the past s390 used a fixed command line length of 896 bytes. This has changed with newer Linux kernels. There is now a parm area indicating the maximum command line size. This parm area has always been initialized to zero, so with old kernels this field would read zero and we must then assume that only 896 bytes are available. Signed-off-by: Marc Hartmayer Reviewed-by: Steffen Eiden Signed-off-by: Jan Höppner --- genprotimg/boot/stage3b.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/genprotimg/boot/stage3b.c b/genprotimg/boot/stage3b.c index 4b5a28d2..34a087dd 100644 --- a/genprotimg/boot/stage3b.c +++ b/genprotimg/boot/stage3b.c @@ -28,6 +28,16 @@ static inline void __noreturn load_psw(struct psw_t psw) ; } +static unsigned long get_kernel_cmdline_size(void) +{ + unsigned long size = *(volatile unsigned long *)MAX_COMMAND_LINE_SIZE; + + if (size != 0) + return size; + + return LEGACY_COMMAND_LINE_SIZE; +} + void __noreturn start(void) { volatile struct stage3b_args *args = &loader_parms; @@ -42,14 +52,14 @@ void __noreturn start(void) if (kernel->size < IMAGE_LOAD_ADDRESS) panic(EINTERNAL, "Invalid kernel\n"); - if (cmdline->size > LEGACY_COMMAND_LINE_SIZE) - panic(EINTERNAL, "Command line is too large\n"); - /* move the kernel and cut the kernel header */ memmove((void *)IMAGE_LOAD_ADDRESS, (void *)(kernel->src + IMAGE_LOAD_ADDRESS), kernel->size - IMAGE_LOAD_ADDRESS); + if (cmdline->size > get_kernel_cmdline_size()) + panic(EINTERNAL, "Command line is too large\n"); + /* move the kernel cmdline */ memmove((void *)COMMAND_LINE, (void *)cmdline->src,