From patchwork Fri Jun 27 11:25:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cornelia Huck X-Patchwork-Id: 364927 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 9F3471400B7 for ; Fri, 27 Jun 2014 22:05:42 +1000 (EST) Received: from localhost ([::1]:49467 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X0UPN-0006qt-M9 for incoming@patchwork.ozlabs.org; Fri, 27 Jun 2014 07:33:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41774) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X0UHv-0001qW-NZ for qemu-devel@nongnu.org; Fri, 27 Jun 2014 07:26:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X0UHj-0007M1-FA for qemu-devel@nongnu.org; Fri, 27 Jun 2014 07:25:51 -0400 Received: from e06smtp15.uk.ibm.com ([195.75.94.111]:60938) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X0UHj-0007LZ-6h for qemu-devel@nongnu.org; Fri, 27 Jun 2014 07:25:39 -0400 Received: from /spool/local by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 27 Jun 2014 12:25:38 +0100 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 27 Jun 2014 12:25:37 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id F2B891B0805F for ; Fri, 27 Jun 2014 12:26:09 +0100 (BST) Received: from d06av10.portsmouth.uk.ibm.com (d06av10.portsmouth.uk.ibm.com [9.149.37.251]) by b06cxnps4074.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s5RBPbwh20381792 for ; Fri, 27 Jun 2014 11:25:37 GMT Received: from d06av10.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av10.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s5RBPa4q006113 for ; Fri, 27 Jun 2014 05:25:36 -0600 Received: from gondolin.boeblingen.de.ibm.com (dyn-9-152-224-107.boeblingen.de.ibm.com [9.152.224.107]) by d06av10.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id s5RBPTVb005693; Fri, 27 Jun 2014 05:25:35 -0600 From: Cornelia Huck To: qemu-devel@nongnu.org Date: Fri, 27 Jun 2014 13:25:25 +0200 Message-Id: <1403868326-7718-10-git-send-email-cornelia.huck@de.ibm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1403868326-7718-1-git-send-email-cornelia.huck@de.ibm.com> References: <1403868326-7718-1-git-send-email-cornelia.huck@de.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14062711-0342-0000-0000-00000041457B X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.75.94.111 Cc: peter.maydell@linaro.org, agraf@suse.de, borntraeger@de.ibm.com, jfrei@linux.vnet.ibm.com, aliguori@amazon.com, Cornelia Huck , "Eugene \(jno\) Dvurechenski" Subject: [Qemu-devel] [PULL 09/10] pc-bios/s390-ccw: IPL from LDL/CMS-formatted ECKD DASD X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: "Eugene (jno) Dvurechenski" Add code that allows us to start from two further ECKD DASD disk layouts: LDL (Linux disk layout) and CMS (cms-formatted disk). Acked-by: Christian Borntraeger Signed-off-by: Eugene (jno) Dvurechenski Signed-off-by: Jens Freimann Signed-off-by: Cornelia Huck --- pc-bios/s390-ccw/bootmap.c | 92 ++++++++++++++++++++++++++++++++++++++++---- pc-bios/s390-ccw/bootmap.h | 7 ++++ 2 files changed, 92 insertions(+), 7 deletions(-) diff --git a/pc-bios/s390-ccw/bootmap.c b/pc-bios/s390-ccw/bootmap.c index beda4d6..fa54abb 100644 --- a/pc-bios/s390-ccw/bootmap.c +++ b/pc-bios/s390-ccw/bootmap.c @@ -80,6 +80,17 @@ static void jump_to_IPL_code(uint64_t address) static unsigned char _bprs[8*1024]; /* guessed "max" ECKD sector size */ const int max_bprs_entries = sizeof(_bprs) / sizeof(ExtEckdBlockPtr); +static inline void verify_boot_info(BootInfo *bip) +{ + IPL_assert(magic_match(bip->magic, ZIPL_MAGIC), "No zIPL magic"); + IPL_assert(bip->version == BOOT_INFO_VERSION, "Wrong zIPL version"); + IPL_assert(bip->bp_type == BOOT_INFO_BP_TYPE_IPL, "DASD is not for IPL"); + IPL_assert(bip->dev_type == BOOT_INFO_DEV_TYPE_ECKD, "DASD is not ECKD"); + IPL_assert(bip->flags == BOOT_INFO_FLAGS_ARCH, "Not for this arch"); + IPL_assert(block_size_ok(bip->bp.ipl.bm_ptr.eckd.bptr.size), + "Bad block size in zIPL section of the 1st record."); +} + static bool eckd_valid_address(BootMapPointer *p) { const uint64_t cylinder = p->eckd.cylinder @@ -198,19 +209,15 @@ static void run_eckd_boot_script(block_number_t mbr_block_nr) jump_to_IPL_code(bms->entry[i].address.load_address); /* no return */ } -static void ipl_eckd(void) +static void ipl_eckd_cdl(void) { XEckdMbr *mbr; Ipl2 *ipl2 = (void *)sec; IplVolumeLabel *vlbl = (void *)sec; block_number_t block_nr; - sclp_print("Using ECKD scheme.\n"); - if (virtio_guessed_disk_nature()) { - sclp_print("Using guessed DASD geometry.\n"); - virtio_assume_eckd(); - } /* we have just read the block #0 and recognized it as "IPL1" */ + sclp_print("CDL\n"); memset(sec, FREE_SPACE_FILLER, sizeof(sec)); read_block(1, ipl2, "Cannot read IPL2 record at block 1"); @@ -238,6 +245,57 @@ static void ipl_eckd(void) /* no return */ } +static void ipl_eckd_ldl(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 "); + switch (vlbl->LDL_version) { + case LDL1_VERSION: + msg[0] = '1'; + break; + case LDL2_VERSION: + msg[0] = '2'; + break; + default: + msg[0] = vlbl->LDL_version; + msg[0] &= 0x0f; /* convert EBCDIC */ + msg[0] |= 0x30; /* to ASCII (digit) */ + msg[1] = '?'; + break; + } + sclp_print(msg); + print_volser(vlbl->volser); + + /* 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 */ + verify_boot_info(bip); + + block_nr = eckd_block_num((void *)&(bip->bp.ipl.bm_ptr.eckd.bptr)); + run_eckd_boot_script(block_nr); + /* 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"); + } +} + /*********************************************************************** * IPL a SCSI disk */ @@ -374,6 +432,7 @@ static void ipl_scsi(void) void zipl_load(void) { ScsiMbr *mbr = (void *)sec; + LDL_VTOC *vlbl = (void *)sec; /* Grab the MBR */ memset(sec, FREE_SPACE_FILLER, sizeof(sec)); @@ -384,8 +443,27 @@ void zipl_load(void) if (magic_match(mbr->magic, ZIPL_MAGIC)) { ipl_scsi(); /* no return */ } + + /* We have failed to follow the SCSI scheme, so */ + sclp_print("Using ECKD scheme.\n"); + if (virtio_guessed_disk_nature()) { + sclp_print("Using guessed DASD geometry.\n"); + virtio_assume_eckd(); + } + if (magic_match(mbr->magic, IPL1_MAGIC)) { - ipl_eckd(); /* CDL ECKD; no return */ + ipl_eckd(ECKD_CDL); /* no return */ + } + + /* LDL/CMS? */ + memset(sec, FREE_SPACE_FILLER, sizeof(sec)); + read_block(2, vlbl, "Cannot read block 2"); + + if (magic_match(vlbl->magic, CMS1_MAGIC)) { + ipl_eckd(ECKD_CMS); /* no return */ + } + if (magic_match(vlbl->magic, LNX1_MAGIC)) { + ipl_eckd(ECKD_LDL); /* no return */ } virtio_panic("\n* invalid MBR magic *\n"); diff --git a/pc-bios/s390-ccw/bootmap.h b/pc-bios/s390-ccw/bootmap.h index 1846632..30ef22f 100644 --- a/pc-bios/s390-ccw/bootmap.h +++ b/pc-bios/s390-ccw/bootmap.h @@ -255,6 +255,13 @@ typedef struct IplVolumeLabel { }; } __attribute__((packed)) IplVolumeLabel; +typedef enum { + ECKD_NO_IPL, + ECKD_CDL, + ECKD_CMS, + ECKD_LDL, +} ECKD_IPL_mode_t; + /* utility code below */ static inline void IPL_assert(bool term, const char *message)