From nobody Wed Oct 29 20:38:27 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 1525272390622106.3379498112032; Wed, 2 May 2018 07:46:30 -0700 (PDT) Received: from localhost ([::1]:50870 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fDt1Z-0004Sb-SQ for importer@patchew.org; Wed, 02 May 2018 10:46:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56905) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fDspC-0002KH-S9 for qemu-devel@nongnu.org; Wed, 02 May 2018 10:33:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fDsp9-00051P-0L for qemu-devel@nongnu.org; Wed, 02 May 2018 10:33:42 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:51374 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 1fDsp8-000518-RP; Wed, 02 May 2018 10:33:38 -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 685414022909; Wed, 2 May 2018 14:33:38 +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 631EA2166BC7; Wed, 2 May 2018 14:33:37 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org, Cornelia Huck Date: Wed, 2 May 2018 16:33:23 +0200 Message-Id: <1525271609-2142-5-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.6]); Wed, 02 May 2018 14:33:38 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 02 May 2018 14:33:38 +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 04/10] 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: Christian Borntraeger , qemu-s390x@nongnu.org, "Collin L. Walling" 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 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 Signed-off-by: Thomas Huth --- 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 1.8.3.1