qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Christian Borntraeger <borntraeger@de.ibm.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel <qemu-devel@nongnu.org>,
	Alexander Graf <agraf@suse.de>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	Jens Freimann <jfrei@linux.vnet.ibm.com>,
	Anthony Liguori <anthony@codemonkey.ws>,
	Cornelia Huck <cornelia.huck@de.ibm.com>,
	"Eugene (jno) Dvurechenski" <jno@linux.vnet.ibm.com>,
	Richard Henderson <rth@twiddle.net>
Subject: [Qemu-devel] [PULL 09/19] pc-bios/s390-ccw: IPL from DASD with format variations
Date: Mon,  1 Sep 2014 14:54:20 +0200	[thread overview]
Message-ID: <1409576070-55803-10-git-send-email-borntraeger@de.ibm.com> (raw)
In-Reply-To: <1409576070-55803-1-git-send-email-borntraeger@de.ibm.com>

From: "Eugene (jno) Dvurechenski" <jno@linux.vnet.ibm.com>

There are two known cases of DASD format where signatures are
incomplete or absent:

1. result of <dasdfmt -d ldl -L ...> (ECKD_LDL_UNLABELED)
2. CDL with zero keys in IPL1 and IPL2 records

Now the code attempts to
1. find zIPL and use SCSI layout
2. find IPL1 and use CDL layout
3. find CMS1 and use LDL layout
3. find LNX1 and use LDL layout
4. find zIPL and use unlabeled LDL layout
5. find zIPL and use CDL layout
6. die
in this sequence.

Signed-off-by: Eugene (jno) Dvurechenski <jno@linux.vnet.ibm.com>
Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 pc-bios/s390-ccw/bootmap.c | 52 ++++++++++++++++++++++++++--------------------
 pc-bios/s390-ccw/bootmap.h |  2 +-
 2 files changed, 30 insertions(+), 24 deletions(-)

diff --git a/pc-bios/s390-ccw/bootmap.c b/pc-bios/s390-ccw/bootmap.c
index d4c579c..aa1cf80 100644
--- a/pc-bios/s390-ccw/bootmap.c
+++ b/pc-bios/s390-ccw/bootmap.c
@@ -222,7 +222,6 @@ static void ipl_eckd_cdl(void)
 
     memset(sec, FREE_SPACE_FILLER, sizeof(sec));
     read_block(1, ipl2, "Cannot read IPL2 record at block 1");
-    IPL_assert(magic_match(ipl2, IPL2_MAGIC), "No IPL2 record");
 
     mbr = &ipl2->u.x.mbr;
     IPL_assert(magic_match(mbr, ZIPL_MAGIC), "No zIPL section in IPL2 record.");
@@ -246,12 +245,10 @@ static void ipl_eckd_cdl(void)
     /* no return */
 }
 
-static void ipl_eckd_ldl(ECKD_IPL_mode_t mode)
+static void print_eckd_ldl_msg(ECKD_IPL_mode_t mode)
 {
     LDL_VTOC *vlbl = (void *)sec; /* already read, 3rd block */
     char msg[4] = { '?', '.', '\n', '\0' };
-    block_number_t block_nr;
-    BootInfo *bip;
 
     sclp_print((mode == ECKD_CMS) ? "CMS" : "LDL");
     sclp_print(" version ");
@@ -271,12 +268,27 @@ static void ipl_eckd_ldl(ECKD_IPL_mode_t mode)
     }
     sclp_print(msg);
     print_volser(vlbl->volser);
+}
+
+static void ipl_eckd_ldl(ECKD_IPL_mode_t mode)
+{
+    block_number_t block_nr;
+    BootInfo *bip = (void *)(sec + 0x70); /* BootInfo is MBR for LDL */
+
+    if (mode != ECKD_LDL_UNLABELED) {
+        print_eckd_ldl_msg(mode);
+    }
 
     /* DO NOT read BootMap pointer (only one, xECKD) at block #2 */
 
     memset(sec, FREE_SPACE_FILLER, sizeof(sec));
-    read_block(0, sec, "Cannot read block 0");
-    bip = (void *)(sec + 0x70); /* "boot info" is "eckd mbr" for LDL */
+    read_block(0, sec, "Cannot read block 0 to grab boot info.");
+    if (mode == ECKD_LDL_UNLABELED) {
+        if (!magic_match(bip->magic, ZIPL_MAGIC)) {
+            return; /* not applicable layout */
+        }
+        sclp_print("unlabeled LDL.\n");
+    }
     verify_boot_info(bip);
 
     block_nr = eckd_block_num((void *)&(bip->bp.ipl.bm_ptr.eckd.bptr));
@@ -284,19 +296,6 @@ static void ipl_eckd_ldl(ECKD_IPL_mode_t mode)
     /* no return */
 }
 
-static void ipl_eckd(ECKD_IPL_mode_t mode)
-{
-    switch (mode) {
-    case ECKD_CDL:
-        ipl_eckd_cdl(); /* no return */
-    case ECKD_CMS:
-    case ECKD_LDL:
-        ipl_eckd_ldl(mode); /* no return */
-    default:
-        virtio_panic("\n! Unknown ECKD IPL mode !\n");
-    }
-}
-
 static void print_eckd_msg(void)
 {
     char msg[] = "Using ECKD scheme (block size *****), ";
@@ -471,7 +470,7 @@ void zipl_load(void)
     }
     print_eckd_msg();
     if (magic_match(mbr->magic, IPL1_MAGIC)) {
-        ipl_eckd(ECKD_CDL); /* no return */
+        ipl_eckd_cdl(); /* no return */
     }
 
     /* LDL/CMS? */
@@ -479,11 +478,18 @@ void zipl_load(void)
     read_block(2, vlbl, "Cannot read block 2");
 
     if (magic_match(vlbl->magic, CMS1_MAGIC)) {
-        ipl_eckd(ECKD_CMS); /* no return */
+        ipl_eckd_ldl(ECKD_CMS); /* no return */
     }
     if (magic_match(vlbl->magic, LNX1_MAGIC)) {
-        ipl_eckd(ECKD_LDL); /* no return */
+        ipl_eckd_ldl(ECKD_LDL); /* no return */
     }
 
-    virtio_panic("\n* invalid MBR magic *\n");
+    ipl_eckd_ldl(ECKD_LDL_UNLABELED); /* it still may return */
+    /*
+     * Ok, it is not a LDL by any means.
+     * It still might be a CDL with zero record keys for IPL1 and IPL2
+     */
+    ipl_eckd_cdl();
+
+    virtio_panic("\n* this can never happen *\n");
 }
diff --git a/pc-bios/s390-ccw/bootmap.h b/pc-bios/s390-ccw/bootmap.h
index 30ef22f..6a4823d 100644
--- a/pc-bios/s390-ccw/bootmap.h
+++ b/pc-bios/s390-ccw/bootmap.h
@@ -257,9 +257,9 @@ typedef struct IplVolumeLabel {
 
 typedef enum {
     ECKD_NO_IPL,
-    ECKD_CDL,
     ECKD_CMS,
     ECKD_LDL,
+    ECKD_LDL_UNLABELED,
 } ECKD_IPL_mode_t;
 
 /* utility code below */
-- 
1.8.4.2

  parent reply	other threads:[~2014-09-01 12:54 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-01 12:54 [Qemu-devel] [PULL 00/19] s390x/kvm: Several updates/fixes/features Christian Borntraeger
2014-09-01 12:54 ` [Qemu-devel] [PULL 01/19] s390x/kvm: run guest triggered resets on the target vcpu thread Christian Borntraeger
2014-09-01 12:54 ` [Qemu-devel] [PULL 02/19] s390x/kvm: execute sigp orders " Christian Borntraeger
2014-09-01 12:54 ` [Qemu-devel] [PULL 03/19] s390x/kvm: execute "system reset" cpu resets on the " Christian Borntraeger
2014-09-01 12:54 ` [Qemu-devel] [PULL 04/19] s390x/kvm: execute the first cpu reset " Christian Borntraeger
2014-09-01 12:54 ` [Qemu-devel] [PULL 05/19] pc-bios/s390-ccw: support all virtio block size Christian Borntraeger
2014-09-01 12:54 ` [Qemu-devel] [PULL 06/19] pc-bios/s390-ccw: handle more ECKD DASD block sizes Christian Borntraeger
2014-09-01 12:54 ` [Qemu-devel] [PULL 07/19] pc-bios/s390-ccw Improve ECKD informational message Christian Borntraeger
2014-09-01 12:54 ` [Qemu-devel] [PULL 08/19] pc-bios/s390-ccw Really big EAV ECKD DASD handling Christian Borntraeger
2014-09-01 12:54 ` Christian Borntraeger [this message]
2014-09-01 12:54 ` [Qemu-devel] [PULL 10/19] pc-bios/s390-ccw: Do proper console setup Christian Borntraeger
2014-09-01 12:54 ` [Qemu-devel] [PULL 11/19] pc-bios/s390-ccw.img binary update Christian Borntraeger
2014-09-01 12:54 ` [Qemu-devel] [PULL 12/19] sclp-s390: Add device to manage s390 memory hotplug Christian Borntraeger
2014-09-01 12:54 ` [Qemu-devel] [PULL 13/19] virtio-ccw: Include standby memory when calculating storage increment Christian Borntraeger
2014-09-01 12:54 ` [Qemu-devel] [PULL 14/19] s390-virtio: Apply same memory boundaries as virtio-ccw Christian Borntraeger
2014-09-01 12:54 ` [Qemu-devel] [PULL 15/19] sclp-s390: Add memory hotplug SCLPs Christian Borntraeger
2014-09-01 12:54 ` [Qemu-devel] [PULL 16/19] s390x/gdb: don't touch the cc if tcg is not enabled Christian Borntraeger
2014-09-01 12:54 ` [Qemu-devel] [PULL 17/19] s390x/gdb: add the feature xml files for s390x Christian Borntraeger
2014-09-01 12:54 ` [Qemu-devel] [PULL 18/19] s390x/gdb: generate target.xml and handle fp/ac as coprocessors Christian Borntraeger
2014-09-01 12:54 ` [Qemu-devel] [PULL 19/19] s390x/gdb: coding style fixes Christian Borntraeger
2014-09-01 13:44 ` [Qemu-devel] [PULL 00/19] s390x/kvm: Several updates/fixes/features Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1409576070-55803-10-git-send-email-borntraeger@de.ibm.com \
    --to=borntraeger@de.ibm.com \
    --cc=agraf@suse.de \
    --cc=anthony@codemonkey.ws \
    --cc=cornelia.huck@de.ibm.com \
    --cc=jfrei@linux.vnet.ibm.com \
    --cc=jno@linux.vnet.ibm.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).