From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57802) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWN2t-0006kt-FJ for qemu-devel@nongnu.org; Mon, 31 Aug 2015 07:14:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWN2p-0006O3-EQ for qemu-devel@nongnu.org; Mon, 31 Aug 2015 07:14:39 -0400 Received: from e06smtp10.uk.ibm.com ([195.75.94.106]:56073) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWN2p-0006MI-5S for qemu-devel@nongnu.org; Mon, 31 Aug 2015 07:14:35 -0400 Received: from /spool/local by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 31 Aug 2015 12:14:34 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id AFC5C17D8059 for ; Mon, 31 Aug 2015 12:16:13 +0100 (BST) Received: from d06av01.portsmouth.uk.ibm.com (d06av01.portsmouth.uk.ibm.com [9.149.37.212]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t7VBETw013893848 for ; Mon, 31 Aug 2015 11:14:32 GMT Received: from d06av01.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t7VBEJYw022456 for ; Mon, 31 Aug 2015 05:14:20 -0600 From: Cornelia Huck Date: Mon, 31 Aug 2015 13:14:01 +0200 Message-Id: <1441019643-10677-22-git-send-email-cornelia.huck@de.ibm.com> In-Reply-To: <1441019643-10677-1-git-send-email-cornelia.huck@de.ibm.com> References: <1441019643-10677-1-git-send-email-cornelia.huck@de.ibm.com> Subject: [Qemu-devel] [PATCH 21/23] s390: unify allocation of initial memory List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Cornelia Huck , borntraeger@de.ibm.com, jfrei@linux.vnet.ibm.com, agraf@suse.de, David Hildenbrand From: David Hildenbrand Now that the calculation of the initial memory is hidden in the sclp device, we can unify the allocation of the initial memory. The remaining ugly part is the reserved memory for the virtio queues, but that can be cleaned up later. Reviewed-by: Matthew Rosato Signed-off-by: David Hildenbrand Signed-off-by: Cornelia Huck --- hw/s390x/s390-virtio-ccw.c | 24 ++++++++++++++---------- hw/s390x/s390-virtio.c | 9 +-------- hw/s390x/s390-virtio.h | 1 + 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index eae1305..27a8360 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -100,15 +100,28 @@ static void virtio_ccw_register_hcalls(void) virtio_ccw_hcall_early_printk); } -static void ccw_init(MachineState *machine) +void s390_memory_init(ram_addr_t mem_size) { MemoryRegion *sysmem = get_system_memory(); MemoryRegion *ram = g_new(MemoryRegion, 1); + + /* allocate RAM for core */ + memory_region_init_ram(ram, NULL, "s390.ram", mem_size, &error_abort); + vmstate_register_ram_global(ram); + memory_region_add_subregion(sysmem, 0, ram); + + /* Initialize storage key device */ + s390_skeys_init(); +} + +static void ccw_init(MachineState *machine) +{ int ret; VirtualCssBus *css_bus; DeviceState *dev; s390_sclp_init(); + s390_memory_init(machine->ram_size); /* get a BUS */ css_bus = virtual_css_bus_init(); @@ -124,15 +137,6 @@ static void ccw_init(MachineState *machine) /* register hypercalls */ virtio_ccw_register_hcalls(); - /* allocate RAM for core */ - memory_region_init_ram(ram, NULL, "s390.ram", machine->ram_size, - &error_abort); - vmstate_register_ram_global(ram); - memory_region_add_subregion(sysmem, 0, ram); - - /* Initialize storage key device */ - s390_skeys_init(); - /* init CPUs */ s390_init_cpus(machine->cpu_model); diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c index c8e4737..e4000c9 100644 --- a/hw/s390x/s390-virtio.c +++ b/hw/s390x/s390-virtio.c @@ -262,8 +262,6 @@ int gtod_load(QEMUFile *f, void *opaque, int version_id) static void s390_init(MachineState *machine) { ram_addr_t my_ram_size; - MemoryRegion *sysmem = get_system_memory(); - MemoryRegion *ram = g_new(MemoryRegion, 1); void *virtio_region; hwaddr virtio_region_len; hwaddr virtio_region_start; @@ -285,9 +283,7 @@ static void s390_init(MachineState *machine) s390_virtio_register_hcalls(); /* allocate RAM */ - memory_region_init_ram(ram, NULL, "s390.ram", my_ram_size, &error_abort); - vmstate_register_ram_global(ram); - memory_region_add_subregion(sysmem, 0, ram); + s390_memory_init(my_ram_size); /* clear virtio region */ virtio_region_len = my_ram_size - ram_size; @@ -298,9 +294,6 @@ static void s390_init(MachineState *machine) cpu_physical_memory_unmap(virtio_region, virtio_region_len, 1, virtio_region_len); - /* Initialize storage key device */ - s390_skeys_init(); - /* init CPUs */ s390_init_cpus(machine->cpu_model); diff --git a/hw/s390x/s390-virtio.h b/hw/s390x/s390-virtio.h index cf68796..f389aa1 100644 --- a/hw/s390x/s390-virtio.h +++ b/hw/s390x/s390-virtio.h @@ -27,4 +27,5 @@ void s390_init_ipl_dev(const char *kernel_filename, bool enforce_bios); void s390_create_virtio_net(BusState *bus, const char *name); void s390_nmi(NMIState *n, int cpu_index, Error **errp); +void s390_memory_init(ram_addr_t mem_size); #endif -- 2.5.1