From nobody Fri Dec 19 16:59:30 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1594247200; cv=none; d=zohomail.com; s=zohoarc; b=Raiz6kcsniYNBauLjAdyNtZ22KguleIWZAOn+WRJKA0cFMIA/SCDG58+8FmoBoZbbaYZdU4ASXbHXBOdYpMSXoKSku1av5HhUFug/ZnbES1pW7/UlKEoR4PqKJrnAarBGVcJ+W065pta6ozjJcA58X1CymooTRe77eyfsq4WJWM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594247200; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ibC8VBxKDigT75V4r6cBk01+W7vG9M45onQMHCdIq18=; b=S8f6mcjnrAMS5mnvUyi6t7Kp8cFJ97vX1BbVqX9+ZP6CrqAw5zoosvn6DOuKIe2mQyk09xDXorZNY9gIeZ7llZyT7p7+o7cxUNLHd4ODsHOMRmcQiAXuUk2pO3DrvZRSsyI9f2WHWYRZBz7LI4DvhTkPL+X6Q+OJnkozpGKILSE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1594247200383333.74760434493055; Wed, 8 Jul 2020 15:26:40 -0700 (PDT) Received: from localhost ([::1]:44748 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jtIWV-0002cz-4Z for importer@patchew.org; Wed, 08 Jul 2020 18:26:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40642) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jtHzK-00041g-6j for qemu-devel@nongnu.org; Wed, 08 Jul 2020 17:52:22 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:21043 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jtHzI-0005G8-CK for qemu-devel@nongnu.org; Wed, 08 Jul 2020 17:52:21 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-216-TTI4SnaMMM6CVVsPbzBsLg-1; Wed, 08 Jul 2020 14:51:56 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B32918015F5; Wed, 8 Jul 2020 18:51:52 +0000 (UTC) Received: from t480s.redhat.com (ovpn-113-117.ams2.redhat.com [10.36.113.117]) by smtp.corp.redhat.com (Postfix) with ESMTP id C49EA7554B; Wed, 8 Jul 2020 18:51:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594245139; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ibC8VBxKDigT75V4r6cBk01+W7vG9M45onQMHCdIq18=; b=ZDBDlMkpTPavJ51JXUkMzoDcqksIBQsVEJe8jwxyVN3F/hHWUM+4wy79q5u90cHzfT13lG NnwvbeVnJagCs9+0LzRAkHGN9XkMiiVsJeO+xkXk/QjIJz7LOqOG93xUYtCE3XKkud4y5z 64s6SJmNfD+t4Zc/0ynPQUHBXVt70/8= X-MC-Unique: TTI4SnaMMM6CVVsPbzBsLg-1 From: David Hildenbrand To: qemu-devel@nongnu.org Subject: [PATCH RFC 1/5] s390x: move setting of maximum ram size to machine init Date: Wed, 8 Jul 2020 20:51:31 +0200 Message-Id: <20200708185135.46694-2-david@redhat.com> In-Reply-To: <20200708185135.46694-1-david@redhat.com> References: <20200708185135.46694-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=david@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/07 17:25:09 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , Janosch Frank , "Michael S . Tsirkin" , Cornelia Huck , Heiko Carstens , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, David Hildenbrand , Claudio Imbrenda , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" As we no longer fixup the maximum ram size in sclp code, let's move setting the maximum ram size to ccw_init()->s390_memory_init(), which now looks like a better fit. Signed-off-by: David Hildenbrand --- hw/s390x/s390-virtio-ccw.c | 19 ++++++++++++++++--- hw/s390x/sclp.c | 20 +------------------- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 023fd25f2b..2e6d292c23 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -160,13 +160,26 @@ static void virtio_ccw_register_hcalls(void) virtio_ccw_hcall_early_printk); } =20 -static void s390_memory_init(MemoryRegion *ram) +static void s390_memory_init(MachineState *machine) { MemoryRegion *sysmem =3D get_system_memory(); Error *local_err =3D NULL; + uint64_t hw_limit; + int ret; + + /* We have to set the memory limit before adding any regions to sysmem= . */ + ret =3D s390_set_memory_limit(machine->maxram_size, &hw_limit); + if (ret =3D=3D -E2BIG) { + error_report("host supports a maximum of %" PRIu64 " GB", + hw_limit / GiB); + exit(EXIT_FAILURE); + } else if (ret) { + error_report("setting the guest size failed"); + exit(EXIT_FAILURE); + } =20 /* allocate RAM for core */ - memory_region_add_subregion(sysmem, 0, ram); + memory_region_add_subregion(sysmem, 0, machine->ram); =20 /* * Configure the maximum page size. As no memory devices were created @@ -249,7 +262,7 @@ static void ccw_init(MachineState *machine) =20 s390_sclp_init(); /* init memory + setup max page size. Required for the CPU model */ - s390_memory_init(machine->ram); + s390_memory_init(machine); =20 /* init CPUs (incl. CPU model) early so s390_has_feature() works */ s390_init_cpus(machine); diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c index d39f6d7785..f59195e15a 100644 --- a/hw/s390x/sclp.c +++ b/hw/s390x/sclp.c @@ -327,32 +327,14 @@ void s390_sclp_init(void) =20 static void sclp_realize(DeviceState *dev, Error **errp) { - MachineState *machine =3D MACHINE(qdev_get_machine()); SCLPDevice *sclp =3D SCLP(dev); - Error *err =3D NULL; - uint64_t hw_limit; - int ret; =20 /* * qdev_device_add searches the sysbus for TYPE_SCLP_EVENTS_BUS. As lo= ng * as we can't find a fitting bus via the qom tree, we have to add the * event facility to the sysbus, so e.g. a sclp console can be created. */ - sysbus_realize(SYS_BUS_DEVICE(sclp->event_facility), &err); - if (err) { - goto out; - } - - ret =3D s390_set_memory_limit(machine->maxram_size, &hw_limit); - if (ret =3D=3D -E2BIG) { - error_setg(&err, "host supports a maximum of %" PRIu64 " GB", - hw_limit / GiB); - } else if (ret) { - error_setg(&err, "setting the guest size failed"); - } - -out: - error_propagate(errp, err); + sysbus_realize(SYS_BUS_DEVICE(sclp->event_facility), errp); } =20 static void sclp_memory_init(SCLPDevice *sclp) --=20 2.26.2