[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH RFCv3 1/9] s390x: move setting of maximum ram size to machine ini
From: |
David Hildenbrand |
Subject: |
[PATCH RFCv3 1/9] s390x: move setting of maximum ram size to machine init |
Date: |
Fri, 24 Jul 2020 16:37:42 +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 | 15 +--------------
2 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 8cc2f25d8a..dca8e43001 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -158,13 +158,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
@@ -247,7 +260,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 a0ce444b4b..f59195e15a 100644
--- a/hw/s390x/sclp.c
+++ b/hw/s390x/sclp.c
@@ -327,27 +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);
- 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.
*/
- if (!sysbus_realize(SYS_BUS_DEVICE(sclp->event_facility), errp)) {
- return;
- }
-
- ret = s390_set_memory_limit(machine->maxram_size, &hw_limit);
- if (ret == -E2BIG) {
- error_setg(errp, "host supports a maximum of %" PRIu64 " GB",
- hw_limit / GiB);
- } else if (ret) {
- error_setg(errp, "setting the guest size failed");
- }
+ sysbus_realize(SYS_BUS_DEVICE(sclp->event_facility), errp);
}
static void sclp_memory_init(SCLPDevice *sclp)
--
2.26.2
- [PATCH RFCv3 0/9] s390x: initial support for virtio-mem, David Hildenbrand, 2020/07/24
- [PATCH RFCv3 2/9] s390x/diag: no need to check for PGM_PRIVILEGED in diag308, David Hildenbrand, 2020/07/24
- [PATCH RFCv3 1/9] s390x: move setting of maximum ram size to machine init,
David Hildenbrand <=
- [PATCH RFCv3 4/9] s390x: prepare for more diag500 hypercalls, David Hildenbrand, 2020/07/24
- [PATCH RFCv3 5/9] s390x: rename s390-virtio-hcall* to s390-hypercall*, David Hildenbrand, 2020/07/24
- [PATCH RFCv3 7/9] s390x: prepare device memory address space, David Hildenbrand, 2020/07/24
- [PATCH RFCv3 6/9] s390x/diag: subcode to query device memory region, David Hildenbrand, 2020/07/24