thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

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

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