From nobody Sun Apr 28 20:00:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517864960916101.2130360849668; Mon, 5 Feb 2018 13:09:20 -0800 (PST) Received: from localhost ([::1]:36258 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eio0n-00037C-Nf for importer@patchew.org; Mon, 05 Feb 2018 16:09:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47485) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eintZ-0005jC-EK for qemu-devel@nongnu.org; Mon, 05 Feb 2018 16:01:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eintY-0003Ss-0X for qemu-devel@nongnu.org; Mon, 05 Feb 2018 16:01:45 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:36952 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eintX-0003SM-KJ for qemu-devel@nongnu.org; Mon, 05 Feb 2018 16:01:43 -0500 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w15KxSbS079842 for ; Mon, 5 Feb 2018 16:01:41 -0500 Received: from e16.ny.us.ibm.com (e16.ny.us.ibm.com [129.33.205.206]) by mx0b-001b2d01.pphosted.com with ESMTP id 2fxwe037cn-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 05 Feb 2018 16:01:39 -0500 Received: from localhost by e16.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 5 Feb 2018 16:01:35 -0500 Received: from b01cxnp22035.gho.pok.ibm.com (9.57.198.25) by e16.ny.us.ibm.com (146.89.104.203) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 5 Feb 2018 16:01:30 -0500 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w15L1U2850004062; Mon, 5 Feb 2018 21:01:30 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AC5B2112047; Mon, 5 Feb 2018 15:59:33 -0500 (EST) Received: from collin-ThinkPad-W541.pok.ibm.com (unknown [9.56.58.149]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id 9DB9011204B; Mon, 5 Feb 2018 15:59:33 -0500 (EST) From: "Collin L. Walling" To: qemu-s390x@nongnu.org, qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 15:57:15 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517864246-11101-1-git-send-email-walling@linux.vnet.ibm.com> References: <1517864246-11101-1-git-send-email-walling@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18020521-0024-0000-0000-0000031F052E X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008478; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000248; SDB=6.00985441; UDB=6.00500014; IPR=6.00764812; BA=6.00005812; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00019386; XFM=3.00000015; UTC=2018-02-05 21:01:33 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18020521-0025-0000-0000-000046E2114A Message-Id: <1517864246-11101-2-git-send-email-walling@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-02-05_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1802050259 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH v5 01/12] s390-ccw: refactor boot map table code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: frankja@linux.vnet.ibm.com, thuth@redhat.com, cohuck@redhat.com, david@redhat.com, alifm@linux.vnet.ibm.com, mihajlov@linux.vnet.ibm.com, borntraeger@de.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" - replace ScsiMbr in ECKD code with BootMapTable - fix read_block messages to reflect BMT - reduce ipl_scsi code with BMT struct Signed-off-by: Collin L. Walling --- pc-bios/s390-ccw/bootmap.c | 53 ++++++++++++++++++------------------------= ---- pc-bios/s390-ccw/bootmap.h | 9 +++++++- 2 files changed, 29 insertions(+), 33 deletions(-) diff --git a/pc-bios/s390-ccw/bootmap.c b/pc-bios/s390-ccw/bootmap.c index 67a6123..8ee9056 100644 --- a/pc-bios/s390-ccw/bootmap.c +++ b/pc-bios/s390-ccw/bootmap.c @@ -182,13 +182,13 @@ static block_number_t load_eckd_segments(block_number= _t blk, uint64_t *address) return block_nr; } =20 -static void run_eckd_boot_script(block_number_t mbr_block_nr) +static void run_eckd_boot_script(block_number_t bmt_block_nr) { int i; unsigned int loadparm =3D get_loadparm_index(); block_number_t block_nr; uint64_t address; - ScsiMbr *bte =3D (void *)sec; /* Eckd bootmap table entry */ + BootMapTable *bmt =3D (void *)sec; BootMapScript *bms =3D (void *)sec; =20 debug_print_int("loadparm", loadparm); @@ -196,10 +196,10 @@ static void run_eckd_boot_script(block_number_t mbr_b= lock_nr) " maximum number of boot entries allowed"); =20 memset(sec, FREE_SPACE_FILLER, sizeof(sec)); - read_block(mbr_block_nr, sec, "Cannot read MBR"); + read_block(bmt_block_nr, sec, "Cannot read Boot Map Table"); =20 - block_nr =3D eckd_block_num((void *)&(bte->blockptr[loadparm])); - IPL_assert(block_nr !=3D -1, "No Boot Map"); + block_nr =3D eckd_block_num((void *)&bmt->bte[loadparm]); + IPL_assert(block_nr !=3D -1, "Cannot find Boot Map Table Entry"); =20 memset(sec, FREE_SPACE_FILLER, sizeof(sec)); read_block(block_nr, sec, "Cannot read Boot Map Script"); @@ -223,7 +223,7 @@ static void ipl_eckd_cdl(void) XEckdMbr *mbr; Ipl2 *ipl2 =3D (void *)sec; IplVolumeLabel *vlbl =3D (void *)sec; - block_number_t block_nr; + block_number_t bmt_block_nr; =20 /* we have just read the block #0 and recognized it as "IPL1" */ sclp_print("CDL\n"); @@ -238,8 +238,8 @@ static void ipl_eckd_cdl(void) IPL_assert(mbr->dev_type =3D=3D DEV_TYPE_ECKD, "Non-ECKD device type in zIPL section of IPL2 record."); =20 - /* save pointer to Boot Script */ - block_nr =3D eckd_block_num((void *)&(mbr->blockptr)); + /* save pointer to Boot Map Table */ + bmt_block_nr =3D eckd_block_num((void *)&mbr->blockptr); =20 memset(sec, FREE_SPACE_FILLER, sizeof(sec)); read_block(2, vlbl, "Cannot read Volume Label at block 2"); @@ -249,7 +249,7 @@ static void ipl_eckd_cdl(void) "Invalid magic of volser block"); print_volser(vlbl->f.volser); =20 - run_eckd_boot_script(block_nr); + run_eckd_boot_script(bmt_block_nr); /* no return */ } =20 @@ -280,7 +280,7 @@ static void print_eckd_ldl_msg(ECKD_IPL_mode_t mode) =20 static void ipl_eckd_ldl(ECKD_IPL_mode_t mode) { - block_number_t block_nr; + block_number_t bmt_block_nr; BootInfo *bip =3D (void *)(sec + 0x70); /* BootInfo is MBR for LDL */ =20 if (mode !=3D ECKD_LDL_UNLABELED) { @@ -299,8 +299,10 @@ static void ipl_eckd_ldl(ECKD_IPL_mode_t mode) } verify_boot_info(bip); =20 - block_nr =3D eckd_block_num((void *)&(bip->bp.ipl.bm_ptr.eckd.bptr)); - run_eckd_boot_script(block_nr); + /* save pointer to Boot Map Table */ + bmt_block_nr =3D eckd_block_num((void *)&bip->bp.ipl.bm_ptr.eckd.bptr); + + run_eckd_boot_script(bmt_block_nr); /* no return */ } =20 @@ -325,7 +327,7 @@ static void print_eckd_msg(void) =20 static void ipl_eckd(void) { - ScsiMbr *mbr =3D (void *)sec; + XEckdMbr *mbr =3D (void *)sec; LDL_VTOC *vlbl =3D (void *)sec; =20 print_eckd_msg(); @@ -449,10 +451,8 @@ static void zipl_run(ScsiBlockPtr *pte) static void ipl_scsi(void) { ScsiMbr *mbr =3D (void *)sec; - uint8_t *ns, *ns_end; int program_table_entries =3D 0; - const int pte_len =3D sizeof(ScsiBlockPtr); - ScsiBlockPtr *prog_table_entry =3D NULL; + BootMapTable *bmt =3D (void *)sec; unsigned int loadparm =3D get_loadparm_index(); =20 /* Grab the MBR */ @@ -467,34 +467,23 @@ static void ipl_scsi(void) debug_print_int("MBR Version", mbr->version_id); IPL_check(mbr->version_id =3D=3D 1, "Unknown MBR layout version, assuming version 1"); - debug_print_int("program table", mbr->blockptr[0].blockno); - IPL_assert(mbr->blockptr[0].blockno, "No Program Table"); + debug_print_int("program table", mbr->bmt.blockno); + IPL_assert(mbr->bmt.blockno, "No Program Table"); =20 /* Parse the program table */ - read_block(mbr->blockptr[0].blockno, sec, - "Error reading Program Table"); + read_block(mbr->bmt.blockno, sec, "Error reading Program Table"); =20 IPL_assert(magic_match(sec, ZIPL_MAGIC), "No zIPL magic in PT"); =20 debug_print_int("loadparm index", loadparm); - ns_end =3D sec + virtio_get_block_size(); - for (ns =3D (sec + pte_len); (ns + pte_len) < ns_end; ns +=3D pte_len)= { - prog_table_entry =3D (ScsiBlockPtr *)ns; - if (!prog_table_entry->blockno) { - break; - } =20 + while (bmt->bte[program_table_entries].scsi.blockno) { program_table_entries++; - if (program_table_entries =3D=3D loadparm + 1) { - break; /* selected entry found */ - } } =20 debug_print_int("program table entries", program_table_entries); =20 - IPL_assert(program_table_entries !=3D 0, "Empty Program Table"); - - zipl_run(prog_table_entry); /* no return */ + zipl_run(&bmt->bte[loadparm].scsi); /* no return */ } =20 /*********************************************************************** diff --git a/pc-bios/s390-ccw/bootmap.h b/pc-bios/s390-ccw/bootmap.h index cf99a4c..77d56db 100644 --- a/pc-bios/s390-ccw/bootmap.h +++ b/pc-bios/s390-ccw/bootmap.h @@ -53,6 +53,13 @@ typedef union BootMapPointer { ExtEckdBlockPtr xeckd; } __attribute__ ((packed)) BootMapPointer; =20 +/* aka Program Table */ +typedef struct BootMapTable { + uint8_t magic[4]; + uint8_t reserved[12]; + BootMapPointer bte[]; +} __attribute__ ((packed)) BootMapTable; + typedef struct ComponentEntry { ScsiBlockPtr data; uint8_t pad[7]; @@ -70,7 +77,7 @@ typedef struct ScsiMbr { uint8_t magic[4]; uint32_t version_id; uint8_t reserved[8]; - ScsiBlockPtr blockptr[]; + ScsiBlockPtr bmt; } __attribute__ ((packed)) ScsiMbr; =20 #define ZIPL_MAGIC "zIPL" --=20 2.7.4 From nobody Sun Apr 28 20:00:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517864805678873.5222232772369; Mon, 5 Feb 2018 13:06:45 -0800 (PST) Received: from localhost ([::1]:36180 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1einyO-00012i-T3 for importer@patchew.org; Mon, 05 Feb 2018 16:06:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47402) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eintW-0005g3-Ui for qemu-devel@nongnu.org; Mon, 05 Feb 2018 16:01:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eintV-0003QT-O0 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 16:01:42 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:57088 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eintV-0003Pg-Gb for qemu-devel@nongnu.org; Mon, 05 Feb 2018 16:01:41 -0500 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w15KxURh130323 for ; Mon, 5 Feb 2018 16:01:38 -0500 Received: from e18.ny.us.ibm.com (e18.ny.us.ibm.com [129.33.205.208]) by mx0b-001b2d01.pphosted.com with ESMTP id 2fxvv1vekq-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 05 Feb 2018 16:01:36 -0500 Received: from localhost by e18.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 5 Feb 2018 16:01:35 -0500 Received: from b01cxnp22035.gho.pok.ibm.com (9.57.198.25) by e18.ny.us.ibm.com (146.89.104.205) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 5 Feb 2018 16:01:31 -0500 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w15L1VKk46792936; Mon, 5 Feb 2018 21:01:31 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BD86F11204B; Mon, 5 Feb 2018 15:59:34 -0500 (EST) Received: from collin-ThinkPad-W541.pok.ibm.com (unknown [9.56.58.149]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id AF1E1112047; Mon, 5 Feb 2018 15:59:34 -0500 (EST) From: "Collin L. Walling" To: qemu-s390x@nongnu.org, qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 15:57:16 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517864246-11101-1-git-send-email-walling@linux.vnet.ibm.com> References: <1517864246-11101-1-git-send-email-walling@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18020521-0044-0000-0000-000003DBF57A X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008478; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000248; SDB=6.00985441; UDB=6.00500015; IPR=6.00764812; BA=6.00005812; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00019386; XFM=3.00000015; UTC=2018-02-05 21:01:33 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18020521-0045-0000-0000-0000080B6442 Message-Id: <1517864246-11101-3-git-send-email-walling@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-02-05_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1802050259 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH v5 02/12] s390-ccw: refactor eckd_block_num to use CHS X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: frankja@linux.vnet.ibm.com, thuth@redhat.com, cohuck@redhat.com, david@redhat.com, alifm@linux.vnet.ibm.com, mihajlov@linux.vnet.ibm.com, borntraeger@de.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add new cylinder/head/sector struct. Use it to calculate eckd block numbers instead of a BootMapPointer (which used eckd chs anyway). Signed-off-by: Collin L. Walling Reviewed-by: Thomas Huth --- pc-bios/s390-ccw/bootmap.c | 28 ++++++++++++++-------------- pc-bios/s390-ccw/bootmap.h | 8 ++++++-- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/pc-bios/s390-ccw/bootmap.c b/pc-bios/s390-ccw/bootmap.c index 8ee9056..9b9696e 100644 --- a/pc-bios/s390-ccw/bootmap.c +++ b/pc-bios/s390-ccw/bootmap.c @@ -95,32 +95,32 @@ static inline void verify_boot_info(BootInfo *bip) "Bad block size in zIPL section of the 1st record."); } =20 -static block_number_t eckd_block_num(BootMapPointer *p) +static block_number_t eckd_block_num(EckdCHS *chs) { const uint64_t sectors =3D virtio_get_sectors(); const uint64_t heads =3D virtio_get_heads(); - const uint64_t cylinder =3D p->eckd.cylinder - + ((p->eckd.head & 0xfff0) << 12); - const uint64_t head =3D p->eckd.head & 0x000f; + const uint64_t cylinder =3D chs->cylinder + + ((chs->head & 0xfff0) << 12); + const uint64_t head =3D chs->head & 0x000f; const block_number_t block =3D sectors * heads * cylinder + sectors * head - + p->eckd.sector + + chs->sector - 1; /* block nr starts with zero */ return block; } =20 static bool eckd_valid_address(BootMapPointer *p) { - const uint64_t head =3D p->eckd.head & 0x000f; + const uint64_t head =3D p->eckd.chs.head & 0x000f; =20 if (head >=3D virtio_get_heads() - || p->eckd.sector > virtio_get_sectors() - || p->eckd.sector <=3D 0) { + || p->eckd.chs.sector > virtio_get_sectors() + || p->eckd.chs.sector <=3D 0) { return false; } =20 if (!virtio_guessed_disk_nature() && - eckd_block_num(p) >=3D virtio_get_blocks()) { + eckd_block_num(&p->eckd.chs) >=3D virtio_get_blocks()) { return false; } =20 @@ -140,7 +140,7 @@ static block_number_t load_eckd_segments(block_number_t= blk, uint64_t *address) do { more_data =3D false; for (j =3D 0;; j++) { - block_nr =3D eckd_block_num((void *)&(bprs[j].xeckd)); + block_nr =3D eckd_block_num(&bprs[j].xeckd.bptr.chs); if (is_null_block_number(block_nr)) { /* end of chunk */ break; } @@ -198,7 +198,7 @@ static void run_eckd_boot_script(block_number_t bmt_blo= ck_nr) memset(sec, FREE_SPACE_FILLER, sizeof(sec)); read_block(bmt_block_nr, sec, "Cannot read Boot Map Table"); =20 - block_nr =3D eckd_block_num((void *)&bmt->bte[loadparm]); + block_nr =3D eckd_block_num(&bmt->bte[loadparm].xeckd.bptr.chs); IPL_assert(block_nr !=3D -1, "Cannot find Boot Map Table Entry"); =20 memset(sec, FREE_SPACE_FILLER, sizeof(sec)); @@ -206,7 +206,7 @@ static void run_eckd_boot_script(block_number_t bmt_blo= ck_nr) =20 for (i =3D 0; bms->entry[i].type =3D=3D BOOT_SCRIPT_LOAD; i++) { address =3D bms->entry[i].address.load_address; - block_nr =3D eckd_block_num(&(bms->entry[i].blkptr)); + block_nr =3D eckd_block_num(&bms->entry[i].blkptr.xeckd.bptr.chs); =20 do { block_nr =3D load_eckd_segments(block_nr, &address); @@ -239,7 +239,7 @@ static void ipl_eckd_cdl(void) "Non-ECKD device type in zIPL section of IPL2 record."); =20 /* save pointer to Boot Map Table */ - bmt_block_nr =3D eckd_block_num((void *)&mbr->blockptr); + bmt_block_nr =3D eckd_block_num(&mbr->blockptr.xeckd.bptr.chs); =20 memset(sec, FREE_SPACE_FILLER, sizeof(sec)); read_block(2, vlbl, "Cannot read Volume Label at block 2"); @@ -300,7 +300,7 @@ static void ipl_eckd_ldl(ECKD_IPL_mode_t mode) verify_boot_info(bip); =20 /* save pointer to Boot Map Table */ - bmt_block_nr =3D eckd_block_num((void *)&bip->bp.ipl.bm_ptr.eckd.bptr); + bmt_block_nr =3D eckd_block_num(&bip->bp.ipl.bm_ptr.eckd.bptr.chs); =20 run_eckd_boot_script(bmt_block_nr); /* no return */ diff --git a/pc-bios/s390-ccw/bootmap.h b/pc-bios/s390-ccw/bootmap.h index 77d56db..260ac2a 100644 --- a/pc-bios/s390-ccw/bootmap.h +++ b/pc-bios/s390-ccw/bootmap.h @@ -32,10 +32,14 @@ typedef struct FbaBlockPtr { uint16_t blockct; } __attribute__ ((packed)) FbaBlockPtr; =20 -typedef struct EckdBlockPtr { - uint16_t cylinder; /* cylinder/head/sector is an address of the block = */ +typedef struct EckdCHS { + uint16_t cylinder; uint16_t head; uint8_t sector; +} __attribute__ ((packed)) EckdCHS; + +typedef struct EckdBlockPtr { + EckdCHS chs; /* cylinder/head/sector is an address of the block */ uint16_t size; uint8_t count; /* (size_in_blocks-1); * it's 0 for TablePtr, ScriptPtr, and SectionPtr */ --=20 2.7.4 From nobody Sun Apr 28 20:00:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 151786465001079.6726368865377; Mon, 5 Feb 2018 13:04:10 -0800 (PST) Received: from localhost ([::1]:36095 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1einvo-000776-5h for importer@patchew.org; Mon, 05 Feb 2018 16:04:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47352) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eintV-0005fa-GK for qemu-devel@nongnu.org; Mon, 05 Feb 2018 16:01:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eintS-0003Nw-DF for qemu-devel@nongnu.org; Mon, 05 Feb 2018 16:01:41 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:58278) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eintS-0003Mh-3Y for qemu-devel@nongnu.org; Mon, 05 Feb 2018 16:01:38 -0500 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w15L12qm113934 for ; Mon, 5 Feb 2018 16:01:36 -0500 Received: from e15.ny.us.ibm.com (e15.ny.us.ibm.com [129.33.205.205]) by mx0a-001b2d01.pphosted.com with ESMTP id 2fxwfbbbdm-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 05 Feb 2018 16:01:36 -0500 Received: from localhost by e15.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 5 Feb 2018 16:01:35 -0500 Received: from b01cxnp22036.gho.pok.ibm.com (9.57.198.26) by e15.ny.us.ibm.com (146.89.104.202) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 5 Feb 2018 16:01:32 -0500 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w15L1W5J44826814; Mon, 5 Feb 2018 21:01:32 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C24BF11205E; Mon, 5 Feb 2018 15:59:35 -0500 (EST) Received: from collin-ThinkPad-W541.pok.ibm.com (unknown [9.56.58.149]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id B48DC112051; Mon, 5 Feb 2018 15:59:35 -0500 (EST) From: "Collin L. Walling" To: qemu-s390x@nongnu.org, qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 15:57:17 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517864246-11101-1-git-send-email-walling@linux.vnet.ibm.com> References: <1517864246-11101-1-git-send-email-walling@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18020521-0036-0000-0000-000002B98FBF X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008478; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000248; SDB=6.00985441; UDB=6.00500015; IPR=6.00764812; BA=6.00005812; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00019386; XFM=3.00000015; UTC=2018-02-05 21:01:34 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18020521-0037-0000-0000-0000433CDD07 Message-Id: <1517864246-11101-4-git-send-email-walling@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-02-05_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=2 malwarescore=0 lowpriorityscore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1802050259 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH v5 03/12] s390-ccw: refactor IPL structs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: frankja@linux.vnet.ibm.com, thuth@redhat.com, cohuck@redhat.com, david@redhat.com, alifm@linux.vnet.ibm.com, mihajlov@linux.vnet.ibm.com, borntraeger@de.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" ECKD DASDs have different IPL structures for CDL and LDL formats. The current Ipl1 and Ipl2 structs follow the CDL format, so we prepend "EckdCdl" to them. Boot info for LDL has been moved to a new struct: EckdLdlIpl1. Signed-off-by: Collin L. Walling Acked-by: Janosch Frank Reviewed-by: Thomas Huth --- pc-bios/s390-ccw/bootmap.c | 12 ++++++------ pc-bios/s390-ccw/bootmap.h | 37 +++++++++++++++++++++---------------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/pc-bios/s390-ccw/bootmap.c b/pc-bios/s390-ccw/bootmap.c index 9b9696e..c97f136 100644 --- a/pc-bios/s390-ccw/bootmap.c +++ b/pc-bios/s390-ccw/bootmap.c @@ -221,7 +221,7 @@ static void run_eckd_boot_script(block_number_t bmt_blo= ck_nr) static void ipl_eckd_cdl(void) { XEckdMbr *mbr; - Ipl2 *ipl2 =3D (void *)sec; + EckdCdlIpl2 *ipl2 =3D (void *)sec; IplVolumeLabel *vlbl =3D (void *)sec; block_number_t bmt_block_nr; =20 @@ -231,7 +231,7 @@ static void ipl_eckd_cdl(void) memset(sec, FREE_SPACE_FILLER, sizeof(sec)); read_block(1, ipl2, "Cannot read IPL2 record at block 1"); =20 - mbr =3D &ipl2->u.x.mbr; + mbr =3D &ipl2->mbr; IPL_assert(magic_match(mbr, ZIPL_MAGIC), "No zIPL section in IPL2 reco= rd."); IPL_assert(block_size_ok(mbr->blockptr.xeckd.bptr.size), "Bad block size in zIPL section of IPL2 record."); @@ -281,7 +281,7 @@ static void print_eckd_ldl_msg(ECKD_IPL_mode_t mode) static void ipl_eckd_ldl(ECKD_IPL_mode_t mode) { block_number_t bmt_block_nr; - BootInfo *bip =3D (void *)(sec + 0x70); /* BootInfo is MBR for LDL */ + EckdLdlIpl1 *ipl1 =3D (void *)sec; =20 if (mode !=3D ECKD_LDL_UNLABELED) { print_eckd_ldl_msg(mode); @@ -292,15 +292,15 @@ static void ipl_eckd_ldl(ECKD_IPL_mode_t mode) memset(sec, FREE_SPACE_FILLER, sizeof(sec)); read_block(0, sec, "Cannot read block 0 to grab boot info."); if (mode =3D=3D ECKD_LDL_UNLABELED) { - if (!magic_match(bip->magic, ZIPL_MAGIC)) { + if (!magic_match(ipl1->bip.magic, ZIPL_MAGIC)) { return; /* not applicable layout */ } sclp_print("unlabeled LDL.\n"); } - verify_boot_info(bip); + verify_boot_info(&ipl1->bip); =20 /* save pointer to Boot Map Table */ - bmt_block_nr =3D eckd_block_num(&bip->bp.ipl.bm_ptr.eckd.bptr.chs); + bmt_block_nr =3D eckd_block_num(&ipl1->bip.bp.ipl.bm_ptr.eckd.bptr.chs= ); =20 run_eckd_boot_script(bmt_block_nr); /* no return */ diff --git a/pc-bios/s390-ccw/bootmap.h b/pc-bios/s390-ccw/bootmap.h index 260ac2a..cfe9ddd 100644 --- a/pc-bios/s390-ccw/bootmap.h +++ b/pc-bios/s390-ccw/bootmap.h @@ -237,22 +237,27 @@ typedef struct BootInfo { /* @ 0x70, record = #0 */ } bp; } __attribute__ ((packed)) BootInfo; /* see also XEckdMbr */ =20 -typedef struct Ipl1 { - unsigned char key[4]; /* =3D=3D "IPL1" */ - unsigned char data[24]; -} __attribute__((packed)) Ipl1; - -typedef struct Ipl2 { - unsigned char key[4]; /* =3D=3D "IPL2" */ - union { - unsigned char data[144]; - struct { - unsigned char reserved1[92-4]; - XEckdMbr mbr; - unsigned char reserved2[144-(92-4)-sizeof(XEckdMbr)]; - } x; - } u; -} __attribute__((packed)) Ipl2; +/* + * Structs for IPL + */ +#define STAGE2_BLK_CNT_MAX 24 /* Stage 1b can load up to 24 blocks */ + +typedef struct EckdCdlIpl1 { + uint8_t key[4]; /* =3D=3D "IPL1" */ + uint8_t data[24]; +} __attribute__((packed)) EckdCdlIpl1; + +typedef struct EckdCdlIpl2 { + uint8_t key[4]; /* =3D=3D "IPL2" */ + uint8_t reserved0[88]; + XEckdMbr mbr; + uint8_t reserved[24]; +} __attribute__((packed)) EckdCdlIpl2; + +typedef struct EckdLdlIpl1 { + uint8_t reserved[112]; + BootInfo bip; /* BootInfo is MBR for LDL */ +} __attribute__((packed)) EckdLdlIpl1; =20 typedef struct IplVolumeLabel { unsigned char key[4]; /* =3D=3D "VOL1" */ --=20 2.7.4 From nobody Sun Apr 28 20:00:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517864961405805.1857476206104; Mon, 5 Feb 2018 13:09:21 -0800 (PST) Received: from localhost ([::1]:36255 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eio0l-00035o-OE for importer@patchew.org; Mon, 05 Feb 2018 16:09:11 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47412) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eintX-0005gP-97 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 16:01:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eintT-0003Oz-UM for qemu-devel@nongnu.org; Mon, 05 Feb 2018 16:01:43 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:39382 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eintT-0003Ok-OZ for qemu-devel@nongnu.org; Mon, 05 Feb 2018 16:01:39 -0500 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w15KxUfr128184 for ; Mon, 5 Feb 2018 16:01:39 -0500 Received: from e18.ny.us.ibm.com (e18.ny.us.ibm.com [129.33.205.208]) by mx0b-001b2d01.pphosted.com with ESMTP id 2fxuj87k4x-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 05 Feb 2018 16:01:37 -0500 Received: from localhost by e18.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 5 Feb 2018 16:01:37 -0500 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) by e18.ny.us.ibm.com (146.89.104.205) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 5 Feb 2018 16:01:33 -0500 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w15L1RR039387362; Mon, 5 Feb 2018 21:01:33 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D1946112051; Mon, 5 Feb 2018 15:59:36 -0500 (EST) Received: from collin-ThinkPad-W541.pok.ibm.com (unknown [9.56.58.149]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id B994D112034; Mon, 5 Feb 2018 15:59:36 -0500 (EST) From: "Collin L. Walling" To: qemu-s390x@nongnu.org, qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 15:57:18 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517864246-11101-1-git-send-email-walling@linux.vnet.ibm.com> References: <1517864246-11101-1-git-send-email-walling@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18020521-0044-0000-0000-000003DBF57E X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008478; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000248; SDB=6.00985441; UDB=6.00500015; IPR=6.00764812; BA=6.00005812; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00019386; XFM=3.00000015; UTC=2018-02-05 21:01:35 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18020521-0045-0000-0000-0000080B6447 Message-Id: <1517864246-11101-5-git-send-email-walling@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-02-05_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1802050259 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH v5 04/12] s390-ccw: update libc X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: frankja@linux.vnet.ibm.com, thuth@redhat.com, cohuck@redhat.com, david@redhat.com, alifm@linux.vnet.ibm.com, mihajlov@linux.vnet.ibm.com, borntraeger@de.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Moved: memcmp from bootmap.h to libc.h (renamed from _memcmp) strlen from sclp.c to libc.h (renamed from _strlen) Added C standard functions: isdigit Added non C-standard function: itostr atoui Signed-off-by: Collin L. Walling Acked-by: Christian Borntraeger Reviewed-by: Janosch Frank --- pc-bios/s390-ccw/Makefile | 2 +- pc-bios/s390-ccw/bootmap.c | 4 +- pc-bios/s390-ccw/bootmap.h | 16 +------- pc-bios/s390-ccw/libc.c | 91 ++++++++++++++++++++++++++++++++++++++++++= ++++ pc-bios/s390-ccw/libc.h | 35 +++++++++++++++++- pc-bios/s390-ccw/main.c | 17 +-------- pc-bios/s390-ccw/sclp.c | 10 +---- 7 files changed, 131 insertions(+), 44 deletions(-) create mode 100644 pc-bios/s390-ccw/libc.c diff --git a/pc-bios/s390-ccw/Makefile b/pc-bios/s390-ccw/Makefile index 6d0c2ee..9f7904f 100644 --- a/pc-bios/s390-ccw/Makefile +++ b/pc-bios/s390-ccw/Makefile @@ -9,7 +9,7 @@ $(call set-vpath, $(SRC_PATH)/pc-bios/s390-ccw) =20 .PHONY : all clean build-all =20 -OBJECTS =3D start.o main.o bootmap.o sclp.o virtio.o virtio-scsi.o virtio-= blkdev.o +OBJECTS =3D start.o main.o bootmap.o sclp.o virtio.o virtio-scsi.o virtio-= blkdev.o libc.o QEMU_CFLAGS :=3D $(filter -W%, $(QEMU_CFLAGS)) QEMU_CFLAGS +=3D -ffreestanding -fno-delete-null-pointer-checks -msoft-flo= at QEMU_CFLAGS +=3D -march=3Dz900 -fPIE -fno-strict-aliasing diff --git a/pc-bios/s390-ccw/bootmap.c b/pc-bios/s390-ccw/bootmap.c index c97f136..e3cbb09b 100644 --- a/pc-bios/s390-ccw/bootmap.c +++ b/pc-bios/s390-ccw/bootmap.c @@ -501,7 +501,7 @@ static bool is_iso_bc_entry_compatible(IsoBcSection *s) "Failed to read image sector 0"); =20 /* Checking bytes 8 - 32 for S390 Linux magic */ - return !_memcmp(magic_sec + 8, linux_s390_magic, 24); + return !memcmp(magic_sec + 8, linux_s390_magic, 24); } =20 /* Location of the current sector of the directory */ @@ -630,7 +630,7 @@ static uint32_t find_iso_bc(void) if (vd->type =3D=3D VOL_DESC_TYPE_BOOT) { IsoVdElTorito *et =3D &vd->vd.boot; =20 - if (!_memcmp(&et->el_torito[0], el_torito_magic, 32)) { + if (!memcmp(&et->el_torito[0], el_torito_magic, 32)) { return bswap32(et->bc_offset); } } diff --git a/pc-bios/s390-ccw/bootmap.h b/pc-bios/s390-ccw/bootmap.h index cfe9ddd..b0a135c 100644 --- a/pc-bios/s390-ccw/bootmap.h +++ b/pc-bios/s390-ccw/bootmap.h @@ -326,20 +326,6 @@ static inline bool magic_match(const void *data, const= void *magic) return *((uint32_t *)data) =3D=3D *((uint32_t *)magic); } =20 -static inline int _memcmp(const void *s1, const void *s2, size_t n) -{ - int i; - const uint8_t *p1 =3D s1, *p2 =3D s2; - - for (i =3D 0; i < n; i++) { - if (p1[i] !=3D p2[i]) { - return p1[i] > p2[i] ? 1 : -1; - } - } - - return 0; -} - static inline uint32_t iso_733_to_u32(uint64_t x) { return (uint32_t)x; @@ -432,7 +418,7 @@ const uint8_t vol_desc_magic[] =3D "CD001"; =20 static inline bool is_iso_vd_valid(IsoVolDesc *vd) { - return !_memcmp(&vd->ident[0], vol_desc_magic, 5) && + return !memcmp(&vd->ident[0], vol_desc_magic, 5) && vd->version =3D=3D 0x1 && vd->type <=3D VOL_DESC_TYPE_PARTITION; } diff --git a/pc-bios/s390-ccw/libc.c b/pc-bios/s390-ccw/libc.c new file mode 100644 index 0000000..e6f434b --- /dev/null +++ b/pc-bios/s390-ccw/libc.c @@ -0,0 +1,91 @@ +/* + * libc-style definitions and functions + * + * Copyright 2018 IBM Corp. + * Author(s): Collin L. Walling + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#include "libc.h" +#include "s390-ccw.h" + +/** + * atoui: + * @str: the string to be converted. + * + * Given a string @str, convert it to an integer. Leading spaces are + * ignored. Any other non-numerical value will terminate the conversion + * and return 0. This function only handles numbers between 0 and + * UINT64_MAX inclusive. + * + * Returns: an integer converted from the string @str, or the number 0 + * if an error occurred. + */ +uint64_t atoui(const char *str) +{ + int val =3D 0; + + if (!str || !str[0]) { + return 0; + } + + while (*str =3D=3D ' ') { + str++; + } + + while (*str) { + if (!isdigit(*str)) { + break; + } + val =3D val * 10 + *str - '0'; + str++; + } + + return val; +} + +/** + * itostr: + * @num: an integer (base 10) to be converted. + * @str: a pointer to a string to store the conversion. + * @len: the length of the passed string. + * + * Given an integer @num, convert it to a string. The string @str must be + * allocated beforehand. The resulting string will be null terminated and + * returned. This function only handles numbers between 0 and UINT64_MAX + * inclusive. + * + * Returns: the string @str of the converted integer @num; NULL if @str + * is NULL or if there is not enough space allocated. + */ +char *itostr(uint64_t num, char *str, size_t len) +{ + size_t num_idx =3D 0; + uint64_t tmp =3D num; + + IPL_assert(num >=3D 0, "itostr: cannot convert negative values"); + IPL_assert(str !=3D NULL, "itostr: no space allocated to store string"= ); + + /* Get index to ones place */ + while ((tmp /=3D 10) !=3D 0) { + num_idx++; + } + + /* Check if we have enough space for num and null */ + IPL_assert(len >=3D num_idx + 1, "itostr: array too small for conversi= on"); + + str[num_idx + 1] =3D '\0'; + + /* Convert int to string */ + while (num_idx >=3D 0) { + str[num_idx] =3D num % 10 + '0'; + num /=3D 10; + num_idx--; + } + + return str; +} diff --git a/pc-bios/s390-ccw/libc.h b/pc-bios/s390-ccw/libc.h index 0142ea8..eb6cec6 100644 --- a/pc-bios/s390-ccw/libc.h +++ b/pc-bios/s390-ccw/libc.h @@ -1,6 +1,8 @@ /* * libc-style definitions and functions * + * Copyright (c) 2013 Alexander Graf + * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your @@ -33,7 +35,7 @@ static inline void *memcpy(void *s1, const void *s2, size= _t n) { uint8_t *dest =3D s1; const uint8_t *src =3D s2; - int i; + size_t i; =20 for (i =3D 0; i < n; i++) { dest[i] =3D src[i]; @@ -42,4 +44,35 @@ static inline void *memcpy(void *s1, const void *s2, siz= e_t n) return s1; } =20 +static inline int memcmp(const void *s1, const void *s2, size_t n) +{ + size_t i; + const uint8_t *p1 =3D s1, *p2 =3D s2; + + for (i =3D 0; i < n; i++) { + if (p1[i] !=3D p2[i]) { + return p1[i] > p2[i] ? 1 : -1; + } + } + + return 0; +} + +static inline size_t strlen(const char *str) +{ + size_t i; + for (i =3D 0; *str; i++) { + str++; + } + return i; +} + +static inline int isdigit(int c) +{ + return (c >=3D '0') && (c <=3D '9'); +} + +uint64_t atoui(const char *str); +char *itostr(uint64_t num, char *str, size_t len); + #endif diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c index 401e9db..e857ce4 100644 --- a/pc-bios/s390-ccw/main.c +++ b/pc-bios/s390-ccw/main.c @@ -40,22 +40,7 @@ void panic(const char *string) =20 unsigned int get_loadparm_index(void) { - const char *lp =3D loadparm; - int i; - unsigned int idx =3D 0; - - for (i =3D 0; i < 8; i++) { - char c =3D lp[i]; - - if (c < '0' || c > '9') { - break; - } - - idx *=3D 10; - idx +=3D c - '0'; - } - - return idx; + return atoui(loadparm); } =20 static bool find_dev(Schib *schib, int dev_no) diff --git a/pc-bios/s390-ccw/sclp.c b/pc-bios/s390-ccw/sclp.c index b1fc8ff..486fce1 100644 --- a/pc-bios/s390-ccw/sclp.c +++ b/pc-bios/s390-ccw/sclp.c @@ -65,14 +65,6 @@ void sclp_setup(void) sclp_set_write_mask(); } =20 -static int _strlen(const char *str) -{ - int i; - for (i =3D 0; *str; i++) - str++; - return i; -} - long write(int fd, const void *str, size_t len) { WriteEventData *sccb =3D (void *)_sccb; @@ -95,7 +87,7 @@ long write(int fd, const void *str, size_t len) =20 void sclp_print(const char *str) { - write(1, str, _strlen(str)); + write(1, str, strlen(str)); } =20 void sclp_get_loadparm_ascii(char *loadparm) --=20 2.7.4 From nobody Sun Apr 28 20:00:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517864650659270.8849556902129; Mon, 5 Feb 2018 13:04:10 -0800 (PST) Received: from localhost ([::1]:36098 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1einvo-0007Ac-TA for importer@patchew.org; Mon, 05 Feb 2018 16:04:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47468) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eintZ-0005iS-0c for qemu-devel@nongnu.org; Mon, 05 Feb 2018 16:01:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eintV-0003Qa-OU for qemu-devel@nongnu.org; Mon, 05 Feb 2018 16:01:45 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:54718) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eintV-0003PN-EP for qemu-devel@nongnu.org; Mon, 05 Feb 2018 16:01:41 -0500 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w15KxSUZ005338 for ; Mon, 5 Feb 2018 16:01:40 -0500 Received: from e14.ny.us.ibm.com (e14.ny.us.ibm.com [129.33.205.204]) by mx0a-001b2d01.pphosted.com with ESMTP id 2fxxkbrhjf-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 05 Feb 2018 16:01:40 -0500 Received: from localhost by e14.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 5 Feb 2018 16:01:38 -0500 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) by e14.ny.us.ibm.com (146.89.104.201) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 5 Feb 2018 16:01:34 -0500 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w15L1RRE39387362; Mon, 5 Feb 2018 21:01:34 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D6D47112034; Mon, 5 Feb 2018 15:59:37 -0500 (EST) Received: from collin-ThinkPad-W541.pok.ibm.com (unknown [9.56.58.149]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id C8F6C112051; Mon, 5 Feb 2018 15:59:37 -0500 (EST) From: "Collin L. Walling" To: qemu-s390x@nongnu.org, qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 15:57:19 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517864246-11101-1-git-send-email-walling@linux.vnet.ibm.com> References: <1517864246-11101-1-git-send-email-walling@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18020521-0052-0000-0000-000002B07DE6 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008478; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000248; SDB=6.00985441; UDB=6.00500015; IPR=6.00764812; BA=6.00005812; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00019386; XFM=3.00000015; UTC=2018-02-05 21:01:36 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18020521-0053-0000-0000-0000537C4B35 Message-Id: <1517864246-11101-6-git-send-email-walling@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-02-05_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 lowpriorityscore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1802050259 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH v5 05/12] s390-ccw: move auxiliary IPL data to separate location X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: frankja@linux.vnet.ibm.com, thuth@redhat.com, cohuck@redhat.com, david@redhat.com, alifm@linux.vnet.ibm.com, mihajlov@linux.vnet.ibm.com, borntraeger@de.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The s390-ccw firmware needs some information in support of the boot process which is not available on the native machine. Examples are the netboot firmware load address and now the boot menu parameters. While storing that data in unused fields of the IPL parameter block works, that approach could create problems if the parameter block definition should change in the future. Because then a guest could overwrite these fields using the set IPLB diagnose. In fact the data in question is of more global nature and not really tied to an IPL device, so separating it is rather logical. This commit introduces a new structure to hold firmware relevant IPL parameters set by QEMU. The data is stored at location 204 (dec) and can contain up to 7 32-bit words. This area is available to programming in the z/Architecture Principles of Operation and can thus safely be used by the firmware until the IPL has completed. Signed-off-by: Viktor Mihajlovski --- hw/s390x/ipl.c | 18 +++++++++++++++++- hw/s390x/ipl.h | 11 +++++++++-- pc-bios/s390-ccw/iplb.h | 12 ++++++++++-- pc-bios/s390-ccw/main.c | 6 +++++- 4 files changed, 41 insertions(+), 6 deletions(-) diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c index 0d06fc1..3e3c3b8 100644 --- a/hw/s390x/ipl.c +++ b/hw/s390x/ipl.c @@ -399,6 +399,20 @@ void s390_reipl_request(void) qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); } =20 +static void s390_ipl_prepare_qipl(S390CPU *cpu) +{ + S390IPLState *ipl =3D get_ipl_device(); + uint8_t *addr; + uint64_t len =3D 4096; + + addr =3D cpu_physical_memory_map(cpu->env.psa, &len, 1); + if (!addr || len < 204 + sizeof(QemuIplParameters)) { + error_report("Cannot set QEMU IPL parameters"); + } + memcpy(addr + 204, &ipl->iplb.qipl, sizeof(QemuIplParameters)); + cpu_physical_memory_unmap(addr, len, 1, len); +} + void s390_ipl_prepare_cpu(S390CPU *cpu) { S390IPLState *ipl =3D get_ipl_device(); @@ -418,8 +432,10 @@ void s390_ipl_prepare_cpu(S390CPU *cpu) error_report_err(err); vm_stop(RUN_STATE_INTERNAL_ERROR); } - ipl->iplb.ccw.netboot_start_addr =3D cpu_to_be64(ipl->start_addr); + ipl->iplb.qipl.netboot_start_addr =3D cpu_to_be64(ipl->start_addr); } + s390_ipl_prepare_qipl(cpu); + } =20 static void s390_ipl_reset(DeviceState *dev) diff --git a/hw/s390x/ipl.h b/hw/s390x/ipl.h index 8a705e0..68dcaf8 100644 --- a/hw/s390x/ipl.h +++ b/hw/s390x/ipl.h @@ -16,8 +16,7 @@ #include "cpu.h" =20 struct IplBlockCcw { - uint64_t netboot_start_addr; - uint8_t reserved0[77]; + uint8_t reserved0[85]; uint8_t ssid; uint16_t devno; uint8_t vm_flags; @@ -59,6 +58,13 @@ typedef struct IplBlockQemuScsi IplBlockQemuScsi; =20 #define DIAG308_FLAGS_LP_VALID 0x80 =20 +struct QemuIplParameters { + uint8_t reserved1[4]; + uint64_t netboot_start_addr; + uint8_t reserved2[16]; +} QEMU_PACKED; +typedef struct QemuIplParameters QemuIplParameters; + union IplParameterBlock { struct { uint32_t len; @@ -74,6 +80,7 @@ union IplParameterBlock { IplBlockFcp fcp; IplBlockQemuScsi scsi; }; + QemuIplParameters qipl; } QEMU_PACKED; struct { uint8_t reserved1[110]; diff --git a/pc-bios/s390-ccw/iplb.h b/pc-bios/s390-ccw/iplb.h index 890aed9..12f6e40 100644 --- a/pc-bios/s390-ccw/iplb.h +++ b/pc-bios/s390-ccw/iplb.h @@ -13,8 +13,7 @@ #define IPLB_H =20 struct IplBlockCcw { - uint64_t netboot_start_addr; - uint8_t reserved0[77]; + uint8_t reserved0[85]; uint8_t ssid; uint16_t devno; uint8_t vm_flags; @@ -73,6 +72,15 @@ typedef struct IplParameterBlock IplParameterBlock; =20 extern IplParameterBlock iplb __attribute__((__aligned__(PAGE_SIZE))); =20 +struct QemuIplParameters { + uint8_t reserved1[4]; + uint64_t netboot_start_addr; + uint8_t reserved2[16]; +} __attribute__ ((packed)); +typedef struct QemuIplParameters QemuIplParameters; + +extern QemuIplParameters qipl; + #define S390_IPL_TYPE_FCP 0x00 #define S390_IPL_TYPE_CCW 0x02 #define S390_IPL_TYPE_QEMU_SCSI 0xff diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c index e857ce4..825a1a3 100644 --- a/pc-bios/s390-ccw/main.c +++ b/pc-bios/s390-ccw/main.c @@ -16,6 +16,7 @@ char stack[PAGE_SIZE * 8] __attribute__((__aligned__(PAGE= _SIZE))); static SubChannelId blk_schid =3D { .one =3D 1 }; IplParameterBlock iplb __attribute__((__aligned__(PAGE_SIZE))); static char loadparm[8] =3D { 0, 0, 0, 0, 0, 0, 0, 0 }; +QemuIplParameters qipl; =20 /* * Priniciples of Operations (SA22-7832-09) chapter 17 requires that @@ -81,6 +82,7 @@ static void virtio_setup(void) uint16_t dev_no; char ldp[] =3D "LOADPARM=3D[________]\n"; VDev *vdev =3D virtio_get_device(); + QemuIplParameters *early_qipl =3D (QemuIplParameters *)204; =20 /* * We unconditionally enable mss support. In every sane configuration, @@ -93,6 +95,8 @@ static void virtio_setup(void) memcpy(ldp + 10, loadparm, 8); sclp_print(ldp); =20 + memcpy(&qipl, early_qipl, sizeof(QemuIplParameters)); + if (store_iplb(&iplb)) { switch (iplb.pbt) { case S390_IPL_TYPE_CCW: @@ -127,7 +131,7 @@ static void virtio_setup(void) =20 if (virtio_get_device_type() =3D=3D VIRTIO_ID_NET) { sclp_print("Network boot device detected\n"); - vdev->netboot_start_addr =3D iplb.ccw.netboot_start_addr; + vdev->netboot_start_addr =3D qipl.netboot_start_addr; } else { virtio_blk_setup_device(blk_schid); =20 --=20 2.7.4 From nobody Sun Apr 28 20:00:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517864806227722.5696566475774; Mon, 5 Feb 2018 13:06:46 -0800 (PST) Received: from localhost ([::1]:36179 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1einyP-00012d-AF for importer@patchew.org; Mon, 05 Feb 2018 16:06:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47488) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eintZ-0005jY-N6 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 16:01:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eintW-0003Rc-Mx for qemu-devel@nongnu.org; Mon, 05 Feb 2018 16:01:45 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:53374 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eintW-0003RD-II for qemu-devel@nongnu.org; Mon, 05 Feb 2018 16:01:42 -0500 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w15KxVq9049418 for ; Mon, 5 Feb 2018 16:01:40 -0500 Received: from e19.ny.us.ibm.com (e19.ny.us.ibm.com [129.33.205.209]) by mx0a-001b2d01.pphosted.com with ESMTP id 2fxuympprx-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 05 Feb 2018 16:01:40 -0500 Received: from localhost by e19.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 5 Feb 2018 16:01:39 -0500 Received: from b01cxnp23034.gho.pok.ibm.com (9.57.198.29) by e19.ny.us.ibm.com (146.89.104.206) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 5 Feb 2018 16:01:35 -0500 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w15L1W3p45547736; Mon, 5 Feb 2018 21:01:35 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DB9CE112056; Mon, 5 Feb 2018 15:59:38 -0500 (EST) Received: from collin-ThinkPad-W541.pok.ibm.com (unknown [9.56.58.149]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id CDBC211205E; Mon, 5 Feb 2018 15:59:38 -0500 (EST) From: "Collin L. Walling" To: qemu-s390x@nongnu.org, qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 15:57:20 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517864246-11101-1-git-send-email-walling@linux.vnet.ibm.com> References: <1517864246-11101-1-git-send-email-walling@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18020521-0056-0000-0000-00000415F70B X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008478; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000248; SDB=6.00985441; UDB=6.00500015; IPR=6.00764812; BA=6.00005812; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00019386; XFM=3.00000015; UTC=2018-02-05 21:01:38 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18020521-0057-0000-0000-0000084D6522 Message-Id: <1517864246-11101-7-git-send-email-walling@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-02-05_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1802050259 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH v5 06/12] s390-ccw: parse and set boot menu options X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: frankja@linux.vnet.ibm.com, thuth@redhat.com, cohuck@redhat.com, david@redhat.com, alifm@linux.vnet.ibm.com, mihajlov@linux.vnet.ibm.com, borntraeger@de.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Set boot menu options for an s390 guest and store them in the iplb. These options are set via the QEMU command line option: -boot menu=3Don|off[,splash-time=3DX] or via the libvirt domain xml: Where X represents some positive integer representing milliseconds. Any value set for loadparm will override all boot menu options. If loadparm=3DPROMPT, then the menu will be enabled without a timeout. The absence of any boot options on the command line will flag to later use the zipl boot loader values. Signed-off-by: Collin L. Walling Reviewed-by: Janosch Frank Reviewed-by: Thomas Huth --- hw/s390x/ipl.c | 52 +++++++++++++++++++++++++++++++++++++++++++++= ++++ hw/s390x/ipl.h | 7 ++++++- pc-bios/s390-ccw/iplb.h | 4 +++- 3 files changed, 61 insertions(+), 2 deletions(-) diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c index 3e3c3b8..227dccb 100644 --- a/hw/s390x/ipl.c +++ b/hw/s390x/ipl.c @@ -23,6 +23,8 @@ #include "hw/s390x/ebcdic.h" #include "ipl.h" #include "qemu/error-report.h" +#include "qemu/config-file.h" +#include "qemu/cutils.h" =20 #define KERN_IMAGE_START 0x010000UL #define KERN_PARM_AREA 0x010480UL @@ -219,6 +221,53 @@ static Property s390_ipl_properties[] =3D { DEFINE_PROP_END_OF_LIST(), }; =20 +static void s390_ipl_set_boot_menu(IplParameterBlock *iplb) +{ + QemuOptsList *plist =3D qemu_find_opts("boot-opts"); + QemuOpts *opts =3D QTAILQ_FIRST(&plist->head); + uint8_t *flags; + uint16_t *timeout; + const char *tmp; + unsigned long result =3D 0; + + switch (iplb->pbt) { + case S390_IPL_TYPE_CCW: + case S390_IPL_TYPE_QEMU_SCSI: + flags =3D &iplb->qipl.boot_menu_flags; + timeout =3D &iplb->qipl.boot_menu_timeout; + break; + default: + error_report("boot menu is not supported for this device type."); + return; + } + + /* In the absence of -boot menu, use zipl parameters */ + if (!qemu_opt_get(opts, "menu")) { + *flags =3D BOOT_MENU_FLAG_ZIPL_OPTS; + } else if (boot_menu) { + *flags =3D BOOT_MENU_FLAG_CMD_OPTS; + + tmp =3D qemu_opt_get(opts, "splash-time"); + + if (tmp && qemu_strtoul(tmp, NULL, 10, &result)) { + error_report("splash-time value is invalid, forcing it to 0."); + *timeout =3D 0; + return; + } + + result =3D (result + 500) / 1000; /* Round and convert to seconds = */ + + if (result > 0xffff) { + error_report("splash-time value is greater than 65535000," + " forcing it to 65535000."); + *timeout =3D 0xffff; + return; + } + + *timeout =3D cpu_to_be16(result); + } +} + static bool s390_gen_initial_iplb(S390IPLState *ipl) { DeviceState *dev_st; @@ -273,6 +322,9 @@ static bool s390_gen_initial_iplb(S390IPLState *ipl) if (!s390_ipl_set_loadparm(ipl->iplb.loadparm)) { ipl->iplb.flags |=3D DIAG308_FLAGS_LP_VALID; } + + s390_ipl_set_boot_menu(&ipl->iplb); + return true; } =20 diff --git a/hw/s390x/ipl.h b/hw/s390x/ipl.h index 68dcaf8..90c0ed3 100644 --- a/hw/s390x/ipl.h +++ b/hw/s390x/ipl.h @@ -58,8 +58,13 @@ typedef struct IplBlockQemuScsi IplBlockQemuScsi; =20 #define DIAG308_FLAGS_LP_VALID 0x80 =20 +#define BOOT_MENU_FLAG_CMD_OPTS 0x80 +#define BOOT_MENU_FLAG_ZIPL_OPTS 0x40 + struct QemuIplParameters { - uint8_t reserved1[4]; + uint8_t boot_menu_flags; + uint8_t reserved1; + uint16_t boot_menu_timeout; uint64_t netboot_start_addr; uint8_t reserved2[16]; } QEMU_PACKED; diff --git a/pc-bios/s390-ccw/iplb.h b/pc-bios/s390-ccw/iplb.h index 12f6e40..0bbc1ac 100644 --- a/pc-bios/s390-ccw/iplb.h +++ b/pc-bios/s390-ccw/iplb.h @@ -73,7 +73,9 @@ typedef struct IplParameterBlock IplParameterBlock; extern IplParameterBlock iplb __attribute__((__aligned__(PAGE_SIZE))); =20 struct QemuIplParameters { - uint8_t reserved1[4]; + uint8_t boot_menu_flags; + uint8_t reserved1; + uint16_t boot_menu_timeout; uint64_t netboot_start_addr; uint8_t reserved2[16]; } __attribute__ ((packed)); --=20 2.7.4 From nobody Sun Apr 28 20:00:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 151786496089659.78294080810599; Mon, 5 Feb 2018 13:09:20 -0800 (PST) Received: from localhost ([::1]:36257 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eio0l-000372-N9 for importer@patchew.org; Mon, 05 Feb 2018 16:09:11 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47476) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eintZ-0005im-4z for qemu-devel@nongnu.org; Mon, 05 Feb 2018 16:01:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eintY-0003T2-0K for qemu-devel@nongnu.org; Mon, 05 Feb 2018 16:01:45 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:36954 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eintX-0003SN-K4 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 16:01:43 -0500 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w15KxWTj080085 for ; Mon, 5 Feb 2018 16:01:40 -0500 Received: from e15.ny.us.ibm.com (e15.ny.us.ibm.com [129.33.205.205]) by mx0b-001b2d01.pphosted.com with ESMTP id 2fxwe037f3-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 05 Feb 2018 16:01:39 -0500 Received: from localhost by e15.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 5 Feb 2018 16:01:38 -0500 Received: from b01cxnp22035.gho.pok.ibm.com (9.57.198.25) by e15.ny.us.ibm.com (146.89.104.202) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 5 Feb 2018 16:01:37 -0500 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w15L1aK850528284; Mon, 5 Feb 2018 21:01:36 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E10E9112057; Mon, 5 Feb 2018 15:59:39 -0500 (EST) Received: from collin-ThinkPad-W541.pok.ibm.com (unknown [9.56.58.149]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id D2E9E112047; Mon, 5 Feb 2018 15:59:39 -0500 (EST) From: "Collin L. Walling" To: qemu-s390x@nongnu.org, qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 15:57:21 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517864246-11101-1-git-send-email-walling@linux.vnet.ibm.com> References: <1517864246-11101-1-git-send-email-walling@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18020521-0036-0000-0000-000002B98FC2 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008478; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000248; SDB=6.00985441; UDB=6.00500015; IPR=6.00764812; BA=6.00005812; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00019386; XFM=3.00000015; UTC=2018-02-05 21:01:38 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18020521-0037-0000-0000-0000433CDD1E Message-Id: <1517864246-11101-8-git-send-email-walling@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-02-05_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1802050259 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH v5 07/12] s390-ccw: set up interactive boot menu parameters X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: frankja@linux.vnet.ibm.com, thuth@redhat.com, cohuck@redhat.com, david@redhat.com, alifm@linux.vnet.ibm.com, mihajlov@linux.vnet.ibm.com, borntraeger@de.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Reads boot menu flag and timeout values from the iplb and sets the respective fields for the menu. Signed-off-by: Collin L. Walling Reviewed-by: Thomas Huth --- pc-bios/s390-ccw/Makefile | 2 +- pc-bios/s390-ccw/main.c | 24 ++++++++++++++++++++++++ pc-bios/s390-ccw/menu.c | 26 ++++++++++++++++++++++++++ pc-bios/s390-ccw/menu.h | 23 +++++++++++++++++++++++ 4 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 pc-bios/s390-ccw/menu.c create mode 100644 pc-bios/s390-ccw/menu.h diff --git a/pc-bios/s390-ccw/Makefile b/pc-bios/s390-ccw/Makefile index 9f7904f..1712c2d 100644 --- a/pc-bios/s390-ccw/Makefile +++ b/pc-bios/s390-ccw/Makefile @@ -9,7 +9,7 @@ $(call set-vpath, $(SRC_PATH)/pc-bios/s390-ccw) =20 .PHONY : all clean build-all =20 -OBJECTS =3D start.o main.o bootmap.o sclp.o virtio.o virtio-scsi.o virtio-= blkdev.o libc.o +OBJECTS =3D start.o main.o bootmap.o sclp.o virtio.o virtio-scsi.o virtio-= blkdev.o libc.o menu.o QEMU_CFLAGS :=3D $(filter -W%, $(QEMU_CFLAGS)) QEMU_CFLAGS +=3D -ffreestanding -fno-delete-null-pointer-checks -msoft-flo= at QEMU_CFLAGS +=3D -march=3Dz900 -fPIE -fno-strict-aliasing diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c index 825a1a3..76d58cc 100644 --- a/pc-bios/s390-ccw/main.c +++ b/pc-bios/s390-ccw/main.c @@ -11,6 +11,7 @@ #include "libc.h" #include "s390-ccw.h" #include "virtio.h" +#include "menu.h" =20 char stack[PAGE_SIZE * 8] __attribute__((__aligned__(PAGE_SIZE))); static SubChannelId blk_schid =3D { .one =3D 1 }; @@ -18,6 +19,9 @@ IplParameterBlock iplb __attribute__((__aligned__(PAGE_SI= ZE))); static char loadparm[8] =3D { 0, 0, 0, 0, 0, 0, 0, 0 }; QemuIplParameters qipl; =20 +#define LOADPARM_PROMPT "PROMPT " +#define LOADPARM_EMPTY "........" + /* * Priniciples of Operations (SA22-7832-09) chapter 17 requires that * a subsystem-identification is at 184-187 and bytes 188-191 are zero @@ -74,6 +78,25 @@ static bool find_dev(Schib *schib, int dev_no) return false; } =20 +static void menu_setup(void) +{ + if (memcmp(loadparm, LOADPARM_PROMPT, 8) =3D=3D 0) { + menu_set_parms(BOOT_MENU_FLAG_CMD_OPTS, 0); + return; + } + + /* If loadparm was set to any other value, then do not enable menu */ + if (memcmp(loadparm, LOADPARM_EMPTY, 8) !=3D 0) { + return; + } + + switch (iplb.pbt) { + case S390_IPL_TYPE_CCW: + menu_set_parms(qipl.boot_menu_flags, qipl.boot_menu_timeout); + return; + } +} + static void virtio_setup(void) { Schib schib; @@ -117,6 +140,7 @@ static void virtio_setup(void) default: panic("List-directed IPL not supported yet!\n"); } + menu_setup(); } else { for (ssid =3D 0; ssid < 0x3; ssid++) { blk_schid.ssid =3D ssid; diff --git a/pc-bios/s390-ccw/menu.c b/pc-bios/s390-ccw/menu.c new file mode 100644 index 0000000..e87aec6 --- /dev/null +++ b/pc-bios/s390-ccw/menu.c @@ -0,0 +1,26 @@ +/* + * QEMU S390 Interactive Boot Menu + * + * Copyright 2018 IBM Corp. + * Author: Collin L. Walling + * + * This work is licensed under the terms of the GNU GPL, version 2 or (at + * your option) any later version. See the COPYING file in the top-level + * directory. + */ + +#include "menu.h" + +static uint8_t flags; +static uint64_t timeout; + +void menu_set_parms(uint8_t boot_menu_flag, uint16_t boot_menu_timeout) +{ + flags =3D boot_menu_flag; + timeout =3D boot_menu_timeout; +} + +int menu_check_flags(uint8_t check_flags) +{ + return flags & check_flags; +} diff --git a/pc-bios/s390-ccw/menu.h b/pc-bios/s390-ccw/menu.h new file mode 100644 index 0000000..6ff9a0e --- /dev/null +++ b/pc-bios/s390-ccw/menu.h @@ -0,0 +1,23 @@ +/* + * QEMU S390 Interactive Boot Menu + * + * Copyright 2018 IBM Corp. + * Author: Collin L. Walling + * + * This work is licensed under the terms of the GNU GPL, version 2 or (at + * your option) any later version. See the COPYING file in the top-level + * directory. + */ + +#ifndef MENU_H +#define MENU_H + +#include "libc.h" + +#define BOOT_MENU_FLAG_CMD_OPTS 0x80 +#define BOOT_MENU_FLAG_ZIPL_OPTS 0x40 + +void menu_set_parms(uint8_t boot_menu_flags, uint16_t boot_menu_timeout); +bool menu_check_flags(uint8_t check_flags); + +#endif /* MENU_H */ --=20 2.7.4 From nobody Sun Apr 28 20:00:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517865104936214.32018778601196; Mon, 5 Feb 2018 13:11:44 -0800 (PST) Received: from localhost ([::1]:36577 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eio3E-0005h3-2H for importer@patchew.org; Mon, 05 Feb 2018 16:11:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47591) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eintd-0005kq-0e for qemu-devel@nongnu.org; Mon, 05 Feb 2018 16:01:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1einta-0003VX-N2 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 16:01:49 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:41302 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1einta-0003V8-HF for qemu-devel@nongnu.org; Mon, 05 Feb 2018 16:01:46 -0500 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w15KxRVn009982 for ; Mon, 5 Feb 2018 16:01:44 -0500 Received: from e16.ny.us.ibm.com (e16.ny.us.ibm.com [129.33.205.206]) by mx0b-001b2d01.pphosted.com with ESMTP id 2fxxmt0cwm-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 05 Feb 2018 16:01:41 -0500 Received: from localhost by e16.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 5 Feb 2018 16:01:41 -0500 Received: from b01cxnp23034.gho.pok.ibm.com (9.57.198.29) by e16.ny.us.ibm.com (146.89.104.203) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 5 Feb 2018 16:01:38 -0500 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w15L1bXe45809688; Mon, 5 Feb 2018 21:01:37 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F0195112051; Mon, 5 Feb 2018 15:59:40 -0500 (EST) Received: from collin-ThinkPad-W541.pok.ibm.com (unknown [9.56.58.149]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id D81C3112047; Mon, 5 Feb 2018 15:59:40 -0500 (EST) From: "Collin L. Walling" To: qemu-s390x@nongnu.org, qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 15:57:22 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517864246-11101-1-git-send-email-walling@linux.vnet.ibm.com> References: <1517864246-11101-1-git-send-email-walling@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18020521-0024-0000-0000-0000031F0532 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008478; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000248; SDB=6.00985441; UDB=6.00500014; IPR=6.00764812; BA=6.00005812; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00019386; XFM=3.00000015; UTC=2018-02-05 21:01:40 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18020521-0025-0000-0000-000046E2116C Message-Id: <1517864246-11101-9-git-send-email-walling@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-02-05_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1802050259 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH v5 08/12] s390-ccw: read stage2 boot loader data to find menu X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: frankja@linux.vnet.ibm.com, thuth@redhat.com, cohuck@redhat.com, david@redhat.com, alifm@linux.vnet.ibm.com, mihajlov@linux.vnet.ibm.com, borntraeger@de.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Read the stage2 boot loader data block-by-block. We scan the current block for the string "zIPL" to detect the start of the boot menu banner. We then load the adjacent blocks (previous block and next block) to account for the possibility of menu data spanning multiple blocks. Signed-off-by: Collin L. Walling Reviewed-by: Thomas Huth --- pc-bios/s390-ccw/bootmap.c | 94 ++++++++++++++++++++++++++++++++++++++++++= +--- pc-bios/s390-ccw/bootmap.h | 23 +++++++++++- pc-bios/s390-ccw/menu.c | 5 +++ pc-bios/s390-ccw/menu.h | 1 + 4 files changed, 116 insertions(+), 7 deletions(-) diff --git a/pc-bios/s390-ccw/bootmap.c b/pc-bios/s390-ccw/bootmap.c index e3cbb09b..adbef41 100644 --- a/pc-bios/s390-ccw/bootmap.c +++ b/pc-bios/s390-ccw/bootmap.c @@ -13,6 +13,7 @@ #include "bootmap.h" #include "virtio.h" #include "bswap.h" +#include "menu.h" =20 #ifdef DEBUG /* #define DEBUG_FALLBACK */ @@ -83,6 +84,10 @@ static void jump_to_IPL_code(uint64_t address) =20 static unsigned char _bprs[8*1024]; /* guessed "max" ECKD sector size */ static const int max_bprs_entries =3D sizeof(_bprs) / sizeof(ExtEckdBlockP= tr); +static uint8_t _s2[MAX_SECTOR_SIZE * 3] __attribute__((__aligned__(PAGE_SI= ZE))); +static void *s2_prev_blk =3D _s2; +static void *s2_cur_blk =3D _s2 + MAX_SECTOR_SIZE; +static void *s2_next_blk =3D _s2 + MAX_SECTOR_SIZE * 2; =20 static inline void verify_boot_info(BootInfo *bip) { @@ -182,7 +187,76 @@ static block_number_t load_eckd_segments(block_number_= t blk, uint64_t *address) return block_nr; } =20 -static void run_eckd_boot_script(block_number_t bmt_block_nr) +static bool find_zipl_boot_menu_banner(int *offset) +{ + int i; + + /* Menu banner starts with "zIPL" */ + for (i =3D 0; i < virtio_get_block_size() - 4; i++) { + if (magic_match(s2_cur_blk + i, ZIPL_MAGIC_EBCDIC)) { + *offset =3D i; + return true; + } + } + + return false; +} + +static int eckd_get_boot_menu_index(block_number_t s1b_block_nr) +{ + block_number_t cur_block_nr; + block_number_t prev_block_nr =3D 0; + block_number_t next_block_nr =3D 0; + EckdStage1b *s1b =3D (void *)sec; + int offset; + int i; + + /* Get Stage1b data */ + memset(sec, FREE_SPACE_FILLER, sizeof(sec)); + read_block(s1b_block_nr, s1b, "Cannot read stage1b boot loader"); + + memset(_s2, FREE_SPACE_FILLER, sizeof(_s2)); + + /* Get Stage2 data */ + for (i =3D 0; i < STAGE2_BLK_CNT_MAX; i++) { + cur_block_nr =3D eckd_block_num(&s1b->seek[i].chs); + + if (!cur_block_nr) { + break; + } + + read_block(cur_block_nr, s2_cur_blk, "Cannot read stage2 boot load= er"); + + if (find_zipl_boot_menu_banner(&offset)) { + /* Load the adjacent blocks to account for the + * possibility of menu data spanning multiple blocks. + */ + if (prev_block_nr) { + read_block(prev_block_nr, s2_prev_blk, + "Cannot read stage2 boot loader"); + } + + if (i + 1 < STAGE2_BLK_CNT_MAX) { + next_block_nr =3D eckd_block_num(&s1b->seek[i + 1].chs); + } + + if (next_block_nr) { + read_block(next_block_nr, s2_next_blk, + "Cannot read stage2 boot loader"); + } + + return menu_get_zipl_boot_index(s2_cur_blk, offset); + } + + prev_block_nr =3D cur_block_nr; + } + + sclp_print("No zipl boot menu data found. Booting default entry."); + return 0; +} + +static void run_eckd_boot_script(block_number_t bmt_block_nr, + block_number_t s1b_block_nr) { int i; unsigned int loadparm =3D get_loadparm_index(); @@ -191,6 +265,10 @@ static void run_eckd_boot_script(block_number_t bmt_bl= ock_nr) BootMapTable *bmt =3D (void *)sec; BootMapScript *bms =3D (void *)sec; =20 + if (menu_check_flags(BOOT_MENU_FLAG_CMD_OPTS | BOOT_MENU_FLAG_ZIPL_OPT= S)) { + loadparm =3D eckd_get_boot_menu_index(s1b_block_nr); + } + debug_print_int("loadparm", loadparm); IPL_assert(loadparm < 31, "loadparm value greater than" " maximum number of boot entries allowed"); @@ -223,7 +301,7 @@ static void ipl_eckd_cdl(void) XEckdMbr *mbr; EckdCdlIpl2 *ipl2 =3D (void *)sec; IplVolumeLabel *vlbl =3D (void *)sec; - block_number_t bmt_block_nr; + block_number_t bmt_block_nr, s1b_block_nr; =20 /* we have just read the block #0 and recognized it as "IPL1" */ sclp_print("CDL\n"); @@ -241,6 +319,9 @@ static void ipl_eckd_cdl(void) /* save pointer to Boot Map Table */ bmt_block_nr =3D eckd_block_num(&mbr->blockptr.xeckd.bptr.chs); =20 + /* save pointer to Stage1b Data */ + s1b_block_nr =3D eckd_block_num(&ipl2->stage1.seek[0].chs); + memset(sec, FREE_SPACE_FILLER, sizeof(sec)); read_block(2, vlbl, "Cannot read Volume Label at block 2"); IPL_assert(magic_match(vlbl->key, VOL1_MAGIC), @@ -249,7 +330,7 @@ static void ipl_eckd_cdl(void) "Invalid magic of volser block"); print_volser(vlbl->f.volser); =20 - run_eckd_boot_script(bmt_block_nr); + run_eckd_boot_script(bmt_block_nr, s1b_block_nr); /* no return */ } =20 @@ -280,7 +361,7 @@ static void print_eckd_ldl_msg(ECKD_IPL_mode_t mode) =20 static void ipl_eckd_ldl(ECKD_IPL_mode_t mode) { - block_number_t bmt_block_nr; + block_number_t bmt_block_nr, s1b_block_nr; EckdLdlIpl1 *ipl1 =3D (void *)sec; =20 if (mode !=3D ECKD_LDL_UNLABELED) { @@ -302,7 +383,10 @@ static void ipl_eckd_ldl(ECKD_IPL_mode_t mode) /* save pointer to Boot Map Table */ bmt_block_nr =3D eckd_block_num(&ipl1->bip.bp.ipl.bm_ptr.eckd.bptr.chs= ); =20 - run_eckd_boot_script(bmt_block_nr); + /* save pointer to Stage1b Data */ + s1b_block_nr =3D eckd_block_num(&ipl1->stage1.seek[0].chs); + + run_eckd_boot_script(bmt_block_nr, s1b_block_nr); /* no return */ } =20 diff --git a/pc-bios/s390-ccw/bootmap.h b/pc-bios/s390-ccw/bootmap.h index b0a135c..8fa6a7b 100644 --- a/pc-bios/s390-ccw/bootmap.h +++ b/pc-bios/s390-ccw/bootmap.h @@ -85,6 +85,7 @@ typedef struct ScsiMbr { } __attribute__ ((packed)) ScsiMbr; =20 #define ZIPL_MAGIC "zIPL" +#define ZIPL_MAGIC_EBCDIC "\xa9\xc9\xd7\xd3" #define IPL1_MAGIC "\xc9\xd7\xd3\xf1" /* =3D=3D "IPL1" in EBCDIC */ #define IPL2_MAGIC "\xc9\xd7\xd3\xf2" /* =3D=3D "IPL2" in EBCDIC */ #define VOL1_MAGIC "\xe5\xd6\xd3\xf1" /* =3D=3D "VOL1" in EBCDIC */ @@ -247,15 +248,33 @@ typedef struct EckdCdlIpl1 { uint8_t data[24]; } __attribute__((packed)) EckdCdlIpl1; =20 +typedef struct EckdSeekArg { + uint16_t pad; + EckdCHS chs; + uint8_t pad2; +} __attribute__ ((packed)) EckdSeekArg; + +typedef struct EckdStage1b { + uint8_t reserved[32 * STAGE2_BLK_CNT_MAX]; + struct EckdSeekArg seek[STAGE2_BLK_CNT_MAX]; + uint8_t unused[64]; +} __attribute__ ((packed)) EckdStage1b; + +typedef struct EckdStage1 { + uint8_t reserved[72]; + struct EckdSeekArg seek[2]; +} __attribute__ ((packed)) EckdStage1; + typedef struct EckdCdlIpl2 { uint8_t key[4]; /* =3D=3D "IPL2" */ - uint8_t reserved0[88]; + struct EckdStage1 stage1; XEckdMbr mbr; uint8_t reserved[24]; } __attribute__((packed)) EckdCdlIpl2; =20 typedef struct EckdLdlIpl1 { - uint8_t reserved[112]; + uint8_t reserved[24]; + struct EckdStage1 stage1; BootInfo bip; /* BootInfo is MBR for LDL */ } __attribute__((packed)) EckdLdlIpl1; =20 diff --git a/pc-bios/s390-ccw/menu.c b/pc-bios/s390-ccw/menu.c index e87aec6..4ba2684 100644 --- a/pc-bios/s390-ccw/menu.c +++ b/pc-bios/s390-ccw/menu.c @@ -14,6 +14,11 @@ static uint8_t flags; static uint64_t timeout; =20 +int menu_get_zipl_boot_index(const void *stage2, int offset) +{ + return 0; /* implemented next patch */ +} + void menu_set_parms(uint8_t boot_menu_flag, uint16_t boot_menu_timeout) { flags =3D boot_menu_flag; diff --git a/pc-bios/s390-ccw/menu.h b/pc-bios/s390-ccw/menu.h index 6ff9a0e..e8e042f 100644 --- a/pc-bios/s390-ccw/menu.h +++ b/pc-bios/s390-ccw/menu.h @@ -17,6 +17,7 @@ #define BOOT_MENU_FLAG_CMD_OPTS 0x80 #define BOOT_MENU_FLAG_ZIPL_OPTS 0x40 =20 +int menu_get_zipl_boot_index(const void *stage2, int offset); void menu_set_parms(uint8_t boot_menu_flags, uint16_t boot_menu_timeout); bool menu_check_flags(uint8_t check_flags); =20 --=20 2.7.4 From nobody Sun Apr 28 20:00:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517864806729690.0130143196828; Mon, 5 Feb 2018 13:06:46 -0800 (PST) Received: from localhost ([::1]:36181 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1einyP-00012o-TJ for importer@patchew.org; Mon, 05 Feb 2018 16:06:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47543) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eintb-0005kh-1X for qemu-devel@nongnu.org; Mon, 05 Feb 2018 16:01:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eintY-0003TT-Hx for qemu-devel@nongnu.org; Mon, 05 Feb 2018 16:01:47 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:56598) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eintY-0003Sb-AG for qemu-devel@nongnu.org; Mon, 05 Feb 2018 16:01:44 -0500 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w15KxUYP054092 for ; Mon, 5 Feb 2018 16:01:43 -0500 Received: from e12.ny.us.ibm.com (e12.ny.us.ibm.com [129.33.205.202]) by mx0a-001b2d01.pphosted.com with ESMTP id 2fxud30gaa-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 05 Feb 2018 16:01:42 -0500 Received: from localhost by e12.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 5 Feb 2018 16:01:41 -0500 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) by e12.ny.us.ibm.com (146.89.104.199) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 5 Feb 2018 16:01:39 -0500 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w15L1c4140501400; Mon, 5 Feb 2018 21:01:38 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EB82111204B; Mon, 5 Feb 2018 15:59:41 -0500 (EST) Received: from collin-ThinkPad-W541.pok.ibm.com (unknown [9.56.58.149]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id E752C112054; Mon, 5 Feb 2018 15:59:41 -0500 (EST) From: "Collin L. Walling" To: qemu-s390x@nongnu.org, qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 15:57:23 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517864246-11101-1-git-send-email-walling@linux.vnet.ibm.com> References: <1517864246-11101-1-git-send-email-walling@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18020521-0048-0000-0000-00000232B6E5 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008478; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000248; SDB=6.00985441; UDB=6.00500015; IPR=6.00764812; BA=6.00005812; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00019386; XFM=3.00000015; UTC=2018-02-05 21:01:40 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18020521-0049-0000-0000-0000440743D2 Message-Id: <1517864246-11101-10-git-send-email-walling@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-02-05_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 lowpriorityscore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1802050259 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH v5 09/12] s390-ccw: print zipl boot menu X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: frankja@linux.vnet.ibm.com, thuth@redhat.com, cohuck@redhat.com, david@redhat.com, alifm@linux.vnet.ibm.com, mihajlov@linux.vnet.ibm.com, borntraeger@de.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When the boot menu options are present and the guest's disk has been configured by the zipl tool, then the user will be presented with an interactive boot menu with labeled entries. An example of what the menu might look like: zIPL v1.37.1-build-20170714 interactive boot menu. 0. default (linux-4.13.0) 1. linux-4.13.0 2. performance 3. kvm Signed-off-by: Collin L. Walling Reviewed-by: Thomas Huth --- pc-bios/s390-ccw/menu.c | 49 +++++++++++++++++++++++++++++++++++++++++++++= +++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/pc-bios/s390-ccw/menu.c b/pc-bios/s390-ccw/menu.c index 4ba2684..e9e283f 100644 --- a/pc-bios/s390-ccw/menu.c +++ b/pc-bios/s390-ccw/menu.c @@ -10,13 +10,60 @@ */ =20 #include "menu.h" +#include "s390-ccw.h" =20 static uint8_t flags; static uint64_t timeout; =20 +/* Offsets from zipl fields to zipl banner start */ +#define ZIPL_TIMEOUT_OFFSET 138 +#define ZIPL_FLAG_OFFSET 140 + +static int get_boot_index(int entries) +{ + return 0; /* Implemented next patch */ +} + +static void zipl_println(const char *data, size_t len) +{ + char buf[len + 2]; + + ebcdic_to_ascii(data, buf, len); + buf[len] =3D '\n'; + buf[len + 1] =3D '\0'; + + sclp_print(buf); +} + int menu_get_zipl_boot_index(const void *stage2, int offset) { - return 0; /* implemented next patch */ + const char *data =3D stage2 + offset; + uint16_t zipl_flag =3D *(uint16_t *)(data - ZIPL_FLAG_OFFSET); + uint16_t zipl_timeout =3D *(uint16_t *)(data - ZIPL_TIMEOUT_OFFSET); + size_t len; + int ct; + + if (flags & BOOT_MENU_FLAG_ZIPL_OPTS) { + if (!zipl_flag) { + return 0; /* Boot default */ + } + timeout =3D zipl_timeout; + } + + /* Print and count all menu items, including the banner */ + for (ct =3D 0; *data; ct++) { + len =3D strlen(data); + zipl_println(data, len); + data +=3D len + 1; + + if (ct < 2) { + sclp_print("\n"); + } + } + + sclp_print("\n"); + + return get_boot_index(ct - 1); } =20 void menu_set_parms(uint8_t boot_menu_flag, uint16_t boot_menu_timeout) --=20 2.7.4 From nobody Sun Apr 28 20:00:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517865226688158.62243497869463; Mon, 5 Feb 2018 13:13:46 -0800 (PST) Received: from localhost ([::1]:36725 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eio5B-0007KT-P0 for importer@patchew.org; Mon, 05 Feb 2018 16:13:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47574) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eintc-0005ko-0J for qemu-devel@nongnu.org; Mon, 05 Feb 2018 16:01:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eintY-0003Tc-Lv for qemu-devel@nongnu.org; Mon, 05 Feb 2018 16:01:48 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:57522 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eintY-0003TI-Ge for qemu-devel@nongnu.org; Mon, 05 Feb 2018 16:01:44 -0500 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w15KxU1h130276 for ; Mon, 5 Feb 2018 16:01:43 -0500 Received: from e13.ny.us.ibm.com (e13.ny.us.ibm.com [129.33.205.203]) by mx0b-001b2d01.pphosted.com with ESMTP id 2fxvv1verc-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 05 Feb 2018 16:01:42 -0500 Received: from localhost by e13.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 5 Feb 2018 16:01:42 -0500 Received: from b01cxnp23033.gho.pok.ibm.com (9.57.198.28) by e13.ny.us.ibm.com (146.89.104.200) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 5 Feb 2018 16:01:40 -0500 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w15L1dN553870796; Mon, 5 Feb 2018 21:01:39 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0FF6A112047; Mon, 5 Feb 2018 15:59:43 -0500 (EST) Received: from collin-ThinkPad-W541.pok.ibm.com (unknown [9.56.58.149]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id EC686112034; Mon, 5 Feb 2018 15:59:42 -0500 (EST) From: "Collin L. Walling" To: qemu-s390x@nongnu.org, qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 15:57:24 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517864246-11101-1-git-send-email-walling@linux.vnet.ibm.com> References: <1517864246-11101-1-git-send-email-walling@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18020521-0008-0000-0000-000002CD02B5 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008478; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000248; SDB=6.00985441; UDB=6.00500014; IPR=6.00764812; BA=6.00005812; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00019386; XFM=3.00000015; UTC=2018-02-05 21:01:41 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18020521-0009-0000-0000-00003828FDE4 Message-Id: <1517864246-11101-11-git-send-email-walling@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-02-05_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1802050259 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH v5 10/12] s390-ccw: read user input for boot index via the SCLP console X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: frankja@linux.vnet.ibm.com, thuth@redhat.com, cohuck@redhat.com, david@redhat.com, alifm@linux.vnet.ibm.com, mihajlov@linux.vnet.ibm.com, borntraeger@de.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Implements an sclp_read function to capture input from the console and a wrapper function that handles parsing certain characters and adding input to a buffer. The input is checked for any erroneous values and is handled appropriately. A prompt will persist until input is entered or the timeout expires (if one was set). Example: Please choose (default will boot in 10 seconds): Correct input will boot the respective boot index. If the user's input is empty, 0, or if the timeout expires, then the default zipl entry will be chosen. If the input is within the range of available boot entries, then the selection will be booted. Any erroneous input will cancel the timeout and re-prompt the user. Signed-off-by: Collin L. Walling Reviewed-by: Thomas Huth --- pc-bios/s390-ccw/menu.c | 150 ++++++++++++++++++++++++++++++++++++++++= +++- pc-bios/s390-ccw/s390-ccw.h | 3 + pc-bios/s390-ccw/sclp.c | 19 ++++++ pc-bios/s390-ccw/virtio.c | 2 +- 4 files changed, 170 insertions(+), 4 deletions(-) diff --git a/pc-bios/s390-ccw/menu.c b/pc-bios/s390-ccw/menu.c index e9e283f..85d285f 100644 --- a/pc-bios/s390-ccw/menu.c +++ b/pc-bios/s390-ccw/menu.c @@ -12,16 +12,160 @@ #include "menu.h" #include "s390-ccw.h" =20 -static uint8_t flags; -static uint64_t timeout; +#define KEYCODE_NO_INP '\0' +#define KEYCODE_ESCAPE '\033' +#define KEYCODE_BACKSP '\177' +#define KEYCODE_ENTER '\r' =20 /* Offsets from zipl fields to zipl banner start */ #define ZIPL_TIMEOUT_OFFSET 138 #define ZIPL_FLAG_OFFSET 140 =20 +#define TOD_CLOCK_SECOND 0xf4240000 + +static uint8_t flags; +static uint64_t timeout; + +static inline void enable_clock_int(void) +{ + uint64_t tmp =3D 0; + + asm volatile( + "stctg 0,0,%0\n" + "oi 6+%0, 0x8\n" + "lctlg 0,0,%0" + : : "Q" (tmp) : "memory" + ); +} + +static inline void disable_clock_int(void) +{ + uint64_t tmp =3D 0; + + asm volatile( + "stctg 0,0,%0\n" + "ni 6+%0, 0xf7\n" + "lctlg 0,0,%0" + : : "Q" (tmp) : "memory" + ); +} + +static inline void set_clock_comparator(uint64_t time) +{ + asm volatile("sckc %0" : : "Q" (time)); +} + +static inline bool check_clock_int(void) +{ + uint16_t *code =3D (uint16_t *)0x86; /* low-core external interrupt co= de */ + + consume_sclp_int(); + + return *code =3D=3D 0x1004; +} + +static int read_prompt(char *buf, size_t len) +{ + char inp[2] =3D {}; + uint8_t idx =3D 0; + uint64_t time; + + if (timeout) { + time =3D get_clock() + timeout * TOD_CLOCK_SECOND; + set_clock_comparator(time); + enable_clock_int(); + timeout =3D 0; + } + + while (!check_clock_int()) { + + sclp_read(inp, 1); /* Process only one character at a time */ + + switch (inp[0]) { + case KEYCODE_NO_INP: + case KEYCODE_ESCAPE: + continue; + case KEYCODE_BACKSP: + if (idx > 0) { + buf[--idx] =3D 0; + sclp_print("\b \b"); + } + continue; + case KEYCODE_ENTER: + disable_clock_int(); + return idx; + default: + /* Echo input and add to buffer */ + if (idx < len) { + buf[idx++] =3D inp[0]; + sclp_print(inp); + } + } + } + + disable_clock_int(); + *buf =3D 0; + + return 0; +} + +static int get_index(void) +{ + char buf[10]; + int len; + int i; + + memset(buf, 0, sizeof(buf)); + + len =3D read_prompt(buf, sizeof(buf)); + + /* If no input, boot default */ + if (len =3D=3D 0) { + return 0; + } + + /* Check for erroneous input */ + for (i =3D 0; i < len; i++) { + if (!isdigit(buf[i])) { + return -1; + } + } + + return atoui(buf); +} + +static void boot_menu_prompt(bool retry) +{ + char tmp[6]; + + if (retry) { + sclp_print("\nError: undefined configuration" + "\nPlease choose:\n"); + } else if (timeout > 0) { + sclp_print("Please choose (default will boot in "); + sclp_print(itostr(timeout, tmp, sizeof(tmp))); + sclp_print(" seconds):\n"); + } else { + sclp_print("Please choose:\n"); + } +} + static int get_boot_index(int entries) { - return 0; /* Implemented next patch */ + int boot_index; + bool retry =3D false; + char tmp[5]; + + do { + boot_menu_prompt(retry); + boot_index =3D get_index(); + retry =3D true; + } while (boot_index < 0 || boot_index >=3D entries); + + sclp_print("\nBooting entry #"); + sclp_print(itostr(boot_index, tmp, sizeof(tmp))); + + return boot_index; } =20 static void zipl_println(const char *data, size_t len) diff --git a/pc-bios/s390-ccw/s390-ccw.h b/pc-bios/s390-ccw/s390-ccw.h index 25d4d21..9249cb2 100644 --- a/pc-bios/s390-ccw/s390-ccw.h +++ b/pc-bios/s390-ccw/s390-ccw.h @@ -71,6 +71,8 @@ unsigned int get_loadparm_index(void); void sclp_print(const char *string); void sclp_setup(void); void sclp_get_loadparm_ascii(char *loadparm); +int sclp_read(char *str, size_t count); +void sclp_clear_write_mask(void); =20 /* virtio.c */ unsigned long virtio_load_direct(ulong rec_list1, ulong rec_list2, @@ -79,6 +81,7 @@ bool virtio_is_supported(SubChannelId schid); void virtio_blk_setup_device(SubChannelId schid); int virtio_read(ulong sector, void *load_addr); int enable_mss_facility(void); +u64 get_clock(void); ulong get_second(void); =20 /* bootmap.c */ diff --git a/pc-bios/s390-ccw/sclp.c b/pc-bios/s390-ccw/sclp.c index 486fce1..5902d5b 100644 --- a/pc-bios/s390-ccw/sclp.c +++ b/pc-bios/s390-ccw/sclp.c @@ -101,3 +101,22 @@ void sclp_get_loadparm_ascii(char *loadparm) ebcdic_to_ascii((char *) sccb->loadparm, loadparm, 8); } } + +int sclp_read(char *str, size_t count) +{ + ReadEventData *sccb =3D (void *)_sccb; + char *buf =3D (char *)(&sccb->ebh) + 7; + + /* If count exceeds max buffer size, then restrict it to the max size = */ + if (count > SCCB_SIZE - 8) { + count =3D SCCB_SIZE - 8; + } + + sccb->h.length =3D SCCB_SIZE; + sccb->h.function_code =3D SCLP_UNCONDITIONAL_READ; + + sclp_service_call(SCLP_CMD_READ_EVENT_DATA, sccb); + memcpy(str, buf, count); + + return sccb->ebh.length - 7; +} diff --git a/pc-bios/s390-ccw/virtio.c b/pc-bios/s390-ccw/virtio.c index c890a03..817e7f5 100644 --- a/pc-bios/s390-ccw/virtio.c +++ b/pc-bios/s390-ccw/virtio.c @@ -176,7 +176,7 @@ void vring_send_buf(VRing *vr, void *p, int len, int fl= ags) } } =20 -static u64 get_clock(void) +u64 get_clock(void) { u64 r; =20 --=20 2.7.4 From nobody Sun Apr 28 20:00:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517865105047507.1530040627881; Mon, 5 Feb 2018 13:11:45 -0800 (PST) Received: from localhost ([::1]:36576 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eio3E-0005ga-7j for importer@patchew.org; Mon, 05 Feb 2018 16:11:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47599) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eintd-0005ku-PG for qemu-devel@nongnu.org; Mon, 05 Feb 2018 16:01:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1einta-0003VS-M4 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 16:01:49 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:41300 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1einta-0003V9-H8 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 16:01:46 -0500 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w15KxS4K010011 for ; Mon, 5 Feb 2018 16:01:45 -0500 Received: from e11.ny.us.ibm.com (e11.ny.us.ibm.com [129.33.205.201]) by mx0b-001b2d01.pphosted.com with ESMTP id 2fxxmt0cyh-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 05 Feb 2018 16:01:44 -0500 Received: from localhost by e11.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 5 Feb 2018 16:01:44 -0500 Received: from b01cxnp22035.gho.pok.ibm.com (9.57.198.25) by e11.ny.us.ibm.com (146.89.104.198) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 5 Feb 2018 16:01:41 -0500 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w15L1ewu47906942; Mon, 5 Feb 2018 21:01:40 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 153F1112034; Mon, 5 Feb 2018 15:59:44 -0500 (EST) Received: from collin-ThinkPad-W541.pok.ibm.com (unknown [9.56.58.149]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id 0703A11204B; Mon, 5 Feb 2018 15:59:44 -0500 (EST) From: "Collin L. Walling" To: qemu-s390x@nongnu.org, qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 15:57:25 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517864246-11101-1-git-send-email-walling@linux.vnet.ibm.com> References: <1517864246-11101-1-git-send-email-walling@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18020521-2213-0000-0000-000002680BE6 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008478; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000248; SDB=6.00985441; UDB=6.00500015; IPR=6.00764812; BA=6.00005812; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00019386; XFM=3.00000015; UTC=2018-02-05 21:01:43 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18020521-2214-0000-0000-000059031794 Message-Id: <1517864246-11101-12-git-send-email-walling@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-02-05_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1802050259 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH v5 11/12] s390-ccw: clear pending irqs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: frankja@linux.vnet.ibm.com, thuth@redhat.com, cohuck@redhat.com, david@redhat.com, alifm@linux.vnet.ibm.com, mihajlov@linux.vnet.ibm.com, borntraeger@de.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" It is possible while waiting for multiple types of external interrupts that we might have pending irqs remaining between irq consumption and irq disabling. Those interrupts could propagate to the guest after IPL completes and cause unwanted behavior. To avoid this, we clear the write event mask to prevent further service interrupts from ASCII events and then consume all pending irqs for a miniscule duration. Once finished, we reset the write event mask and resume business as usual. Signed-off-by: Collin L. Walling --- pc-bios/s390-ccw/menu.c | 16 ++++++++++++++++ pc-bios/s390-ccw/sclp.c | 12 ++++++++++++ 2 files changed, 28 insertions(+) diff --git a/pc-bios/s390-ccw/menu.c b/pc-bios/s390-ccw/menu.c index 85d285f..971f6b6 100644 --- a/pc-bios/s390-ccw/menu.c +++ b/pc-bios/s390-ccw/menu.c @@ -64,6 +64,20 @@ static inline bool check_clock_int(void) return *code =3D=3D 0x1004; } =20 +static void clear_pending_irqs(void) +{ + uint64_t time =3D 50 * TOD_CLOCK_SECOND / 0x3e8; + + sclp_clear_write_mask(); + + set_clock_comparator(get_clock() + time); + enable_clock_int(); + consume_sclp_int(); + disable_clock_int(); + + sclp_setup(); /* re-enable write mask */ +} + static int read_prompt(char *buf, size_t len) { char inp[2] =3D {}; @@ -165,6 +179,8 @@ static int get_boot_index(int entries) sclp_print("\nBooting entry #"); sclp_print(itostr(boot_index, tmp, sizeof(tmp))); =20 + clear_pending_irqs(); + return boot_index; } =20 diff --git a/pc-bios/s390-ccw/sclp.c b/pc-bios/s390-ccw/sclp.c index 5902d5b..025eb2d 100644 --- a/pc-bios/s390-ccw/sclp.c +++ b/pc-bios/s390-ccw/sclp.c @@ -46,6 +46,18 @@ static int sclp_service_call(unsigned int command, void = *sccb) return 0; } =20 +void sclp_clear_write_mask(void) +{ + WriteEventMask *sccb =3D (void *)_sccb; + + sccb->h.length =3D sizeof(WriteEventMask); + sccb->mask_length =3D sizeof(unsigned int); + sccb->cp_receive_mask =3D 0; + sccb->cp_send_mask =3D 0; + + sclp_service_call(SCLP_CMD_WRITE_EVENT_MASK, sccb); +} + static void sclp_set_write_mask(void) { WriteEventMask *sccb =3D (void *)_sccb; --=20 2.7.4 From nobody Sun Apr 28 20:00:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517865362469289.0731897661367; Mon, 5 Feb 2018 13:16:02 -0800 (PST) Received: from localhost ([::1]:37151 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eio7F-00013t-0y for importer@patchew.org; Mon, 05 Feb 2018 16:15:53 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47637) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eintg-0005oR-Jn for qemu-devel@nongnu.org; Mon, 05 Feb 2018 16:01:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eintc-0003XF-PE for qemu-devel@nongnu.org; Mon, 05 Feb 2018 16:01:52 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:59598) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eintc-0003Wd-HO for qemu-devel@nongnu.org; Mon, 05 Feb 2018 16:01:48 -0500 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w15L0auX111974 for ; Mon, 5 Feb 2018 16:01:47 -0500 Received: from e15.ny.us.ibm.com (e15.ny.us.ibm.com [129.33.205.205]) by mx0a-001b2d01.pphosted.com with ESMTP id 2fxwfbbbme-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 05 Feb 2018 16:01:46 -0500 Received: from localhost by e15.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 5 Feb 2018 16:01:45 -0500 Received: from b01cxnp22035.gho.pok.ibm.com (9.57.198.25) by e15.ny.us.ibm.com (146.89.104.202) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 5 Feb 2018 16:01:42 -0500 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w15L1fB444564682; Mon, 5 Feb 2018 21:01:41 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1A503112057; Mon, 5 Feb 2018 15:59:45 -0500 (EST) Received: from collin-ThinkPad-W541.pok.ibm.com (unknown [9.56.58.149]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id 0C52F112034; Mon, 5 Feb 2018 15:59:45 -0500 (EST) From: "Collin L. Walling" To: qemu-s390x@nongnu.org, qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 15:57:26 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517864246-11101-1-git-send-email-walling@linux.vnet.ibm.com> References: <1517864246-11101-1-git-send-email-walling@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18020521-0036-0000-0000-000002B98FC7 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008478; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000248; SDB=6.00985441; UDB=6.00500015; IPR=6.00764812; BA=6.00005812; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00019386; XFM=3.00000015; UTC=2018-02-05 21:01:43 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18020521-0037-0000-0000-0000433CDD37 Message-Id: <1517864246-11101-13-git-send-email-walling@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-02-05_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1802050259 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH v5 12/12] s390-ccw: interactive boot menu for scsi X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: frankja@linux.vnet.ibm.com, thuth@redhat.com, cohuck@redhat.com, david@redhat.com, alifm@linux.vnet.ibm.com, mihajlov@linux.vnet.ibm.com, borntraeger@de.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Interactive boot menu for scsi. This follows a similar procedure as the interactive menu for eckd dasd. An example follows: s390x Enumerated Boot Menu. 3 entries detected. Select from index 0 to 2. Signed-off-by: Collin L. Walling Reviewed-by: Thomas Huth --- pc-bios/s390-ccw/bootmap.c | 4 ++++ pc-bios/s390-ccw/main.c | 1 + pc-bios/s390-ccw/menu.c | 14 ++++++++++++++ pc-bios/s390-ccw/menu.h | 1 + 4 files changed, 20 insertions(+) diff --git a/pc-bios/s390-ccw/bootmap.c b/pc-bios/s390-ccw/bootmap.c index adbef41..13b2936 100644 --- a/pc-bios/s390-ccw/bootmap.c +++ b/pc-bios/s390-ccw/bootmap.c @@ -567,6 +567,10 @@ static void ipl_scsi(void) =20 debug_print_int("program table entries", program_table_entries); =20 + if (menu_check_flags(BOOT_MENU_FLAG_CMD_OPTS)) { + loadparm =3D menu_get_enum_boot_index(program_table_entries); + } + zipl_run(&bmt->bte[loadparm].scsi); /* no return */ } =20 diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c index 76d58cc..3548cd4 100644 --- a/pc-bios/s390-ccw/main.c +++ b/pc-bios/s390-ccw/main.c @@ -92,6 +92,7 @@ static void menu_setup(void) =20 switch (iplb.pbt) { case S390_IPL_TYPE_CCW: + case S390_IPL_TYPE_QEMU_SCSI: menu_set_parms(qipl.boot_menu_flags, qipl.boot_menu_timeout); return; } diff --git a/pc-bios/s390-ccw/menu.c b/pc-bios/s390-ccw/menu.c index 971f6b6..41a59e3 100644 --- a/pc-bios/s390-ccw/menu.c +++ b/pc-bios/s390-ccw/menu.c @@ -226,6 +226,20 @@ int menu_get_zipl_boot_index(const void *stage2, int o= ffset) return get_boot_index(ct - 1); } =20 +int menu_get_enum_boot_index(int entries) +{ + char tmp[4]; + + sclp_print("s390x Enumerated Boot Menu.\n\n"); + + sclp_print(itostr(entries, tmp, sizeof(tmp))); + sclp_print(" entries detected. Select from boot index 0 to "); + sclp_print(itostr(entries - 1, tmp, sizeof(tmp))); + sclp_print(".\n\n"); + + return get_boot_index(entries); +} + void menu_set_parms(uint8_t boot_menu_flag, uint16_t boot_menu_timeout) { flags =3D boot_menu_flag; diff --git a/pc-bios/s390-ccw/menu.h b/pc-bios/s390-ccw/menu.h index e8e042f..c08e4cf 100644 --- a/pc-bios/s390-ccw/menu.h +++ b/pc-bios/s390-ccw/menu.h @@ -18,6 +18,7 @@ #define BOOT_MENU_FLAG_ZIPL_OPTS 0x40 =20 int menu_get_zipl_boot_index(const void *stage2, int offset); +int menu_get_enum_boot_index(int entries); void menu_set_parms(uint8_t boot_menu_flags, uint16_t boot_menu_timeout); bool menu_check_flags(uint8_t check_flags); =20 --=20 2.7.4