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

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