Blame SOURCES/kvm-pc-bios-s390-ccw-virtio-blkdev-Simplify-fix-virtio_i.patch

29b115
From f07e4629a7c58407f903810a038660c88c6a6315 Mon Sep 17 00:00:00 2001
29b115
From: Thomas Huth <thuth@redhat.com>
29b115
Date: Fri, 8 Jul 2022 20:49:01 +0200
29b115
Subject: [PATCH 08/17] pc-bios/s390-ccw/virtio-blkdev: Simplify/fix
29b115
 virtio_ipl_disk_is_valid()
29b115
29b115
RH-Author: Thomas Huth <thuth@redhat.com>
29b115
RH-MergeRequest: 106: pc-bios/s390-ccw: Fix boot from disks with 4k sectors that do not have the typical DASD geometry
29b115
RH-Commit: [3/10] fb06830a3e50d9da3d84913b50bb227865cc44b3 (thuth/qemu-kvm-cs9)
29b115
RH-Bugzilla: 2098077
29b115
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
29b115
RH-Acked-by: David Hildenbrand <david@redhat.com>
29b115
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
29b115
29b115
Bugzilla: http://bugzilla.redhat.com/2098077
29b115
29b115
commit bbf615f7b707f009ef8e757d170902ad33b90644
29b115
Author: Thomas Huth <thuth@redhat.com>
29b115
Date:   Mon Jul 4 13:18:55 2022 +0200
29b115
29b115
    pc-bios/s390-ccw/virtio-blkdev: Simplify/fix virtio_ipl_disk_is_valid()
29b115
29b115
    The s390-ccw bios fails to boot if the boot disk is a virtio-blk
29b115
    disk with a sector size of 4096. For example:
29b115
29b115
     dasdfmt -b 4096 -d cdl -y -p -M quick /dev/dasdX
29b115
     fdasd -a /dev/dasdX
29b115
     install a guest onto /dev/dasdX1 using virtio-blk
29b115
     qemu-system-s390x -nographic -hda /dev/dasdX1
29b115
29b115
    The bios then bails out with:
29b115
29b115
     ! Cannot read block 0 !
29b115
29b115
    Looking at virtio_ipl_disk_is_valid() and especially the function
29b115
    virtio_disk_is_scsi(), it does not really make sense that we expect
29b115
    only such a limited disk geometry (like a block size of 512) for
29b115
    our boot disks. Let's relax the check and allow everything that
29b115
    remotely looks like a sane disk.
29b115
29b115
    Message-Id: <20220704111903.62400-5-thuth@redhat.com>
29b115
    Reviewed-by: Eric Farman <farman@linux.ibm.com>
29b115
    Signed-off-by: Thomas Huth <thuth@redhat.com>
29b115
29b115
Signed-off-by: Thomas Huth <thuth@redhat.com>
29b115
---
29b115
 pc-bios/s390-ccw/virtio-blkdev.c | 41 ++++++--------------------------
29b115
 pc-bios/s390-ccw/virtio.h        |  2 --
29b115
 2 files changed, 7 insertions(+), 36 deletions(-)
29b115
29b115
diff --git a/pc-bios/s390-ccw/virtio-blkdev.c b/pc-bios/s390-ccw/virtio-blkdev.c
29b115
index 6483307630..7e13155589 100644
29b115
--- a/pc-bios/s390-ccw/virtio-blkdev.c
29b115
+++ b/pc-bios/s390-ccw/virtio-blkdev.c
29b115
@@ -166,46 +166,19 @@ void virtio_assume_eckd(void)
29b115
         virtio_eckd_sectors_for_block_size(vdev->config.blk.blk_size);
29b115
 }
29b115
 
29b115
-bool virtio_disk_is_scsi(void)
29b115
-{
29b115
-    VDev *vdev = virtio_get_device();
29b115
-
29b115
-    if (vdev->guessed_disk_nature == VIRTIO_GDN_SCSI) {
29b115
-        return true;
29b115
-    }
29b115
-    switch (vdev->senseid.cu_model) {
29b115
-    case VIRTIO_ID_BLOCK:
29b115
-        return (vdev->config.blk.geometry.heads == 255)
29b115
-            && (vdev->config.blk.geometry.sectors == 63)
29b115
-            && (virtio_get_block_size()  == VIRTIO_SCSI_BLOCK_SIZE);
29b115
-    case VIRTIO_ID_SCSI:
29b115
-        return true;
29b115
-    }
29b115
-    return false;
29b115
-}
29b115
-
29b115
-bool virtio_disk_is_eckd(void)
29b115
+bool virtio_ipl_disk_is_valid(void)
29b115
 {
29b115
+    int blksize = virtio_get_block_size();
29b115
     VDev *vdev = virtio_get_device();
29b115
-    const int block_size = virtio_get_block_size();
29b115
 
29b115
-    if (vdev->guessed_disk_nature == VIRTIO_GDN_DASD) {
29b115
+    if (vdev->guessed_disk_nature == VIRTIO_GDN_SCSI ||
29b115
+        vdev->guessed_disk_nature == VIRTIO_GDN_DASD) {
29b115
         return true;
29b115
     }
29b115
-    switch (vdev->senseid.cu_model) {
29b115
-    case VIRTIO_ID_BLOCK:
29b115
-        return (vdev->config.blk.geometry.heads == 15)
29b115
-            && (vdev->config.blk.geometry.sectors ==
29b115
-                virtio_eckd_sectors_for_block_size(block_size));
29b115
-    case VIRTIO_ID_SCSI:
29b115
-        return false;
29b115
-    }
29b115
-    return false;
29b115
-}
29b115
 
29b115
-bool virtio_ipl_disk_is_valid(void)
29b115
-{
29b115
-    return virtio_disk_is_scsi() || virtio_disk_is_eckd();
29b115
+    return (vdev->senseid.cu_model == VIRTIO_ID_BLOCK ||
29b115
+            vdev->senseid.cu_model == VIRTIO_ID_SCSI) &&
29b115
+           blksize >= 512 && blksize <= 4096;
29b115
 }
29b115
 
29b115
 int virtio_get_block_size(void)
29b115
diff --git a/pc-bios/s390-ccw/virtio.h b/pc-bios/s390-ccw/virtio.h
29b115
index 9e410bde6f..241730effe 100644
29b115
--- a/pc-bios/s390-ccw/virtio.h
29b115
+++ b/pc-bios/s390-ccw/virtio.h
29b115
@@ -186,8 +186,6 @@ void virtio_assume_scsi(void);
29b115
 void virtio_assume_eckd(void);
29b115
 void virtio_assume_iso9660(void);
29b115
 
29b115
-extern bool virtio_disk_is_scsi(void);
29b115
-extern bool virtio_disk_is_eckd(void);
29b115
 extern bool virtio_ipl_disk_is_valid(void);
29b115
 extern int virtio_get_block_size(void);
29b115
 extern uint8_t virtio_get_heads(void);
29b115
-- 
29b115
2.31.1
29b115