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

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