Blame SOURCES/0028-pc-bios-s390-ccw-fix-loadparm-initialization-and-int.patch

ae23c9
From 3301328699d574c8d6617eb4105cd9d4794f722c Mon Sep 17 00:00:00 2001
ae23c9
From: Collin Walling <walling@linux.ibm.com>
ae23c9
Date: Tue, 8 May 2018 09:01:14 +0000
ae23c9
Subject: pc-bios/s390-ccw: fix loadparm initialization and int conversion
ae23c9
ae23c9
Rename the loadparm char array in main.c to loadparm_str and
ae23c9
increased the size by one byte to account for a null termination
ae23c9
when converting the loadparm string to an int  via atoui. We
ae23c9
also allow the boot menu to be enabled when loadparm is set to
ae23c9
an empty string or a series of spaces.
ae23c9
ae23c9
Signed-off-by: Collin Walling <walling@linux.ibm.com>
ae23c9
Reported-by: Vasily Gorbik <gor@linux.ibm.com>
ae23c9
Reviewed-by: Thomas Huth <thuth@redhat.com>
ae23c9
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
ae23c9
Signed-off-by: Thomas Huth <thuth@redhat.com>
ae23c9
(cherry picked from commit 074afe60d4c8167dcfaee7aca1065c6360449eaa)
ae23c9
---
ae23c9
 hw/s390x/ipl.c          |  4 ++++
ae23c9
 pc-bios/s390-ccw/main.c | 14 +++++++-------
ae23c9
 2 files changed, 11 insertions(+), 7 deletions(-)
ae23c9
ae23c9
diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
ae23c9
index fb554ab..150f6c0 100644
ae23c9
--- a/hw/s390x/ipl.c
ae23c9
+++ b/hw/s390x/ipl.c
ae23c9
@@ -373,6 +373,10 @@ int s390_ipl_set_loadparm(uint8_t *loadparm)
ae23c9
             loadparm[i] = ascii2ebcdic[(uint8_t) lp[i]];
ae23c9
         }
ae23c9
 
ae23c9
+        if (i < 8) {
ae23c9
+            memset(loadparm + i, 0x40, 8 - i); /* fill with EBCDIC spaces */
ae23c9
+        }
ae23c9
+
ae23c9
         g_free(lp);
ae23c9
         return 0;
ae23c9
     }
ae23c9
diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c
ae23c9
index 9d9f8cf..26f9adf 100644
ae23c9
--- a/pc-bios/s390-ccw/main.c
ae23c9
+++ b/pc-bios/s390-ccw/main.c
ae23c9
@@ -15,11 +15,11 @@
ae23c9
 char stack[PAGE_SIZE * 8] __attribute__((__aligned__(PAGE_SIZE)));
ae23c9
 static SubChannelId blk_schid = { .one = 1 };
ae23c9
 IplParameterBlock iplb __attribute__((__aligned__(PAGE_SIZE)));
ae23c9
-static char loadparm[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
ae23c9
+static char loadparm_str[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
ae23c9
 QemuIplParameters qipl;
ae23c9
 
ae23c9
 #define LOADPARM_PROMPT "PROMPT  "
ae23c9
-#define LOADPARM_EMPTY  "........"
ae23c9
+#define LOADPARM_EMPTY  "        "
ae23c9
 #define BOOT_MENU_FLAG_MASK (QIPL_FLAG_BM_OPTS_CMD | QIPL_FLAG_BM_OPTS_ZIPL)
ae23c9
 
ae23c9
 /*
ae23c9
@@ -45,7 +45,7 @@ void panic(const char *string)
ae23c9
 
ae23c9
 unsigned int get_loadparm_index(void)
ae23c9
 {
ae23c9
-    return atoui(loadparm);
ae23c9
+    return atoui(loadparm_str);
ae23c9
 }
ae23c9
 
ae23c9
 static bool find_dev(Schib *schib, int dev_no)
ae23c9
@@ -80,13 +80,13 @@ static bool find_dev(Schib *schib, int dev_no)
ae23c9
 
ae23c9
 static void menu_setup(void)
ae23c9
 {
ae23c9
-    if (memcmp(loadparm, LOADPARM_PROMPT, 8) == 0) {
ae23c9
+    if (memcmp(loadparm_str, LOADPARM_PROMPT, 8) == 0) {
ae23c9
         menu_set_parms(QIPL_FLAG_BM_OPTS_CMD, 0);
ae23c9
         return;
ae23c9
     }
ae23c9
 
ae23c9
     /* If loadparm was set to any other value, then do not enable menu */
ae23c9
-    if (memcmp(loadparm, LOADPARM_EMPTY, 8) != 0) {
ae23c9
+    if (memcmp(loadparm_str, LOADPARM_EMPTY, 8) != 0) {
ae23c9
         return;
ae23c9
     }
ae23c9
 
ae23c9
@@ -116,8 +116,8 @@ static void virtio_setup(void)
ae23c9
      */
ae23c9
     enable_mss_facility();
ae23c9
 
ae23c9
-    sclp_get_loadparm_ascii(loadparm);
ae23c9
-    memcpy(ldp + 10, loadparm, 8);
ae23c9
+    sclp_get_loadparm_ascii(loadparm_str);
ae23c9
+    memcpy(ldp + 10, loadparm_str, 8);
ae23c9
     sclp_print(ldp);
ae23c9
 
ae23c9
     memcpy(&qipl, early_qipl, sizeof(QemuIplParameters));
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9