From nobody Tue Feb 10 04:14:13 2026 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 1529410374731404.70727150449545; Tue, 19 Jun 2018 05:12:54 -0700 (PDT) Received: from localhost ([::1]:41203 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fVFVA-0004me-OC for importer@patchew.org; Tue, 19 Jun 2018 08:12:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41774) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fVFNR-000774-IS for qemu-devel@nongnu.org; Tue, 19 Jun 2018 08:04:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fVFNQ-0001nV-EY for qemu-devel@nongnu.org; Tue, 19 Jun 2018 08:04:49 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:47528 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 1fVFNQ-0001nJ-83; Tue, 19 Jun 2018 08:04:48 -0400 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 C739140122A8; Tue, 19 Jun 2018 12:04:47 +0000 (UTC) Received: from localhost (dhcp-192-215.str.redhat.com [10.33.192.215]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 723D62026D68; Tue, 19 Jun 2018 12:04:47 +0000 (UTC) From: Cornelia Huck To: Peter Maydell Date: Tue, 19 Jun 2018 14:04:26 +0200 Message-Id: <20180619120434.25062-5-cohuck@redhat.com> In-Reply-To: <20180619120434.25062-1-cohuck@redhat.com> References: <20180619120434.25062-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.5]); Tue, 19 Jun 2018 12:04:47 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 19 Jun 2018 12:04:47 +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 04/12] s390x/ipl: Try to detect Linux vs non Linux for initial IPL PSW 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 , Cornelia Huck , Alexander Graf , qemu-devel@nongnu.org, Christian Borntraeger , qemu-s390x@nongnu.org, 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: Christian Borntraeger Right now the IPL device always starts from address 0x10000 (the usual Linux entry point). To run other guests (e.g. test programs) it is useful to use the IPL PSW from address 0. We can use the Linux magic at 0x10008 to decide. Signed-off-by: Christian Borntraeger Message-Id: <20180612125933.262679-1-borntraeger@de.ibm.com> Reviewed-by: David Hildenbrand Reviewed-by: Thomas Huth Signed-off-by: Cornelia Huck --- hw/s390x/ipl.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c index 04245b5258..0d67349004 100644 --- a/hw/s390x/ipl.c +++ b/hw/s390x/ipl.c @@ -29,6 +29,7 @@ #include "exec/exec-all.h" =20 #define KERN_IMAGE_START 0x010000UL +#define LINUX_MAGIC_ADDR 0x010008UL #define KERN_PARM_AREA 0x010480UL #define INITRD_START 0x800000UL #define INITRD_PARM_START 0x010408UL @@ -105,7 +106,9 @@ static uint64_t bios_translate_addr(void *opaque, uint6= 4_t srcaddr) static void s390_ipl_realize(DeviceState *dev, Error **errp) { S390IPLState *ipl =3D S390_IPL(dev); - uint64_t pentry =3D KERN_IMAGE_START; + uint32_t *ipl_psw; + uint64_t pentry; + char *magic; int kernel_size; Error *err =3D NULL; =20 @@ -157,10 +160,24 @@ static void s390_ipl_realize(DeviceState *dev, Error = **errp) NULL, 1, EM_S390, 0, 0); if (kernel_size < 0) { kernel_size =3D load_image_targphys(ipl->kernel, 0, ram_size); - } - if (kernel_size < 0) { - error_setg(&err, "could not load kernel '%s'", ipl->kernel); - goto error; + if (kernel_size < 0) { + error_setg(&err, "could not load kernel '%s'", ipl->kernel= ); + goto error; + } + /* if this is Linux use KERN_IMAGE_START */ + magic =3D rom_ptr(LINUX_MAGIC_ADDR); + if (magic && !memcmp(magic, "S390EP", 6)) { + pentry =3D KERN_IMAGE_START; + } else { + /* if not Linux load the address of the (short) IPL PSW */ + ipl_psw =3D rom_ptr(4); + if (ipl_psw) { + pentry =3D be32_to_cpu(*ipl_psw) & 0x7fffffffUL; + } else { + error_setg(&err, "Could not get IPL PSW"); + goto error; + } + } } /* * Is it a Linux kernel (starting at 0x10000)? If yes, we fill in = the --=20 2.14.4