cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-pc-bios-s390-ccw-Move-the-inner-logic-of-find_subch-.patch

8fced6
From d90cbb55fe3ec232091a24137cab45419aac8bc5 Mon Sep 17 00:00:00 2001
8fced6
From: Thomas Huth <thuth@redhat.com>
8fced6
Date: Fri, 9 Oct 2020 10:08:44 -0400
8fced6
Subject: [PATCH 08/14] pc-bios/s390-ccw: Move the inner logic of find_subch()
8fced6
 to a separate function
8fced6
8fced6
RH-Author: Thomas Huth <thuth@redhat.com>
8fced6
Message-id: <20201009100849.264994-5-thuth@redhat.com>
8fced6
Patchwork-id: 98598
8fced6
O-Subject: [RHEL-8.4.0 qemu-kvm PATCH 4/9] pc-bios/s390-ccw: Move the inner logic of find_subch() to a separate function
8fced6
Bugzilla: 1846975
8fced6
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
8fced6
RH-Acked-by: David Hildenbrand <david@redhat.com>
8fced6
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
8fced6
8fced6
Move the code to a separate function to be able to re-use it from a
8fced6
different spot later.
8fced6
8fced6
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
8fced6
Message-Id: <20200806105349.632-5-thuth@redhat.com>
8fced6
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
8fced6
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
8fced6
Signed-off-by: Thomas Huth <thuth@redhat.com>
8fced6
(cherry picked from commit d2cf4af1f4af02f6f2d5827d9a06c31690084d3b)
8fced6
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
8fced6
---
8fced6
 pc-bios/s390-ccw/main.c | 99 ++++++++++++++++++++++++-----------------
8fced6
 1 file changed, 57 insertions(+), 42 deletions(-)
8fced6
8fced6
diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c
8fced6
index 5e565be5b1..d6fd218074 100644
8fced6
--- a/pc-bios/s390-ccw/main.c
8fced6
+++ b/pc-bios/s390-ccw/main.c
8fced6
@@ -60,6 +60,60 @@ unsigned int get_loadparm_index(void)
8fced6
     return atoui(loadparm_str);
8fced6
 }
8fced6
 
8fced6
+static int is_dev_possibly_bootable(int dev_no, int sch_no)
8fced6
+{
8fced6
+    bool is_virtio;
8fced6
+    Schib schib;
8fced6
+    int r;
8fced6
+
8fced6
+    blk_schid.sch_no = sch_no;
8fced6
+    r = stsch_err(blk_schid, &schib);
8fced6
+    if (r == 3 || r == -EIO) {
8fced6
+        return -ENODEV;
8fced6
+    }
8fced6
+    if (!schib.pmcw.dnv) {
8fced6
+        return false;
8fced6
+    }
8fced6
+
8fced6
+    enable_subchannel(blk_schid);
8fced6
+    cutype = cu_type(blk_schid);
8fced6
+
8fced6
+    /*
8fced6
+     * Note: we always have to run virtio_is_supported() here to make
8fced6
+     * sure that the vdev.senseid data gets pre-initialized correctly
8fced6
+     */
8fced6
+    is_virtio = virtio_is_supported(blk_schid);
8fced6
+
8fced6
+    /* No specific devno given, just return whether the device is possibly bootable */
8fced6
+    if (dev_no < 0) {
8fced6
+        switch (cutype) {
8fced6
+        case CU_TYPE_VIRTIO:
8fced6
+            if (is_virtio) {
8fced6
+                /*
8fced6
+                 * Skip net devices since no IPLB is created and therefore
8fced6
+                 * no network bootloader has been loaded
8fced6
+                 */
8fced6
+                if (virtio_get_device_type() != VIRTIO_ID_NET) {
8fced6
+                    return true;
8fced6
+                }
8fced6
+            }
8fced6
+            return false;
8fced6
+        case CU_TYPE_DASD_3990:
8fced6
+        case CU_TYPE_DASD_2107:
8fced6
+            return true;
8fced6
+        default:
8fced6
+            return false;
8fced6
+        }
8fced6
+    }
8fced6
+
8fced6
+    /* Caller asked for a specific devno */
8fced6
+    if (schib.pmcw.dev == dev_no) {
8fced6
+        return true;
8fced6
+    }
8fced6
+
8fced6
+    return false;
8fced6
+}
8fced6
+
8fced6
 /*
8fced6
  * Find the subchannel connected to the given device (dev_no) and fill in the
8fced6
  * subchannel information block (schib) with the connected subchannel's info.
8fced6
@@ -71,53 +125,14 @@ unsigned int get_loadparm_index(void)
8fced6
  */
8fced6
 static bool find_subch(int dev_no)
8fced6
 {
8fced6
-    Schib schib;
8fced6
     int i, r;
8fced6
-    bool is_virtio;
8fced6
 
8fced6
     for (i = 0; i < 0x10000; i++) {
8fced6
-        blk_schid.sch_no = i;
8fced6
-        r = stsch_err(blk_schid, &schib);
8fced6
-        if ((r == 3) || (r == -EIO)) {
8fced6
+        r = is_dev_possibly_bootable(dev_no, i);
8fced6
+        if (r < 0) {
8fced6
             break;
8fced6
         }
8fced6
-        if (!schib.pmcw.dnv) {
8fced6
-            continue;
8fced6
-        }
8fced6
-
8fced6
-        enable_subchannel(blk_schid);
8fced6
-        cutype = cu_type(blk_schid);
8fced6
-
8fced6
-        /*
8fced6
-         * Note: we always have to run virtio_is_supported() here to make
8fced6
-         * sure that the vdev.senseid data gets pre-initialized correctly
8fced6
-         */
8fced6
-        is_virtio = virtio_is_supported(blk_schid);
8fced6
-
8fced6
-        /* No specific devno given, just return 1st possibly bootable device */
8fced6
-        if (dev_no < 0) {
8fced6
-            switch (cutype) {
8fced6
-            case CU_TYPE_VIRTIO:
8fced6
-                if (is_virtio) {
8fced6
-                    /*
8fced6
-                     * Skip net devices since no IPLB is created and therefore
8fced6
-                     * no network bootloader has been loaded
8fced6
-                     */
8fced6
-                    if (virtio_get_device_type() != VIRTIO_ID_NET) {
8fced6
-                        return true;
8fced6
-                    }
8fced6
-                }
8fced6
-                continue;
8fced6
-            case CU_TYPE_DASD_3990:
8fced6
-            case CU_TYPE_DASD_2107:
8fced6
-                return true;
8fced6
-            default:
8fced6
-                continue;
8fced6
-            }
8fced6
-        }
8fced6
-
8fced6
-        /* Caller asked for a specific devno */
8fced6
-        if (schib.pmcw.dev == dev_no) {
8fced6
+        if (r == true) {
8fced6
             return true;
8fced6
         }
8fced6
     }
8fced6
-- 
8fced6
2.27.0
8fced6