[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 04/18] pc-bios/s390-ccw/bootmap: Improve the guessing logic in zip
From: |
Thomas Huth |
Subject: |
[PULL 04/18] pc-bios/s390-ccw/bootmap: Improve the guessing logic in zipl_load_vblk() |
Date: |
Thu, 7 Jul 2022 09:54:12 +0200 |
The logic of trying an final ISO or ECKD boot on virtio-block devices is
very weird: Since the geometry hardly ever matches in virtio_disk_is_scsi(),
virtio_blk_setup_device() always sets a "guessed" disk geometry via
virtio_assume_scsi() (which is certainly also wrong in a lot of cases).
zipl_load_vblk() then sees that there's been a "virtio_guessed_disk_nature"
and tries to fix up the geometry again via virtio_assume_iso9660() before
always trying to do ipl_iso_el_torito(). That's a very brain-twisting
way of attempting to boot from ISO images, which won't work anymore after
the following patches that will clean up the virtio_assume_scsi() mess
(and thus get rid of the "virtio_guessed_disk_nature" here).
Let's try a better approach instead: ISO files always have a magic
string "CD001" at offset 0x8001 (see e.g. the ECMA-119 specification)
which we can use to decide whether we should try to boot in ISO 9660
mode (which we should also try if we see a sector size of 2048).
And if we were not able to boot in ISO mode here, the final boot attempt
before panicking is to boot in ECKD mode. Since this is our last boot
attempt anyway, simply always assume the ECKD geometry here (if the sector
size was not 4096 yet), so that we also do not depend on the guessed disk
geometry from virtio_blk_setup_device() here anymore.
Message-Id: <20220704111903.62400-4-thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
pc-bios/s390-ccw/bootmap.c | 27 +++++++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)
diff --git a/pc-bios/s390-ccw/bootmap.c b/pc-bios/s390-ccw/bootmap.c
index 56411ab3b6..994e59c0b0 100644
--- a/pc-bios/s390-ccw/bootmap.c
+++ b/pc-bios/s390-ccw/bootmap.c
@@ -780,18 +780,37 @@ static void ipl_iso_el_torito(void)
}
}
+/**
+ * Detect whether we're trying to boot from an .ISO image.
+ * These always have a signature string "CD001" at offset 0x8001.
+ */
+static bool has_iso_signature(void)
+{
+ int blksize = virtio_get_block_size();
+
+ if (!blksize || virtio_read(0x8000 / blksize, sec)) {
+ return false;
+ }
+
+ return !memcmp("CD001", &sec[1], 5);
+}
+
/***********************************************************************
* Bus specific IPL sequences
*/
static void zipl_load_vblk(void)
{
- if (virtio_guessed_disk_nature()) {
- virtio_assume_iso9660();
+ int blksize = virtio_get_block_size();
+
+ if (blksize == VIRTIO_ISO_BLOCK_SIZE || has_iso_signature()) {
+ if (blksize != VIRTIO_ISO_BLOCK_SIZE) {
+ virtio_assume_iso9660();
+ }
+ ipl_iso_el_torito();
}
- ipl_iso_el_torito();
- if (virtio_guessed_disk_nature()) {
+ if (blksize != VIRTIO_DASD_DEFAULT_BLOCK_SIZE) {
sclp_print("Using guessed DASD geometry.\n");
virtio_assume_eckd();
}
--
2.31.1
- [PULL 00/18] s390x updates, Thomas Huth, 2022/07/07
- [PULL 03/18] pc-bios/s390-ccw/virtio: Introduce a macro for the DASD block size, Thomas Huth, 2022/07/07
- [PULL 02/18] pc-bios/s390-ccw: Add a proper prototype for main(), Thomas Huth, 2022/07/07
- [PULL 06/18] pc-bios/s390-ccw/virtio-blkdev: Remove virtio_assume_scsi(), Thomas Huth, 2022/07/07
- [PULL 08/18] pc-bios/s390-ccw/virtio: Read device config after feature negotiation, Thomas Huth, 2022/07/07
- [PULL 13/18] pc-bios/s390-ccw/netboot.mak: Ignore Clang's warnings about GNU extensions, Thomas Huth, 2022/07/07
- [PULL 10/18] pc-bios/s390-ccw: Split virtio-scsi code from virtio_blk_setup_device(), Thomas Huth, 2022/07/07
- [PULL 04/18] pc-bios/s390-ccw/bootmap: Improve the guessing logic in zipl_load_vblk(),
Thomas Huth <=
- [PULL 05/18] pc-bios/s390-ccw/virtio-blkdev: Simplify/fix virtio_ipl_disk_is_valid(), Thomas Huth, 2022/07/07
- [PULL 07/18] pc-bios/s390-ccw/virtio: Set missing status bits while initializing, Thomas Huth, 2022/07/07
- [PULL 09/18] pc-bios/s390-ccw/virtio: Beautify the code for reading virtqueue configuration, Thomas Huth, 2022/07/07
- [PULL 01/18] target/s390x/tcg: SPX: check validity of new prefix, Thomas Huth, 2022/07/07
- [PULL 12/18] pc-bios/s390-ccw/virtio: Remove "extern" keyword from prototypes, Thomas Huth, 2022/07/07
- [PULL 15/18] target/s390x: Remove DISAS_GOTO_TB, Thomas Huth, 2022/07/07
- [PULL 11/18] pc-bios/s390-ccw/virtio-blkdev: Request the right feature bits, Thomas Huth, 2022/07/07
- [PULL 18/18] target/s390x: Exit tb after executing ex_value, Thomas Huth, 2022/07/07
- [PULL 17/18] target/s390x: Remove DISAS_PC_STALE_NOCHAIN, Thomas Huth, 2022/07/07
- [PULL 14/18] pc-bios/s390-ccw: Update the s390-ccw bios binaries with the virtio-blk fixes, Thomas Huth, 2022/07/07