From nobody Fri Mar 29 16:00:36 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; dmarc=fail(p=none dis=none) header.from=linux.ibm.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 152389812926658.10195973560337; Mon, 16 Apr 2018 10:02:09 -0700 (PDT) Received: from localhost ([::1]:58408 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f87Vy-00015J-DP for importer@patchew.org; Mon, 16 Apr 2018 13:02:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58696) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f87Ql-0005Cf-Ov for qemu-devel@nongnu.org; Mon, 16 Apr 2018 12:56:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f87Qi-0001HI-Jj for qemu-devel@nongnu.org; Mon, 16 Apr 2018 12:56:39 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:60160) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f87Qi-0001Gf-BE for qemu-devel@nongnu.org; Mon, 16 Apr 2018 12:56:36 -0400 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 w3GGmM6S145056 for ; Mon, 16 Apr 2018 12:56:35 -0400 Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153]) by mx0a-001b2d01.pphosted.com with ESMTP id 2hcxu1juf5-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Mon, 16 Apr 2018 12:56:34 -0400 Received: from localhost by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 16 Apr 2018 10:56:33 -0600 Received: from b03cxnp08025.gho.boulder.ibm.com (9.17.130.17) by e35.co.us.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 16 Apr 2018 10:56:31 -0600 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w3GGuT8J12583168; Mon, 16 Apr 2018 09:56:29 -0700 Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 43F8BC603C; Mon, 16 Apr 2018 10:56:29 -0600 (MDT) Received: from collin-ThinkPad-W541.pok.ibm.com (unknown [9.56.58.57]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP id B80AAC6037; Mon, 16 Apr 2018 10:56:28 -0600 (MDT) From: Collin Walling To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org, cohuck@redhat.com, thuth@redhat.com, borntraeger@de.ibm.com Date: Mon, 16 Apr 2018 12:56:07 -0400 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523897770-30155-1-git-send-email-walling@linux.ibm.com> References: <1523897770-30155-1-git-send-email-walling@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18041616-0012-0000-0000-0000160D6FB9 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008864; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000257; SDB=6.01018816; UDB=6.00519711; IPR=6.00798057; MB=3.00020601; MTD=3.00000008; XFM=3.00000015; UTC=2018-04-16 16:56:32 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18041616-0013-0000-0000-000052504FD2 Message-Id: <1523897770-30155-2-git-send-email-walling@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-04-16_09:, , 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-1804160151 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/4] pc-bios/s390-ccw: rename MAX_TABLE_ENTRIES to MAX_BOOT_ENTRIES 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.ibm.com, gor@linux.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 MAX_TABLE_ENTRIES constant has a name that is too generic. As we want to declare a limit for boot menu entries, let's rename it to a more fitting MAX_BOOT_ENTRIES and set its value to 31 (30 boot entries and 1 default entry). Also we move it from bootmap.h to s390-ccw.h to make it available for menu.c in a later patch. Signed-off-by: Collin Walling Reviewed-by: Thomas Huth Reviewed-by: Janosch Frank --- pc-bios/s390-ccw/bootmap.c | 6 +++--- pc-bios/s390-ccw/bootmap.h | 2 -- pc-bios/s390-ccw/s390-ccw.h | 2 ++ 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pc-bios/s390-ccw/bootmap.c b/pc-bios/s390-ccw/bootmap.c index fc2a9fe..2f79346 100644 --- a/pc-bios/s390-ccw/bootmap.c +++ b/pc-bios/s390-ccw/bootmap.c @@ -290,7 +290,7 @@ static void run_eckd_boot_script(block_number_t bmt_blo= ck_nr, } =20 debug_print_int("loadparm", loadparm); - IPL_assert(loadparm <=3D MAX_TABLE_ENTRIES, "loadparm value greater th= an" + IPL_assert(loadparm < MAX_BOOT_ENTRIES, "loadparm value greater than" " maximum number of boot entries allowed"); =20 memset(sec, FREE_SPACE_FILLER, sizeof(sec)); @@ -578,7 +578,7 @@ static void ipl_scsi(void) read_block(mbr->pt.blockno, sec, "Error reading Program Table"); IPL_assert(magic_match(sec, ZIPL_MAGIC), "No zIPL magic in PT"); =20 - while (program_table_entries <=3D MAX_TABLE_ENTRIES) { + while (program_table_entries < MAX_BOOT_ENTRIES) { if (!prog_table->entry[program_table_entries].scsi.blockno) { break; } @@ -593,7 +593,7 @@ static void ipl_scsi(void) } =20 debug_print_int("loadparm", loadparm); - IPL_assert(loadparm <=3D MAX_TABLE_ENTRIES, "loadparm value greater th= an" + IPL_assert(loadparm < MAX_BOOT_ENTRIES, "loadparm value greater than" " maximum number of boot entries allowed"); =20 zipl_run(&prog_table->entry[loadparm].scsi); /* no return */ diff --git a/pc-bios/s390-ccw/bootmap.h b/pc-bios/s390-ccw/bootmap.h index 07eb600..732c111 100644 --- a/pc-bios/s390-ccw/bootmap.h +++ b/pc-bios/s390-ccw/bootmap.h @@ -57,8 +57,6 @@ typedef union BootMapPointer { ExtEckdBlockPtr xeckd; } __attribute__ ((packed)) BootMapPointer; =20 -#define MAX_TABLE_ENTRIES 30 - /* aka Program Table */ typedef struct BootMapTable { uint8_t magic[4]; diff --git a/pc-bios/s390-ccw/s390-ccw.h b/pc-bios/s390-ccw/s390-ccw.h index fd18da2..2c9e601 100644 --- a/pc-bios/s390-ccw/s390-ccw.h +++ b/pc-bios/s390-ccw/s390-ccw.h @@ -94,6 +94,8 @@ bool menu_is_enabled_zipl(void); int menu_get_enum_boot_index(int entries); bool menu_is_enabled_enum(void); =20 +#define MAX_BOOT_ENTRIES 31 + static inline void fill_hex(char *out, unsigned char val) { const char hex[] =3D "0123456789abcdef"; --=20 2.7.4 From nobody Fri Mar 29 16:00:36 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; dmarc=fail(p=none dis=none) header.from=linux.ibm.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1523898021043109.75140591857541; Mon, 16 Apr 2018 10:00:21 -0700 (PDT) Received: from localhost ([::1]:58337 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f87UC-0007zA-Is for importer@patchew.org; Mon, 16 Apr 2018 13:00:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58748) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f87Qn-0005Ea-PW for qemu-devel@nongnu.org; Mon, 16 Apr 2018 12:56:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f87Qj-0001Hg-FJ for qemu-devel@nongnu.org; Mon, 16 Apr 2018 12:56:41 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:39944 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 1f87Qj-0001HS-98 for qemu-devel@nongnu.org; Mon, 16 Apr 2018 12:56:37 -0400 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 w3GGkKXB001262 for ; Mon, 16 Apr 2018 12:56:36 -0400 Received: from e38.co.us.ibm.com (e38.co.us.ibm.com [32.97.110.159]) by mx0a-001b2d01.pphosted.com with ESMTP id 2hcxhb40s0-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Mon, 16 Apr 2018 12:56:36 -0400 Received: from localhost by e38.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 16 Apr 2018 10:56:35 -0600 Received: from b03cxnp07028.gho.boulder.ibm.com (9.17.130.15) by e38.co.us.ibm.com (192.168.1.138) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 16 Apr 2018 10:56:32 -0600 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w3GGuUtx12714470; Mon, 16 Apr 2018 09:56:30 -0700 Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D92ACC6037; Mon, 16 Apr 2018 10:56:30 -0600 (MDT) Received: from collin-ThinkPad-W541.pok.ibm.com (unknown [9.56.58.57]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP id 5667CC603E; Mon, 16 Apr 2018 10:56:30 -0600 (MDT) From: Collin Walling To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org, cohuck@redhat.com, thuth@redhat.com, borntraeger@de.ibm.com Date: Mon, 16 Apr 2018 12:56:08 -0400 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523897770-30155-1-git-send-email-walling@linux.ibm.com> References: <1523897770-30155-1-git-send-email-walling@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18041616-0028-0000-0000-0000097458AA X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008863; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000257; SDB=6.01018816; UDB=6.00519711; IPR=6.00798057; MB=3.00020601; MTD=3.00000008; XFM=3.00000015; UTC=2018-04-16 16:56:34 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18041616-0029-0000-0000-00003A66CA30 Message-Id: <1523897770-30155-3-git-send-email-walling@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-04-16_09:, , 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-1804160151 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/4] pc-bios/s390-ccw: fix loadparm initialization and int conversion 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.ibm.com, gor@linux.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" Rename the loadparm char array in main.c to loadparm_str and increased the size by one byte to account for a null termination when converting the loadparm string to an int via atoui. We also allow the boot menu to be enabled when loadparm is set to an empty string or a series of spaces. Signed-off-by: Collin Walling Reported-by: Vasily Gorbik Reviewed-by: Thomas Huth Reviewed-by: Janosch Frank --- hw/s390x/ipl.c | 4 ++++ pc-bios/s390-ccw/main.c | 14 +++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c index fdeaec3..8907136 100644 --- a/hw/s390x/ipl.c +++ b/hw/s390x/ipl.c @@ -352,6 +352,10 @@ int s390_ipl_set_loadparm(uint8_t *loadparm) loadparm[i] =3D ascii2ebcdic[(uint8_t) lp[i]]; } =20 + if (i < 8) { + memset(loadparm + i, 0x40, 8 - i); /* fill with EBCDIC spaces = */ + } + g_free(lp); return 0; } diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c index 9d9f8cf..26f9adf 100644 --- a/pc-bios/s390-ccw/main.c +++ b/pc-bios/s390-ccw/main.c @@ -15,11 +15,11 @@ 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 }; +static char loadparm_str[9] =3D { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; QemuIplParameters qipl; =20 #define LOADPARM_PROMPT "PROMPT " -#define LOADPARM_EMPTY "........" +#define LOADPARM_EMPTY " " #define BOOT_MENU_FLAG_MASK (QIPL_FLAG_BM_OPTS_CMD | QIPL_FLAG_BM_OPTS_ZIP= L) =20 /* @@ -45,7 +45,7 @@ void panic(const char *string) =20 unsigned int get_loadparm_index(void) { - return atoui(loadparm); + return atoui(loadparm_str); } =20 static bool find_dev(Schib *schib, int dev_no) @@ -80,13 +80,13 @@ static bool find_dev(Schib *schib, int dev_no) =20 static void menu_setup(void) { - if (memcmp(loadparm, LOADPARM_PROMPT, 8) =3D=3D 0) { + if (memcmp(loadparm_str, LOADPARM_PROMPT, 8) =3D=3D 0) { menu_set_parms(QIPL_FLAG_BM_OPTS_CMD, 0); return; } =20 /* If loadparm was set to any other value, then do not enable menu */ - if (memcmp(loadparm, LOADPARM_EMPTY, 8) !=3D 0) { + if (memcmp(loadparm_str, LOADPARM_EMPTY, 8) !=3D 0) { return; } =20 @@ -116,8 +116,8 @@ static void virtio_setup(void) */ enable_mss_facility(); =20 - sclp_get_loadparm_ascii(loadparm); - memcpy(ldp + 10, loadparm, 8); + sclp_get_loadparm_ascii(loadparm_str); + memcpy(ldp + 10, loadparm_str, 8); sclp_print(ldp); =20 memcpy(&qipl, early_qipl, sizeof(QemuIplParameters)); --=20 2.7.4 From nobody Fri Mar 29 16:00:36 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; dmarc=fail(p=none dis=none) header.from=linux.ibm.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1523897943656692.0722407647419; Mon, 16 Apr 2018 09:59:03 -0700 (PDT) Received: from localhost ([::1]:58334 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f87Sx-0006iI-If for importer@patchew.org; Mon, 16 Apr 2018 12:58:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58848) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f87Qp-0005HA-Po for qemu-devel@nongnu.org; Mon, 16 Apr 2018 12:56:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f87Ql-0001KP-OC for qemu-devel@nongnu.org; Mon, 16 Apr 2018 12:56:43 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:39866 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 1f87Ql-0001Iu-Gn for qemu-devel@nongnu.org; Mon, 16 Apr 2018 12:56:39 -0400 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 w3GGkghg087650 for ; Mon, 16 Apr 2018 12:56:38 -0400 Received: from e38.co.us.ibm.com (e38.co.us.ibm.com [32.97.110.159]) by mx0b-001b2d01.pphosted.com with ESMTP id 2hcvpgj27q-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Mon, 16 Apr 2018 12:56:38 -0400 Received: from localhost by e38.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 16 Apr 2018 10:56:37 -0600 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e38.co.us.ibm.com (192.168.1.138) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 16 Apr 2018 10:56:34 -0600 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w3GGuWiv9568670; Mon, 16 Apr 2018 09:56:32 -0700 Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 705CFC603E; Mon, 16 Apr 2018 10:56:32 -0600 (MDT) Received: from collin-ThinkPad-W541.pok.ibm.com (unknown [9.56.58.57]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP id EA602C6037; Mon, 16 Apr 2018 10:56:31 -0600 (MDT) From: Collin Walling To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org, cohuck@redhat.com, thuth@redhat.com, borntraeger@de.ibm.com Date: Mon, 16 Apr 2018 12:56:09 -0400 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523897770-30155-1-git-send-email-walling@linux.ibm.com> References: <1523897770-30155-1-git-send-email-walling@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18041616-0028-0000-0000-0000097458AE X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008863; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000257; SDB=6.01018816; UDB=6.00519711; IPR=6.00798057; MB=3.00020601; MTD=3.00000008; XFM=3.00000015; UTC=2018-04-16 16:56:36 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18041616-0029-0000-0000-00003A66CA35 Message-Id: <1523897770-30155-4-git-send-email-walling@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-04-16_09:, , 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-1804160151 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 3/4] pc-bios/s390-ccw: fix non-sequential boot entries (eckd) 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.ibm.com, gor@linux.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" zIPL boot menu entries can be non-sequential. Let's account for this issue for the s390 zIPL boot menu. Since this boot menu is actually an imitation and is not completely capable of everything the real zIPL menu can do, let's also print a different banner to the user. Signed-off-by: Collin Walling Reported-by: Vasily Gorbik Reviewed-by: Thomas Huth Reviewed-by: Janosch Frank --- pc-bios/s390-ccw/menu.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/pc-bios/s390-ccw/menu.c b/pc-bios/s390-ccw/menu.c index 96eec81..aaf5d61 100644 --- a/pc-bios/s390-ccw/menu.c +++ b/pc-bios/s390-ccw/menu.c @@ -158,7 +158,7 @@ static void boot_menu_prompt(bool retry) } } =20 -static int get_boot_index(int entries) +static int get_boot_index(bool *valid_entries) { int boot_index; bool retry =3D false; @@ -168,7 +168,8 @@ static int get_boot_index(int entries) boot_menu_prompt(retry); boot_index =3D get_index(); retry =3D true; - } while (boot_index < 0 || boot_index >=3D entries); + } while (boot_index < 0 || boot_index >=3D MAX_BOOT_ENTRIES || + !valid_entries[boot_index]); =20 sclp_print("\nBooting entry #"); sclp_print(uitoa(boot_index, tmp, sizeof(tmp))); @@ -176,7 +177,8 @@ static int get_boot_index(int entries) return boot_index; } =20 -static void zipl_println(const char *data, size_t len) +/* Returns the entry number that was printed */ +static int zipl_print_entry(const char *data, size_t len) { char buf[len + 2]; =20 @@ -185,12 +187,15 @@ static void zipl_println(const char *data, size_t len) buf[len + 1] =3D '\0'; =20 sclp_print(buf); + + return buf[0] =3D=3D ' ' ? atoui(buf + 1) : atoui(buf); } =20 int menu_get_zipl_boot_index(const char *menu_data) { size_t len; - int entries; + int entry; + bool valid_entries[MAX_BOOT_ENTRIES] =3D {false}; uint16_t zipl_flag =3D *(uint16_t *)(menu_data - ZIPL_FLAG_OFFSET); uint16_t zipl_timeout =3D *(uint16_t *)(menu_data - ZIPL_TIMEOUT_OFFSE= T); =20 @@ -202,19 +207,25 @@ int menu_get_zipl_boot_index(const char *menu_data) timeout =3D zipl_timeout * 1000; } =20 - /* Print and count all menu items, including the banner */ - for (entries =3D 0; *menu_data; entries++) { + /* Print banner */ + sclp_print("s390-ccw zIPL Boot Menu\n\n"); + menu_data +=3D strlen(menu_data) + 1; + + /* Print entries */ + while (*menu_data) { len =3D strlen(menu_data); - zipl_println(menu_data, len); + entry =3D zipl_print_entry(menu_data, len); menu_data +=3D len + 1; =20 - if (entries < 2) { + valid_entries[entry] =3D true; + + if (entry =3D=3D 0) { sclp_print("\n"); } } =20 sclp_print("\n"); - return get_boot_index(entries - 1); /* subtract 1 to exclude banner */ + return get_boot_index(valid_entries); } =20 =20 --=20 2.7.4 From nobody Fri Mar 29 16:00:36 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; dmarc=fail(p=none dis=none) header.from=linux.ibm.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1523897947026122.04970335771816; Mon, 16 Apr 2018 09:59:07 -0700 (PDT) Received: from localhost ([::1]:58335 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f87T1-0006kI-5Y for importer@patchew.org; Mon, 16 Apr 2018 12:58:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58929) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f87Qs-0005KY-1S for qemu-devel@nongnu.org; Mon, 16 Apr 2018 12:56:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f87Qn-0001Mz-Ul for qemu-devel@nongnu.org; Mon, 16 Apr 2018 12:56:46 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:52894 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 1f87Qn-0001MM-Fs for qemu-devel@nongnu.org; Mon, 16 Apr 2018 12:56:41 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w3GGkI7Y113925 for ; Mon, 16 Apr 2018 12:56:40 -0400 Received: from e37.co.us.ibm.com (e37.co.us.ibm.com [32.97.110.158]) by mx0a-001b2d01.pphosted.com with ESMTP id 2hcxu2jx0r-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Mon, 16 Apr 2018 12:56:39 -0400 Received: from localhost by e37.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 16 Apr 2018 10:56:38 -0600 Received: from b03cxnp08027.gho.boulder.ibm.com (9.17.130.19) by e37.co.us.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 16 Apr 2018 10:56:36 -0600 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w3GGuYfW9896368; Mon, 16 Apr 2018 09:56:34 -0700 Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 04BE7C603E; Mon, 16 Apr 2018 10:56:34 -0600 (MDT) Received: from collin-ThinkPad-W541.pok.ibm.com (unknown [9.56.58.57]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP id 817D5C603C; Mon, 16 Apr 2018 10:56:33 -0600 (MDT) From: Collin Walling To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org, cohuck@redhat.com, thuth@redhat.com, borntraeger@de.ibm.com Date: Mon, 16 Apr 2018 12:56:10 -0400 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523897770-30155-1-git-send-email-walling@linux.ibm.com> References: <1523897770-30155-1-git-send-email-walling@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18041616-0024-0000-0000-0000183CC8AA X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008863; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000257; SDB=6.01018816; UDB=6.00519711; IPR=6.00798057; MB=3.00020601; MTD=3.00000008; XFM=3.00000015; UTC=2018-04-16 16:56:37 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18041616-0025-0000-0000-00004F8CE5A5 Message-Id: <1523897770-30155-5-git-send-email-walling@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-04-16_09:, , 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-1804160151 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/4] pc-bios/s390-ccw: fix non-sequential boot entries (enum) 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.ibm.com, gor@linux.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" zIPL boot menu entries can be non-sequential. Let's account for this issue for the s390 enumerated boot menu. Since we can no longer print a range of available entries to the user, we have to present a list of each available entry. An example of this menu: s390-ccw Enumerated Boot Menu. [0] default [1] [2] [7] [8] [9] [11] [12] Please choose: Signed-off-by: Collin Walling Reported-by: Vasily Gorbik Reviewed-by: Thomas Huth Reviewed-by: Janosch Frank --- pc-bios/s390-ccw/bootmap.c | 12 +++++++----- pc-bios/s390-ccw/menu.c | 29 ++++++++++++++++++++--------- pc-bios/s390-ccw/s390-ccw.h | 2 +- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/pc-bios/s390-ccw/bootmap.c b/pc-bios/s390-ccw/bootmap.c index 2f79346..f9a2fb3 100644 --- a/pc-bios/s390-ccw/bootmap.c +++ b/pc-bios/s390-ccw/bootmap.c @@ -558,6 +558,8 @@ static void ipl_scsi(void) int program_table_entries =3D 0; BootMapTable *prog_table =3D (void *)sec; unsigned int loadparm =3D get_loadparm_index(); + bool valid_entries[MAX_BOOT_ENTRIES] =3D {false}; + size_t i; =20 /* Grab the MBR */ memset(sec, FREE_SPACE_FILLER, sizeof(sec)); @@ -578,18 +580,18 @@ static void ipl_scsi(void) read_block(mbr->pt.blockno, sec, "Error reading Program Table"); IPL_assert(magic_match(sec, ZIPL_MAGIC), "No zIPL magic in PT"); =20 - while (program_table_entries < MAX_BOOT_ENTRIES) { - if (!prog_table->entry[program_table_entries].scsi.blockno) { - break; + for (i =3D 0; i < MAX_BOOT_ENTRIES; i++) { + if (prog_table->entry[i].scsi.blockno) { + valid_entries[i] =3D true; + program_table_entries++; } - program_table_entries++; } =20 debug_print_int("program table entries", program_table_entries); IPL_assert(program_table_entries !=3D 0, "Empty Program Table"); =20 if (menu_is_enabled_enum()) { - loadparm =3D menu_get_enum_boot_index(program_table_entries); + loadparm =3D menu_get_enum_boot_index(valid_entries); } =20 debug_print_int("loadparm", loadparm); diff --git a/pc-bios/s390-ccw/menu.c b/pc-bios/s390-ccw/menu.c index aaf5d61..82a4ae6 100644 --- a/pc-bios/s390-ccw/menu.c +++ b/pc-bios/s390-ccw/menu.c @@ -228,19 +228,30 @@ int menu_get_zipl_boot_index(const char *menu_data) return get_boot_index(valid_entries); } =20 - -int menu_get_enum_boot_index(int entries) +int menu_get_enum_boot_index(bool *valid_entries) { - char tmp[4]; + char tmp[3]; + int i; =20 - sclp_print("s390x Enumerated Boot Menu.\n\n"); + sclp_print("s390-ccw Enumerated Boot Menu.\n\n"); =20 - sclp_print(uitoa(entries, tmp, sizeof(tmp))); - sclp_print(" entries detected. Select from boot index 0 to "); - sclp_print(uitoa(entries - 1, tmp, sizeof(tmp))); - sclp_print(".\n\n"); + for (i =3D 0; i < MAX_BOOT_ENTRIES; i++) { + if (valid_entries[i]) { + if (i < 10) { + sclp_print(" "); + } + sclp_print("["); + sclp_print(uitoa(i, tmp, sizeof(tmp))); + sclp_print("]"); + if (i =3D=3D 0) { + sclp_print(" default\n"); + } + sclp_print("\n"); + } + } =20 - return get_boot_index(entries); + sclp_print("\n"); + return get_boot_index(valid_entries); } =20 void menu_set_parms(uint8_t boot_menu_flag, uint32_t boot_menu_timeout) diff --git a/pc-bios/s390-ccw/s390-ccw.h b/pc-bios/s390-ccw/s390-ccw.h index 2c9e601..a1bdb4c 100644 --- a/pc-bios/s390-ccw/s390-ccw.h +++ b/pc-bios/s390-ccw/s390-ccw.h @@ -91,7 +91,7 @@ void zipl_load(void); void menu_set_parms(uint8_t boot_menu_flag, uint32_t boot_menu_timeout); int menu_get_zipl_boot_index(const char *menu_data); bool menu_is_enabled_zipl(void); -int menu_get_enum_boot_index(int entries); +int menu_get_enum_boot_index(bool *valid_entries); bool menu_is_enabled_enum(void); =20 #define MAX_BOOT_ENTRIES 31 --=20 2.7.4