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

1be5c7
From f09f2f12133073d6ccab3b2bd95717d435adc442 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 31/37] pc-bios/s390-ccw/virtio-blkdev: Simplify/fix
1be5c7
 virtio_ipl_disk_is_valid()
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: [3/9] ca0b836a417ce5bbd26e489551f573d6b2fc9e94
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 bbf615f7b707f009ef8e757d170902ad33b90644
1be5c7
Author: Thomas Huth <thuth@redhat.com>
1be5c7
Date:   Mon Jul 4 13:18:55 2022 +0200
1be5c7
1be5c7
    pc-bios/s390-ccw/virtio-blkdev: Simplify/fix virtio_ipl_disk_is_valid()
1be5c7
1be5c7
    The s390-ccw bios fails to boot if the boot disk is a virtio-blk
1be5c7
    disk with a sector size of 4096. For example:
1be5c7
1be5c7
     dasdfmt -b 4096 -d cdl -y -p -M quick /dev/dasdX
1be5c7
     fdasd -a /dev/dasdX
1be5c7
     install a guest onto /dev/dasdX1 using virtio-blk
1be5c7
     qemu-system-s390x -nographic -hda /dev/dasdX1
1be5c7
1be5c7
    The bios then bails out with:
1be5c7
1be5c7
     ! Cannot read block 0 !
1be5c7
1be5c7
    Looking at virtio_ipl_disk_is_valid() and especially the function
1be5c7
    virtio_disk_is_scsi(), it does not really make sense that we expect
1be5c7
    only such a limited disk geometry (like a block size of 512) for
1be5c7
    our boot disks. Let's relax the check and allow everything that
1be5c7
    remotely looks like a sane disk.
1be5c7
1be5c7
    Message-Id: <20220704111903.62400-5-thuth@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-blkdev.c | 41 ++++++--------------------------
1be5c7
 pc-bios/s390-ccw/virtio.h        |  2 --
1be5c7
 2 files changed, 7 insertions(+), 36 deletions(-)
1be5c7
1be5c7
diff --git a/pc-bios/s390-ccw/virtio-blkdev.c b/pc-bios/s390-ccw/virtio-blkdev.c
1be5c7
index 6483307630..7e13155589 100644
1be5c7
--- a/pc-bios/s390-ccw/virtio-blkdev.c
1be5c7
+++ b/pc-bios/s390-ccw/virtio-blkdev.c
1be5c7
@@ -166,46 +166,19 @@ void virtio_assume_eckd(void)
1be5c7
         virtio_eckd_sectors_for_block_size(vdev->config.blk.blk_size);
1be5c7
 }
1be5c7
 
1be5c7
-bool virtio_disk_is_scsi(void)
1be5c7
-{
1be5c7
-    VDev *vdev = virtio_get_device();
1be5c7
-
1be5c7
-    if (vdev->guessed_disk_nature == VIRTIO_GDN_SCSI) {
1be5c7
-        return true;
1be5c7
-    }
1be5c7
-    switch (vdev->senseid.cu_model) {
1be5c7
-    case VIRTIO_ID_BLOCK:
1be5c7
-        return (vdev->config.blk.geometry.heads == 255)
1be5c7
-            && (vdev->config.blk.geometry.sectors == 63)
1be5c7
-            && (virtio_get_block_size()  == VIRTIO_SCSI_BLOCK_SIZE);
1be5c7
-    case VIRTIO_ID_SCSI:
1be5c7
-        return true;
1be5c7
-    }
1be5c7
-    return false;
1be5c7
-}
1be5c7
-
1be5c7
-bool virtio_disk_is_eckd(void)
1be5c7
+bool virtio_ipl_disk_is_valid(void)
1be5c7
 {
1be5c7
+    int blksize = virtio_get_block_size();
1be5c7
     VDev *vdev = virtio_get_device();
1be5c7
-    const int block_size = virtio_get_block_size();
1be5c7
 
1be5c7
-    if (vdev->guessed_disk_nature == VIRTIO_GDN_DASD) {
1be5c7
+    if (vdev->guessed_disk_nature == VIRTIO_GDN_SCSI ||
1be5c7
+        vdev->guessed_disk_nature == VIRTIO_GDN_DASD) {
1be5c7
         return true;
1be5c7
     }
1be5c7
-    switch (vdev->senseid.cu_model) {
1be5c7
-    case VIRTIO_ID_BLOCK:
1be5c7
-        return (vdev->config.blk.geometry.heads == 15)
1be5c7
-            && (vdev->config.blk.geometry.sectors ==
1be5c7
-                virtio_eckd_sectors_for_block_size(block_size));
1be5c7
-    case VIRTIO_ID_SCSI:
1be5c7
-        return false;
1be5c7
-    }
1be5c7
-    return false;
1be5c7
-}
1be5c7
 
1be5c7
-bool virtio_ipl_disk_is_valid(void)
1be5c7
-{
1be5c7
-    return virtio_disk_is_scsi() || virtio_disk_is_eckd();
1be5c7
+    return (vdev->senseid.cu_model == VIRTIO_ID_BLOCK ||
1be5c7
+            vdev->senseid.cu_model == VIRTIO_ID_SCSI) &&
1be5c7
+           blksize >= 512 && blksize <= 4096;
1be5c7
 }
1be5c7
 
1be5c7
 int virtio_get_block_size(void)
1be5c7
diff --git a/pc-bios/s390-ccw/virtio.h b/pc-bios/s390-ccw/virtio.h
1be5c7
index 9e410bde6f..241730effe 100644
1be5c7
--- a/pc-bios/s390-ccw/virtio.h
1be5c7
+++ b/pc-bios/s390-ccw/virtio.h
1be5c7
@@ -186,8 +186,6 @@ void virtio_assume_scsi(void);
1be5c7
 void virtio_assume_eckd(void);
1be5c7
 void virtio_assume_iso9660(void);
1be5c7
 
1be5c7
-extern bool virtio_disk_is_scsi(void);
1be5c7
-extern bool virtio_disk_is_eckd(void);
1be5c7
 extern bool virtio_ipl_disk_is_valid(void);
1be5c7
 extern int virtio_get_block_size(void);
1be5c7
 extern uint8_t virtio_get_heads(void);
1be5c7
-- 
1be5c7
2.35.3
1be5c7