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

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