cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/0030-pc-bios-s390-ccw-fix-non-sequential-boot-entries-enu.patch

26ba25
From f6d3898264a5083ebe7bcc663eab353bfa6ba1f4 Mon Sep 17 00:00:00 2001
26ba25
From: Collin Walling <walling@linux.ibm.com>
26ba25
Date: Tue, 8 May 2018 09:01:16 +0000
26ba25
Subject: pc-bios/s390-ccw: fix non-sequential boot entries (enum)
26ba25
26ba25
zIPL boot menu entries can be non-sequential. Let's account
26ba25
for this issue for the s390 enumerated boot menu. Since we
26ba25
can no longer print a range of available entries to the
26ba25
user, we have to present a list of each available entry.
26ba25
26ba25
An example of this menu:
26ba25
26ba25
  s390-ccw Enumerated Boot Menu.
26ba25
26ba25
   [0] default
26ba25
26ba25
   [1]
26ba25
   [2]
26ba25
   [7]
26ba25
   [8]
26ba25
   [9]
26ba25
  [11]
26ba25
  [12]
26ba25
26ba25
  Please choose:
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 622b39178057289a1c8c1b5148f513e658e90ea1)
26ba25
---
26ba25
 pc-bios/s390-ccw/bootmap.c  | 12 +++++++-----
26ba25
 pc-bios/s390-ccw/menu.c     | 29 ++++++++++++++++++++---------
26ba25
 pc-bios/s390-ccw/s390-ccw.h |  2 +-
26ba25
 3 files changed, 28 insertions(+), 15 deletions(-)
26ba25
26ba25
diff --git a/pc-bios/s390-ccw/bootmap.c b/pc-bios/s390-ccw/bootmap.c
26ba25
index b767fa2..e41e715 100644
26ba25
--- a/pc-bios/s390-ccw/bootmap.c
26ba25
+++ b/pc-bios/s390-ccw/bootmap.c
26ba25
@@ -565,6 +565,8 @@ static void ipl_scsi(void)
26ba25
     int program_table_entries = 0;
26ba25
     BootMapTable *prog_table = (void *)sec;
26ba25
     unsigned int loadparm = get_loadparm_index();
26ba25
+    bool valid_entries[MAX_BOOT_ENTRIES] = {false};
26ba25
+    size_t i;
26ba25
 
26ba25
     /* Grab the MBR */
26ba25
     memset(sec, FREE_SPACE_FILLER, sizeof(sec));
26ba25
@@ -585,18 +587,18 @@ static void ipl_scsi(void)
26ba25
     read_block(mbr->pt.blockno, sec, "Error reading Program Table");
26ba25
     IPL_assert(magic_match(sec, ZIPL_MAGIC), "No zIPL magic in PT");
26ba25
 
26ba25
-    while (program_table_entries < MAX_BOOT_ENTRIES) {
26ba25
-        if (!prog_table->entry[program_table_entries].scsi.blockno) {
26ba25
-            break;
26ba25
+    for (i = 0; i < MAX_BOOT_ENTRIES; i++) {
26ba25
+        if (prog_table->entry[i].scsi.blockno) {
26ba25
+            valid_entries[i] = true;
26ba25
+            program_table_entries++;
26ba25
         }
26ba25
-        program_table_entries++;
26ba25
     }
26ba25
 
26ba25
     debug_print_int("program table entries", program_table_entries);
26ba25
     IPL_assert(program_table_entries != 0, "Empty Program Table");
26ba25
 
26ba25
     if (menu_is_enabled_enum()) {
26ba25
-        loadparm = menu_get_enum_boot_index(program_table_entries);
26ba25
+        loadparm = menu_get_enum_boot_index(valid_entries);
26ba25
     }
26ba25
 
26ba25
     debug_print_int("loadparm", loadparm);
26ba25
diff --git a/pc-bios/s390-ccw/menu.c b/pc-bios/s390-ccw/menu.c
26ba25
index aaf5d61..82a4ae6 100644
26ba25
--- a/pc-bios/s390-ccw/menu.c
26ba25
+++ b/pc-bios/s390-ccw/menu.c
26ba25
@@ -228,19 +228,30 @@ int menu_get_zipl_boot_index(const char *menu_data)
26ba25
     return get_boot_index(valid_entries);
26ba25
 }
26ba25
 
26ba25
-
26ba25
-int menu_get_enum_boot_index(int entries)
26ba25
+int menu_get_enum_boot_index(bool *valid_entries)
26ba25
 {
26ba25
-    char tmp[4];
26ba25
+    char tmp[3];
26ba25
+    int i;
26ba25
 
26ba25
-    sclp_print("s390x Enumerated Boot Menu.\n\n");
26ba25
+    sclp_print("s390-ccw Enumerated Boot Menu.\n\n");
26ba25
 
26ba25
-    sclp_print(uitoa(entries, tmp, sizeof(tmp)));
26ba25
-    sclp_print(" entries detected. Select from boot index 0 to ");
26ba25
-    sclp_print(uitoa(entries - 1, tmp, sizeof(tmp)));
26ba25
-    sclp_print(".\n\n");
26ba25
+    for (i = 0; i < MAX_BOOT_ENTRIES; i++) {
26ba25
+        if (valid_entries[i]) {
26ba25
+            if (i < 10) {
26ba25
+                sclp_print(" ");
26ba25
+            }
26ba25
+            sclp_print("[");
26ba25
+            sclp_print(uitoa(i, tmp, sizeof(tmp)));
26ba25
+            sclp_print("]");
26ba25
+            if (i == 0) {
26ba25
+                sclp_print(" default\n");
26ba25
+            }
26ba25
+            sclp_print("\n");
26ba25
+        }
26ba25
+    }
26ba25
 
26ba25
-    return get_boot_index(entries);
26ba25
+    sclp_print("\n");
26ba25
+    return get_boot_index(valid_entries);
26ba25
 }
26ba25
 
26ba25
 void menu_set_parms(uint8_t boot_menu_flag, uint32_t boot_menu_timeout)
26ba25
diff --git a/pc-bios/s390-ccw/s390-ccw.h b/pc-bios/s390-ccw/s390-ccw.h
26ba25
index 2c9e601..a1bdb4c 100644
26ba25
--- a/pc-bios/s390-ccw/s390-ccw.h
26ba25
+++ b/pc-bios/s390-ccw/s390-ccw.h
26ba25
@@ -91,7 +91,7 @@ void zipl_load(void);
26ba25
 void menu_set_parms(uint8_t boot_menu_flag, uint32_t boot_menu_timeout);
26ba25
 int menu_get_zipl_boot_index(const char *menu_data);
26ba25
 bool menu_is_enabled_zipl(void);
26ba25
-int menu_get_enum_boot_index(int entries);
26ba25
+int menu_get_enum_boot_index(bool *valid_entries);
26ba25
 bool menu_is_enabled_enum(void);
26ba25
 
26ba25
 #define MAX_BOOT_ENTRIES  31
26ba25
-- 
26ba25
1.8.3.1
26ba25