Blame SOURCES/kvm-pc-bios-s390-ccw-Allow-booting-in-case-the-first-vir.patch

a19a21
From e46aaac6f1ad67753face896e827ad1da920b9e5 Mon Sep 17 00:00:00 2001
a19a21
From: Thomas Huth <thuth@redhat.com>
a19a21
Date: Fri, 9 Oct 2020 10:08:47 -0400
a19a21
Subject: [PATCH 11/14] pc-bios/s390-ccw: Allow booting in case the first
a19a21
 virtio-blk disk is bad
a19a21
a19a21
RH-Author: Thomas Huth <thuth@redhat.com>
a19a21
Message-id: <20201009100849.264994-8-thuth@redhat.com>
a19a21
Patchwork-id: 98601
a19a21
O-Subject: [RHEL-8.4.0 qemu-kvm PATCH 7/9] pc-bios/s390-ccw: Allow booting in case the first virtio-blk disk is bad
a19a21
Bugzilla: 1846975
a19a21
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
a19a21
RH-Acked-by: David Hildenbrand <david@redhat.com>
a19a21
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
a19a21
a19a21
If you try to boot with two virtio-blk disks (without bootindex), and
a19a21
only the second one is bootable, the s390-ccw bios currently stops at
a19a21
the first disk and does not continue booting from the second one. This
a19a21
is annoying - and all other major QEMU firmwares succeed to boot from
a19a21
the second disk in this case, so we should do the same in the s390-ccw
a19a21
bios, too.
a19a21
a19a21
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
a19a21
Message-Id: <20200806105349.632-8-thuth@redhat.com>
a19a21
Signed-off-by: Thomas Huth <thuth@redhat.com>
a19a21
(cherry picked from commit 5dc739f343cd06ecb9b058294564ce7504856f3f)
a19a21
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
a19a21
---
a19a21
 pc-bios/s390-ccw/bootmap.c | 34 +++++++++++++++++++++++-----------
a19a21
 pc-bios/s390-ccw/main.c    |  2 +-
a19a21
 2 files changed, 24 insertions(+), 12 deletions(-)
a19a21
a19a21
diff --git a/pc-bios/s390-ccw/bootmap.c b/pc-bios/s390-ccw/bootmap.c
a19a21
index d13b7cbd15..e91ea719ff 100644
a19a21
--- a/pc-bios/s390-ccw/bootmap.c
a19a21
+++ b/pc-bios/s390-ccw/bootmap.c
a19a21
@@ -289,11 +289,18 @@ static void ipl_eckd_cdl(void)
a19a21
     read_block(1, ipl2, "Cannot read IPL2 record at block 1");
a19a21
 
a19a21
     mbr = &ipl2->mbr;
a19a21
-    IPL_assert(magic_match(mbr, ZIPL_MAGIC), "No zIPL section in IPL2 record.");
a19a21
-    IPL_assert(block_size_ok(mbr->blockptr.xeckd.bptr.size),
a19a21
-               "Bad block size in zIPL section of IPL2 record.");
a19a21
-    IPL_assert(mbr->dev_type == DEV_TYPE_ECKD,
a19a21
-               "Non-ECKD device type in zIPL section of IPL2 record.");
a19a21
+    if (!magic_match(mbr, ZIPL_MAGIC)) {
a19a21
+        sclp_print("No zIPL section in IPL2 record.\n");
a19a21
+        return;
a19a21
+    }
a19a21
+    if (!block_size_ok(mbr->blockptr.xeckd.bptr.size)) {
a19a21
+        sclp_print("Bad block size in zIPL section of IPL2 record.\n");
a19a21
+        return;
a19a21
+    }
a19a21
+    if (!mbr->dev_type == DEV_TYPE_ECKD) {
a19a21
+        sclp_print("Non-ECKD device type in zIPL section of IPL2 record.\n");
a19a21
+        return;
a19a21
+    }
a19a21
 
a19a21
     /* save pointer to Boot Map Table */
a19a21
     bmt_block_nr = eckd_block_num(&mbr->blockptr.xeckd.bptr.chs);
a19a21
@@ -303,10 +310,14 @@ static void ipl_eckd_cdl(void)
a19a21
 
a19a21
     memset(sec, FREE_SPACE_FILLER, sizeof(sec));
a19a21
     read_block(2, vlbl, "Cannot read Volume Label at block 2");
a19a21
-    IPL_assert(magic_match(vlbl->key, VOL1_MAGIC),
a19a21
-               "Invalid magic of volume label block");
a19a21
-    IPL_assert(magic_match(vlbl->f.key, VOL1_MAGIC),
a19a21
-               "Invalid magic of volser block");
a19a21
+    if (!magic_match(vlbl->key, VOL1_MAGIC)) {
a19a21
+        sclp_print("Invalid magic of volume label block.\n");
a19a21
+        return;
a19a21
+    }
a19a21
+    if (!magic_match(vlbl->f.key, VOL1_MAGIC)) {
a19a21
+        sclp_print("Invalid magic of volser block.\n");
a19a21
+        return;
a19a21
+    }
a19a21
     print_volser(vlbl->f.volser);
a19a21
 
a19a21
     run_eckd_boot_script(bmt_block_nr, s1b_block_nr);
a19a21
@@ -400,7 +411,8 @@ static void ipl_eckd(void)
a19a21
     read_block(0, mbr, "Cannot read block 0 on DASD");
a19a21
 
a19a21
     if (magic_match(mbr->magic, IPL1_MAGIC)) {
a19a21
-        ipl_eckd_cdl(); /* no return */
a19a21
+        ipl_eckd_cdl();         /* only returns in case of error */
a19a21
+        return;
a19a21
     }
a19a21
 
a19a21
     /* LDL/CMS? */
a19a21
@@ -827,5 +839,5 @@ void zipl_load(void)
a19a21
         panic("\n! Unknown IPL device type !\n");
a19a21
     }
a19a21
 
a19a21
-    panic("\n* this can never happen *\n");
a19a21
+    sclp_print("zIPL load failed.\n");
a19a21
 }
a19a21
diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c
a19a21
index 5c1c98341d..b5c721c395 100644
a19a21
--- a/pc-bios/s390-ccw/main.c
a19a21
+++ b/pc-bios/s390-ccw/main.c
a19a21
@@ -249,7 +249,7 @@ static void ipl_boot_device(void)
a19a21
         break;
a19a21
     case CU_TYPE_VIRTIO:
a19a21
         if (virtio_setup() == 0) {
a19a21
-            zipl_load(); /* no return */
a19a21
+            zipl_load();             /* Only returns in case of errors */
a19a21
         }
a19a21
         break;
a19a21
     default:
a19a21
-- 
a19a21
2.27.0
a19a21