From nobody Wed Oct 29 20:38:59 2025 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 152541963595136.541871022208625; Fri, 4 May 2018 00:40:35 -0700 (PDT) Received: from localhost ([::1]:32828 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fEVKV-0008Rq-9j for importer@patchew.org; Fri, 04 May 2018 03:40:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34226) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fEV68-0004Vf-7X for qemu-devel@nongnu.org; Fri, 04 May 2018 03:25:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fEV67-0007RN-1j for qemu-devel@nongnu.org; Fri, 04 May 2018 03:25:44 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:57612 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fEV66-0007Qz-S9; Fri, 04 May 2018 03:25:42 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6FDACEB706; Fri, 4 May 2018 07:25:42 +0000 (UTC) Received: from localhost (dhcp-192-222.str.redhat.com [10.33.192.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2A6ED2022C00; Fri, 4 May 2018 07:25:42 +0000 (UTC) From: Cornelia Huck To: Peter Maydell Date: Fri, 4 May 2018 09:25:09 +0200 Message-Id: <20180504072514.8450-11-cohuck@redhat.com> In-Reply-To: <20180504072514.8450-1-cohuck@redhat.com> References: <20180504072514.8450-1-cohuck@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 04 May 2018 07:25:42 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 04 May 2018 07:25:42 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'cohuck@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 10/15] 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: Thomas Huth , David Hildenbrand , Alexander Graf , qemu-devel@nongnu.org, Christian Borntraeger , qemu-s390x@nongnu.org, Collin Walling , Richard Henderson 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" From: Collin Walling 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 Signed-off-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 b767fa2afc..e41e715624 100644 --- a/pc-bios/s390-ccw/bootmap.c +++ b/pc-bios/s390-ccw/bootmap.c @@ -565,6 +565,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)); @@ -585,18 +587,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 aaf5d61ae6..82a4ae6315 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 2c9e6017b7..a1bdb4cc2a 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.14.3