From nobody Sat Apr 27 07:09:13 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 1523372667678641.5280100520146; Tue, 10 Apr 2018 08:04:27 -0700 (PDT) Received: from localhost ([::1]:50626 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f5uos-0002XN-Qu for importer@patchew.org; Tue, 10 Apr 2018 11:04:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32904) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f5umF-000140-Ej for qemu-devel@nongnu.org; Tue, 10 Apr 2018 11:01:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f5um9-0000M4-P0 for qemu-devel@nongnu.org; Tue, 10 Apr 2018 11:01:43 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:22619) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f5um9-0000LG-GM for qemu-devel@nongnu.org; Tue, 10 Apr 2018 11:01:37 -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 w3AEwdu5060692 for ; Tue, 10 Apr 2018 11:01:36 -0400 Received: from e32.co.us.ibm.com (e32.co.us.ibm.com [32.97.110.150]) by mx0a-001b2d01.pphosted.com with ESMTP id 2h8ts16y9v-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Tue, 10 Apr 2018 11:01:34 -0400 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 10 Apr 2018 09:01:33 -0600 Received: from b03cxnp08026.gho.boulder.ibm.com (9.17.130.18) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 10 Apr 2018 09:01:31 -0600 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w3AF1Tf3262618; Tue, 10 Apr 2018 08:01:29 -0700 Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 329326A03F; Tue, 10 Apr 2018 09:01:29 -0600 (MDT) Received: from collin-ThinkPad-W541.pok.ibm.com (unknown [9.56.58.46]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP id 88B246A03B; Tue, 10 Apr 2018 09:01: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: Tue, 10 Apr 2018 11:01:23 -0400 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523372486-13190-1-git-send-email-walling@linux.ibm.com> References: <1523372486-13190-1-git-send-email-walling@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18041015-0004-0000-0000-000013EEE246 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008831; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000256; SDB=6.01015903; UDB=6.00518032; IPR=6.00795153; MB=3.00020502; MTD=3.00000008; XFM=3.00000015; UTC=2018-04-10 15:01:32 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18041015-0005-0000-0000-000086D35CB2 Message-Id: <1523372486-13190-2-git-send-email-walling@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-04-10_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1804100146 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 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 --- 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 Sat Apr 27 07:09:13 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 1523372665904453.53600419953364; Tue, 10 Apr 2018 08:04:25 -0700 (PDT) Received: from localhost ([::1]:50625 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f5uop-0002VM-By for importer@patchew.org; Tue, 10 Apr 2018 11:04:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32910) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f5umF-000143-I8 for qemu-devel@nongnu.org; Tue, 10 Apr 2018 11:01:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f5umA-0000Mn-Jo for qemu-devel@nongnu.org; Tue, 10 Apr 2018 11:01:43 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:56126 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 1f5umA-0000MK-Dw for qemu-devel@nongnu.org; Tue, 10 Apr 2018 11:01:38 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w3AEq1qc135767 for ; Tue, 10 Apr 2018 11:01:37 -0400 Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153]) by mx0b-001b2d01.pphosted.com with ESMTP id 2h8y75h60u-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Tue, 10 Apr 2018 11:01:36 -0400 Received: from localhost by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 10 Apr 2018 09:01:34 -0600 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e35.co.us.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 10 Apr 2018 09:01:32 -0600 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w3AF1Vrv852372; Tue, 10 Apr 2018 08:01:31 -0700 Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E63C56A03F; Tue, 10 Apr 2018 09:01:30 -0600 (MDT) Received: from collin-ThinkPad-W541.pok.ibm.com (unknown [9.56.58.46]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP id 4A3ED6A045; Tue, 10 Apr 2018 09:01: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: Tue, 10 Apr 2018 11:01:24 -0400 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523372486-13190-1-git-send-email-walling@linux.ibm.com> References: <1523372486-13190-1-git-send-email-walling@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18041015-0012-0000-0000-000016060BBC X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008831; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000256; SDB=6.01015903; UDB=6.00518032; IPR=6.00795153; MB=3.00020502; MTD=3.00000008; XFM=3.00000015; UTC=2018-04-10 15:01:34 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18041015-0013-0000-0000-0000523ACBE5 Message-Id: <1523372486-13190-3-git-send-email-walling@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-04-10_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1804100146 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 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 increase the size by one byte to account for a null termination when converting the loadparm string to an int via atoui. Also=20 allow the boot menu to be enabled when loadparm is set to an=20 empty string or a series of spaces. Signed-off-by: Collin Walling Reported-by: Vasily Gorbik Reviewed-by: Thomas Huth --- hw/s390x/ipl.c | 2 ++ pc-bios/s390-ccw/main.c | 14 +++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c index fdeaec3..23b5b54 100644 --- a/hw/s390x/ipl.c +++ b/hw/s390x/ipl.c @@ -352,6 +352,8 @@ int s390_ipl_set_loadparm(uint8_t *loadparm) loadparm[i] =3D ascii2ebcdic[(uint8_t) lp[i]]; } =20 + 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 Sat Apr 27 07:09:13 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1523372663760435.3002406914485; Tue, 10 Apr 2018 08:04:23 -0700 (PDT) Received: from localhost ([::1]:50624 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f5uoj-0002Oy-Td for importer@patchew.org; Tue, 10 Apr 2018 11:04:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32919) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f5umF-00014C-Tv for qemu-devel@nongnu.org; Tue, 10 Apr 2018 11:01:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f5umE-0000Qx-U4 for qemu-devel@nongnu.org; Tue, 10 Apr 2018 11:01:43 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:36398 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 1f5umE-0000QV-P4 for qemu-devel@nongnu.org; Tue, 10 Apr 2018 11:01:42 -0400 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 w3AF149u024061 for ; Tue, 10 Apr 2018 11:01:42 -0400 Received: from e32.co.us.ibm.com (e32.co.us.ibm.com [32.97.110.150]) by mx0b-001b2d01.pphosted.com with ESMTP id 2h8wtd5wg7-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Tue, 10 Apr 2018 11:01:40 -0400 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 10 Apr 2018 09:01:37 -0600 Received: from b03cxnp08025.gho.boulder.ibm.com (9.17.130.17) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 10 Apr 2018 09:01:34 -0600 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w3AF1WNa13500918; Tue, 10 Apr 2018 08:01:32 -0700 Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A765A6A03B; Tue, 10 Apr 2018 09:01:32 -0600 (MDT) Received: from collin-ThinkPad-W541.pok.ibm.com (unknown [9.56.58.46]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP id 09CF76A03F; Tue, 10 Apr 2018 09:01: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: Tue, 10 Apr 2018 11:01:25 -0400 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523372486-13190-1-git-send-email-walling@linux.ibm.com> References: <1523372486-13190-1-git-send-email-walling@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18041015-0004-0000-0000-000013EEE252 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008831; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000256; SDB=6.01015903; UDB=6.00518032; IPR=6.00795153; MB=3.00020502; MTD=3.00000008; XFM=3.00000015; UTC=2018-04-10 15:01:36 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18041015-0005-0000-0000-000086D35CCB Message-Id: <1523372486-13190-4-git-send-email-walling@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-04-10_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1804100146 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 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 --- pc-bios/s390-ccw/menu.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/pc-bios/s390-ccw/menu.c b/pc-bios/s390-ccw/menu.c index 96eec81..083405f 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,21 +177,28 @@ static int get_boot_index(int entries) return boot_index; } =20 -static void zipl_println(const char *data, size_t len) +static void zipl_println(const char *data, size_t len, bool *valid_entries) { char buf[len + 2]; + int entry; =20 ebcdic_to_ascii(data, buf, len); buf[len] =3D '\n'; buf[len + 1] =3D '\0'; =20 sclp_print(buf); + + entry =3D buf[0] =3D=3D ' ' ? atoui(buf + 1) : atoui(buf); + valid_entries[entry] =3D true; + + if (entry =3D=3D 0) + sclp_print("\n"); } =20 int menu_get_zipl_boot_index(const char *menu_data) { size_t len; - int entries; + 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 +210,19 @@ 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); + zipl_println(menu_data, len, valid_entries); menu_data +=3D len + 1; - - if (entries < 2) { - 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 Sat Apr 27 07:09:13 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 1523372845601676.3151006955595; Tue, 10 Apr 2018 08:07:25 -0700 (PDT) Received: from localhost ([::1]:50806 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f5urk-0005Z2-RU for importer@patchew.org; Tue, 10 Apr 2018 11:07:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32977) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f5umJ-00018A-Py for qemu-devel@nongnu.org; Tue, 10 Apr 2018 11:01:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f5umE-0000QR-Do for qemu-devel@nongnu.org; Tue, 10 Apr 2018 11:01:47 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:34670 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 1f5umE-0000Q9-7g for qemu-devel@nongnu.org; Tue, 10 Apr 2018 11:01:42 -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 w3AEpi9e125704 for ; Tue, 10 Apr 2018 11:01:41 -0400 Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) by mx0a-001b2d01.pphosted.com with ESMTP id 2h8wfn73jy-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Tue, 10 Apr 2018 11:01:40 -0400 Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 10 Apr 2018 09:01:38 -0600 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; Tue, 10 Apr 2018 09:01:36 -0600 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w3AF1YXm4391268; Tue, 10 Apr 2018 08:01:34 -0700 Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6771F6A03D; Tue, 10 Apr 2018 09:01:34 -0600 (MDT) Received: from collin-ThinkPad-W541.pok.ibm.com (unknown [9.56.58.46]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP id BEE246A03B; Tue, 10 Apr 2018 09:01: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: Tue, 10 Apr 2018 11:01:26 -0400 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523372486-13190-1-git-send-email-walling@linux.ibm.com> References: <1523372486-13190-1-git-send-email-walling@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18041015-0020-0000-0000-00000DB7E36C X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008831; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000256; SDB=6.01015903; UDB=6.00518032; IPR=6.00795153; MB=3.00020502; MTD=3.00000008; XFM=3.00000015; UTC=2018-04-10 15:01:37 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18041015-0021-0000-0000-000060D9827E Message-Id: <1523372486-13190-5-git-send-email-walling@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-04-10_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1804100146 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 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 --- 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 083405f..2f11a51 100644 --- a/pc-bios/s390-ccw/menu.c +++ b/pc-bios/s390-ccw/menu.c @@ -225,19 +225,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