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

383d26
From 81a0dae65a07d9323c78c6bc9adc7f8dbbb19145 Mon Sep 17 00:00:00 2001
383d26
From: Thomas Huth <thuth@redhat.com>
383d26
Date: Mon, 7 May 2018 07:58:08 +0200
383d26
Subject: [PATCH 12/13] pc-bios/s390-ccw: fix non-sequential boot entries
383d26
 (enum)
383d26
383d26
RH-Author: Thomas Huth <thuth@redhat.com>
383d26
Message-id: <1525679888-9234-7-git-send-email-thuth@redhat.com>
383d26
Patchwork-id: 80054
383d26
O-Subject: [RHEL-7.6 qemu-kvm-ma PATCH 6/6] pc-bios/s390-ccw: fix non-sequential boot entries (enum)
383d26
Bugzilla: 1523857
383d26
RH-Acked-by: David Hildenbrand <david@redhat.com>
383d26
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
383d26
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
383d26
383d26
From: Collin Walling <walling@linux.ibm.com>
383d26
383d26
zIPL boot menu entries can be non-sequential. Let's account
383d26
for this issue for the s390 enumerated boot menu. Since we
383d26
can no longer print a range of available entries to the
383d26
user, we have to present a list of each available entry.
383d26
383d26
An example of this menu:
383d26
383d26
  s390-ccw Enumerated Boot Menu.
383d26
383d26
   [0] default
383d26
383d26
   [1]
383d26
   [2]
383d26
   [7]
383d26
   [8]
383d26
   [9]
383d26
  [11]
383d26
  [12]
383d26
383d26
  Please choose:
383d26
383d26
Signed-off-by: Collin Walling <walling@linux.ibm.com>
383d26
Reported-by: Vasily Gorbik <gor@linux.ibm.com>
383d26
Reviewed-by: Thomas Huth <thuth@redhat.com>
383d26
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
383d26
Signed-off-by: Thomas Huth <thuth@redhat.com>
383d26
(cherry picked from commit 622b39178057289a1c8c1b5148f513e658e90ea1)
383d26
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
383d26
---
383d26
 pc-bios/s390-ccw/bootmap.c  | 12 +++++++-----
383d26
 pc-bios/s390-ccw/menu.c     | 29 ++++++++++++++++++++---------
383d26
 pc-bios/s390-ccw/s390-ccw.h |  2 +-
383d26
 3 files changed, 28 insertions(+), 15 deletions(-)
383d26
383d26
diff --git a/pc-bios/s390-ccw/bootmap.c b/pc-bios/s390-ccw/bootmap.c
383d26
index b767fa2..e41e715 100644
383d26
--- a/pc-bios/s390-ccw/bootmap.c
383d26
+++ b/pc-bios/s390-ccw/bootmap.c
383d26
@@ -565,6 +565,8 @@ static void ipl_scsi(void)
383d26
     int program_table_entries = 0;
383d26
     BootMapTable *prog_table = (void *)sec;
383d26
     unsigned int loadparm = get_loadparm_index();
383d26
+    bool valid_entries[MAX_BOOT_ENTRIES] = {false};
383d26
+    size_t i;
383d26
 
383d26
     /* Grab the MBR */
383d26
     memset(sec, FREE_SPACE_FILLER, sizeof(sec));
383d26
@@ -585,18 +587,18 @@ static void ipl_scsi(void)
383d26
     read_block(mbr->pt.blockno, sec, "Error reading Program Table");
383d26
     IPL_assert(magic_match(sec, ZIPL_MAGIC), "No zIPL magic in PT");
383d26
 
383d26
-    while (program_table_entries < MAX_BOOT_ENTRIES) {
383d26
-        if (!prog_table->entry[program_table_entries].scsi.blockno) {
383d26
-            break;
383d26
+    for (i = 0; i < MAX_BOOT_ENTRIES; i++) {
383d26
+        if (prog_table->entry[i].scsi.blockno) {
383d26
+            valid_entries[i] = true;
383d26
+            program_table_entries++;
383d26
         }
383d26
-        program_table_entries++;
383d26
     }
383d26
 
383d26
     debug_print_int("program table entries", program_table_entries);
383d26
     IPL_assert(program_table_entries != 0, "Empty Program Table");
383d26
 
383d26
     if (menu_is_enabled_enum()) {
383d26
-        loadparm = menu_get_enum_boot_index(program_table_entries);
383d26
+        loadparm = menu_get_enum_boot_index(valid_entries);
383d26
     }
383d26
 
383d26
     debug_print_int("loadparm", loadparm);
383d26
diff --git a/pc-bios/s390-ccw/menu.c b/pc-bios/s390-ccw/menu.c
383d26
index aaf5d61..82a4ae6 100644
383d26
--- a/pc-bios/s390-ccw/menu.c
383d26
+++ b/pc-bios/s390-ccw/menu.c
383d26
@@ -228,19 +228,30 @@ int menu_get_zipl_boot_index(const char *menu_data)
383d26
     return get_boot_index(valid_entries);
383d26
 }
383d26
 
383d26
-
383d26
-int menu_get_enum_boot_index(int entries)
383d26
+int menu_get_enum_boot_index(bool *valid_entries)
383d26
 {
383d26
-    char tmp[4];
383d26
+    char tmp[3];
383d26
+    int i;
383d26
 
383d26
-    sclp_print("s390x Enumerated Boot Menu.\n\n");
383d26
+    sclp_print("s390-ccw Enumerated Boot Menu.\n\n");
383d26
 
383d26
-    sclp_print(uitoa(entries, tmp, sizeof(tmp)));
383d26
-    sclp_print(" entries detected. Select from boot index 0 to ");
383d26
-    sclp_print(uitoa(entries - 1, tmp, sizeof(tmp)));
383d26
-    sclp_print(".\n\n");
383d26
+    for (i = 0; i < MAX_BOOT_ENTRIES; i++) {
383d26
+        if (valid_entries[i]) {
383d26
+            if (i < 10) {
383d26
+                sclp_print(" ");
383d26
+            }
383d26
+            sclp_print("[");
383d26
+            sclp_print(uitoa(i, tmp, sizeof(tmp)));
383d26
+            sclp_print("]");
383d26
+            if (i == 0) {
383d26
+                sclp_print(" default\n");
383d26
+            }
383d26
+            sclp_print("\n");
383d26
+        }
383d26
+    }
383d26
 
383d26
-    return get_boot_index(entries);
383d26
+    sclp_print("\n");
383d26
+    return get_boot_index(valid_entries);
383d26
 }
383d26
 
383d26
 void menu_set_parms(uint8_t boot_menu_flag, uint32_t boot_menu_timeout)
383d26
diff --git a/pc-bios/s390-ccw/s390-ccw.h b/pc-bios/s390-ccw/s390-ccw.h
383d26
index 2c9e601..a1bdb4c 100644
383d26
--- a/pc-bios/s390-ccw/s390-ccw.h
383d26
+++ b/pc-bios/s390-ccw/s390-ccw.h
383d26
@@ -91,7 +91,7 @@ void zipl_load(void);
383d26
 void menu_set_parms(uint8_t boot_menu_flag, uint32_t boot_menu_timeout);
383d26
 int menu_get_zipl_boot_index(const char *menu_data);
383d26
 bool menu_is_enabled_zipl(void);
383d26
-int menu_get_enum_boot_index(int entries);
383d26
+int menu_get_enum_boot_index(bool *valid_entries);
383d26
 bool menu_is_enabled_enum(void);
383d26
 
383d26
 #define MAX_BOOT_ENTRIES  31
383d26
-- 
383d26
1.8.3.1
383d26