From patchwork Tue Feb 27 13:21:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cornelia Huck X-Patchwork-Id: 10245211 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 595C160211 for ; Tue, 27 Feb 2018 13:29:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CCAC2835B for ; Tue, 27 Feb 2018 13:29:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 41276288DD; Tue, 27 Feb 2018 13:29:16 +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=-6.9 required=2.0 tests=BAYES_00,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 C75EE2835B for ; Tue, 27 Feb 2018 13:29:15 +0000 (UTC) Received: from localhost ([::1]:37102 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqfJi-0003Bf-VV for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Feb 2018 08:29:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34625) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqfD2-0005Ex-D0 for qemu-devel@nongnu.org; Tue, 27 Feb 2018 08:22:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqfD1-0008HF-A0 for qemu-devel@nongnu.org; Tue, 27 Feb 2018 08:22:20 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:33484 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 1eqfD1-0008Gv-4g; Tue, 27 Feb 2018 08:22:19 -0500 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 BD38C40FB650; Tue, 27 Feb 2018 13:22:18 +0000 (UTC) Received: from localhost (ovpn-117-77.ams2.redhat.com [10.36.117.77]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6E3B02024CA2; Tue, 27 Feb 2018 13:22:18 +0000 (UTC) From: Cornelia Huck To: peter.maydell@linaro.org Date: Tue, 27 Feb 2018 14:21:30 +0100 Message-Id: <20180227132150.13847-7-cohuck@redhat.com> In-Reply-To: <20180227132150.13847-1-cohuck@redhat.com> References: <20180227132150.13847-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.7]); Tue, 27 Feb 2018 13:22:18 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 27 Feb 2018 13:22:18 +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 06/26] s390-ccw: parse and set boot menu options 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: thuth@redhat.com, david@redhat.com, qemu-devel@nongnu.org, agraf@suse.de, borntraeger@de.ibm.com, qemu-s390x@nongnu.org, "Collin L. Walling" , rth@twiddle.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: "Collin L. Walling" Set boot menu options for an s390 guest and store them in the iplb. These options are set via the QEMU command line option: -boot menu=on|off[,splash-time=X] or via the libvirt domain xml: Where X represents some positive integer representing milliseconds. Any value set for loadparm will override all boot menu options. If loadparm=PROMPT, then the menu will be enabled without a timeout. Signed-off-by: Collin L. Walling Reviewed-by: Janosch Frank Reviewed-by: Thomas Huth Signed-off-by: Thomas Huth --- hw/s390x/ipl.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ hw/s390x/ipl.h | 9 +++++++-- pc-bios/s390-ccw/iplb.h | 9 +++++++-- 3 files changed, 66 insertions(+), 4 deletions(-) diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c index 79f5a58adb..ee2039dc69 100644 --- a/hw/s390x/ipl.c +++ b/hw/s390x/ipl.c @@ -23,6 +23,9 @@ #include "hw/s390x/ebcdic.h" #include "ipl.h" #include "qemu/error-report.h" +#include "qemu/config-file.h" +#include "qemu/cutils.h" +#include "qemu/option.h" #define KERN_IMAGE_START 0x010000UL #define KERN_PARM_AREA 0x010480UL @@ -219,6 +222,54 @@ static Property s390_ipl_properties[] = { DEFINE_PROP_END_OF_LIST(), }; +static void s390_ipl_set_boot_menu(S390IPLState *ipl) +{ + QemuOptsList *plist = qemu_find_opts("boot-opts"); + QemuOpts *opts = QTAILQ_FIRST(&plist->head); + uint8_t *flags = &ipl->qipl.qipl_flags; + uint32_t *timeout = &ipl->qipl.boot_menu_timeout; + const char *tmp; + unsigned long splash_time = 0; + + if (!get_boot_device(0)) { + if (boot_menu) { + error_report("boot menu requires a bootindex to be specified for " + "the IPL device."); + } + return; + } + + switch (ipl->iplb.pbt) { + case S390_IPL_TYPE_CCW: + break; + default: + error_report("boot menu is not supported for this device type."); + return; + } + + if (!boot_menu) { + return; + } + + *flags |= QIPL_FLAG_BM_OPTS_CMD; + + tmp = qemu_opt_get(opts, "splash-time"); + + if (tmp && qemu_strtoul(tmp, NULL, 10, &splash_time)) { + error_report("splash-time is invalid, forcing it to 0."); + *timeout = 0; + return; + } + + if (splash_time > 0xffffffff) { + error_report("splash-time is too large, forcing it to max value."); + *timeout = 0xffffffff; + return; + } + + *timeout = cpu_to_be32(splash_time); +} + static bool s390_gen_initial_iplb(S390IPLState *ipl) { DeviceState *dev_st; @@ -435,6 +486,7 @@ void s390_ipl_prepare_cpu(S390CPU *cpu) } ipl->qipl.netboot_start_addr = cpu_to_be64(ipl->start_addr); } + s390_ipl_set_boot_menu(ipl); s390_ipl_prepare_qipl(cpu); } diff --git a/hw/s390x/ipl.h b/hw/s390x/ipl.h index 5cc3b770d4..d6c6f75b76 100644 --- a/hw/s390x/ipl.h +++ b/hw/s390x/ipl.h @@ -91,6 +91,9 @@ void s390_reipl_request(void); #define QIPL_ADDRESS 0xcc +/* Boot Menu flags */ +#define QIPL_FLAG_BM_OPTS_CMD 0x80 + /* * The QEMU IPL Parameters will be stored at absolute address * 204 (0xcc) which means it is 32-bit word aligned but not @@ -104,9 +107,11 @@ void s390_reipl_request(void); * in pc-bios/s390-ccw/iplb.h. */ struct QemuIplParameters { - uint8_t reserved1[4]; + uint8_t qipl_flags; + uint8_t reserved1[3]; uint64_t netboot_start_addr; - uint8_t reserved2[16]; + uint32_t boot_menu_timeout; + uint8_t reserved2[12]; } QEMU_PACKED; typedef struct QemuIplParameters QemuIplParameters; diff --git a/pc-bios/s390-ccw/iplb.h b/pc-bios/s390-ccw/iplb.h index 31d2934762..832bb94440 100644 --- a/pc-bios/s390-ccw/iplb.h +++ b/pc-bios/s390-ccw/iplb.h @@ -74,14 +74,19 @@ extern IplParameterBlock iplb __attribute__((__aligned__(PAGE_SIZE))); #define QIPL_ADDRESS 0xcc +/* Boot Menu flags */ +#define QIPL_FLAG_BM_OPTS_CMD 0x80 + /* * This definition must be kept in sync with the defininition * in hw/s390x/ipl.h */ struct QemuIplParameters { - uint8_t reserved1[4]; + uint8_t qipl_flags; + uint8_t reserved1[3]; uint64_t netboot_start_addr; - uint8_t reserved2[16]; + uint32_t boot_menu_timeout; + uint8_t reserved2[12]; } __attribute__ ((packed)); typedef struct QemuIplParameters QemuIplParameters;