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

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