thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-pc-bios-s390-ccw-Fix-booting-with-logical-block-size.patch

0727d3
From 115507e5e8b97993b50ea7b39d6d4bb493973e46 Mon Sep 17 00:00:00 2001
0727d3
From: Thomas Huth <thuth@redhat.com>
0727d3
Date: Fri, 5 Aug 2022 11:42:14 +0200
0727d3
Subject: [PATCH 9/9] pc-bios/s390-ccw: Fix booting with logical block size <
0727d3
 physical block size
0727d3
0727d3
RH-Author: Thomas Huth <thuth@redhat.com>
0727d3
RH-MergeRequest: 207: pc-bios/s390-ccw: Fix booting with logical block size < physical block size
0727d3
RH-Commit: [1/1] ab22832592e0a48277bf7aca1b941a1be79aeab6
0727d3
RH-Bugzilla: 2112296
0727d3
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
0727d3
RH-Acked-by: David Hildenbrand <david@redhat.com>
0727d3
RH-Acked-by: Claudio Imbrenda <None>
0727d3
0727d3
For accessing single blocks during boot, it's the logical block size that
0727d3
matters. (Physical block sizes are rather interesting e.g. for creating
0727d3
file systems with the correct alignment for speed reasons etc.).
0727d3
So the s390-ccw bios has to use the logical block size for calculating
0727d3
sector numbers during the boot phase, the "physical_block_exp" shift
0727d3
value must not be taken into account. This change fixes the boot process
0727d3
when the guest hast been installed on a disk where the logical block size
0727d3
differs from the physical one, e.g. if the guest has been installed
0727d3
like this:
0727d3
0727d3
 qemu-system-s390x -nographic -accel kvm -m 2G \
0727d3
  -drive if=none,id=d1,file=fedora.iso,format=raw,media=cdrom \
0727d3
  -device virtio-scsi -device scsi-cd,drive=d1 \
0727d3
  -drive if=none,id=d2,file=test.qcow2,format=qcow2
0727d3
  -device virtio-blk,drive=d2,physical_block_size=4096,logical_block_size=512
0727d3
0727d3
Linux correctly uses the logical block size of 512 for the installation,
0727d3
but the s390-ccw bios tries to boot from a disk with 4096 block size so
0727d3
far, as long as this patch has not been applied yet (well, it used to work
0727d3
by accident in the past due to the virtio_assume_scsi() hack that used to
0727d3
enforce 512 byte sectors on all virtio-block disks, but that hack has been
0727d3
well removed in commit 5447de2619050a0a4d to fix other scenarios).
0727d3
0727d3
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2112296
0727d3
Message-Id: <20220805094214.285223-1-thuth@redhat.com>
0727d3
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
0727d3
Reviewed-by: Eric Farman <farman@linux.ibm.com>
0727d3
Signed-off-by: Thomas Huth <thuth@redhat.com>
0727d3
(cherry picked from commit 393296de19650e1400ca265914cfdeb313725363)
0727d3
---
0727d3
 pc-bios/s390-ccw/virtio-blkdev.c | 2 +-
0727d3
 1 file changed, 1 insertion(+), 1 deletion(-)
0727d3
0727d3
diff --git a/pc-bios/s390-ccw/virtio-blkdev.c b/pc-bios/s390-ccw/virtio-blkdev.c
0727d3
index 8271c47296..794f99b42c 100644
0727d3
--- a/pc-bios/s390-ccw/virtio-blkdev.c
0727d3
+++ b/pc-bios/s390-ccw/virtio-blkdev.c
0727d3
@@ -173,7 +173,7 @@ int virtio_get_block_size(void)
0727d3
 
0727d3
     switch (vdev->senseid.cu_model) {
0727d3
     case VIRTIO_ID_BLOCK:
0727d3
-        return vdev->config.blk.blk_size << vdev->config.blk.physical_block_exp;
0727d3
+        return vdev->config.blk.blk_size;
0727d3
     case VIRTIO_ID_SCSI:
0727d3
         return vdev->scsi_block_size;
0727d3
     }
0727d3
-- 
0727d3
2.31.1
0727d3