[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH RFC 1/5] s390x: move setting of maximum ram size to machine init
From: |
David Hildenbrand |
Subject: |
[PATCH RFC 1/5] s390x: move setting of maximum ram size to machine init |
Date: |
Wed, 8 Jul 2020 20:51:31 +0200 |
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
- Re: [PATCH RFC 2/5] s390x: implement diag260, (continued)
- Re: [PATCH RFC 2/5] s390x: implement diag260, David Hildenbrand, 2020/07/15
- Re: [PATCH RFC 2/5] s390x: implement diag260, Heiko Carstens, 2020/07/15
- Re: [PATCH RFC 2/5] s390x: implement diag260, David Hildenbrand, 2020/07/15
- Re: [PATCH RFC 2/5] s390x: implement diag260, Heiko Carstens, 2020/07/15
- Re: [PATCH RFC 2/5] s390x: implement diag260, David Hildenbrand, 2020/07/15
- Re: [PATCH RFC 2/5] s390x: implement diag260, Heiko Carstens, 2020/07/15
- Re: [PATCH RFC 2/5] s390x: implement diag260, David Hildenbrand, 2020/07/15
- Re: [PATCH RFC 2/5] s390x: implement diag260, David Hildenbrand, 2020/07/15
- Re: [PATCH RFC 2/5] s390x: implement diag260, Heiko Carstens, 2020/07/20
- Re: [PATCH RFC 2/5] s390x: implement diag260, David Hildenbrand, 2020/07/20
[PATCH RFC 1/5] s390x: move setting of maximum ram size to machine init,
David Hildenbrand <=
[PATCH RFC 5/5] s390x: initial support for virtio-mem, David Hildenbrand, 2020/07/08
[PATCH RFC 4/5] s390x: implement virtio-mem-ccw, David Hildenbrand, 2020/07/08
[PATCH RFC 3/5] s390x: prepare device memory address space, David Hildenbrand, 2020/07/08