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 1525419522049215.1846931923983; Fri, 4 May 2018 00:38:42 -0700 (PDT) Received: from localhost ([::1]:32809 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fEVIY-0006P1-8Z for importer@patchew.org; Fri, 04 May 2018 03:38:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34206) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fEV66-0004TN-G3 for qemu-devel@nongnu.org; Fri, 04 May 2018 03:25:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fEV65-0007Pe-Ge for qemu-devel@nongnu.org; Fri, 04 May 2018 03:25:42 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:48250 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 1fEV65-0007Oe-Bn; Fri, 04 May 2018 03:25:41 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E866F81A88A0; Fri, 4 May 2018 07:25:40 +0000 (UTC) Received: from localhost (dhcp-192-222.str.redhat.com [10.33.192.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AB16C11166E0; Fri, 4 May 2018 07:25:38 +0000 (UTC) From: Cornelia Huck To: Peter Maydell Date: Fri, 4 May 2018 09:25:08 +0200 Message-Id: <20180504072514.8450-10-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.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Fri, 04 May 2018 07:25:40 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Fri, 04 May 2018 07:25:40 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.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 09/15] 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: 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 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 96eec81e84..aaf5d61ae6 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.14.3