From nobody Thu May 2 00:27:21 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 1516034983763323.54841888178373; Mon, 15 Jan 2018 08:49:43 -0800 (PST) Received: from localhost ([::1]:47020 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eb7x8-0007oy-W3 for importer@patchew.org; Mon, 15 Jan 2018 11:49:43 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57304) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eb7sm-0004v7-Cb for qemu-devel@nongnu.org; Mon, 15 Jan 2018 11:45:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eb7si-00020q-AX for qemu-devel@nongnu.org; Mon, 15 Jan 2018 11:45:12 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:39298) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eb7si-0001zd-1Z for qemu-devel@nongnu.org; Mon, 15 Jan 2018 11:45:08 -0500 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w0FGdjEx137115 for ; Mon, 15 Jan 2018 11:45:06 -0500 Received: from e32.co.us.ibm.com (e32.co.us.ibm.com [32.97.110.150]) by mx0a-001b2d01.pphosted.com with ESMTP id 2fgucuw76j-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 15 Jan 2018 11:45:06 -0500 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 15 Jan 2018 09:45:05 -0700 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 15 Jan 2018 09:45:03 -0700 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w0FGj3nc58589380; Mon, 15 Jan 2018 09:45:03 -0700 Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2A42F6E03D; Mon, 15 Jan 2018 09:45:03 -0700 (MST) Received: from collin-ThinkPad-W541.pok.ibm.com (unknown [9.56.58.154]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP id 75DD36E03F; Mon, 15 Jan 2018 09:45:02 -0700 (MST) From: "Collin L. Walling" To: qemu-s390x@nongnu.org, qemu-devel@nongnu.org Date: Mon, 15 Jan 2018 11:44:18 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516034665-27606-1-git-send-email-walling@linux.vnet.ibm.com> References: <1516034665-27606-1-git-send-email-walling@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18011516-0004-0000-0000-000013851C1A X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008383; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000245; SDB=6.00975440; UDB=6.00494388; IPR=6.00755367; BA=6.00005778; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00019046; XFM=3.00000015; UTC=2018-01-15 16:45:05 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18011516-0005-0000-0000-000085AC60B3 Message-Id: <1516034665-27606-2-git-send-email-walling@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-01-15_08:, , 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=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1801150238 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 v3 1/8] 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, 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 atoi Added non-C standard function: itostr 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 | 83 ++++++++++++++++++++++++++++++++++++++++++= ++++ pc-bios/s390-ccw/libc.h | 31 +++++++++++++++++ pc-bios/s390-ccw/main.c | 17 +--------- pc-bios/s390-ccw/sclp.c | 10 +----- 7 files changed, 120 insertions(+), 43 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 67a6123..6f8e30f 100644 --- a/pc-bios/s390-ccw/bootmap.c +++ b/pc-bios/s390-ccw/bootmap.c @@ -512,7 +512,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 */ @@ -641,7 +641,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 cf99a4c..4980838 100644 --- a/pc-bios/s390-ccw/bootmap.h +++ b/pc-bios/s390-ccw/bootmap.h @@ -310,20 +310,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; @@ -416,7 +402,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..3ce0fb7 --- /dev/null +++ b/pc-bios/s390-ccw/libc.c @@ -0,0 +1,83 @@ +/* + * libc-style definitions and functions + * + * 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" + +/** + * atoi: + * @str: the string to be converted. + * + * Given a string @str, convert it to an integer. Any non-numerical value + * will terminate the conversion. + * + * Returns: an integer converted from the string @str. + */ +int atoi(const char *str) +{ + int i; + int val =3D 0; + + for (i =3D 0; str[i]; i++) { + char c =3D str[i]; + if (!isdigit(c)) { + break; + } + val *=3D 10; + val +=3D c - '0'; + } + + return val; +} + +/** + * itostr: + * @num: the integer 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. + * + * Returns: the string @str of the converted integer @num. + */ +static char *_itostr(int num, char *str, size_t len) +{ + long num_len =3D 1; + int tmp =3D num; + int i; + + /* Count length of num */ + while ((tmp /=3D 10) > 0) { + num_len++; + } + + /* Check if we have enough space for num and null */ + if (len <=3D num_len) { + return 0; + } + + /* Convert int to string */ + for (i =3D num_len - 1; i >=3D 0; i--) { + str[i] =3D num % 10 + '0'; + num /=3D 10; + } + + str[num_len] =3D '\0'; + + return str; +} + +char *itostr(int num, char *str, size_t len) +{ + char *tmp =3D _itostr(num, str, len); + IPL_assert(tmp !=3D 0, "array too small for itostr conversion"); + return tmp; +} diff --git a/pc-bios/s390-ccw/libc.h b/pc-bios/s390-ccw/libc.h index 0142ea8..00268e3 100644 --- a/pc-bios/s390-ccw/libc.h +++ b/pc-bios/s390-ccw/libc.h @@ -42,4 +42,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) +{ + 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 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'); +} + +int atoi(const char *str); +char *itostr(int 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..a8ef120 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 atoi(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 Thu May 2 00:27:21 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 1516034829735257.3091052021542; Mon, 15 Jan 2018 08:47:09 -0800 (PST) Received: from localhost ([::1]:46981 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eb7ub-00060g-CC for importer@patchew.org; Mon, 15 Jan 2018 11:47:05 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57322) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eb7so-0004wK-Rc for qemu-devel@nongnu.org; Mon, 15 Jan 2018 11:45:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eb7sk-000239-Ot for qemu-devel@nongnu.org; Mon, 15 Jan 2018 11:45:14 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:33210 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 1eb7sk-00022n-Jc for qemu-devel@nongnu.org; Mon, 15 Jan 2018 11:45:10 -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 w0FGfFKO132173 for ; Mon, 15 Jan 2018 11:45:08 -0500 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0b-001b2d01.pphosted.com with ESMTP id 2fgvs6sw0c-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 15 Jan 2018 11:45:08 -0500 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 15 Jan 2018 09:45:07 -0700 Received: from b03cxnp07028.gho.boulder.ibm.com (9.17.130.15) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 15 Jan 2018 09:45:05 -0700 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w0FGj54g14221722; Mon, 15 Jan 2018 09:45:05 -0700 Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E9DB96E03D; Mon, 15 Jan 2018 09:45:04 -0700 (MST) Received: from collin-ThinkPad-W541.pok.ibm.com (unknown [9.56.58.154]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP id 4B0066E035; Mon, 15 Jan 2018 09:45:04 -0700 (MST) From: "Collin L. Walling" To: qemu-s390x@nongnu.org, qemu-devel@nongnu.org Date: Mon, 15 Jan 2018 11:44:19 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516034665-27606-1-git-send-email-walling@linux.vnet.ibm.com> References: <1516034665-27606-1-git-send-email-walling@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18011516-8235-0000-0000-00000CDF5713 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008383; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000245; SDB=6.00975440; UDB=6.00494388; IPR=6.00755367; BA=6.00005778; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00019046; XFM=3.00000015; UTC=2018-01-15 16:45:07 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18011516-8236-0000-0000-00003F420762 Message-Id: <1516034665-27606-3-git-send-email-walling@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-01-15_08:, , 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-1801150238 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 v3 2/8] s390-ccw: ipl structs for eckd cdl/ldl 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, 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. Also introduce structs for IPL stages 1 and 1b and for disk geometry. Signed-off-by: Collin L. Walling Acked-by: Janosch Frank --- pc-bios/s390-ccw/bootmap.c | 29 +++++++++++++----------- pc-bios/s390-ccw/bootmap.h | 55 +++++++++++++++++++++++++++++++++---------= ---- 2 files changed, 56 insertions(+), 28 deletions(-) diff --git a/pc-bios/s390-ccw/bootmap.c b/pc-bios/s390-ccw/bootmap.c index 6f8e30f..29915e4 100644 --- a/pc-bios/s390-ccw/bootmap.c +++ b/pc-bios/s390-ccw/bootmap.c @@ -221,9 +221,9 @@ static void run_eckd_boot_script(block_number_t mbr_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 block_nr; + block_number_t mbr_block_nr; =20 /* we have just read the block #0 and recognized it as "IPL1" */ sclp_print("CDL\n"); @@ -231,16 +231,13 @@ 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."); 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)); - 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 +246,10 @@ static void ipl_eckd_cdl(void) "Invalid magic of volser block"); print_volser(vlbl->f.volser); =20 - run_eckd_boot_script(block_nr); + /* save pointer to Boot Script */ + mbr_block_nr =3D eckd_block_num((void *)&mbr->blockptr); + + run_eckd_boot_script(mbr_block_nr); /* no return */ } =20 @@ -280,8 +280,8 @@ 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; - BootInfo *bip =3D (void *)(sec + 0x70); /* BootInfo is MBR for LDL */ + block_number_t mbr_block_nr; + EckdLdlIpl1 *ipl1 =3D (void *)sec; =20 if (mode !=3D ECKD_LDL_UNLABELED) { print_eckd_ldl_msg(mode); @@ -292,15 +292,18 @@ 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->boot_info.magic, ZIPL_MAGIC)) { return; /* not applicable layout */ } sclp_print("unlabeled LDL.\n"); } - verify_boot_info(bip); + verify_boot_info(&ipl1->boot_info); + + /* save pointer to Boot Script */ + mbr_block_nr =3D + eckd_block_num((void *)&ipl1->boot_info.bp.ipl.bm_ptr.eckd.bptr); =20 - block_nr =3D eckd_block_num((void *)&(bip->bp.ipl.bm_ptr.eckd.bptr)); - run_eckd_boot_script(block_nr); + run_eckd_boot_script(mbr_block_nr); /* no return */ } =20 diff --git a/pc-bios/s390-ccw/bootmap.h b/pc-bios/s390-ccw/bootmap.h index 4980838..df956f2 100644 --- a/pc-bios/s390-ccw/bootmap.h +++ b/pc-bios/s390-ccw/bootmap.h @@ -226,22 +226,47 @@ 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; +/* + * Structs for IPL + */ +#define STAGE2_BLK_CNT_MAX 24 /* Stage 1b can load up to 24 blocks */ =20 -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; +typedef struct EckdCdlIpl1 { + uint8_t key[4]; /* =3D=3D "IPL1" */ + uint8_t data[24]; +} __attribute__((packed)) EckdCdlIpl1; + +typedef struct EckdSeekArg { + uint16_t pad; + uint16_t cyl; + uint16_t head; + uint8_t sec; + 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" */ + struct EckdStage1 stage1; + XEckdMbr mbr; + uint8_t reserved[24]; +} __attribute__((packed)) EckdCdlIpl2; + +typedef struct EckdLdlIpl1 { + uint8_t reserved[24]; + struct EckdStage1 stage1; + BootInfo boot_info; /* 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 Thu May 2 00:27:21 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 1516034833094239.68126856683546; Mon, 15 Jan 2018 08:47:13 -0800 (PST) Received: from localhost ([::1]:46984 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eb7ug-00064Y-6q for importer@patchew.org; Mon, 15 Jan 2018 11:47:10 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57352) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eb7sq-0004xU-5M for qemu-devel@nongnu.org; Mon, 15 Jan 2018 11:45:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eb7sp-00027v-1Q for qemu-devel@nongnu.org; Mon, 15 Jan 2018 11:45:16 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:42640) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eb7so-00026q-Pb for qemu-devel@nongnu.org; Mon, 15 Jan 2018 11:45:14 -0500 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w0FGiuoR008257 for ; Mon, 15 Jan 2018 11:45:11 -0500 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0a-001b2d01.pphosted.com with ESMTP id 2fh00agacv-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 15 Jan 2018 11:45:10 -0500 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 15 Jan 2018 09:45:09 -0700 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 15 Jan 2018 09:45:07 -0700 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w0FGj6Cv6685130; Mon, 15 Jan 2018 09:45:06 -0700 Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A0D636E045; Mon, 15 Jan 2018 09:45:06 -0700 (MST) Received: from collin-ThinkPad-W541.pok.ibm.com (unknown [9.56.58.154]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP id 0CB086E03A; Mon, 15 Jan 2018 09:45:05 -0700 (MST) From: "Collin L. Walling" To: qemu-s390x@nongnu.org, qemu-devel@nongnu.org Date: Mon, 15 Jan 2018 11:44:20 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516034665-27606-1-git-send-email-walling@linux.vnet.ibm.com> References: <1516034665-27606-1-git-send-email-walling@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18011516-8235-0000-0000-00000CDF5717 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008383; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000245; SDB=6.00975440; UDB=6.00494388; IPR=6.00755367; BA=6.00005778; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00019046; XFM=3.00000015; UTC=2018-01-15 16:45:09 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18011516-8236-0000-0000-00003F420769 Message-Id: <1516034665-27606-4-git-send-email-walling@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-01-15_08:, , 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-1801150238 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 v3 3/8] 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, 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. A loadparm other than 'prompt' will disable the menu and just boot the specified entry. Signed-off-by: Collin L. Walling Reviewed-by: Janosch Frank Reviewed-by: Thomas Huth --- hw/s390x/ipl.c | 54 +++++++++++++++++++++++++++++++++++++++++++++= ++++ hw/s390x/ipl.h | 11 ++++++++-- pc-bios/s390-ccw/iplb.h | 8 ++++++-- 3 files changed, 69 insertions(+), 4 deletions(-) diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c index 0d06fc1..81ba9ed 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,55 @@ 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: + flags =3D &iplb->ccw.boot_menu_flags; + timeout =3D &iplb->ccw.boot_menu_timeout; + break; + case S390_IPL_TYPE_QEMU_SCSI: + flags =3D &iplb->scsi.boot_menu_flags; + timeout =3D &iplb->scsi.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_BOOT_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."); + return; + } + + result /=3D 1000; /* Store timeout value as 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 +324,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 8a705e0..48e82cf 100644 --- a/hw/s390x/ipl.h +++ b/hw/s390x/ipl.h @@ -15,9 +15,14 @@ #include "hw/qdev.h" #include "cpu.h" =20 +#define BOOT_MENU_FLAG_BOOT_OPTS 0x80 +#define BOOT_MENU_FLAG_ZIPL_OPTS 0x40 + struct IplBlockCcw { uint64_t netboot_start_addr; - uint8_t reserved0[77]; + uint8_t reserved0[74]; + uint16_t boot_menu_timeout; + uint8_t boot_menu_flags; uint8_t ssid; uint16_t devno; uint8_t vm_flags; @@ -51,7 +56,9 @@ struct IplBlockQemuScsi { uint32_t lun; uint16_t target; uint16_t channel; - uint8_t reserved0[77]; + uint8_t reserved0[74]; + uint16_t boot_menu_timeout; + uint8_t boot_menu_flags; uint8_t ssid; uint16_t devno; } QEMU_PACKED; diff --git a/pc-bios/s390-ccw/iplb.h b/pc-bios/s390-ccw/iplb.h index 890aed9..fe909d2 100644 --- a/pc-bios/s390-ccw/iplb.h +++ b/pc-bios/s390-ccw/iplb.h @@ -14,7 +14,9 @@ =20 struct IplBlockCcw { uint64_t netboot_start_addr; - uint8_t reserved0[77]; + uint8_t reserved0[74]; + uint16_t boot_menu_timeout; + uint8_t boot_menu_flags; uint8_t ssid; uint16_t devno; uint8_t vm_flags; @@ -48,7 +50,9 @@ struct IplBlockQemuScsi { uint32_t lun; uint16_t target; uint16_t channel; - uint8_t reserved0[77]; + uint8_t reserved0[74]; + uint16_t boot_menu_timeout; + uint8_t boot_menu_flags; uint8_t ssid; uint16_t devno; } __attribute__ ((packed)); --=20 2.7.4 From nobody Thu May 2 00:27:21 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 1516034993233746.630914332686; Mon, 15 Jan 2018 08:49:53 -0800 (PST) Received: from localhost ([::1]:47027 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eb7xI-000815-FZ for importer@patchew.org; Mon, 15 Jan 2018 11:49:52 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57388) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eb7ss-0004zN-8p for qemu-devel@nongnu.org; Mon, 15 Jan 2018 11:45:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eb7sp-00028F-8q for qemu-devel@nongnu.org; Mon, 15 Jan 2018 11:45:18 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:51932 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 1eb7sp-00027V-4Q for qemu-devel@nongnu.org; Mon, 15 Jan 2018 11:45:15 -0500 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w0FGdbFD119015 for ; Mon, 15 Jan 2018 11:45:12 -0500 Received: from e33.co.us.ibm.com (e33.co.us.ibm.com [32.97.110.151]) by mx0b-001b2d01.pphosted.com with ESMTP id 2fgy4ktu8e-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 15 Jan 2018 11:45:12 -0500 Received: from localhost by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 15 Jan 2018 09:45:11 -0700 Received: from b03cxnp07029.gho.boulder.ibm.com (9.17.130.16) by e33.co.us.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 15 Jan 2018 09:45:08 -0700 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w0FGj8gA9175298; Mon, 15 Jan 2018 09:45:08 -0700 Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 613916E038; Mon, 15 Jan 2018 09:45:08 -0700 (MST) Received: from collin-ThinkPad-W541.pok.ibm.com (unknown [9.56.58.154]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP id C282F6E03A; Mon, 15 Jan 2018 09:45:07 -0700 (MST) From: "Collin L. Walling" To: qemu-s390x@nongnu.org, qemu-devel@nongnu.org Date: Mon, 15 Jan 2018 11:44:21 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516034665-27606-1-git-send-email-walling@linux.vnet.ibm.com> References: <1516034665-27606-1-git-send-email-walling@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18011516-0008-0000-0000-0000092C0B7E X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008383; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000245; SDB=6.00975440; UDB=6.00494388; IPR=6.00755367; BA=6.00005778; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00019046; XFM=3.00000015; UTC=2018-01-15 16:45:10 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18011516-0009-0000-0000-000045903075 Message-Id: <1516034665-27606-5-git-send-email-walling@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-01-15_08:, , 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-1801150238 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 v3 4/8] s390-ccw: interactive boot menu for eckd dasd (menu setup) 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, 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/iplb.h | 3 +++ pc-bios/s390-ccw/main.c | 21 +++++++++++++++++++++ pc-bios/s390-ccw/menu.c | 26 ++++++++++++++++++++++++++ pc-bios/s390-ccw/menu.h | 23 +++++++++++++++++++++++ 5 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/iplb.h b/pc-bios/s390-ccw/iplb.h index fe909d2..da29e6e 100644 --- a/pc-bios/s390-ccw/iplb.h +++ b/pc-bios/s390-ccw/iplb.h @@ -81,6 +81,9 @@ extern IplParameterBlock iplb __attribute__((__aligned__(= PAGE_SIZE))); #define S390_IPL_TYPE_CCW 0x02 #define S390_IPL_TYPE_QEMU_SCSI 0xff =20 +#define LOADPARM_PROMPT "PROMPT " +#define LOADPARM_EMPTY "........" + static inline bool store_iplb(IplParameterBlock *iplb) { register unsigned long addr asm("0") =3D (unsigned long) iplb; diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c index a8ef120..709e5ef 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 }; @@ -73,6 +74,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_BOOT_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(iplb.ccw.boot_menu_flags, iplb.ccw.boot_menu_timeou= t); + return; + } +} + static void virtio_setup(void) { Schib schib; @@ -113,6 +133,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..e15a7f2 --- /dev/null +++ b/pc-bios/s390-ccw/menu.c @@ -0,0 +1,26 @@ +/* + * QEMU S390 Interactive Boot Menu + * + * Copyright 2017 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..04b1db1 --- /dev/null +++ b/pc-bios/s390-ccw/menu.h @@ -0,0 +1,23 @@ +/* + * QEMU S390 Interactive Boot Menu + * + * Copyright 2017 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_BOOT_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 Thu May 2 00:27:21 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 1516035115091336.32774962260135; Mon, 15 Jan 2018 08:51:55 -0800 (PST) Received: from localhost ([::1]:47162 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eb7zG-0001Db-Cs for importer@patchew.org; Mon, 15 Jan 2018 11:51:54 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57424) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eb7su-00052g-Bg for qemu-devel@nongnu.org; Mon, 15 Jan 2018 11:45:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eb7sp-000294-UJ for qemu-devel@nongnu.org; Mon, 15 Jan 2018 11:45:20 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:40236) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eb7sp-00027P-Jz for qemu-devel@nongnu.org; Mon, 15 Jan 2018 11:45:15 -0500 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w0FGgT6N146179 for ; Mon, 15 Jan 2018 11:45:14 -0500 Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) by mx0a-001b2d01.pphosted.com with ESMTP id 2fgucuw7bn-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 15 Jan 2018 11:45:14 -0500 Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 15 Jan 2018 09:45:13 -0700 Received: from b03cxnp07028.gho.boulder.ibm.com (9.17.130.15) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 15 Jan 2018 09:45:10 -0700 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w0FGjAHc14090640; Mon, 15 Jan 2018 09:45:10 -0700 Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 38B826E035; Mon, 15 Jan 2018 09:45:10 -0700 (MST) Received: from collin-ThinkPad-W541.pok.ibm.com (unknown [9.56.58.154]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP id 820A26E038; Mon, 15 Jan 2018 09:45:09 -0700 (MST) From: "Collin L. Walling" To: qemu-s390x@nongnu.org, qemu-devel@nongnu.org Date: Mon, 15 Jan 2018 11:44:22 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516034665-27606-1-git-send-email-walling@linux.vnet.ibm.com> References: <1516034665-27606-1-git-send-email-walling@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18011516-0020-0000-0000-00000D4E1DB3 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008383; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000245; SDB=6.00975440; UDB=6.00494388; IPR=6.00755367; BA=6.00005778; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00019046; XFM=3.00000015; UTC=2018-01-15 16:45:12 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18011516-0021-0000-0000-00005FB3CECA Message-Id: <1516034665-27606-6-git-send-email-walling@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-01-15_08:, , 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-1801150238 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 v3 5/8] s390-ccw: interactive boot menu for eckd dasd (read stage2 data) 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, 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 --- pc-bios/s390-ccw/bootmap.c | 112 +++++++++++++++++++++++++++++++++++++++++= ++-- pc-bios/s390-ccw/bootmap.h | 1 + pc-bios/s390-ccw/menu.h | 10 ++++ 3 files changed, 118 insertions(+), 5 deletions(-) diff --git a/pc-bios/s390-ccw/bootmap.c b/pc-bios/s390-ccw/bootmap.c index 29915e4..fb8ff80 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 * 4] __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,94 @@ 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 ZiplParms get_zipl_parms(int offset) +{ + ZiplParms zipl_parms =3D { + .flag =3D *(uint16_t *)(s2_cur_blk + offset - ZIPL_FLAG_OFFSET), + .timeout =3D *(uint16_t *)(s2_cur_blk + offset - ZIPL_TIMEOUT_OFFS= ET), + .menu_start =3D offset, + }; + + return zipl_parms; +} + +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, prev_block_nr, next_block_nr; + EckdStage1b *s1b =3D (void *)sec; + ZiplParms zipl_parms; + bool found =3D false; + 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((void *)&s1b->seek[i].cyl); + + 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((void *)&s1b->seek[i + 1]= .cyl); + } + + if (next_block_nr) { + read_block(next_block_nr, s2_next_blk, + "Cannot read stage2 boot loader"); + } + + zipl_parms =3D get_zipl_parms(offset); + found =3D true; + break; + } + + prev_block_nr =3D cur_block_nr; + } + + if (!found) { + sclp_print("No zipl boot menu data found. Booting default entry."); + return 0; + } + + zipl_parms.menu_start++; /* make compiler happy -- does nothing vital = */ + return 0; /* implemented next patch */ +} + +static void run_eckd_boot_script(block_number_t mbr_block_nr, + block_number_t s1b_block_nr) { int i; unsigned int loadparm =3D get_loadparm_index(); @@ -191,6 +283,10 @@ static void run_eckd_boot_script(block_number_t mbr_bl= ock_nr) ScsiMbr *bte =3D (void *)sec; /* Eckd bootmap table entry */ BootMapScript *bms =3D (void *)sec; =20 + if (menu_check_flags(BOOT_MENU_FLAG_BOOT_OPTS | BOOT_MENU_FLAG_ZIPL_OP= TS)) { + 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 +319,7 @@ static void ipl_eckd_cdl(void) XEckdMbr *mbr; EckdCdlIpl2 *ipl2 =3D (void *)sec; IplVolumeLabel *vlbl =3D (void *)sec; - block_number_t mbr_block_nr; + block_number_t mbr_block_nr, s1b_block_nr; =20 /* we have just read the block #0 and recognized it as "IPL1" */ sclp_print("CDL\n"); @@ -249,7 +345,10 @@ static void ipl_eckd_cdl(void) /* save pointer to Boot Script */ mbr_block_nr =3D eckd_block_num((void *)&mbr->blockptr); =20 - run_eckd_boot_script(mbr_block_nr); + /* save pointer to Stage1b Data */ + s1b_block_nr =3D eckd_block_num((void *)&ipl2->stage1.seek[0].cyl); + + run_eckd_boot_script(mbr_block_nr, s1b_block_nr); /* no return */ } =20 @@ -280,7 +379,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 mbr_block_nr; + block_number_t mbr_block_nr, s1b_block_nr; EckdLdlIpl1 *ipl1 =3D (void *)sec; =20 if (mode !=3D ECKD_LDL_UNLABELED) { @@ -303,7 +402,10 @@ static void ipl_eckd_ldl(ECKD_IPL_mode_t mode) mbr_block_nr =3D eckd_block_num((void *)&ipl1->boot_info.bp.ipl.bm_ptr.eckd.bptr); =20 - run_eckd_boot_script(mbr_block_nr); + /* save pointer to Stage1b Data */ + s1b_block_nr =3D eckd_block_num((void *)&ipl1->stage1.seek[0].cyl); + + run_eckd_boot_script(mbr_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 df956f2..56445f2 100644 --- a/pc-bios/s390-ccw/bootmap.h +++ b/pc-bios/s390-ccw/bootmap.h @@ -74,6 +74,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 */ diff --git a/pc-bios/s390-ccw/menu.h b/pc-bios/s390-ccw/menu.h index 04b1db1..3a8a487 100644 --- a/pc-bios/s390-ccw/menu.h +++ b/pc-bios/s390-ccw/menu.h @@ -17,6 +17,16 @@ #define BOOT_MENU_FLAG_BOOT_OPTS 0x80 #define BOOT_MENU_FLAG_ZIPL_OPTS 0x40 =20 +/* Offsets from zipl fields to zipl banner start */ +#define ZIPL_TIMEOUT_OFFSET 138 +#define ZIPL_FLAG_OFFSET 140 + +typedef struct ZiplParms { + uint16_t flag; + uint16_t timeout; + uint64_t menu_start; +} ZiplParms; + 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 Thu May 2 00:27:21 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 1516034988322670.8937554072954; Mon, 15 Jan 2018 08:49:48 -0800 (PST) Received: from localhost ([::1]:47026 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eb7xD-0007vT-KF for importer@patchew.org; Mon, 15 Jan 2018 11:49:47 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57456) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eb7sw-00056q-9G for qemu-devel@nongnu.org; Mon, 15 Jan 2018 11:45:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eb7sr-0002BY-PD for qemu-devel@nongnu.org; Mon, 15 Jan 2018 11:45:22 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:55502 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 1eb7sr-0002AV-DI for qemu-devel@nongnu.org; Mon, 15 Jan 2018 11:45:17 -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 w0FGdg06041275 for ; Mon, 15 Jan 2018 11:45:16 -0500 Received: from e34.co.us.ibm.com (e34.co.us.ibm.com [32.97.110.152]) by mx0a-001b2d01.pphosted.com with ESMTP id 2fgu8rx3bb-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 15 Jan 2018 11:45:16 -0500 Received: from localhost by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 15 Jan 2018 09:45:15 -0700 Received: from b03cxnp08027.gho.boulder.ibm.com (9.17.130.19) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 15 Jan 2018 09:45:12 -0700 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w0FGjCVD12452236; Mon, 15 Jan 2018 09:45:12 -0700 Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EC9676E04E; Mon, 15 Jan 2018 09:45:11 -0700 (MST) Received: from collin-ThinkPad-W541.pok.ibm.com (unknown [9.56.58.154]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP id 4F9A96E03F; Mon, 15 Jan 2018 09:45:11 -0700 (MST) From: "Collin L. Walling" To: qemu-s390x@nongnu.org, qemu-devel@nongnu.org Date: Mon, 15 Jan 2018 11:44:23 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516034665-27606-1-git-send-email-walling@linux.vnet.ibm.com> References: <1516034665-27606-1-git-send-email-walling@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18011516-0016-0000-0000-0000081D1E67 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008383; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000245; SDB=6.00975440; UDB=6.00494388; IPR=6.00755367; BA=6.00005778; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00019046; XFM=3.00000015; UTC=2018-01-15 16:45:14 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18011516-0017-0000-0000-00003D0E62E0 Message-Id: <1516034665-27606-7-git-send-email-walling@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-01-15_08:, , 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-1801150238 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 v3 6/8] s390-ccw: interactive boot menu for eckd dasd (print 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, 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" Prints the menu data starting from the zIPL menu banner. Signed-off-by: Collin L. Walling --- pc-bios/s390-ccw/bootmap.c | 3 +-- pc-bios/s390-ccw/menu.c | 42 ++++++++++++++++++++++++++++++++++++++++++ pc-bios/s390-ccw/menu.h | 1 + 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/pc-bios/s390-ccw/bootmap.c b/pc-bios/s390-ccw/bootmap.c index fb8ff80..f894760 100644 --- a/pc-bios/s390-ccw/bootmap.c +++ b/pc-bios/s390-ccw/bootmap.c @@ -269,8 +269,7 @@ static int eckd_get_boot_menu_index(block_number_t s1b_= block_nr) return 0; } =20 - zipl_parms.menu_start++; /* make compiler happy -- does nothing vital = */ - return 0; /* implemented next patch */ + return menu_get_zipl_boot_index(s2_cur_blk, zipl_parms); } =20 static void run_eckd_boot_script(block_number_t mbr_block_nr, diff --git a/pc-bios/s390-ccw/menu.c b/pc-bios/s390-ccw/menu.c index e15a7f2..30470b3 100644 --- a/pc-bios/s390-ccw/menu.c +++ b/pc-bios/s390-ccw/menu.c @@ -10,10 +10,52 @@ */ =20 #include "menu.h" +#include "s390-ccw.h" =20 static uint8_t flags; static uint64_t timeout; =20 +static void zipl_println(const char *data, size_t len) +{ + char buf[len + 1]; + + 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, ZiplParms zipl_parms) +{ + const char *data =3D stage2 + zipl_parms.menu_start; + size_t len; + int ct; + + if (flags & BOOT_MENU_FLAG_ZIPL_OPTS) { + if (zipl_parms.flag) { + timeout =3D zipl_parms.timeout; + } else { + return 0; /* Boot default */ + } + } + + /* 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 0; /* return user input 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 3a8a487..c6615aa 100644 --- a/pc-bios/s390-ccw/menu.h +++ b/pc-bios/s390-ccw/menu.h @@ -27,6 +27,7 @@ typedef struct ZiplParms { uint64_t menu_start; } ZiplParms; =20 +int menu_get_zipl_boot_index(const void *stage2, ZiplParms zipl_parms); 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 Thu May 2 00:27:21 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 1516035119352125.65898112695413; Mon, 15 Jan 2018 08:51:59 -0800 (PST) Received: from localhost ([::1]:47165 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eb7zK-0001Gx-Hy for importer@patchew.org; Mon, 15 Jan 2018 11:51:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57474) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eb7sx-00058h-C2 for qemu-devel@nongnu.org; Mon, 15 Jan 2018 11:45:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eb7sv-0002Jb-RO for qemu-devel@nongnu.org; Mon, 15 Jan 2018 11:45:23 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:53906) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eb7sv-0002Hz-Is for qemu-devel@nongnu.org; Mon, 15 Jan 2018 11:45:21 -0500 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w0FGdbD9030760 for ; Mon, 15 Jan 2018 11:45:19 -0500 Received: from e34.co.us.ibm.com (e34.co.us.ibm.com [32.97.110.152]) by mx0a-001b2d01.pphosted.com with ESMTP id 2fgxducncq-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 15 Jan 2018 11:45:18 -0500 Received: from localhost by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 15 Jan 2018 09:45:18 -0700 Received: from b03cxnp08027.gho.boulder.ibm.com (9.17.130.19) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 15 Jan 2018 09:45:14 -0700 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w0FGjDIe11731222; Mon, 15 Jan 2018 09:45:13 -0700 Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B526B6E03A; Mon, 15 Jan 2018 09:45:13 -0700 (MST) Received: from collin-ThinkPad-W541.pok.ibm.com (unknown [9.56.58.154]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP id 0ECB16E03F; Mon, 15 Jan 2018 09:45:12 -0700 (MST) From: "Collin L. Walling" To: qemu-s390x@nongnu.org, qemu-devel@nongnu.org Date: Mon, 15 Jan 2018 11:44:24 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516034665-27606-1-git-send-email-walling@linux.vnet.ibm.com> References: <1516034665-27606-1-git-send-email-walling@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18011516-0016-0000-0000-0000081D1E6A X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008383; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000245; SDB=6.00975440; UDB=6.00494388; IPR=6.00755367; BA=6.00005778; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00019046; XFM=3.00000015; UTC=2018-01-15 16:45:16 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18011516-0017-0000-0000-00003D0E62E9 Message-Id: <1516034665-27606-8-git-send-email-walling@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-01-15_08:, , 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-1801150238 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 v3 7/8] s390-ccw: interactive boot menu for eckd dasd (read input) 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, 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 Please choose (default will boot in 10 seconds): If the user's input is empty or 0, the default zipl entry will be chosen. If the input is within the range presented by the menu, then the selection will be booted. Any erroneous input will cancel the timeout and prompt the user until correct input is given. Any value set for loadparm will override all boot menu options. If loadparm=3DPROMPT, then the menu prompt will continuously wait until correct user input is given. The absence of any boot options on the command line will attempt to use the zipl loader values. --- Specific notes regarding this patch --- Implements an sclp_read function to capture input from the console, and a wrapper function in that handles parsing certain characters and adding input to a buffer. The input is checked for any erroneous values and is handled appropriately. A correct value will boot the respective boot menu entry. Signed-off-by: Collin L. Walling --- pc-bios/s390-ccw/menu.c | 160 ++++++++++++++++++++++++++++++++++++++++= +++- pc-bios/s390-ccw/s390-ccw.h | 2 + pc-bios/s390-ccw/sclp.c | 20 ++++++ pc-bios/s390-ccw/virtio.c | 2 +- 4 files changed, 182 insertions(+), 2 deletions(-) diff --git a/pc-bios/s390-ccw/menu.c b/pc-bios/s390-ccw/menu.c index 30470b3..c219b7f 100644 --- a/pc-bios/s390-ccw/menu.c +++ b/pc-bios/s390-ccw/menu.c @@ -12,9 +12,167 @@ #include "menu.h" #include "s390-ccw.h" =20 +#define KEYCODE_NO_INP '\0' +#define KEYCODE_ESCAPE '\033' +#define KEYCODE_BACKSP '\177' +#define KEYCODE_ENTER '\r' + static uint8_t flags; static uint64_t timeout; =20 +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; + + 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 << 32); + set_clock_comparator(time); + enable_clock_int(); + timeout =3D 0; + } + + while (!check_clock_int()) { + + /* Process only one character at a time */ + sclp_read(inp, 1); + + switch (inp[0]) { + case KEYCODE_NO_INP: + case KEYCODE_ESCAPE: + continue; + case KEYCODE_BACKSP: + if (idx > 0) { + /* Remove last character */ + buf[idx - 1] =3D ' '; + sclp_print("\r"); + sclp_print(buf); + + idx--; + + /* Reset cursor */ + buf[idx] =3D 0; + sclp_print("\r"); + sclp_print(buf); + } + continue; + case KEYCODE_ENTER: + disable_clock_int(); + return idx; + } + + /* Echo input and add to buffer */ + if (idx < len) { + buf[idx] =3D inp[0]; + sclp_print(inp); + idx++; + } + } + + 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 atoi(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) +{ + 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; +} + static void zipl_println(const char *data, size_t len) { char buf[len + 1]; @@ -53,7 +211,7 @@ int menu_get_zipl_boot_index(const void *stage2, ZiplPar= ms zipl_parms) =20 sclp_print("\n"); =20 - return 0; /* return user input next patch */ + return get_boot_index(ct - 1); } =20 void menu_set_parms(uint8_t boot_menu_flag, uint16_t boot_menu_timeout) diff --git a/pc-bios/s390-ccw/s390-ccw.h b/pc-bios/s390-ccw/s390-ccw.h index 25d4d21..df4bc88 100644 --- a/pc-bios/s390-ccw/s390-ccw.h +++ b/pc-bios/s390-ccw/s390-ccw.h @@ -71,6 +71,7 @@ unsigned int get_loadparm_index(void); void sclp_print(const char *string); void sclp_setup(void); void sclp_get_loadparm_ascii(char *loadparm); +void sclp_read(char *str, size_t len); =20 /* virtio.c */ unsigned long virtio_load_direct(ulong rec_list1, ulong rec_list2, @@ -79,6 +80,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..5e4a78b 100644 --- a/pc-bios/s390-ccw/sclp.c +++ b/pc-bios/s390-ccw/sclp.c @@ -101,3 +101,23 @@ void sclp_get_loadparm_ascii(char *loadparm) ebcdic_to_ascii((char *) sccb->loadparm, loadparm, 8); } } + +void sclp_read(char *str, size_t len) +{ + ReadEventData *sccb =3D (void *)_sccb; + char *buf =3D (char *)(&sccb->ebh) + 7; + + /* Len should not exceed the maximum size of the event buffer */ + if (len > SCCB_SIZE - 8) { + len =3D SCCB_SIZE - 8; + } + + sccb->h.length =3D SCCB_SIZE; + sccb->h.function_code =3D SCLP_UNCONDITIONAL_READ; + sccb->ebh.length =3D sizeof(EventBufferHeader); + sccb->ebh.type =3D SCLP_EVENT_ASCII_CONSOLE_DATA; + sccb->ebh.flags =3D 0; + + sclp_service_call(SCLP_CMD_READ_EVENT_DATA, sccb); + memcpy(str, buf, len); +} 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 Thu May 2 00:27:21 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 1516035243565796.7035504182508; Mon, 15 Jan 2018 08:54:03 -0800 (PST) Received: from localhost ([::1]:47315 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eb81K-0002rf-Sz for importer@patchew.org; Mon, 15 Jan 2018 11:54:02 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57497) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eb7sz-0005BK-AY for qemu-devel@nongnu.org; Mon, 15 Jan 2018 11:45:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eb7sv-0002Ib-6Z for qemu-devel@nongnu.org; Mon, 15 Jan 2018 11:45:25 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:44982) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eb7su-0002Gu-V7 for qemu-devel@nongnu.org; Mon, 15 Jan 2018 11:45:21 -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 w0FGgjbi008683 for ; Mon, 15 Jan 2018 11:45:19 -0500 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0a-001b2d01.pphosted.com with ESMTP id 2fgu7up04p-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 15 Jan 2018 11:45:19 -0500 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 15 Jan 2018 09:45:18 -0700 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 15 Jan 2018 09:45:16 -0700 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w0FGjFlI1245600; Mon, 15 Jan 2018 09:45:15 -0700 Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 748C96E03D; Mon, 15 Jan 2018 09:45:15 -0700 (MST) Received: from collin-ThinkPad-W541.pok.ibm.com (unknown [9.56.58.154]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP id CBD966E041; Mon, 15 Jan 2018 09:45:14 -0700 (MST) From: "Collin L. Walling" To: qemu-s390x@nongnu.org, qemu-devel@nongnu.org Date: Mon, 15 Jan 2018 11:44:25 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516034665-27606-1-git-send-email-walling@linux.vnet.ibm.com> References: <1516034665-27606-1-git-send-email-walling@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18011516-8235-0000-0000-00000CDF5726 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008383; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000245; SDB=6.00975440; UDB=6.00494388; IPR=6.00755367; BA=6.00005778; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00019046; XFM=3.00000015; UTC=2018-01-15 16:45:18 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18011516-8236-0000-0000-00003F420789 Message-Id: <1516034665-27606-9-git-send-email-walling@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-01-15_08:, , 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-1801150238 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 v3 8/8] 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, 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 the same procedure as the interactive menu for eckd dasd. An example follows: s390x Enumerated Boot Menu. 3 entries detected. Select from index 0 to 2. Please choose: Signed-off-by: Collin L. Walling Reviewed-by: Thomas Huth --- pc-bios/s390-ccw/bootmap.c | 9 ++++++--- pc-bios/s390-ccw/main.c | 3 +++ pc-bios/s390-ccw/menu.c | 14 ++++++++++++++ pc-bios/s390-ccw/menu.h | 1 + 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/pc-bios/s390-ccw/bootmap.c b/pc-bios/s390-ccw/bootmap.c index f894760..5b622de 100644 --- a/pc-bios/s390-ccw/bootmap.c +++ b/pc-bios/s390-ccw/bootmap.c @@ -589,15 +589,18 @@ static void ipl_scsi(void) } =20 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"); =20 + if (menu_check_flags(BOOT_MENU_FLAG_BOOT_OPTS)) { + loadparm =3D menu_get_enum_boot_index(program_table_entries); + } + + prog_table_entry =3D (ScsiBlockPtr *)(sec + pte_len * (loadparm + 1)); + zipl_run(prog_table_entry); /* no return */ } =20 diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c index 709e5ef..808d111 100644 --- a/pc-bios/s390-ccw/main.c +++ b/pc-bios/s390-ccw/main.c @@ -90,6 +90,9 @@ static void menu_setup(void) case S390_IPL_TYPE_CCW: menu_set_parms(iplb.ccw.boot_menu_flags, iplb.ccw.boot_menu_timeou= t); return; + case S390_IPL_TYPE_QEMU_SCSI: + menu_set_parms(iplb.scsi.boot_menu_flags, iplb.scsi.boot_menu_time= out); + return; } } =20 diff --git a/pc-bios/s390-ccw/menu.c b/pc-bios/s390-ccw/menu.c index c219b7f..007d96f 100644 --- a/pc-bios/s390-ccw/menu.c +++ b/pc-bios/s390-ccw/menu.c @@ -214,6 +214,20 @@ int menu_get_zipl_boot_index(const void *stage2, ZiplP= arms zipl_parms) 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 c6615aa..0c65009 100644 --- a/pc-bios/s390-ccw/menu.h +++ b/pc-bios/s390-ccw/menu.h @@ -28,6 +28,7 @@ typedef struct ZiplParms { } ZiplParms; =20 int menu_get_zipl_boot_index(const void *stage2, ZiplParms zipl_parms); +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