|
|
ae23c9 |
From c0577fcb360841afe54f76deee37ea4a52761bf3 Mon Sep 17 00:00:00 2001
|
|
|
ae23c9 |
From: Collin Walling <walling@linux.ibm.com>
|
|
|
ae23c9 |
Date: Tue, 8 May 2018 09:01:15 +0000
|
|
|
ae23c9 |
Subject: pc-bios/s390-ccw: fix non-sequential boot entries (eckd)
|
|
|
ae23c9 |
|
|
|
ae23c9 |
zIPL boot menu entries can be non-sequential. Let's account
|
|
|
ae23c9 |
for this issue for the s390 zIPL boot menu. Since this boot
|
|
|
ae23c9 |
menu is actually an imitation and is not completely capable
|
|
|
ae23c9 |
of everything the real zIPL menu can do, let's also print a
|
|
|
ae23c9 |
different banner to the user.
|
|
|
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 7385e947fc65a44dd05abb86c874beb915c1989c)
|
|
|
ae23c9 |
---
|
|
|
ae23c9 |
pc-bios/s390-ccw/menu.c | 29 ++++++++++++++++++++---------
|
|
|
ae23c9 |
1 file changed, 20 insertions(+), 9 deletions(-)
|
|
|
ae23c9 |
|
|
|
ae23c9 |
diff --git a/pc-bios/s390-ccw/menu.c b/pc-bios/s390-ccw/menu.c
|
|
|
ae23c9 |
index 96eec81..aaf5d61 100644
|
|
|
ae23c9 |
--- a/pc-bios/s390-ccw/menu.c
|
|
|
ae23c9 |
+++ b/pc-bios/s390-ccw/menu.c
|
|
|
ae23c9 |
@@ -158,7 +158,7 @@ static void boot_menu_prompt(bool retry)
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
-static int get_boot_index(int entries)
|
|
|
ae23c9 |
+static int get_boot_index(bool *valid_entries)
|
|
|
ae23c9 |
{
|
|
|
ae23c9 |
int boot_index;
|
|
|
ae23c9 |
bool retry = false;
|
|
|
ae23c9 |
@@ -168,7 +168,8 @@ static int get_boot_index(int entries)
|
|
|
ae23c9 |
boot_menu_prompt(retry);
|
|
|
ae23c9 |
boot_index = get_index();
|
|
|
ae23c9 |
retry = true;
|
|
|
ae23c9 |
- } while (boot_index < 0 || boot_index >= entries);
|
|
|
ae23c9 |
+ } while (boot_index < 0 || boot_index >= MAX_BOOT_ENTRIES ||
|
|
|
ae23c9 |
+ !valid_entries[boot_index]);
|
|
|
ae23c9 |
|
|
|
ae23c9 |
sclp_print("\nBooting entry #");
|
|
|
ae23c9 |
sclp_print(uitoa(boot_index, tmp, sizeof(tmp)));
|
|
|
ae23c9 |
@@ -176,7 +177,8 @@ static int get_boot_index(int entries)
|
|
|
ae23c9 |
return boot_index;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
-static void zipl_println(const char *data, size_t len)
|
|
|
ae23c9 |
+/* Returns the entry number that was printed */
|
|
|
ae23c9 |
+static int zipl_print_entry(const char *data, size_t len)
|
|
|
ae23c9 |
{
|
|
|
ae23c9 |
char buf[len + 2];
|
|
|
ae23c9 |
|
|
|
ae23c9 |
@@ -185,12 +187,15 @@ static void zipl_println(const char *data, size_t len)
|
|
|
ae23c9 |
buf[len + 1] = '\0';
|
|
|
ae23c9 |
|
|
|
ae23c9 |
sclp_print(buf);
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ return buf[0] == ' ' ? atoui(buf + 1) : atoui(buf);
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
int menu_get_zipl_boot_index(const char *menu_data)
|
|
|
ae23c9 |
{
|
|
|
ae23c9 |
size_t len;
|
|
|
ae23c9 |
- int entries;
|
|
|
ae23c9 |
+ int entry;
|
|
|
ae23c9 |
+ bool valid_entries[MAX_BOOT_ENTRIES] = {false};
|
|
|
ae23c9 |
uint16_t zipl_flag = *(uint16_t *)(menu_data - ZIPL_FLAG_OFFSET);
|
|
|
ae23c9 |
uint16_t zipl_timeout = *(uint16_t *)(menu_data - ZIPL_TIMEOUT_OFFSET);
|
|
|
ae23c9 |
|
|
|
ae23c9 |
@@ -202,19 +207,25 @@ int menu_get_zipl_boot_index(const char *menu_data)
|
|
|
ae23c9 |
timeout = zipl_timeout * 1000;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
- /* Print and count all menu items, including the banner */
|
|
|
ae23c9 |
- for (entries = 0; *menu_data; entries++) {
|
|
|
ae23c9 |
+ /* Print banner */
|
|
|
ae23c9 |
+ sclp_print("s390-ccw zIPL Boot Menu\n\n");
|
|
|
ae23c9 |
+ menu_data += strlen(menu_data) + 1;
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ /* Print entries */
|
|
|
ae23c9 |
+ while (*menu_data) {
|
|
|
ae23c9 |
len = strlen(menu_data);
|
|
|
ae23c9 |
- zipl_println(menu_data, len);
|
|
|
ae23c9 |
+ entry = zipl_print_entry(menu_data, len);
|
|
|
ae23c9 |
menu_data += len + 1;
|
|
|
ae23c9 |
|
|
|
ae23c9 |
- if (entries < 2) {
|
|
|
ae23c9 |
+ valid_entries[entry] = true;
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ if (entry == 0) {
|
|
|
ae23c9 |
sclp_print("\n");
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
sclp_print("\n");
|
|
|
ae23c9 |
- return get_boot_index(entries - 1); /* subtract 1 to exclude banner */
|
|
|
ae23c9 |
+ return get_boot_index(valid_entries);
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
|
|
|
ae23c9 |
--
|
|
|
ae23c9 |
1.8.3.1
|
|
|
ae23c9 |
|