yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-s390-bios-Factor-finding-boot-device-out-of-virtio-c.patch

4ec855
From e9b154b1297ac5aff8737dde61b6793fcd7c0a69 Mon Sep 17 00:00:00 2001
4ec855
From: Thomas Huth <thuth@redhat.com>
4ec855
Date: Mon, 14 Oct 2019 10:06:40 +0100
4ec855
Subject: [PATCH 15/21] s390-bios: Factor finding boot device out of virtio
4ec855
 code path
4ec855
4ec855
RH-Author: Thomas Huth <thuth@redhat.com>
4ec855
Message-id: <20191014100645.22862-13-thuth@redhat.com>
4ec855
Patchwork-id: 91789
4ec855
O-Subject: [RHEL-8.2.0 qemu-kvm PATCH v2 12/17] s390-bios: Factor finding boot device out of virtio code path
4ec855
Bugzilla: 1664376
4ec855
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
4ec855
RH-Acked-by: David Hildenbrand <david@redhat.com>
4ec855
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
4ec855
4ec855
From: "Jason J. Herne" <jjherne@linux.ibm.com>
4ec855
4ec855
Make a new routine find_boot_device to locate the boot device for all
4ec855
cases, not just virtio.
4ec855
4ec855
The error message for the case where no boot device has been specified
4ec855
and a suitable boot device cannot be auto detected was specific to
4ec855
virtio devices. We update this message to remove virtio specific wording.
4ec855
4ec855
Signed-off-by: Jason J. Herne <jjherne@linux.ibm.com>
4ec855
Reviewed-by: Farhan Ali <alifm@linux.ibm.com>
4ec855
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
4ec855
Message-Id: <1554388475-18329-12-git-send-email-jjherne@linux.ibm.com>
4ec855
Signed-off-by: Thomas Huth <thuth@redhat.com>
4ec855
(cherry picked from commit 7b361db37b18a75860decc0a85e0194936401d66)
4ec855
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
4ec855
4ec855
Conflicts:
4ec855
	tests/boot-serial-test.c
4ec855
	(we're missing commit 052888f043ba in downstream)
4ec855
Signed-off-by: Thomas Huth <thuth@redhat.com>
4ec855
4ec855
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
4ec855
---
4ec855
 pc-bios/s390-ccw/main.c  | 85 ++++++++++++++++++++++++++----------------------
4ec855
 tests/boot-serial-test.c |  2 +-
4ec855
 2 files changed, 47 insertions(+), 40 deletions(-)
4ec855
4ec855
diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c
4ec855
index d04ea89..d3a161c 100644
4ec855
--- a/pc-bios/s390-ccw/main.c
4ec855
+++ b/pc-bios/s390-ccw/main.c
4ec855
@@ -58,17 +58,18 @@ unsigned int get_loadparm_index(void)
4ec855
  * NOTE: The global variable blk_schid is updated to contain the subchannel
4ec855
  * information.
4ec855
  */
4ec855
-static bool find_dev(Schib *schib, int dev_no)
4ec855
+static bool find_subch(int dev_no)
4ec855
 {
4ec855
+    Schib schib;
4ec855
     int i, r;
4ec855
 
4ec855
     for (i = 0; i < 0x10000; i++) {
4ec855
         blk_schid.sch_no = i;
4ec855
-        r = stsch_err(blk_schid, schib);
4ec855
+        r = stsch_err(blk_schid, &schib);
4ec855
         if ((r == 3) || (r == -EIO)) {
4ec855
             break;
4ec855
         }
4ec855
-        if (!schib->pmcw.dnv) {
4ec855
+        if (!schib.pmcw.dnv) {
4ec855
             continue;
4ec855
         }
4ec855
 
4ec855
@@ -80,7 +81,7 @@ static bool find_dev(Schib *schib, int dev_no)
4ec855
             continue;
4ec855
         }
4ec855
 
4ec855
-        if ((dev_no < 0) || (schib->pmcw.dev == dev_no)) {
4ec855
+        if ((dev_no < 0) || (schib.pmcw.dev == dev_no)) {
4ec855
             return true;
4ec855
         }
4ec855
     }
4ec855
@@ -136,56 +137,61 @@ static void boot_setup(void)
4ec855
     have_iplb = store_iplb(&iplb);
4ec855
 }
4ec855
 
4ec855
-static void virtio_setup(void)
4ec855
+static void find_boot_device(void)
4ec855
 {
4ec855
-    Schib schib;
4ec855
-    int ssid;
4ec855
-    bool found = false;
4ec855
-    uint16_t dev_no;
4ec855
     VDev *vdev = virtio_get_device();
4ec855
-    QemuIplParameters *early_qipl = (QemuIplParameters *)QIPL_ADDRESS;
4ec855
-
4ec855
-    memcpy(&qipl, early_qipl, sizeof(QemuIplParameters));
4ec855
+    int ssid;
4ec855
+    bool found;
4ec855
 
4ec855
-    if (have_iplb) {
4ec855
-        switch (iplb.pbt) {
4ec855
-        case S390_IPL_TYPE_CCW:
4ec855
-            dev_no = iplb.ccw.devno;
4ec855
-            debug_print_int("device no. ", dev_no);
4ec855
-            blk_schid.ssid = iplb.ccw.ssid & 0x3;
4ec855
-            debug_print_int("ssid ", blk_schid.ssid);
4ec855
-            found = find_dev(&schib, dev_no);
4ec855
-            break;
4ec855
-        case S390_IPL_TYPE_QEMU_SCSI:
4ec855
-            vdev->scsi_device_selected = true;
4ec855
-            vdev->selected_scsi_device.channel = iplb.scsi.channel;
4ec855
-            vdev->selected_scsi_device.target = iplb.scsi.target;
4ec855
-            vdev->selected_scsi_device.lun = iplb.scsi.lun;
4ec855
-            blk_schid.ssid = iplb.scsi.ssid & 0x3;
4ec855
-            found = find_dev(&schib, iplb.scsi.devno);
4ec855
-            break;
4ec855
-        default:
4ec855
-            panic("List-directed IPL not supported yet!\n");
4ec855
-        }
4ec855
-        menu_setup();
4ec855
-    } else {
4ec855
+    if (!have_iplb) {
4ec855
         for (ssid = 0; ssid < 0x3; ssid++) {
4ec855
             blk_schid.ssid = ssid;
4ec855
-            found = find_dev(&schib, -1);
4ec855
+            found = find_subch(-1);
4ec855
             if (found) {
4ec855
-                break;
4ec855
+                return;
4ec855
             }
4ec855
         }
4ec855
+        panic("Could not find a suitable boot device (none specified)\n");
4ec855
+    }
4ec855
+
4ec855
+    switch (iplb.pbt) {
4ec855
+    case S390_IPL_TYPE_CCW:
4ec855
+        debug_print_int("device no. ", iplb.ccw.devno);
4ec855
+        blk_schid.ssid = iplb.ccw.ssid & 0x3;
4ec855
+        debug_print_int("ssid ", blk_schid.ssid);
4ec855
+        found = find_subch(iplb.ccw.devno);
4ec855
+        break;
4ec855
+    case S390_IPL_TYPE_QEMU_SCSI:
4ec855
+        vdev->scsi_device_selected = true;
4ec855
+        vdev->selected_scsi_device.channel = iplb.scsi.channel;
4ec855
+        vdev->selected_scsi_device.target = iplb.scsi.target;
4ec855
+        vdev->selected_scsi_device.lun = iplb.scsi.lun;
4ec855
+        blk_schid.ssid = iplb.scsi.ssid & 0x3;
4ec855
+        found = find_subch(iplb.scsi.devno);
4ec855
+        break;
4ec855
+    default:
4ec855
+        panic("List-directed IPL not supported yet!\n");
4ec855
     }
4ec855
 
4ec855
-    IPL_assert(found, "No virtio device found");
4ec855
+    IPL_assert(found, "Boot device not found\n");
4ec855
+}
4ec855
+
4ec855
+static void virtio_setup(void)
4ec855
+{
4ec855
+    VDev *vdev = virtio_get_device();
4ec855
+    QemuIplParameters *early_qipl = (QemuIplParameters *)QIPL_ADDRESS;
4ec855
+
4ec855
+    memcpy(&qipl, early_qipl, sizeof(QemuIplParameters));
4ec855
+
4ec855
+    if (have_iplb) {
4ec855
+        menu_setup();
4ec855
+    }
4ec855
 
4ec855
     if (virtio_get_device_type() == VIRTIO_ID_NET) {
4ec855
         sclp_print("Network boot device detected\n");
4ec855
         vdev->netboot_start_addr = qipl.netboot_start_addr;
4ec855
     } else {
4ec855
         virtio_blk_setup_device(blk_schid);
4ec855
-
4ec855
         IPL_assert(virtio_ipl_disk_is_valid(), "No valid IPL device detected");
4ec855
     }
4ec855
 }
4ec855
@@ -195,8 +201,9 @@ int main(void)
4ec855
     sclp_setup();
4ec855
     css_setup();
4ec855
     boot_setup();
4ec855
-    virtio_setup();
4ec855
+    find_boot_device();
4ec855
 
4ec855
+    virtio_setup();
4ec855
     zipl_load(); /* no return */
4ec855
 
4ec855
     panic("Failed to load OS from hard disk\n");
4ec855
diff --git a/tests/boot-serial-test.c b/tests/boot-serial-test.c
4ec855
index dc682c1..fe52668 100644
4ec855
--- a/tests/boot-serial-test.c
4ec855
+++ b/tests/boot-serial-test.c
4ec855
@@ -97,7 +97,7 @@ static testdef_t tests[] = {
4ec855
     { "sparc", "SS-600MP", "", "TMS390Z55" },
4ec855
     { "sparc64", "sun4u", "", "UltraSPARC" },
4ec855
     { "s390x", "s390-ccw-virtio",
4ec855
-      "-nodefaults -device sclpconsole,chardev=serial0", "virtio device" },
4ec855
+      "-nodefaults -device sclpconsole,chardev=serial0", "device" },
4ec855
     { "m68k", "mcf5208evb", "", "TT", sizeof(kernel_mcf5208), kernel_mcf5208 },
4ec855
     { "microblaze", "petalogix-s3adsp1800", "", "TT",
4ec855
       sizeof(kernel_pls3adsp1800), kernel_pls3adsp1800 },
4ec855
-- 
4ec855
1.8.3.1
4ec855