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

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