From patchwork Wed May 2 14:33:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 10375769 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 463A46037D for ; Wed, 2 May 2018 14:36:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3610628EB9 for ; Wed, 2 May 2018 14:36:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2A97528EBB; Wed, 2 May 2018 14:36:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9B0B828EB9 for ; Wed, 2 May 2018 14:36:02 +0000 (UTC) Received: from localhost ([::1]:50800 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fDsrR-0004J8-Bc for patchwork-qemu-devel@patchwork.kernel.org; Wed, 02 May 2018 10:36:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56922) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fDspE-0002KK-Hf for qemu-devel@nongnu.org; Wed, 02 May 2018 10:33:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fDspA-00052W-Uf for qemu-devel@nongnu.org; Wed, 02 May 2018 10:33:44 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:52764 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 1fDspA-000529-QU; Wed, 02 May 2018 10:33:40 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5C755406C78D; Wed, 2 May 2018 14:33:40 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-116-75.ams2.redhat.com [10.36.116.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id DC6562166BAD; Wed, 2 May 2018 14:33:38 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org, Cornelia Huck Date: Wed, 2 May 2018 16:33:24 +0200 Message-Id: <1525271609-2142-6-git-send-email-thuth@redhat.com> In-Reply-To: <1525271609-2142-1-git-send-email-thuth@redhat.com> References: <1525271609-2142-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 02 May 2018 14:33:40 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 02 May 2018 14:33:40 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'thuth@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 SUBSYSTEM s390x 05/10] 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: Christian Borntraeger , qemu-s390x@nongnu.org, "Collin L. Walling" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 b767fa2..e41e715 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 = 0; BootMapTable *prog_table = (void *)sec; unsigned int loadparm = get_loadparm_index(); + bool valid_entries[MAX_BOOT_ENTRIES] = {false}; + size_t i; /* 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"); - while (program_table_entries < MAX_BOOT_ENTRIES) { - if (!prog_table->entry[program_table_entries].scsi.blockno) { - break; + for (i = 0; i < MAX_BOOT_ENTRIES; i++) { + if (prog_table->entry[i].scsi.blockno) { + valid_entries[i] = true; + program_table_entries++; } - program_table_entries++; } debug_print_int("program table entries", program_table_entries); IPL_assert(program_table_entries != 0, "Empty Program Table"); if (menu_is_enabled_enum()) { - loadparm = menu_get_enum_boot_index(program_table_entries); + loadparm = menu_get_enum_boot_index(valid_entries); } 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); } - -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; - sclp_print("s390x Enumerated Boot Menu.\n\n"); + sclp_print("s390-ccw Enumerated Boot Menu.\n\n"); - 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 = 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 == 0) { + sclp_print(" default\n"); + } + sclp_print("\n"); + } + } - return get_boot_index(entries); + sclp_print("\n"); + return get_boot_index(valid_entries); } 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); #define MAX_BOOT_ENTRIES 31