All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: qemu-devel@nongnu.org
Cc: Thomas Huth <thuth@redhat.com>,
	Janosch Frank <frankja@linux.ibm.com>,
	"Michael S . Tsirkin" <mst@redhat.com>,
	Cornelia Huck <cohuck@redhat.com>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	Halil Pasic <pasic@linux.ibm.com>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	qemu-s390x@nongnu.org, David Hildenbrand <david@redhat.com>,
	Claudio Imbrenda <imbrenda@linux.ibm.com>,
	Richard Henderson <rth@twiddle.net>
Subject: [PATCH RFC 1/5] s390x: move setting of maximum ram size to machine init
Date: Wed,  8 Jul 2020 20:51:31 +0200	[thread overview]
Message-ID: <20200708185135.46694-2-david@redhat.com> (raw)
In-Reply-To: <20200708185135.46694-1-david@redhat.com>

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 <david@redhat.com>
---
 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);
 }
 
-static void s390_memory_init(MemoryRegion *ram)
+static void s390_memory_init(MachineState *machine)
 {
     MemoryRegion *sysmem = get_system_memory();
     Error *local_err = NULL;
+    uint64_t hw_limit;
+    int ret;
+
+    /* We have to set the memory limit before adding any regions to sysmem. */
+    ret = s390_set_memory_limit(machine->maxram_size, &hw_limit);
+    if (ret == -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);
+    }
 
     /* allocate RAM for core */
-    memory_region_add_subregion(sysmem, 0, ram);
+    memory_region_add_subregion(sysmem, 0, machine->ram);
 
     /*
      * Configure the maximum page size. As no memory devices were created
@@ -249,7 +262,7 @@ static void ccw_init(MachineState *machine)
 
     s390_sclp_init();
     /* init memory + setup max page size. Required for the CPU model */
-    s390_memory_init(machine->ram);
+    s390_memory_init(machine);
 
     /* 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)
 
 static void sclp_realize(DeviceState *dev, Error **errp)
 {
-    MachineState *machine = MACHINE(qdev_get_machine());
     SCLPDevice *sclp = SCLP(dev);
-    Error *err = NULL;
-    uint64_t hw_limit;
-    int ret;
 
     /*
      * qdev_device_add searches the sysbus for TYPE_SCLP_EVENTS_BUS. As long
      * 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 = s390_set_memory_limit(machine->maxram_size, &hw_limit);
-    if (ret == -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);
 }
 
 static void sclp_memory_init(SCLPDevice *sclp)
-- 
2.26.2



  reply	other threads:[~2020-07-08 22:26 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-08 18:51 [PATCH RFC 0/5] s390x: initial support for virtio-mem David Hildenbrand
2020-07-08 18:51 ` David Hildenbrand [this message]
2020-07-08 18:51 ` [PATCH RFC 2/5] s390x: implement diag260 David Hildenbrand
2020-07-09 10:37   ` Cornelia Huck
2020-07-09 17:54     ` David Hildenbrand
2020-07-10  8:32     ` David Hildenbrand
2020-07-10  8:41       ` David Hildenbrand
2020-07-10  9:19         ` Cornelia Huck
2020-07-13 11:54       ` Christian Borntraeger
2020-07-13 12:11         ` Cornelia Huck
2020-07-13 12:13           ` Christian Borntraeger
2020-07-09 10:52   ` Christian Borntraeger
2020-07-09 18:15     ` David Hildenbrand
2020-07-10  9:17       ` David Hildenbrand
2020-07-10 12:12         ` David Hildenbrand
2020-07-10 15:18           ` Heiko Carstens
2020-07-10 15:24             ` David Hildenbrand
2020-07-10 15:43               ` Heiko Carstens
2020-07-10 15:45                 ` David Hildenbrand
2020-07-13  9:12               ` Heiko Carstens
2020-07-13 10:27                 ` David Hildenbrand
2020-07-13 11:08                   ` Christian Borntraeger
2020-07-15  9:42                     ` David Hildenbrand
2020-07-15 10:43                       ` Heiko Carstens
2020-07-15 11:21                         ` David Hildenbrand
2020-07-15 11:34                           ` Heiko Carstens
2020-07-15 11:42                             ` David Hildenbrand
2020-07-15 16:14                               ` Heiko Carstens
2020-07-15 17:38                                 ` David Hildenbrand
2020-07-15 17:51                                   ` David Hildenbrand
2020-07-20 14:43                                     ` Heiko Carstens
2020-07-20 15:43                                       ` David Hildenbrand
2020-07-08 18:51 ` [PATCH RFC 3/5] s390x: prepare device memory address space David Hildenbrand
2020-07-09 10:59   ` Cornelia Huck
2020-07-10  7:46     ` David Hildenbrand
2020-07-08 18:51 ` [PATCH RFC 4/5] s390x: implement virtio-mem-ccw David Hildenbrand
2020-07-09  9:24   ` Cornelia Huck
2020-07-09  9:26     ` David Hildenbrand
2020-07-08 18:51 ` [PATCH RFC 5/5] s390x: initial support for virtio-mem David Hildenbrand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200708185135.46694-2-david@redhat.com \
    --to=david@redhat.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=frankja@linux.ibm.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=imbrenda@linux.ibm.com \
    --cc=mst@redhat.com \
    --cc=pasic@linux.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.