From patchwork Fri Feb 23 15:43:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Collin L. Walling" X-Patchwork-Id: 10238249 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 11C7460390 for ; Fri, 23 Feb 2018 16:12:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 011D729799 for ; Fri, 23 Feb 2018 16:12:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EA0BA297C8; Fri, 23 Feb 2018 16:12:08 +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 671D129799 for ; Fri, 23 Feb 2018 16:12:07 +0000 (UTC) Received: from localhost ([::1]:45476 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1epFx8-0001kz-Pp for patchwork-qemu-devel@patchwork.kernel.org; Fri, 23 Feb 2018 11:12:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46946) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1epFVt-0001IL-7t for qemu-devel@nongnu.org; Fri, 23 Feb 2018 10:43:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1epFVq-0007lL-VC for qemu-devel@nongnu.org; Fri, 23 Feb 2018 10:43:57 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:45004 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1epFVq-0007kQ-OQ for qemu-devel@nongnu.org; Fri, 23 Feb 2018 10:43:54 -0500 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w1NFfgwK046344 for ; Fri, 23 Feb 2018 10:43:54 -0500 Received: from e17.ny.us.ibm.com (e17.ny.us.ibm.com [129.33.205.207]) by mx0b-001b2d01.pphosted.com with ESMTP id 2gaka9yax4-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 23 Feb 2018 10:43:53 -0500 Received: from localhost by e17.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 23 Feb 2018 10:43:53 -0500 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) by e17.ny.us.ibm.com (146.89.104.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 23 Feb 2018 10:43:50 -0500 Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w1NFhnQG32112678; Fri, 23 Feb 2018 15:43:49 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2479812403F; Fri, 23 Feb 2018 11:46:05 -0500 (EST) Received: from collin-ThinkPad-W541.pok.ibm.com (unknown [9.56.58.74]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP id 16918124037; Fri, 23 Feb 2018 11:46:05 -0500 (EST) From: "Collin L. Walling" To: qemu-s390x@nongnu.org, qemu-devel@nongnu.org Date: Fri, 23 Feb 2018 10:43:18 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519400599-21081-1-git-send-email-walling@linux.vnet.ibm.com> References: <1519400599-21081-1-git-send-email-walling@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18022315-0040-0000-0000-000003FC0365 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008584; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000254; SDB=6.00993971; UDB=6.00505108; IPR=6.00773311; MB=3.00019709; MTD=3.00000008; XFM=3.00000015; UTC=2018-02-23 15:43:52 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18022315-0041-0000-0000-000007FD0B24 Message-Id: <1519400599-21081-13-git-send-email-walling@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-02-23_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1802230194 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH v9 12/13] s390-ccw: use zipl values when no boot menu options are present 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: frankja@linux.vnet.ibm.com, thuth@redhat.com, cohuck@redhat.com, david@redhat.com, alifm@linux.vnet.ibm.com, mihajlov@linux.vnet.ibm.com, borntraeger@de.ibm.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP If no boot menu options are present, then flag the boot menu to use the zipl options that were set in the zipl configuration file (and stored on disk by zipl). These options are found at some offset prior to the start of the zipl boot menu banner. The zipl timeout value is limited to a 16-bit unsigned integer and stored as seconds, so we take care to convert it to milliseconds in order to conform to the rest of the boot menu functionality. This is limited to CCW devices. For reference, the zipl configuration file uses the following fields in the menu section: prompt=1 enable the boot menu timeout=X set the timeout to X seconds To explicitly disregard any boot menu options, then menu=off or must be specified. Signed-off-by: Collin L. Walling Reviewed-by: Thomas Huth --- hw/s390x/ipl.c | 5 +++++ hw/s390x/ipl.h | 1 + pc-bios/s390-ccw/iplb.h | 1 + pc-bios/s390-ccw/main.c | 3 ++- pc-bios/s390-ccw/menu.c | 16 +++++++++++++++- 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c index ee2039d..c12e460 100644 --- a/hw/s390x/ipl.c +++ b/hw/s390x/ipl.c @@ -241,6 +241,11 @@ static void s390_ipl_set_boot_menu(S390IPLState *ipl) switch (ipl->iplb.pbt) { case S390_IPL_TYPE_CCW: + /* In the absence of -boot menu, use zipl parameters */ + if (!qemu_opt_get(opts, "menu")) { + *flags |= QIPL_FLAG_BM_OPTS_ZIPL; + return; + } break; default: error_report("boot menu is not supported for this device type."); diff --git a/hw/s390x/ipl.h b/hw/s390x/ipl.h index 3a37924..1a8adc2 100644 --- a/hw/s390x/ipl.h +++ b/hw/s390x/ipl.h @@ -93,6 +93,7 @@ void s390_reipl_request(void); /* Boot Menu flags */ #define QIPL_FLAG_BM_OPTS_CMD 0x80 +#define QIPL_FLAG_BM_OPTS_ZIPL 0x40 /* * The QEMU IPL Parameters will be stored at absolute address diff --git a/pc-bios/s390-ccw/iplb.h b/pc-bios/s390-ccw/iplb.h index 832bb94..7dfce4f 100644 --- a/pc-bios/s390-ccw/iplb.h +++ b/pc-bios/s390-ccw/iplb.h @@ -76,6 +76,7 @@ extern IplParameterBlock iplb __attribute__((__aligned__(PAGE_SIZE))); /* Boot Menu flags */ #define QIPL_FLAG_BM_OPTS_CMD 0x80 +#define QIPL_FLAG_BM_OPTS_ZIPL 0x40 /* * This definition must be kept in sync with the defininition diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c index 32ed70e..a7473b0 100644 --- a/pc-bios/s390-ccw/main.c +++ b/pc-bios/s390-ccw/main.c @@ -20,6 +20,7 @@ QemuIplParameters qipl; #define LOADPARM_PROMPT "PROMPT " #define LOADPARM_EMPTY "........" +#define BOOT_MENU_FLAG_MASK (QIPL_FLAG_BM_OPTS_CMD | QIPL_FLAG_BM_OPTS_ZIPL) /* * Priniciples of Operations (SA22-7832-09) chapter 17 requires that @@ -91,7 +92,7 @@ static void menu_setup(void) switch (iplb.pbt) { case S390_IPL_TYPE_CCW: - menu_set_parms(qipl.qipl_flags & QIPL_FLAG_BM_OPTS_CMD, + menu_set_parms(qipl.qipl_flags & BOOT_MENU_FLAG_MASK, qipl.boot_menu_timeout); return; } diff --git a/pc-bios/s390-ccw/menu.c b/pc-bios/s390-ccw/menu.c index 8d55869..ee56939 100644 --- a/pc-bios/s390-ccw/menu.c +++ b/pc-bios/s390-ccw/menu.c @@ -18,6 +18,10 @@ #define KEYCODE_BACKSP '\177' #define KEYCODE_ENTER '\r' +/* Offsets from zipl fields to zipl banner start */ +#define ZIPL_TIMEOUT_OFFSET 138 +#define ZIPL_FLAG_OFFSET 140 + #define TOD_CLOCK_MILLISECOND 0x3e8000 #define LOW_CORE_EXTERNAL_INT_ADDR 0x86 @@ -187,6 +191,16 @@ int menu_get_zipl_boot_index(const char *menu_data) { size_t len; int entries; + uint16_t zipl_flag = *(uint16_t *)(menu_data - ZIPL_FLAG_OFFSET); + uint16_t zipl_timeout = *(uint16_t *)(menu_data - ZIPL_TIMEOUT_OFFSET); + + if (flag == QIPL_FLAG_BM_OPTS_ZIPL) { + if (!zipl_flag) { + return 0; /* Boot default */ + } + /* zipl stores timeout as seconds */ + timeout = zipl_timeout * 1000; + } /* Print and count all menu items, including the banner */ for (entries = 0; *menu_data; entries++) { @@ -211,5 +225,5 @@ void menu_set_parms(uint8_t boot_menu_flag, uint32_t boot_menu_timeout) bool menu_is_enabled_zipl(void) { - return flag & QIPL_FLAG_BM_OPTS_CMD; + return flag & (QIPL_FLAG_BM_OPTS_CMD | QIPL_FLAG_BM_OPTS_ZIPL); }