Blame SOURCES/kvm-pc-bios-s390-ccw-virtio-Set-missing-status-bits-whil.patch

586cba
From 303fb3ddcdbbd1373c5b1aa28e03f90507e217f3 Mon Sep 17 00:00:00 2001
586cba
From: Thomas Huth <thuth@redhat.com>
586cba
Date: Fri, 8 Jul 2022 20:49:01 +0200
586cba
Subject: [PATCH 10/17] pc-bios/s390-ccw/virtio: Set missing status bits while
586cba
 initializing
586cba
586cba
RH-Author: Thomas Huth <thuth@redhat.com>
586cba
RH-MergeRequest: 106: pc-bios/s390-ccw: Fix boot from disks with 4k sectors that do not have the typical DASD geometry
586cba
RH-Commit: [5/10] 4bc44d9adae055fb60b79d04a2f08535b4d38d2b (thuth/qemu-kvm-cs9)
586cba
RH-Bugzilla: 2098077
586cba
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
586cba
RH-Acked-by: David Hildenbrand <david@redhat.com>
586cba
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
586cba
586cba
Bugzilla: http://bugzilla.redhat.com/2098077
586cba
586cba
commit 175aa06a152ef6b58ba9b2e47a1296b024dea70c
586cba
Author: Thomas Huth <thuth@redhat.com>
586cba
Date:   Mon Jul 4 13:18:57 2022 +0200
586cba
586cba
    pc-bios/s390-ccw/virtio: Set missing status bits while initializing
586cba
586cba
    According chapter "3.1.1 Driver Requirements: Device Initialization"
586cba
    of the Virtio specification (v1.1), a driver for a device has to set
586cba
    the ACKNOWLEDGE and DRIVER bits in the status field after resetting
586cba
    the device. The s390-ccw bios skipped these steps so far and seems
586cba
    like QEMU never cared. Anyway, it's better to follow the spec, so
586cba
    let's set these bits now in the right spots, too.
586cba
586cba
    Message-Id: <20220704111903.62400-7-thuth@redhat.com>
586cba
    Acked-by: Christian Borntraeger <borntraeger@linux.ibm.com>
586cba
    Reviewed-by: Cornelia Huck <cohuck@redhat.com>
586cba
    Reviewed-by: Eric Farman <farman@linux.ibm.com>
586cba
    Signed-off-by: Thomas Huth <thuth@redhat.com>
586cba
586cba
Signed-off-by: Thomas Huth <thuth@redhat.com>
586cba
---
586cba
 pc-bios/s390-ccw/virtio.c | 18 ++++++++++++++----
586cba
 1 file changed, 14 insertions(+), 4 deletions(-)
586cba
586cba
diff --git a/pc-bios/s390-ccw/virtio.c b/pc-bios/s390-ccw/virtio.c
586cba
index 5d2c6e3381..4e85a2eb82 100644
586cba
--- a/pc-bios/s390-ccw/virtio.c
586cba
+++ b/pc-bios/s390-ccw/virtio.c
586cba
@@ -220,7 +220,7 @@ int virtio_run(VDev *vdev, int vqid, VirtioCmd *cmd)
586cba
 void virtio_setup_ccw(VDev *vdev)
586cba
 {
586cba
     int i, rc, cfg_size = 0;
586cba
-    unsigned char status = VIRTIO_CONFIG_S_DRIVER_OK;
586cba
+    uint8_t status;
586cba
     struct VirtioFeatureDesc {
586cba
         uint32_t features;
586cba
         uint8_t index;
586cba
@@ -234,6 +234,10 @@ void virtio_setup_ccw(VDev *vdev)
586cba
 
586cba
     run_ccw(vdev, CCW_CMD_VDEV_RESET, NULL, 0, false);
586cba
 
586cba
+    status = VIRTIO_CONFIG_S_ACKNOWLEDGE;
586cba
+    rc = run_ccw(vdev, CCW_CMD_WRITE_STATUS, &status, sizeof(status), false);
586cba
+    IPL_assert(rc == 0, "Could not write ACKNOWLEDGE status to host");
586cba
+
586cba
     switch (vdev->senseid.cu_model) {
586cba
     case VIRTIO_ID_NET:
586cba
         vdev->nr_vqs = 2;
586cba
@@ -253,6 +257,11 @@ void virtio_setup_ccw(VDev *vdev)
586cba
     default:
586cba
         panic("Unsupported virtio device\n");
586cba
     }
586cba
+
586cba
+    status |= VIRTIO_CONFIG_S_DRIVER;
586cba
+    rc = run_ccw(vdev, CCW_CMD_WRITE_STATUS, &status, sizeof(status), false);
586cba
+    IPL_assert(rc == 0, "Could not write DRIVER status to host");
586cba
+
586cba
     IPL_assert(
586cba
         run_ccw(vdev, CCW_CMD_READ_CONF, &vdev->config, cfg_size, false) == 0,
586cba
        "Could not get block device configuration");
586cba
@@ -291,9 +300,10 @@ void virtio_setup_ccw(VDev *vdev)
586cba
             run_ccw(vdev, CCW_CMD_SET_VQ, &info, sizeof(info), false) == 0,
586cba
             "Cannot set VQ info");
586cba
     }
586cba
-    IPL_assert(
586cba
-        run_ccw(vdev, CCW_CMD_WRITE_STATUS, &status, sizeof(status), false) == 0,
586cba
-        "Could not write status to host");
586cba
+
586cba
+    status |= VIRTIO_CONFIG_S_DRIVER_OK;
586cba
+    rc = run_ccw(vdev, CCW_CMD_WRITE_STATUS, &status, sizeof(status), false);
586cba
+    IPL_assert(rc == 0, "Could not write DRIVER_OK status to host");
586cba
 }
586cba
 
586cba
 bool virtio_is_supported(SubChannelId schid)
586cba
-- 
586cba
2.31.1
586cba