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

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