From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581961078104206.0131246825348; Mon, 17 Feb 2020 09:37:58 -0800 (PST) Received: from localhost ([::1]:49386 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kLE-0006iX-T3 for importer@patchew.org; Mon, 17 Feb 2020 12:37:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37940) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kIT-0000lG-6M for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kIS-0001Xd-2h for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:05 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:59969 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kIR-0001XG-VZ for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:04 -0500 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-2-iebxV0C3M1qRkNsOPLoMdg-1; Mon, 17 Feb 2020 12:34:59 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D8DBE800D50 for ; Mon, 17 Feb 2020 17:34:58 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0CFA28CCE0; Mon, 17 Feb 2020 17:34:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960903; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8Y2YgFxe5IqeICC0h6obDWm/4an82mcgUtyg/lHc6eM=; b=fLG2LczwsOBWg6eDzcPQEy0GD9KW7+R2XO0akMZrn0w5PXzBZpRVdd9gwrdubN9a7C7cm6 hokst/oTS5HeHUEPDVkH0J4we7g2LtZbipWxAKCPKkauBhg9g1jLIsyAUmH20D4taIu4K6 vlPeTNwXHXfk8BckE3oM2PrygW7xCF0= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 01/79] numa: remove deprecated -mem-path fallback to anonymous RAM Date: Mon, 17 Feb 2020 12:33:34 -0500 Message-Id: <20200217173452.15243-2-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: iebxV0C3M1qRkNsOPLoMdg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 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: Paolo Bonzini , ehabkost@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" it has been deprecated since 4.0 by commit cb79224b7 (deprecate -mem-path fallback to anonymous RAM) Deprecation period ran out and it's time to remove it so it won't get in a way of switching to using hostmem backend for RAM. Signed-off-by: Igor Mammedov Reviewed-by: Richard Henderson --- CC:libvir-list@redhat.com CC: ehabkost@redhat.com --- hw/core/numa.c | 18 +----------------- qemu-deprecated.texi | 9 --------- 2 files changed, 1 insertion(+), 26 deletions(-) diff --git a/hw/core/numa.c b/hw/core/numa.c index 0d1b4be76a..840e68581f 100644 --- a/hw/core/numa.c +++ b/hw/core/numa.c @@ -784,24 +784,8 @@ static void allocate_system_memory_nonnuma(MemoryRegio= n *mr, Object *owner, { if (mem_path) { #ifdef __linux__ - Error *err =3D NULL; memory_region_init_ram_from_file(mr, owner, name, ram_size, 0, 0, - mem_path, &err); - if (err) { - error_report_err(err); - if (mem_prealloc) { - exit(1); - } - warn_report("falling back to regular RAM allocation"); - error_printf("This is deprecated. Make sure that -mem-path " - " specified path has sufficient resources to allo= cate" - " -m specified RAM amount\n"); - /* Legacy behavior: if allocation failed, fall back to - * regular RAM allocation. - */ - mem_path =3D NULL; - memory_region_init_ram_nomigrate(mr, owner, name, ram_size, &e= rror_fatal); - } + mem_path, &error_fatal); #else fprintf(stderr, "-mem-path not supported on this host\n"); exit(1); diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi index 0671c26c80..66eca3a1de 100644 --- a/qemu-deprecated.texi +++ b/qemu-deprecated.texi @@ -113,15 +113,6 @@ QEMU using implicit generic or board specific splittin= g rule. Use @option{memdev} with @var{memory-backend-ram} backend or @option{mem} = (if it's supported by used machine type) to define mapping explictly instead. =20 -@subsection -mem-path fallback to RAM (since 4.1) -Currently if guest RAM allocation from file pointed by @option{mem-path} -fails, QEMU falls back to allocating from RAM, which might result -in unpredictable behavior since the backing file specified by the user -is ignored. In the future, users will be responsible for making sure -the backing storage specified with @option{-mem-path} can actually provide -the guest RAM configured with @option{-m} and QEMU will fail to start up if -RAM allocation is unsuccessful. - @subsection RISC-V -bios (since 4.1) =20 QEMU 4.1 introduced support for the -bios option in QEMU for RISC-V for the --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581960983478284.7417464973398; Mon, 17 Feb 2020 09:36:23 -0800 (PST) Received: from localhost ([::1]:49276 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJh-0002bM-Iu for importer@patchew.org; Mon, 17 Feb 2020 12:36:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37962) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kIV-0000nn-6Y for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kIU-0001ZE-1U for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:07 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:46948 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kIT-0001Yc-UA for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:05 -0500 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-243-XyMIkjTBOgCa2lXyVdtW4A-1; Mon, 17 Feb 2020 12:35:01 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 30614800D55; Mon, 17 Feb 2020 17:35:00 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2FD558CCE0; Mon, 17 Feb 2020 17:34:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960905; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZsXpjLltu/5LV+mrSGUwNyaNs02ahmEtpDaqOy4C/zw=; b=I1mL3PBgChT+m6vjp2hclTZE/1OmmUwwr3axQ8xJfL/qDBTMJ3eEK32gBePkbb+vEgCnzn Zm/hSamiJtjvpjKGjN+TSmtRae+e9H8HvtojJuEBIDSdztHV4PYMxrPw7PhIkf/K0Y83G0 S9TSH3SixYjjfc0BJvqgpxB9/IM5Yvc= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 02/79] machine: introduce memory-backend property Date: Mon, 17 Feb 2020 12:33:35 -0500 Message-Id: <20200217173452.15243-3-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: XyMIkjTBOgCa2lXyVdtW4A-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 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: pasic@linux.ibm.com, Paolo Bonzini , ehabkost@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Property will contain link to memory backend that will be used for backing initial RAM. Follow up commit will alias -mem-path and -mem-prealloc CLI options into memory backend options to make memory handling consistent (using only hostmem backend family for guest RAM allocation). Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- v4: * make property a string, instead of a link. Fixes -M memory-backend=3Dfoo: foo not found error since foo creation is delayed well beyond point where machine's properties are set v3: * rename property name from ram-memdev to memory-backend (Paolo Bonzini ) CC: ehabkost@redhat.com CC: pbonzini@redhat.com CC: pasic@linux.ibm.com --- include/hw/boards.h | 2 ++ hw/core/machine.c | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/hw/boards.h b/include/hw/boards.h index fb1b43d5b9..7b4b6b79d7 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -4,6 +4,7 @@ #define HW_BOARDS_H =20 #include "exec/memory.h" +#include "sysemu/hostmem.h" #include "sysemu/blockdev.h" #include "sysemu/accel.h" #include "qapi/qapi-types-machine.h" @@ -285,6 +286,7 @@ struct MachineState { bool enforce_config_section; bool enable_graphics; char *memory_encryption; + char *ram_memdev_id; DeviceMemoryState *device_memory; =20 ram_addr_t ram_size; diff --git a/hw/core/machine.c b/hw/core/machine.c index 84812a1d1c..1a6e485c87 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -508,6 +508,22 @@ static void validate_sysbus_device(SysBusDevice *sbdev= , void *opaque) } } =20 +static char *machine_get_memdev(Object *obj, Error **errp) +{ + MachineState *ms =3D MACHINE(obj); + + return g_strdup(ms->ram_memdev_id); +} + +static void machine_set_memdev(Object *obj, const char *value, Error **err= p) +{ + MachineState *ms =3D MACHINE(obj); + + g_free(ms->ram_memdev_id); + ms->ram_memdev_id =3D g_strdup(value); +} + + static void machine_init_notify(Notifier *notifier, void *data) { MachineState *machine =3D MACHINE(qdev_get_machine()); @@ -889,6 +905,14 @@ static void machine_initfn(Object *obj) "Table (HMAT)", NULL); } =20 + object_property_add_str(obj, "memory-backend", + machine_get_memdev, machine_set_memdev, + &error_abort); + object_property_set_description(obj, "memory-backend", + "Set RAM backend" + "Valid value is ID of hostmem based ba= ckend", + &error_abort); + /* Register notifier when init is done for sysbus sanity checks */ ms->sysbus_notifier.notify =3D machine_init_notify; qemu_add_machine_init_done_notifier(&ms->sysbus_notifier); --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581960998061969.8749174053123; Mon, 17 Feb 2020 09:36:38 -0800 (PST) Received: from localhost ([::1]:49286 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJw-0002rI-DK for importer@patchew.org; Mon, 17 Feb 2020 12:36:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37985) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kIZ-0000t7-5w for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kIX-0001bo-Oo for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:11 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:52027 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kIX-0001bR-Kf for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:09 -0500 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-148-xLJL2t8dP3CpJqzyE6fqlw-1; Mon, 17 Feb 2020 12:35:05 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 53F82107ACC5; Mon, 17 Feb 2020 17:35:04 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7BCD98CCE0; Mon, 17 Feb 2020 17:35:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960909; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RHbQacxYOv+U2X1sWtSNF0Hw6aIvjDuOLElsJhiu51o=; b=RTGxcFXHgZWqSMchOlg3fDx+cGKuhA3O0PuV6RngwkFqUq2CTSLBfsvvGkvH8ZWypamWqT rtvfv+Fgox77dguGTSr2AZigjSHw4/V3VuXegA6dzjzEzrea+MBTX8xwY1UIVZT8szFcA0 hmTbCiaD9XLx2hw8cWiW173K/aEnSOg= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 03/79] machine: alias -mem-path and -mem-prealloc into memory-foo backend Date: Mon, 17 Feb 2020 12:33:36 -0500 Message-Id: <20200217173452.15243-4-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: xLJL2t8dP3CpJqzyE6fqlw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 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: pasic@linux.ibm.com, Paolo Bonzini , philmd@redhat.com, ehabkost@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Allow machine to opt in for hostmem backend based initial RAM even if user uses old -mem-path/prealloc options by providing MachineClass::default_ram_id Follow up patches will incrementally convert machines to new API, by dropping memory_region_allocate_system_memory() and setting default_ram_id that board used to use before conversion to keep migration stream the same. Signed-off-by: Igor Mammedov --- v3: * rename "ram-memdev" property to "memory-backend" (Paolo Bonzini ) v4: * previous patch changed memory-backend property from link to string to allow for delayed backend creation, when backend comes explicitly from CLI. So s/object_property_set_link()/object_property_set_str()/ to account for that. v5: * add comment clarifaing that MachineClass::default_ram_id will serve as a way to enable "-m" support CC: ehabkost@redhat.com CC: pbonzini@redhat.com CC: philmd@redhat.com CC: pasic@linux.ibm.com --- include/hw/boards.h | 8 ++++++++ include/sysemu/hostmem.h | 16 ++++++++++++++++ backends/hostmem-file.c | 7 ------- backends/hostmem-ram.c | 2 -- vl.c | 25 +++++++++++++++++++++++++ 5 files changed, 49 insertions(+), 9 deletions(-) diff --git a/include/hw/boards.h b/include/hw/boards.h index 7b4b6b79d7..8e536cafb2 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -170,6 +170,13 @@ typedef struct { * false is returned, an error must be set to show the reason of * the rejection. If the hook is not provided, all hotplug will be * allowed. + * @default_ram_id: + * Specifies inital RAM MemoryRegion name to be used for default backend + * creation if user explicitly hasn't specified backend with "memory-ba= ckend" + * property. + * It also will be used as a way to optin into "-m" option support. + * If it's not set by board, '-m' will be ignored and generic code will + * not create default RAM MemoryRegion. */ struct MachineClass { /*< private >*/ @@ -226,6 +233,7 @@ struct MachineClass { bool nvdimm_supported; bool numa_mem_supported; bool auto_enable_numa; + const char *default_ram_id; =20 HotplugHandler *(*get_hotplug_handler)(MachineState *machine, DeviceState *dev); diff --git a/include/sysemu/hostmem.h b/include/sysemu/hostmem.h index 4dbdadd39e..5db0d668ec 100644 --- a/include/sysemu/hostmem.h +++ b/include/sysemu/hostmem.h @@ -27,6 +27,22 @@ #define MEMORY_BACKEND_CLASS(klass) \ OBJECT_CLASS_CHECK(HostMemoryBackendClass, (klass), TYPE_MEMORY_BACKEN= D) =20 +/* hostmem-ram.c */ +/** + * @TYPE_MEMORY_BACKEND_RAM: + * name of backend that uses mmap on the anonymous RAM + */ + +#define TYPE_MEMORY_BACKEND_RAM "memory-backend-ram" + +/* hostmem-file.c */ +/** + * @TYPE_MEMORY_BACKEND_FILE: + * name of backend that uses mmap on a file descriptor + */ +#define TYPE_MEMORY_BACKEND_FILE "memory-backend-file" + +typedef struct HostMemoryBackend HostMemoryBackend; typedef struct HostMemoryBackendClass HostMemoryBackendClass; =20 /** diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c index be64020746..cb319a9157 100644 --- a/backends/hostmem-file.c +++ b/backends/hostmem-file.c @@ -18,13 +18,6 @@ #include "sysemu/sysemu.h" #include "qom/object_interfaces.h" =20 -/* hostmem-file.c */ -/** - * @TYPE_MEMORY_BACKEND_FILE: - * name of backend that uses mmap on a file descriptor - */ -#define TYPE_MEMORY_BACKEND_FILE "memory-backend-file" - #define MEMORY_BACKEND_FILE(obj) \ OBJECT_CHECK(HostMemoryBackendFile, (obj), TYPE_MEMORY_BACKEND_FILE) =20 diff --git a/backends/hostmem-ram.c b/backends/hostmem-ram.c index 6aab8d3a73..5cc53e76c9 100644 --- a/backends/hostmem-ram.c +++ b/backends/hostmem-ram.c @@ -16,8 +16,6 @@ #include "qemu/module.h" #include "qom/object_interfaces.h" =20 -#define TYPE_MEMORY_BACKEND_RAM "memory-backend-ram" - static void ram_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) { diff --git a/vl.c b/vl.c index 794f2e5733..4dc4803611 100644 --- a/vl.c +++ b/vl.c @@ -75,6 +75,7 @@ int main(int argc, char **argv) #include "ui/input.h" #include "sysemu/sysemu.h" #include "sysemu/numa.h" +#include "sysemu/hostmem.h" #include "exec/gdbstub.h" #include "qemu/timer.h" #include "chardev/char.h" @@ -2805,6 +2806,26 @@ static void configure_accelerators(const char *progn= ame) } } =20 +static void create_default_memdev(MachineState *ms, const char *path, + bool prealloc) +{ + Object *obj; + MachineClass *mc =3D MACHINE_GET_CLASS(ms); + + obj =3D object_new(path ? TYPE_MEMORY_BACKEND_FILE : TYPE_MEMORY_BACKE= ND_RAM); + if (path) { + object_property_set_str(obj, path, "mem-path", &error_fatal); + } + object_property_set_bool(obj, prealloc, "prealloc", &error_fatal); + object_property_set_int(obj, ms->ram_size, "size", &error_fatal); + object_property_add_child(object_get_objects_root(), mc->default_ram_i= d, + obj, &error_fatal); + user_creatable_complete(USER_CREATABLE(obj), &error_fatal); + object_unref(obj); + object_property_set_str(OBJECT(ms), mc->default_ram_id, "memory-backen= d", + &error_fatal); +} + int main(int argc, char **argv, char **envp) { int i; @@ -4268,6 +4289,10 @@ int main(int argc, char **argv, char **envp) } parse_numa_opts(current_machine); =20 + if (machine_class->default_ram_id && current_machine->ram_size && + !current_machine->ram_memdev_id) { + create_default_memdev(current_machine, mem_path, mem_prealloc); + } /* do monitor/qmp handling at preconfig state if requested */ main_loop(); =20 --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581961073246863.9358551493722; Mon, 17 Feb 2020 09:37:53 -0800 (PST) Received: from localhost ([::1]:49382 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kL8-0006SL-BC for importer@patchew.org; Mon, 17 Feb 2020 12:37:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38004) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kIa-0000uV-C4 for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kIY-0001cm-OL for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:12 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:20916 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kIY-0001cI-KR for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:10 -0500 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-351-Kq3uIhbLP7KQW_2OJU6DEg-1; Mon, 17 Feb 2020 12:35:06 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A365F1800D42; Mon, 17 Feb 2020 17:35:05 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9F2508CCE0; Mon, 17 Feb 2020 17:35:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960910; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ivlRZtY903I1hV9WUHSZsk36V3vXW8LwZA5VIV2yhq4=; b=C9Gta0qH4o0Qlvom12fMZ1HVP7NmzX+wXuPyEos1z0lgNG+Jxmyeigm44wNRY1YUavRr3X yscTS4p7m+SiFVeqkb36JL+d9dP7+V5rRpaWDvk5MMmc6zBUyTyWoLqr9nmvksbKK83s/s vq2Y3d+fKqSK2SB8ZUSpTJAb2FPqTp4= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 04/79] machine: introduce convenience MachineState::ram Date: Mon, 17 Feb 2020 12:33:37 -0500 Message-Id: <20200217173452.15243-5-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: Kq3uIhbLP7KQW_2OJU6DEg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 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: pasic@linux.ibm.com, Paolo Bonzini , ehabkost@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" the new field will be used by boards to get access to main RAM memory region and will help to save boiler plate in boards which often introduce a field or variable just for this purpose. Memory region will be equivalent to what currently used memory_region_allocate_system_memory() is returning apart from that it will come from hostmem backend. Followup patches will incrementally switch boards to using RAM from MachineState::ram. Patch takes care of non-NUMA case and follow up patch will initialize MachineState::ram for NUMA case. Signed-off-by: Igor Mammedov Reviewed-by: Richard Henderson --- CC: ehabkost@redhat.com CC: pbonzini@redhat.com CC: pasic@linux.ibm.com --- include/hw/boards.h | 12 +++++++++++- hw/core/machine.c | 24 ++++++++++++++++++++++++ hw/core/numa.c | 14 +------------- 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/include/hw/boards.h b/include/hw/boards.h index 8e536cafb2..ae2b60fb5e 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -73,7 +73,12 @@ void machine_set_cpu_numa_node(MachineState *machine, Error **errp); =20 void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *= type); - +/* + * Checks that backend isn't used, preps it for exclusive usage and + * returns migratable MemoryRegion provided by backend. + */ +MemoryRegion *machine_consume_memdev(MachineState *machine, + HostMemoryBackend *backend); =20 /** * CPUArchId: @@ -295,6 +300,11 @@ struct MachineState { bool enable_graphics; char *memory_encryption; char *ram_memdev_id; + /* + * convenience alias to ram_memdev_id backend memory region + * or to numa container memory region + */ + MemoryRegion *ram; DeviceMemoryState *device_memory; =20 ram_addr_t ram_size; diff --git a/hw/core/machine.c b/hw/core/machine.c index 1a6e485c87..c8d361b710 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -26,6 +26,7 @@ #include "sysemu/qtest.h" #include "hw/pci/pci.h" #include "hw/mem/nvdimm.h" +#include "migration/vmstate.h" =20 GlobalProperty hw_compat_4_2[] =3D { { "virtio-blk-device", "x-enable-wce-if-config-wce", "off" }, @@ -1059,10 +1060,33 @@ static void machine_numa_finish_cpu_init(MachineSta= te *machine) g_string_free(s, true); } =20 +MemoryRegion *machine_consume_memdev(MachineState *machine, + HostMemoryBackend *backend) +{ + MemoryRegion *ret =3D host_memory_backend_get_memory(backend); + + if (memory_region_is_mapped(ret)) { + char *path =3D object_get_canonical_path_component(OBJECT(backend)= ); + error_report("memory backend %s can't be used multiple times.", pa= th); + g_free(path); + exit(EXIT_FAILURE); + } + host_memory_backend_set_mapped(backend, true); + vmstate_register_ram_global(ret); + return ret; +} + void machine_run_board_init(MachineState *machine) { MachineClass *machine_class =3D MACHINE_GET_CLASS(machine); =20 + if (machine->ram_memdev_id) { + Object *o; + o =3D object_resolve_path_type(machine->ram_memdev_id, + TYPE_MEMORY_BACKEND, NULL); + machine->ram =3D machine_consume_memdev(machine, MEMORY_BACKEND(o)= ); + } + if (machine->numa_state) { numa_complete_configuration(machine); if (machine->numa_state->num_nodes) { diff --git a/hw/core/numa.c b/hw/core/numa.c index 840e68581f..8264336209 100644 --- a/hw/core/numa.c +++ b/hw/core/numa.c @@ -817,20 +817,8 @@ void memory_region_allocate_system_memory(MemoryRegion= *mr, Object *owner, if (!backend) { continue; } - MemoryRegion *seg =3D host_memory_backend_get_memory(backend); - - if (memory_region_is_mapped(seg)) { - char *path =3D object_get_canonical_path_component(OBJECT(back= end)); - error_report("memory backend %s is used multiple times. Each " - "-numa option must use a different memdev value.", - path); - g_free(path); - exit(1); - } - - host_memory_backend_set_mapped(backend, true); + MemoryRegion *seg =3D machine_consume_memdev(ms, backend); memory_region_add_subregion(mr, addr, seg); - vmstate_register_ram_global(seg); addr +=3D size; } } --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581961066405270.65021413672525; Mon, 17 Feb 2020 09:37:46 -0800 (PST) Received: from localhost ([::1]:49380 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kL3-0006Az-6I for importer@patchew.org; Mon, 17 Feb 2020 12:37:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37997) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kIa-0000u1-1N for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kIY-0001cZ-KZ for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:11 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:44180 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kIY-0001c8-G9 for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:10 -0500 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-111-1HeA4JhsPViUDiCpBkrVfQ-1; Mon, 17 Feb 2020 12:35:08 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EFD8918FE862; Mon, 17 Feb 2020 17:35:06 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id EBC7B90526; Mon, 17 Feb 2020 17:35:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960910; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RM7uhLD53k+hNkv1a4EgcMlQV+rv0h03YJkOpdhwAT4=; b=VaMJpW55ZpujB+UOUYMJSCauzBOyaNFF0YQMBtYUOKnPtXLQHwpDHlylK/5bHRErp0C/Sw 3SecauwNTWWhD3founM42cB2PXJ/QU0zB2L4i7bHEamYAvqkJUjGssLB/hD7HN451bRcV8 TVjPDvP4C+BoOaT/91+H5kUwKK5bdKs= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 05/79] initialize MachineState::ram in NUMA case Date: Mon, 17 Feb 2020 12:33:38 -0500 Message-Id: <20200217173452.15243-6-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: 1HeA4JhsPViUDiCpBkrVfQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 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: pasic@linux.ibm.com, Paolo Bonzini , ehabkost@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In case of NUMA there are 2 cases to consider: 1. '-numa node,memdev', the only one that will be available for 5.0 and newer machine types. In this case reuse current behavior, with only difference memdevs are put into MachineState::ram container + a temporary glue to keep memory_region_allocate_system_memory() working until all boards converted. 2. fake NUMA ("-numa node mem" and default RAM splitting) the later has been deprecated and will be removed but the former is going to stay available for compat reasons for 5.0 and older machine types it takes allocate_system_memory_nonnuma() path, like non-NUMA case and falls under conversion to memdev. So extend non-NUMA MachineState::ram initialization introduced in previous patch to take care of fake NUMA case. Signed-off-by: Igor Mammedov --- CC: ehabkost@redhat.com CC: pbonzini@redhat.com CC: pasic@linux.ibm.com --- include/sysemu/numa.h | 1 + hw/core/numa.c | 43 ++++++++++++++++++++++++++++++------------- vl.c | 2 +- 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/include/sysemu/numa.h b/include/sysemu/numa.h index ba693cc80b..ad58ee88f7 100644 --- a/include/sysemu/numa.h +++ b/include/sysemu/numa.h @@ -112,5 +112,6 @@ void numa_default_auto_assign_ram(MachineClass *mc, Nod= eInfo *nodes, int nb_nodes, ram_addr_t size); void numa_cpu_pre_plug(const struct CPUArchId *slot, DeviceState *dev, Error **errp); +bool numa_uses_legacy_mem(void); =20 #endif diff --git a/hw/core/numa.c b/hw/core/numa.c index 8264336209..e6baf2c33e 100644 --- a/hw/core/numa.c +++ b/hw/core/numa.c @@ -52,6 +52,11 @@ QemuOptsList qemu_numa_opts =3D { }; =20 static int have_memdevs; +bool numa_uses_legacy_mem(void) +{ + return !have_memdevs; +} + static int have_mem; static int max_numa_nodeid; /* Highest specified NUMA node ID, plus one. * For all nodes, nodeid < max_numa_nodeid @@ -652,6 +657,23 @@ void numa_default_auto_assign_ram(MachineClass *mc, No= deInfo *nodes, nodes[i].node_mem =3D size - usedmem; } =20 +static void numa_init_memdev_container(MachineState *ms, MemoryRegion *ram) +{ + int i; + uint64_t addr =3D 0; + + for (i =3D 0; i < ms->numa_state->num_nodes; i++) { + uint64_t size =3D ms->numa_state->nodes[i].node_mem; + HostMemoryBackend *backend =3D ms->numa_state->nodes[i].node_memde= v; + if (!backend) { + continue; + } + MemoryRegion *seg =3D machine_consume_memdev(ms, backend); + memory_region_add_subregion(ram, addr, seg); + addr +=3D size; + } +} + void numa_complete_configuration(MachineState *ms) { int i; @@ -734,6 +756,12 @@ void numa_complete_configuration(MachineState *ms) exit(1); } =20 + if (!numa_uses_legacy_mem() && mc->default_ram_id) { + ms->ram =3D g_new(MemoryRegion, 1); + memory_region_init(ms->ram, OBJECT(ms), mc->default_ram_id, + ram_size); + numa_init_memdev_container(ms, ms->ram); + } /* QEMU needs at least all unique node pair distances to build * the whole NUMA distance table. QEMU treats the distance table * as symmetric by default, i.e. distance A->B =3D=3D distance B->= A. @@ -800,27 +828,16 @@ void memory_region_allocate_system_memory(MemoryRegio= n *mr, Object *owner, const char *name, uint64_t ram_size) { - uint64_t addr =3D 0; - int i; MachineState *ms =3D MACHINE(qdev_get_machine()); =20 if (ms->numa_state =3D=3D NULL || - ms->numa_state->num_nodes =3D=3D 0 || !have_memdevs) { + ms->numa_state->num_nodes =3D=3D 0 || numa_uses_legacy_mem()) { allocate_system_memory_nonnuma(mr, owner, name, ram_size); return; } =20 memory_region_init(mr, owner, name, ram_size); - for (i =3D 0; i < ms->numa_state->num_nodes; i++) { - uint64_t size =3D ms->numa_state->nodes[i].node_mem; - HostMemoryBackend *backend =3D ms->numa_state->nodes[i].node_memde= v; - if (!backend) { - continue; - } - MemoryRegion *seg =3D machine_consume_memdev(ms, backend); - memory_region_add_subregion(mr, addr, seg); - addr +=3D size; - } + numa_init_memdev_container(ms, mr); } =20 static void numa_stat_memory_devices(NumaNodeMem node_mem[]) diff --git a/vl.c b/vl.c index 4dc4803611..2103804c52 100644 --- a/vl.c +++ b/vl.c @@ -4290,7 +4290,7 @@ int main(int argc, char **argv, char **envp) parse_numa_opts(current_machine); =20 if (machine_class->default_ram_id && current_machine->ram_size && - !current_machine->ram_memdev_id) { + numa_uses_legacy_mem() && !current_machine->ram_memdev_id) { create_default_memdev(current_machine, mem_path, mem_prealloc); } /* do monitor/qmp handling at preconfig state if requested */ --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581961158975496.8704545709304; Mon, 17 Feb 2020 09:39:18 -0800 (PST) Received: from localhost ([::1]:49426 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kMX-0001qf-QQ for importer@patchew.org; Mon, 17 Feb 2020 12:39:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38015) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kIa-0000vL-Tp for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kIZ-0001dP-Lg for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:12 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:22676 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kIZ-0001d5-Hl for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:11 -0500 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-404-L8HmyUzEMdmQ8Bhuk756IA-1; Mon, 17 Feb 2020 12:35:09 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1F50E1005513; Mon, 17 Feb 2020 17:35:08 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4515F90508; Mon, 17 Feb 2020 17:35:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960911; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=B6QuhLUUdajcwFl5aoo5HJCiteCeqU1tdmAw3L7A8gg=; b=N5PZZmzSZAE+FWRsUU1lHlm+OH3fe65SBjcr40evkn+9eRiEpYTqTwTNL5uzD1SbztakRq zXpVEWMMzEcDVefw4IobXaLMpyFo+ql55Zz4LRGlIq6nhlYBpuClp/o3hltqT627KLSshJ nslrdNvTGbwGcuXqR861Z7oX8r++rvU= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 06/79] vl.c: move -m parsing after memory backends has been processed Date: Mon, 17 Feb 2020 12:33:39 -0500 Message-Id: <20200217173452.15243-7-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: L8HmyUzEMdmQ8Bhuk756IA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 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: pasic@linux.ibm.com, Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" It will be possible for main RAM to come from memory-backend and we should check that size specified in -m matches the size of the backend and [MachineState::]ram_size also matches backend's size. However -m parsing (set_memory_options()) happens before backends are intialized (object_create_delayed()) which complicates it. Consolidate set_memory_options() and assigning parsed results to current_machine after backends are initialized, so it would be possible access the initialized backend instance to compare sizes. This patch only consolidates scattered places touching ram_size within vl.c. And follow up patch will integrate backend handling to set_memory_options(). Signed-off-by: Igor Mammedov --- CC: pasic@linux.ibm.com CC: pbonzini@redhat.com --- vl.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/vl.c b/vl.c index 2103804c52..72ffc06f2f 100644 --- a/vl.c +++ b/vl.c @@ -2655,6 +2655,14 @@ static void set_memory_options(uint64_t *ram_slots, = ram_addr_t *maxram_size, exit(EXIT_FAILURE); } =20 + if (!xen_enabled()) { + /* On 32-bit hosts, QEMU is limited by virtual address space */ + if (ram_size > (2047 << 20) && HOST_LONG_BITS =3D=3D 32) { + error_report("at most 2047 MB RAM can be simulated"); + exit(1); + } + } + loc_pop(&loc); } =20 @@ -3819,8 +3827,6 @@ int main(int argc, char **argv, char **envp) machine_class =3D select_machine(); object_set_machine_compat_props(machine_class->compat_props); =20 - set_memory_options(&ram_slots, &maxram_size, machine_class); - os_daemonize(); rcu_disable_atfork(); =20 @@ -4122,9 +4128,6 @@ int main(int argc, char **argv, char **envp) machine_opts =3D qemu_get_machine_opts(); qemu_opt_foreach(machine_opts, machine_set_property, current_machine, &error_fatal); - current_machine->ram_size =3D ram_size; - current_machine->maxram_size =3D maxram_size; - current_machine->ram_slots =3D ram_slots; =20 /* * Note: uses machine properties such as kernel-irqchip, must run @@ -4235,14 +4238,6 @@ int main(int argc, char **argv, char **envp) =20 tpm_init(); =20 - if (!xen_enabled()) { - /* On 32-bit hosts, QEMU is limited by virtual address space */ - if (ram_size > (2047 << 20) && HOST_LONG_BITS =3D=3D 32) { - error_report("at most 2047 MB RAM can be simulated"); - exit(1); - } - } - blk_mig_init(); ram_mig_init(); dirty_bitmap_mig_init(); @@ -4287,6 +4282,12 @@ int main(int argc, char **argv, char **envp) if (cpu_option) { current_machine->cpu_type =3D parse_cpu_option(cpu_option); } + + set_memory_options(&ram_slots, &maxram_size, machine_class); + current_machine->ram_size =3D ram_size; + current_machine->maxram_size =3D maxram_size; + current_machine->ram_slots =3D ram_slots; + parse_numa_opts(current_machine); =20 if (machine_class->default_ram_id && current_machine->ram_size && --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581960998817443.52926453431303; Mon, 17 Feb 2020 09:36:38 -0800 (PST) Received: from localhost ([::1]:49292 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJx-0002wx-KX for importer@patchew.org; Mon, 17 Feb 2020 12:36:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38039) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kIb-0000xH-VW for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kIa-0001h2-Vr for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:13 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:34632 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kIa-0001fP-Rm for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:12 -0500 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-13-CHF08h0PP2OI3kvAKQfrdg-1; Mon, 17 Feb 2020 12:35:10 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 497D31800D42; Mon, 17 Feb 2020 17:35:09 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6AD7B90526; Mon, 17 Feb 2020 17:35:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960912; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dLTFw+CktQgSrej1IbjHdt27BnydF2v1oUhwoWTHQFY=; b=XqiaVdp5ln9QzAXIC3SnhF0JfZcEfIKGljIyR+gTN0a0RLFrnz5PXFZZSaUxyke+axpCl6 Bx/i8GyiDFTQJig1zwP0f96Xnl+JQ4BA34jydgcUom3ywhQnkmiE+/ISz9SinMgqQqWS47 Bd2GCqXiI8nHvo8F2xb7Ch9ZMNJ5W/k= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 07/79] vl.c: ensure that ram_size matches size of machine.memory-backend Date: Mon, 17 Feb 2020 12:33:40 -0500 Message-Id: <20200217173452.15243-8-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: CHF08h0PP2OI3kvAKQfrdg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 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: pasic@linux.ibm.com, Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Extend set_memory_options() to check that size specified by -m matches the size of backend pointed by memory-backend. And in case of -m was omitted adjust ram_size to match that of explicitly provided backend. Signed-off-by: Igor Mammedov Reviewed-by: Richard Henderson --- CC: pasic@linux.ibm.com CC: pbonzini@redhat.com --- vl.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/vl.c b/vl.c index 72ffc06f2f..a7edcba094 100644 --- a/vl.c +++ b/vl.c @@ -2655,6 +2655,21 @@ static void set_memory_options(uint64_t *ram_slots, = ram_addr_t *maxram_size, exit(EXIT_FAILURE); } =20 + if (current_machine->ram_memdev_id) { + Object *backend; + ram_addr_t backend_size; + + backend =3D object_resolve_path_type(current_machine->ram_memdev_i= d, + TYPE_MEMORY_BACKEND, NULL); + backend_size =3D object_property_get_uint(backend, "size", &error= _abort); + if (mem_str && backend_size !=3D ram_size) { + error_report("Size specified by -m option must match size = of " + "explicitly specified 'memory-backend' proper= ty"); + exit(EXIT_FAILURE); + } + ram_size =3D backend_size; + } + if (!xen_enabled()) { /* On 32-bit hosts, QEMU is limited by virtual address space */ if (ram_size > (2047 << 20) && HOST_LONG_BITS =3D=3D 32) { --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581961147838820.1313842742021; Mon, 17 Feb 2020 09:39:07 -0800 (PST) Received: from localhost ([::1]:49408 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kML-0001K6-Lg for importer@patchew.org; Mon, 17 Feb 2020 12:39:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38054) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kIc-0000z2-SE for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kIb-0001iC-Mv for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:14 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:40766 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kIb-0001hN-IZ for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:13 -0500 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-175-aKjmStv5MKq238YocSveXQ-1; Mon, 17 Feb 2020 12:35:11 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 413F31005513 for ; Mon, 17 Feb 2020 17:35:10 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F2748CCE0; Mon, 17 Feb 2020 17:35:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960913; 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=ZTDdiBw534Kgpsai00TQOGKgVGGgSTWt8zL34TYXzhQ=; b=LihXtRVQKfry9KYckXLW/4rZ5dcaDo8zjFGR/aIZCqTkLeCvhz6CyZV+nmxT+bi2DS9zo1 EH2eb7UdVxzEedOYYeV+bDfAFLm0FOM9E5EEzghHVxCvdh6ql6fmhNnDDNqDJMqrzCPpuE tTy899jS1LuFWfzccFcDW00ZSCTh8xA= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 08/79] alpha/dp264: use memdev for RAM Date: Mon, 17 Feb 2020 12:33:41 -0500 Message-Id: <20200217173452.15243-9-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: aKjmStv5MKq238YocSveXQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Acked-by: Richard Henderson --- hw/alpha/alpha_sys.h | 2 +- hw/alpha/dp264.c | 3 ++- hw/alpha/typhoon.c | 8 ++------ 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/hw/alpha/alpha_sys.h b/hw/alpha/alpha_sys.h index 95033d7f0b..bc0a286226 100644 --- a/hw/alpha/alpha_sys.h +++ b/hw/alpha/alpha_sys.h @@ -11,7 +11,7 @@ #include "hw/intc/i8259.h" =20 =20 -PCIBus *typhoon_init(ram_addr_t, ISABus **, qemu_irq *, AlphaCPU *[4], +PCIBus *typhoon_init(MemoryRegion *, ISABus **, qemu_irq *, AlphaCPU *[4], pci_map_irq_fn); =20 /* alpha_pci.c. */ diff --git a/hw/alpha/dp264.c b/hw/alpha/dp264.c index a8f9a89cc4..8d71a30617 100644 --- a/hw/alpha/dp264.c +++ b/hw/alpha/dp264.c @@ -75,7 +75,7 @@ static void clipper_init(MachineState *machine) cpus[0]->env.trap_arg2 =3D smp_cpus; =20 /* Init the chipset. */ - pci_bus =3D typhoon_init(ram_size, &isa_bus, &rtc_irq, cpus, + pci_bus =3D typhoon_init(machine->ram, &isa_bus, &rtc_irq, cpus, clipper_pci_map_irq); =20 /* Since we have an SRM-compatible PALcode, use the SRM epoch. */ @@ -183,6 +183,7 @@ static void clipper_machine_init(MachineClass *mc) mc->max_cpus =3D 4; mc->is_default =3D 1; mc->default_cpu_type =3D ALPHA_CPU_TYPE_NAME("ev67"); + mc->default_ram_id =3D "ram"; } =20 DEFINE_MACHINE("clipper", clipper_machine_init) diff --git a/hw/alpha/typhoon.c b/hw/alpha/typhoon.c index 179e1f7658..1795e2f29d 100644 --- a/hw/alpha/typhoon.c +++ b/hw/alpha/typhoon.c @@ -58,7 +58,6 @@ typedef struct TyphoonState { TyphoonCchip cchip; TyphoonPchip pchip; MemoryRegion dchip_region; - MemoryRegion ram_region; } TyphoonState; =20 /* Called when one of DRIR or DIM changes. */ @@ -817,8 +816,7 @@ static void typhoon_alarm_timer(void *opaque) cpu_interrupt(CPU(s->cchip.cpu[cpu]), CPU_INTERRUPT_TIMER); } =20 -PCIBus *typhoon_init(ram_addr_t ram_size, ISABus **isa_bus, - qemu_irq *p_rtc_irq, +PCIBus *typhoon_init(MemoryRegion *ram, ISABus **isa_bus, qemu_irq *p_rtc_= irq, AlphaCPU *cpus[4], pci_map_irq_fn sys_map_irq) { MemoryRegion *addr_space =3D get_system_memory(); @@ -851,9 +849,7 @@ PCIBus *typhoon_init(ram_addr_t ram_size, ISABus **isa_= bus, =20 /* Main memory region, 0x00.0000.0000. Real hardware supports 32GB, but the address space hole reserved at this point is 8TB. */ - memory_region_allocate_system_memory(&s->ram_region, OBJECT(s), "ram", - ram_size); - memory_region_add_subregion(addr_space, 0, &s->ram_region); + memory_region_add_subregion(addr_space, 0, ram); =20 /* TIGbus, 0x801.0000.0000, 1GB. */ /* ??? The TIGbus is used for delivering interrupts, and access to --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581961252694947.5948916317071; Mon, 17 Feb 2020 09:40:52 -0800 (PST) Received: from localhost ([::1]:49454 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kO3-0005Co-Fr for importer@patchew.org; Mon, 17 Feb 2020 12:40:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38070) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kIe-00012r-G2 for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kIc-0001jH-Il for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:16 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:57541 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kIc-0001id-EN for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:14 -0500 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-248-IX5MjUGAOHqDJMx-IFXU5w-1; Mon, 17 Feb 2020 12:35:12 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3ED57800D50 for ; Mon, 17 Feb 2020 17:35:11 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8B7878CCE0; Mon, 17 Feb 2020 17:35:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960914; 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=BYdstxzcQ0JeYJbq6+rim6fJ1h/j5r1EpcjftqpL+CI=; b=HYKf5vZN4aorRuLwgg9vCLOqQaan7m7fp63Ji2yu53DfupGwlbDTAI87h3qkuJoTAq9H3A ru207ohpHLFv3OzVPqb1h222jf9SLzvkvFBWKmJvUoQ8qjSoHYCugrUE9vjPOvPM41uQn7 oLKwTVaSz62s1ix8AeGCsoR9GW2kyLQ= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 09/79] arm/aspeed: actually check RAM size Date: Mon, 17 Feb 2020 12:33:42 -0500 Message-Id: <20200217173452.15243-10-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: IX5MjUGAOHqDJMx-IFXU5w-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" It's supposed that SOC will check if "-m" provided RAM size is valid by setting "ram-size" property and then board would read back valid (possibly corrected value) to map RAM MemoryReging with valid size. It isn't doing so, since check is called only indirectly from aspeed_sdmc_reset()->asc->compute_conf() or much later when guest writes to configuration register. So depending on "-m" value QEMU end-ups with a warning and an invalid MemoryRegion size allocated and mapped. (examples: -M ast2500-evb -m 1M 0000000080000000-000000017ffffffe (prio 0, i/o): aspeed-ram-container 0000000080000000-00000000800fffff (prio 0, ram): ram 0000000080100000-00000000bfffffff (prio 0, i/o): max_ram -M ast2500-evb -m 3G 0000000080000000-000000017ffffffe (prio 0, i/o): aspeed-ram-container 0000000080000000-000000013fffffff (prio 0, ram): ram [DETECTED OVERFLOW!] 0000000140000000-00000000bfffffff (prio 0, i/o):= max_ram ) On top of that sdmc falls back and reports to guest "default" size, it thinks machine should have. This patch makes ram-size check actually work and changes behavior from a warning later on during machine reset to error_fatal at the moment SOC.ram-size is set so user will have to fix RAM size on CLI to start machine. It also gets out of the way mutable ram-size logic, so we could consolidate RAM allocation logic around pre-allocated hostmem backend (supplied by user or auto created by generic machine code depending on supplied -m/mem-path/mem-prealloc options. Signed-off-by: Igor Mammedov Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Richard Henderson --- v3: * replace [PATCH v2 07/86] arm:aspeed: convert valid RAM sizes to data [PATCH v2 08/86] arm:aspeed: actually check RAM size with a simplified variant that adds ram_size check to sdmc.ram-size property * use g_assert_not_reached() in default branch (C=C3=A9dric Le Goater ) --- include/hw/misc/aspeed_sdmc.h | 1 + hw/arm/aspeed.c | 13 +++--- hw/misc/aspeed_sdmc.c | 83 +++++++++++++++++++++++++++-------- 3 files changed, 70 insertions(+), 27 deletions(-) diff --git a/include/hw/misc/aspeed_sdmc.h b/include/hw/misc/aspeed_sdmc.h index 5dbde59fe7..cea1e67fe3 100644 --- a/include/hw/misc/aspeed_sdmc.h +++ b/include/hw/misc/aspeed_sdmc.h @@ -40,6 +40,7 @@ typedef struct AspeedSDMCClass { SysBusDeviceClass parent_class; =20 uint64_t max_ram_size; + const uint64_t *valid_ram_sizes; uint32_t (*compute_conf)(AspeedSDMCState *s, uint32_t data); void (*write)(AspeedSDMCState *s, uint32_t reg, uint32_t data); } AspeedSDMCClass; diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c index a17843f0d3..805bebd0d0 100644 --- a/hw/arm/aspeed.c +++ b/hw/arm/aspeed.c @@ -204,8 +204,12 @@ static void aspeed_machine_init(MachineState *machine) =20 sc =3D ASPEED_SOC_GET_CLASS(&bmc->soc); =20 + /* + * This will error out if isize is not supported by memory controller. + */ object_property_set_uint(OBJECT(&bmc->soc), ram_size, "ram-size", - &error_abort); + &error_fatal); + object_property_set_int(OBJECT(&bmc->soc), amc->hw_strap1, "hw-strap1", &error_abort); object_property_set_int(OBJECT(&bmc->soc), amc->hw_strap2, "hw-strap2", @@ -228,13 +232,6 @@ static void aspeed_machine_init(MachineState *machine) object_property_set_bool(OBJECT(&bmc->soc), true, "realized", &error_abort); =20 - /* - * Allocate RAM after the memory controller has checked the size - * was valid. If not, a default value is used. - */ - ram_size =3D object_property_get_uint(OBJECT(&bmc->soc), "ram-size", - &error_abort); - memory_region_allocate_system_memory(&bmc->ram, NULL, "ram", ram_size); memory_region_add_subregion(&bmc->ram_container, 0, &bmc->ram); memory_region_add_subregion(get_system_memory(), diff --git a/hw/misc/aspeed_sdmc.c b/hw/misc/aspeed_sdmc.c index 9c184790cd..7b466bf19a 100644 --- a/hw/misc/aspeed_sdmc.c +++ b/hw/misc/aspeed_sdmc.c @@ -17,6 +17,9 @@ #include "migration/vmstate.h" #include "qapi/error.h" #include "trace.h" +#include "qemu/units.h" +#include "qemu/cutils.h" +#include "qapi/visitor.h" =20 /* Protection Key Register */ #define R_PROT (0x00 / 4) @@ -160,14 +163,9 @@ static int ast2400_rambits(AspeedSDMCState *s) case 512: return ASPEED_SDMC_DRAM_512MB; default: + g_assert_not_reached(); break; } - - /* use a common default */ - warn_report("Invalid RAM size 0x%" PRIx64 ". Using default 256M", - s->ram_size); - s->ram_size =3D 256 << 20; - return ASPEED_SDMC_DRAM_256MB; } =20 static int ast2500_rambits(AspeedSDMCState *s) @@ -182,14 +180,9 @@ static int ast2500_rambits(AspeedSDMCState *s) case 1024: return ASPEED_SDMC_AST2500_1024MB; default: + g_assert_not_reached(); break; } - - /* use a common default */ - warn_report("Invalid RAM size 0x%" PRIx64 ". Using default 512M", - s->ram_size); - s->ram_size =3D 512 << 20; - return ASPEED_SDMC_AST2500_512MB; } =20 static int ast2600_rambits(AspeedSDMCState *s) @@ -204,14 +197,9 @@ static int ast2600_rambits(AspeedSDMCState *s) case 2048: return ASPEED_SDMC_AST2600_2048MB; default: + g_assert_not_reached(); break; } - - /* use a common default */ - warn_report("Invalid RAM size 0x%" PRIx64 ". Using default 1024M", - s->ram_size); - s->ram_size =3D 1024 << 20; - return ASPEED_SDMC_AST2600_1024MB; } =20 static void aspeed_sdmc_reset(DeviceState *dev) @@ -225,6 +213,51 @@ static void aspeed_sdmc_reset(DeviceState *dev) s->regs[R_CONF] =3D asc->compute_conf(s, 0); } =20 +static void aspeed_sdmc_get_ram_size(Object *obj, Visitor *v, const char *= name, + void *opaque, Error **errp) +{ + AspeedSDMCState *s =3D ASPEED_SDMC(obj); + int64_t value =3D s->ram_size; + + visit_type_int(v, name, &value, errp); +} + +static void aspeed_sdmc_set_ram_size(Object *obj, Visitor *v, const char *= name, + void *opaque, Error **errp) +{ + int i; + char *sz; + int64_t value; + Error *local_err =3D NULL; + AspeedSDMCState *s =3D ASPEED_SDMC(obj); + AspeedSDMCClass *asc =3D ASPEED_SDMC_GET_CLASS(s); + + visit_type_int(v, name, &value, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + + for (i =3D 0; asc->valid_ram_sizes[i]; i++) { + if (value =3D=3D asc->valid_ram_sizes[i]) { + s->ram_size =3D value; + return; + } + } + + sz =3D size_to_str(value); + error_setg(&local_err, "Invalid RAM size %s", sz); + g_free(sz); + error_propagate(errp, local_err); +} + +static void aspeed_sdmc_initfn(Object *obj) +{ + object_property_add(obj, "ram-size", "int", + aspeed_sdmc_get_ram_size, aspeed_sdmc_set_ram_size, + NULL, NULL, NULL); +} + static void aspeed_sdmc_realize(DeviceState *dev, Error **errp) { SysBusDevice *sbd =3D SYS_BUS_DEVICE(dev); @@ -249,7 +282,6 @@ static const VMStateDescription vmstate_aspeed_sdmc =3D= { }; =20 static Property aspeed_sdmc_properties[] =3D { - DEFINE_PROP_UINT64("ram-size", AspeedSDMCState, ram_size, 0), DEFINE_PROP_UINT64("max-ram-size", AspeedSDMCState, max_ram_size, 0), DEFINE_PROP_END_OF_LIST(), }; @@ -268,6 +300,7 @@ static const TypeInfo aspeed_sdmc_info =3D { .name =3D TYPE_ASPEED_SDMC, .parent =3D TYPE_SYS_BUS_DEVICE, .instance_size =3D sizeof(AspeedSDMCState), + .instance_init =3D aspeed_sdmc_initfn, .class_init =3D aspeed_sdmc_class_init, .class_size =3D sizeof(AspeedSDMCClass), .abstract =3D true, @@ -298,6 +331,9 @@ static void aspeed_2400_sdmc_write(AspeedSDMCState *s, = uint32_t reg, s->regs[reg] =3D data; } =20 +static const uint64_t +aspeed_2400_ram_sizes[] =3D { 64 * MiB, 128 * MiB, 256 * MiB, 512 * MiB, 0= }; + static void aspeed_2400_sdmc_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); @@ -307,6 +343,7 @@ static void aspeed_2400_sdmc_class_init(ObjectClass *kl= ass, void *data) asc->max_ram_size =3D 512 << 20; asc->compute_conf =3D aspeed_2400_sdmc_compute_conf; asc->write =3D aspeed_2400_sdmc_write; + asc->valid_ram_sizes =3D aspeed_2400_ram_sizes; } =20 static const TypeInfo aspeed_2400_sdmc_info =3D { @@ -351,6 +388,9 @@ static void aspeed_2500_sdmc_write(AspeedSDMCState *s, = uint32_t reg, s->regs[reg] =3D data; } =20 +static const uint64_t +aspeed_2500_ram_sizes[] =3D { 128 * MiB, 256 * MiB, 512 * MiB, 1024 * MiB,= 0}; + static void aspeed_2500_sdmc_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); @@ -360,6 +400,7 @@ static void aspeed_2500_sdmc_class_init(ObjectClass *kl= ass, void *data) asc->max_ram_size =3D 1024 << 20; asc->compute_conf =3D aspeed_2500_sdmc_compute_conf; asc->write =3D aspeed_2500_sdmc_write; + asc->valid_ram_sizes =3D aspeed_2500_ram_sizes; } =20 static const TypeInfo aspeed_2500_sdmc_info =3D { @@ -404,6 +445,9 @@ static void aspeed_2600_sdmc_write(AspeedSDMCState *s, = uint32_t reg, s->regs[reg] =3D data; } =20 +static const uint64_t +aspeed_2600_ram_sizes[] =3D { 256 * MiB, 512 * MiB, 1024 * MiB, 2048 * MiB= , 0}; + static void aspeed_2600_sdmc_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); @@ -413,6 +457,7 @@ static void aspeed_2600_sdmc_class_init(ObjectClass *kl= ass, void *data) asc->max_ram_size =3D 2048 << 20; asc->compute_conf =3D aspeed_2600_sdmc_compute_conf; asc->write =3D aspeed_2600_sdmc_write; + asc->valid_ram_sizes =3D aspeed_2600_ram_sizes; } =20 static const TypeInfo aspeed_2600_sdmc_info =3D { --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581961074256669.0797849077327; Mon, 17 Feb 2020 09:37:54 -0800 (PST) Received: from localhost ([::1]:49384 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kLB-0006XU-0r for importer@patchew.org; Mon, 17 Feb 2020 12:37:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38076) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kIe-00013n-Vl for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kId-0001ke-LX for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:16 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:51334 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kId-0001kO-HK for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:15 -0500 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-284-44ExbWsTMA-fmNorxip64w-1; Mon, 17 Feb 2020 12:35:13 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 39DD81005512 for ; Mon, 17 Feb 2020 17:35:12 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8812490526; Mon, 17 Feb 2020 17:35:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960915; 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=6M8Cd8cuz0kDz8J7k9EkHApVheStboBJiX+Z0LxiAAE=; b=F0D3Vl+u/SXjBE2OlS7t+IneCDOK8dmqeSud7ZAXtpuFZxhMzBOaQht0L/gM231OviXExN hUXeP2B3/OUi50dnBjpPYSTvLoeRODpP+mSfk5gn6D27UXI9NYwsnWX9l82z2Y1VkS9m0P tCrLWAaTLcgrznUQH+sNOcgAgywt2bo= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 10/79] arm/aspeed: use memdev for RAM Date: Mon, 17 Feb 2020 12:33:43 -0500 Message-Id: <20200217173452.15243-11-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: 44ExbWsTMA-fmNorxip64w-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: C=C3=A9dric Le Goater Acked-by: Joel Stanley Reviewed-by: Richard Henderson --- hw/arm/aspeed.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c index 805bebd0d0..a6a2102a93 100644 --- a/hw/arm/aspeed.c +++ b/hw/arm/aspeed.c @@ -35,7 +35,6 @@ static struct arm_boot_info aspeed_board_binfo =3D { struct AspeedBoardState { AspeedSoCState soc; MemoryRegion ram_container; - MemoryRegion ram; MemoryRegion max_ram; }; =20 @@ -197,6 +196,7 @@ static void aspeed_machine_init(MachineState *machine) =20 memory_region_init(&bmc->ram_container, NULL, "aspeed-ram-container", UINT32_MAX); + memory_region_add_subregion(&bmc->ram_container, 0, machine->ram); =20 object_initialize_child(OBJECT(machine), "soc", &bmc->soc, (sizeof(bmc->soc)), amc->soc_name, &error_abor= t, @@ -232,8 +232,6 @@ static void aspeed_machine_init(MachineState *machine) object_property_set_bool(OBJECT(&bmc->soc), true, "realized", &error_abort); =20 - memory_region_allocate_system_memory(&bmc->ram, NULL, "ram", ram_size); - memory_region_add_subregion(&bmc->ram_container, 0, &bmc->ram); memory_region_add_subregion(get_system_memory(), sc->memmap[ASPEED_SDRAM], &bmc->ram_container); @@ -436,6 +434,7 @@ static void aspeed_machine_class_init(ObjectClass *oc, = void *data) mc->no_floppy =3D 1; mc->no_cdrom =3D 1; mc->no_parallel =3D 1; + mc->default_ram_id =3D "ram"; =20 aspeed_machine_class_props_init(oc); } --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581961234470579.0526273942078; Mon, 17 Feb 2020 09:40:34 -0800 (PST) Received: from localhost ([::1]:49446 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kNl-0004df-0a for importer@patchew.org; Mon, 17 Feb 2020 12:40:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38083) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kIf-00014v-GU for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kIe-0001lK-9r for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:17 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:34533 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kIe-0001kr-5a for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:16 -0500 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-320-I6S0PUP1M6G1y1OZBQt5Hw-1; Mon, 17 Feb 2020 12:35:14 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 39C8918FE860 for ; Mon, 17 Feb 2020 17:35:13 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 88F8490526; Mon, 17 Feb 2020 17:35:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960915; 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=GX7ZP+Z3ukgokdjlGVg3Xww8w3o7m7mRnx8yNMa+F+Q=; b=HUrc3uv+pPal2w56xrU1/JVR1RWToX0F1rMaxDmiX12CqXIygLLRalLO+jAzWtCpXF+aBL zLMMd7IIQfD6z/13XfRrMsge4SVIogIFsi2PKzARyTKo1c68AOm136xjCWh6Jw/XoygiBG 04hjj+qpixJqNd2ClQHl96GBC/CWkyY= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 11/79] arm/collie: use memdev for RAM Date: Mon, 17 Feb 2020 12:33:44 -0500 Message-Id: <20200217173452.15243-12-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: I6S0PUP1M6G1y1OZBQt5Hw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. PS: - while at it add check for user supplied RAM size and error out if it mismatches board expected value. - introduce RAM_ADDR_UFMT to avoid build errors on 32-bit hosts when specifying format string for ram_addr_t type Signed-off-by: Igor Mammedov Reviewed-by: Andrew Jones Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- v2: * fix format string causing build failure on 32-bit host (Philippe Mathieu-Daud=C3=A9 ) v3: * instead of RAM_ADDR_UFMT adding use size_to_str() Philippe Mathieu-Daud=C3=A9 --- hw/arm/collie.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/hw/arm/collie.c b/hw/arm/collie.c index 970a4405cc..024893fc9e 100644 --- a/hw/arm/collie.c +++ b/hw/arm/collie.c @@ -10,6 +10,7 @@ */ #include "qemu/osdep.h" #include "qemu/units.h" +#include "qemu/cutils.h" #include "hw/sysbus.h" #include "hw/boards.h" #include "strongarm.h" @@ -20,20 +21,24 @@ =20 static struct arm_boot_info collie_binfo =3D { .loader_start =3D SA_SDCS0, - .ram_size =3D 0x20000000, }; =20 static void collie_init(MachineState *machine) { StrongARMState *s; DriveInfo *dinfo; - MemoryRegion *sdram =3D g_new(MemoryRegion, 1); + MachineClass *mc =3D MACHINE_GET_CLASS(machine); + + if (machine->ram_size !=3D mc->default_ram_size) { + char *sz =3D size_to_str(mc->default_ram_size); + error_report("Invalid RAM size, should be %s", sz); + g_free(sz); + exit(EXIT_FAILURE); + } =20 s =3D sa1110_init(machine->cpu_type); =20 - memory_region_allocate_system_memory(sdram, NULL, "strongarm.sdram", - collie_binfo.ram_size); - memory_region_add_subregion(get_system_memory(), SA_SDCS0, sdram); + memory_region_add_subregion(get_system_memory(), SA_SDCS0, machine->ra= m); =20 dinfo =3D drive_get(IF_PFLASH, 0, 0); pflash_cfi01_register(SA_CS0, "collie.fl1", 0x02000000, @@ -57,6 +62,8 @@ static void collie_machine_init(MachineClass *mc) mc->init =3D collie_init; mc->ignore_memory_transaction_failures =3D true; mc->default_cpu_type =3D ARM_CPU_TYPE_NAME("sa1110"); + mc->default_ram_size =3D 0x20000000; + mc->default_ram_id =3D "strongarm.sdram"; } =20 DEFINE_MACHINE("collie", collie_machine_init) --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581961153631418.73244120198945; Mon, 17 Feb 2020 09:39:13 -0800 (PST) Received: from localhost ([::1]:49422 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kMS-0001bZ-An for importer@patchew.org; Mon, 17 Feb 2020 12:39:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38116) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kIh-00017d-2d for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kIf-0001mn-Mo for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:18 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:58157) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kIf-0001mF-IQ for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:17 -0500 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-8-JA1iFBSjO4Gq5hOdj-r8Aw-1; Mon, 17 Feb 2020 12:35:15 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5F2E78017CC; Mon, 17 Feb 2020 17:35:14 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 856A390526; Mon, 17 Feb 2020 17:35:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960917; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mugs9o65bmPEJZ2zERUHzbi8QvkdU7jQznOqW/fTzts=; b=hsxGwm7aJryVMD8e89FXhE2Sd8cPgNb6MHREQnjvsWTq03gf4toCZ329YzEBYxcwnzEGMr 16MC7/8i5Ry/scHABB8+0bKa8agwBdBH3Ru7Em+BNMlYPY7rtdo5OLsVl2v5z32jphXKb8 ZxpDbiDyoyM8h7ETChb6PI3dubzVFBk= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 12/79] arm/cubieboard: use memdev for RAM Date: Mon, 17 Feb 2020 12:33:45 -0500 Message-Id: <20200217173452.15243-13-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: JA1iFBSjO4Gq5hOdj-r8Aw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 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: b.galvani@gmail.com, Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. PS: While at it, get rid of no longer needed CubieBoardState wrapper. Signed-off-by: Igor Mammedov Reviewed-by: Andrew Jones Reviewed-by: Richard Henderson --- CC: b.galvani@gmail.com --- hw/arm/cubieboard.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/hw/arm/cubieboard.c b/hw/arm/cubieboard.c index 6dc2f1d6b6..089f9a30c1 100644 --- a/hw/arm/cubieboard.c +++ b/hw/arm/cubieboard.c @@ -28,52 +28,42 @@ static struct arm_boot_info cubieboard_binfo =3D { .board_id =3D 0x1008, }; =20 -typedef struct CubieBoardState { - AwA10State *a10; - MemoryRegion sdram; -} CubieBoardState; - static void cubieboard_init(MachineState *machine) { - CubieBoardState *s =3D g_new(CubieBoardState, 1); + AwA10State *a10 =3D AW_A10(object_new(TYPE_AW_A10)); Error *err =3D NULL; =20 - s->a10 =3D AW_A10(object_new(TYPE_AW_A10)); - - object_property_set_int(OBJECT(&s->a10->emac), 1, "phy-addr", &err); + object_property_set_int(OBJECT(&a10->emac), 1, "phy-addr", &err); if (err !=3D NULL) { error_reportf_err(err, "Couldn't set phy address: "); exit(1); } =20 - object_property_set_int(OBJECT(&s->a10->timer), 32768, "clk0-freq", &e= rr); + object_property_set_int(OBJECT(&a10->timer), 32768, "clk0-freq", &err); if (err !=3D NULL) { error_reportf_err(err, "Couldn't set clk0 frequency: "); exit(1); } =20 - object_property_set_int(OBJECT(&s->a10->timer), 24000000, "clk1-freq", - &err); + object_property_set_int(OBJECT(&a10->timer), 24000000, "clk1-freq", &e= rr); if (err !=3D NULL) { error_reportf_err(err, "Couldn't set clk1 frequency: "); exit(1); } =20 - object_property_set_bool(OBJECT(s->a10), true, "realized", &err); + object_property_set_bool(OBJECT(a10), true, "realized", &err); if (err !=3D NULL) { error_reportf_err(err, "Couldn't realize Allwinner A10: "); exit(1); } =20 - memory_region_allocate_system_memory(&s->sdram, NULL, "cubieboard.ram", - machine->ram_size); memory_region_add_subregion(get_system_memory(), AW_A10_SDRAM_BASE, - &s->sdram); + machine->ram); =20 /* TODO create and connect IDE devices for ide_drive_get() */ =20 cubieboard_binfo.ram_size =3D machine->ram_size; - arm_load_kernel(&s->a10->cpu, machine, &cubieboard_binfo); + arm_load_kernel(&a10->cpu, machine, &cubieboard_binfo); } =20 static void cubieboard_machine_init(MachineClass *mc) @@ -84,6 +74,7 @@ static void cubieboard_machine_init(MachineClass *mc) mc->block_default_type =3D IF_IDE; mc->units_per_default_bus =3D 1; mc->ignore_memory_transaction_failures =3D true; + mc->default_ram_id =3D "cubieboard.ram"; } =20 DEFINE_MACHINE("cubieboard", cubieboard_machine_init) --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581961467151874.7069583184862; Mon, 17 Feb 2020 09:44:27 -0800 (PST) Received: from localhost ([::1]:49512 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kRV-0003nx-UC for importer@patchew.org; Mon, 17 Feb 2020 12:44:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38171) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kIl-0001Id-8D for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kIj-0001pr-Nc for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:23 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:53671 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kIj-0001pF-JC for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:21 -0500 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-312-zahwd2FmMYOLIoS1dx6qaw-1; Mon, 17 Feb 2020 12:35:17 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8257C107ACCA; Mon, 17 Feb 2020 17:35:15 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id A8D189052B; Mon, 17 Feb 2020 17:35:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960921; 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=N49iBt5mUsbw/GHz0zPTk+Np0cNFJMPgoU20U6V87I0=; b=FIdUojxdAHA5eaFkxzYrvDKOTPUltaeLv7YWZktLeBD2VfhPwevVMdTuAApRRi5PTDZ1dF Cbc5BtM7Z9wY3WNVK4F/Rkq2Dwu+2OyQE4ZjTu65872pJYGaB62+IwyZm1vzZrZzqdS5vV zICQ8AGczFAdv/+TCvbA9DLWus4jqhA= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 13/79] arm/digic_boards: use memdev for RAM Date: Mon, 17 Feb 2020 12:33:46 -0500 Message-Id: <20200217173452.15243-14-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: zahwd2FmMYOLIoS1dx6qaw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 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: Paolo Bonzini , antonynpavlov@gmail.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. PS: remove no longer needed DigicBoardState PS2: while at it add check for user supplied RAM size and error out if it mismatches board expected value. Signed-off-by: Igor Mammedov Reviewed-by: Andrew Jones Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- v3: * move 'DigicState *s' declaration to the top of digic4_board_init() v2: * fix format string causing build failure on 32-bit host (Philippe Mathieu-Daud=C3=A9 ) CC: antonynpavlov@gmail.com --- hw/arm/digic_boards.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/hw/arm/digic_boards.c b/hw/arm/digic_boards.c index ef3fc2b6a5..518a63e61d 100644 --- a/hw/arm/digic_boards.c +++ b/hw/arm/digic_boards.c @@ -35,39 +35,40 @@ #include "hw/loader.h" #include "sysemu/sysemu.h" #include "sysemu/qtest.h" +#include "qemu/units.h" +#include "qemu/cutils.h" =20 #define DIGIC4_ROM0_BASE 0xf0000000 #define DIGIC4_ROM1_BASE 0xf8000000 #define DIGIC4_ROM_MAX_SIZE 0x08000000 =20 -typedef struct DigicBoardState { - DigicState *digic; - MemoryRegion ram; -} DigicBoardState; - typedef struct DigicBoard { - hwaddr ram_size; - void (*add_rom0)(DigicBoardState *, hwaddr, const char *); + void (*add_rom0)(DigicState *, hwaddr, const char *); const char *rom0_def_filename; - void (*add_rom1)(DigicBoardState *, hwaddr, const char *); + void (*add_rom1)(DigicState *, hwaddr, const char *); const char *rom1_def_filename; } DigicBoard; =20 -static void digic4_board_init(DigicBoard *board) +static void digic4_board_init(MachineState *machine, DigicBoard *board) { Error *err =3D NULL; + DigicState *s =3D DIGIC(object_new(TYPE_DIGIC)); + MachineClass *mc =3D MACHINE_GET_CLASS(machine); + + if (machine->ram_size !=3D mc->default_ram_size) { + char *sz =3D size_to_str(mc->default_ram_size); + error_report("Invalid RAM size, should be %s", sz); + g_free(sz); + exit(EXIT_FAILURE); + } =20 - DigicBoardState *s =3D g_new(DigicBoardState, 1); - - s->digic =3D DIGIC(object_new(TYPE_DIGIC)); - object_property_set_bool(OBJECT(s->digic), true, "realized", &err); + object_property_set_bool(OBJECT(s), true, "realized", &err); if (err !=3D NULL) { error_reportf_err(err, "Couldn't realize DIGIC SoC: "); exit(1); } =20 - memory_region_allocate_system_memory(&s->ram, NULL, "ram", board->ram_= size); - memory_region_add_subregion(get_system_memory(), 0, &s->ram); + memory_region_add_subregion(get_system_memory(), 0, machine->ram); =20 if (board->add_rom0) { board->add_rom0(s, DIGIC4_ROM0_BASE, board->rom0_def_filename); @@ -78,7 +79,7 @@ static void digic4_board_init(DigicBoard *board) } } =20 -static void digic_load_rom(DigicBoardState *s, hwaddr addr, +static void digic_load_rom(DigicState *s, hwaddr addr, hwaddr max_size, const char *def_filename) { target_long rom_size; @@ -118,7 +119,7 @@ static void digic_load_rom(DigicBoardState *s, hwaddr a= ddr, * Samsung K8P3215UQB * 64M Bit (4Mx16) Page Mode / Multi-Bank NOR Flash Memory */ -static void digic4_add_k8p3215uqb_rom(DigicBoardState *s, hwaddr addr, +static void digic4_add_k8p3215uqb_rom(DigicState *s, hwaddr addr, const char *def_filename) { #define FLASH_K8P3215UQB_SIZE (4 * 1024 * 1024) @@ -135,14 +136,13 @@ static void digic4_add_k8p3215uqb_rom(DigicBoardState= *s, hwaddr addr, } =20 static DigicBoard digic4_board_canon_a1100 =3D { - .ram_size =3D 64 * 1024 * 1024, .add_rom1 =3D digic4_add_k8p3215uqb_rom, .rom1_def_filename =3D "canon-a1100-rom1.bin", }; =20 static void canon_a1100_init(MachineState *machine) { - digic4_board_init(&digic4_board_canon_a1100); + digic4_board_init(machine, &digic4_board_canon_a1100); } =20 static void canon_a1100_machine_init(MachineClass *mc) @@ -150,6 +150,8 @@ static void canon_a1100_machine_init(MachineClass *mc) mc->desc =3D "Canon PowerShot A1100 IS"; mc->init =3D &canon_a1100_init; mc->ignore_memory_transaction_failures =3D true; + mc->default_ram_size =3D 64 * MiB; + mc->default_ram_id =3D "ram"; } =20 DEFINE_MACHINE("canon-a1100", canon_a1100_machine_init) --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581961369593575.0599567750404; Mon, 17 Feb 2020 09:42:49 -0800 (PST) Received: from localhost ([::1]:49488 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kPw-0000P5-BA for importer@patchew.org; Mon, 17 Feb 2020 12:42:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38141) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kIj-0001Ed-Ku for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kIi-0001oZ-AD for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:21 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:35174 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kIi-0001oA-5G for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:20 -0500 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-412-hkfVTUg6Pq2m8rAMRFxOhA-1; Mon, 17 Feb 2020 12:35:17 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A7F931084431; Mon, 17 Feb 2020 17:35:16 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id CDAD48CCE0; Mon, 17 Feb 2020 17:35:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960919; 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=fyGiYVnyrESE+bDVRdAtrFy5/IupR4jaS3wni1rBVjQ=; b=BdsP+PQHhuiO759Q+u3eFZ8aQpqxCtYuwhv+t9VilttKVxp+orTqXCQL+L2C2pbVoGjT3V Hby/6UXmn0HP3KY2SvdugtqExwoiBOfsWw9Dh9k4Ptd1LCWQp1iTyIEJnwOI4UbanXBDT2 MRHeMqA/mRbrPSVOU7NJu9O1KPpmTiM= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 14/79] arm/highbank: use memdev for RAM Date: Mon, 17 Feb 2020 12:33:47 -0500 Message-Id: <20200217173452.15243-15-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: hkfVTUg6Pq2m8rAMRFxOhA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 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: Paolo Bonzini , robh@kernel.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- CC: robh@kernel.org --- hw/arm/highbank.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c index 518d935fdf..ac9de9411e 100644 --- a/hw/arm/highbank.c +++ b/hw/arm/highbank.c @@ -236,7 +236,6 @@ enum cxmachines { */ static void calxeda_init(MachineState *machine, enum cxmachines machine_id) { - ram_addr_t ram_size =3D machine->ram_size; DeviceState *dev =3D NULL; SysBusDevice *busdev; qemu_irq pic[128]; @@ -247,7 +246,6 @@ static void calxeda_init(MachineState *machine, enum cx= machines machine_id) qemu_irq cpu_virq[4]; qemu_irq cpu_vfiq[4]; MemoryRegion *sysram; - MemoryRegion *dram; MemoryRegion *sysmem; char *sysboot_filename; =20 @@ -290,10 +288,8 @@ static void calxeda_init(MachineState *machine, enum c= xmachines machine_id) } =20 sysmem =3D get_system_memory(); - dram =3D g_new(MemoryRegion, 1); - memory_region_allocate_system_memory(dram, NULL, "highbank.dram", ram_= size); /* SDRAM at address zero. */ - memory_region_add_subregion(sysmem, 0, dram); + memory_region_add_subregion(sysmem, 0, machine->ram); =20 sysram =3D g_new(MemoryRegion, 1); memory_region_init_ram(sysram, NULL, "highbank.sysram", 0x8000, @@ -387,7 +383,7 @@ static void calxeda_init(MachineState *machine, enum cx= machines machine_id) =20 /* TODO create and connect IDE devices for ide_drive_get() */ =20 - highbank_binfo.ram_size =3D ram_size; + highbank_binfo.ram_size =3D machine->ram_size; /* highbank requires a dtb in order to boot, and the dtb will override * the board ID. The following value is ignored, so set it to -1 to be * clear that the value is meaningless. @@ -430,6 +426,7 @@ static void highbank_class_init(ObjectClass *oc, void *= data) mc->units_per_default_bus =3D 1; mc->max_cpus =3D 4; mc->ignore_memory_transaction_failures =3D true; + mc->default_ram_id =3D "highbank.dram"; } =20 static const TypeInfo highbank_type =3D { @@ -448,6 +445,7 @@ static void midway_class_init(ObjectClass *oc, void *da= ta) mc->units_per_default_bus =3D 1; mc->max_cpus =3D 4; mc->ignore_memory_transaction_failures =3D true; + mc->default_ram_id =3D "highbank.dram"; } =20 static const TypeInfo midway_type =3D { --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581961155686722.9541912176845; Mon, 17 Feb 2020 09:39:15 -0800 (PST) Received: from localhost ([::1]:49424 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kMU-0001h9-GF for importer@patchew.org; Mon, 17 Feb 2020 12:39:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38167) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kIl-0001I6-0d for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kIj-0001q2-Qi for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:22 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:46590 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kIj-0001pK-MY for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:21 -0500 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-422-wZugAkmWMqut0vxOq6qlbA-1; Mon, 17 Feb 2020 12:35:19 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7C6048017DF; Mon, 17 Feb 2020 17:35:18 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id F23A78CCE0; Mon, 17 Feb 2020 17:35:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960921; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PoLKVuD8z1OSIeOnDJ8QRLSEIGCP8+HptdOHqvqlXlk=; b=aymhT6uLX8t2eupGLzKoUtBG4FSBtz1bcOrDxSM7dfscjmnisCNOsZz6ZlNjL5HCG6YnD3 qo5bZAjKQ7VH1DBG8anUKu1XKMHz8BATeQn+k/LFeufHW569JjYxGEQiZGer9dGnKpuCHD a0ZKL1+fr16GjSgRhvu9D0VZAZEhVWk= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 15/79] arm/imx25_pdk: drop RAM size fixup Date: Mon, 17 Feb 2020 12:33:48 -0500 Message-Id: <20200217173452.15243-16-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: wZugAkmWMqut0vxOq6qlbA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 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: peter.maydell@linaro.org, Paolo Bonzini , qemu-arm@nongnu.org, philmd@redhat.com, jcd@tribudubois.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If user provided non-sense RAM size, board will complain and continue running with max RAM size supported. Also RAM is going to be allocated by generic code, so it won't be possible for board to fix things up for user. Make it error message and exit to force user fix CLI, instead of accepting non-sense CLI values. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- CC: jcd@tribudubois.net CC: peter.maydell@linaro.org CC: qemu-arm@nongnu.org CC: philmd@redhat.com --- hw/arm/imx25_pdk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/arm/imx25_pdk.c b/hw/arm/imx25_pdk.c index c76fc2bd94..a2b7b35dcc 100644 --- a/hw/arm/imx25_pdk.c +++ b/hw/arm/imx25_pdk.c @@ -78,10 +78,10 @@ static void imx25_pdk_init(MachineState *machine) =20 /* We need to initialize our memory */ if (machine->ram_size > (FSL_IMX25_SDRAM0_SIZE + FSL_IMX25_SDRAM1_SIZE= )) { - warn_report("RAM size " RAM_ADDR_FMT " above max supported, " + error_report("RAM size " RAM_ADDR_FMT " above max supported, " "reduced to %x", machine->ram_size, FSL_IMX25_SDRAM0_SIZE + FSL_IMX25_SDRAM1_SIZE); - machine->ram_size =3D FSL_IMX25_SDRAM0_SIZE + FSL_IMX25_SDRAM1_SIZ= E; + exit(EXIT_FAILURE); } =20 memory_region_allocate_system_memory(&s->ram, NULL, "imx25.ram", --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581961294957888.5069058718835; Mon, 17 Feb 2020 09:41:34 -0800 (PST) Received: from localhost ([::1]:49464 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kOj-0006KU-J3 for importer@patchew.org; Mon, 17 Feb 2020 12:41:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38195) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kIn-0001P6-2A for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kIl-0001rt-TX for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:24 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:58273 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kIl-0001rL-PE for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:23 -0500 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-56-deNTr94_MHeCzrmF5iRVLQ-1; Mon, 17 Feb 2020 12:35:20 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C60BD18FE860; Mon, 17 Feb 2020 17:35:19 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id C43FB8CCE0; Mon, 17 Feb 2020 17:35:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960923; 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=HnhdSXL39kygO0jjQDrylUKy22GYKWdOdTBn5a5pYTY=; b=aiHlqL8reoKNmq3CazZD/k4rqixYqG4duwPGOpIj7VWJf9pMQPk1GZuVz86flqs8Vj1h9H mgewtz9vYhUVaxgvnoGwcpnnOlRUXcQ1v/KOJ5/Er0z6l4nQ2Mq1Ofvv1LBH0fvEZdFRJd fcU8tQJr4LQWFZGyU5epJvYsYjUQIBM= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 16/79] arm/imx25_pdk: use memdev for RAM Date: Mon, 17 Feb 2020 12:33:49 -0500 Message-Id: <20200217173452.15243-17-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: deNTr94_MHeCzrmF5iRVLQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 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: Paolo Bonzini , jcd@tribudubois.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- CC: jcd@tribudubois.net --- hw/arm/imx25_pdk.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/hw/arm/imx25_pdk.c b/hw/arm/imx25_pdk.c index a2b7b35dcc..9087fcbb80 100644 --- a/hw/arm/imx25_pdk.c +++ b/hw/arm/imx25_pdk.c @@ -58,7 +58,6 @@ =20 typedef struct IMX25PDK { FslIMX25State soc; - MemoryRegion ram; MemoryRegion ram_alias; } IMX25PDK; =20 @@ -84,10 +83,8 @@ static void imx25_pdk_init(MachineState *machine) exit(EXIT_FAILURE); } =20 - memory_region_allocate_system_memory(&s->ram, NULL, "imx25.ram", - machine->ram_size); memory_region_add_subregion(get_system_memory(), FSL_IMX25_SDRAM0_ADDR, - &s->ram); + machine->ram); =20 /* initialize the alias memory if any */ for (i =3D 0, ram_size =3D machine->ram_size, alias_offset =3D 0; @@ -107,7 +104,8 @@ static void imx25_pdk_init(MachineState *machine) =20 if (size < ram[i].size) { memory_region_init_alias(&s->ram_alias, NULL, "ram.alias", - &s->ram, alias_offset, ram[i].size - = size); + machine->ram, + alias_offset, ram[i].size - size); memory_region_add_subregion(get_system_memory(), ram[i].addr + size, &s->ram_alias); } @@ -135,6 +133,7 @@ static void imx25_pdk_machine_init(MachineClass *mc) mc->desc =3D "ARM i.MX25 PDK board (ARM926)"; mc->init =3D imx25_pdk_init; mc->ignore_memory_transaction_failures =3D true; + mc->default_ram_id =3D "imx25.ram"; } =20 DEFINE_MACHINE("imx25-pdk", imx25_pdk_machine_init) --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581961600174709.9730333066883; Mon, 17 Feb 2020 09:46:40 -0800 (PST) Received: from localhost ([::1]:49554 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kTe-0007VG-Vo for importer@patchew.org; Mon, 17 Feb 2020 12:46:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38212) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kIo-0001S6-65 for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kIm-0001sW-QM for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:26 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:27329 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kIm-0001sA-ME for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:24 -0500 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-94-qZkeF3EYM7-1m2ZALnvuvQ-1; Mon, 17 Feb 2020 12:35:22 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2746E1084433; Mon, 17 Feb 2020 17:35:21 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1CB339051D; Mon, 17 Feb 2020 17:35:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960924; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=W8ENp3JcAQ0uQwo+I3OlCW3LJSIu4nkkXrkerZjBiIc=; b=egUkFIOOD+7HSyA4CjColtEuAGNlkL6oWkjIZhBxofbqMGG7DcUPW/j8uKUWyOoy47edMq XG3uHk0I7P7nToV3XtxJ+upEd1iOKYjf4FyFXmmtEP2tWrtcnNzNCc2gEC6gTk/kjQaiiI Xuq2lTrJIlZf6atuuf8uicFmZRiYEUQ= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 17/79] arm/integratorcp: use memdev for RAM Date: Mon, 17 Feb 2020 12:33:50 -0500 Message-Id: <20200217173452.15243-18-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: qZkeF3EYM7-1m2ZALnvuvQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 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: Paolo Bonzini , peter.chubb@nicta.com.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Andrew Jones Reviewed-by: Richard Henderson --- CC: peter.chubb@nicta.com.au --- hw/arm/integratorcp.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/hw/arm/integratorcp.c b/hw/arm/integratorcp.c index 0cd94d9f09..cc845b8534 100644 --- a/hw/arm/integratorcp.c +++ b/hw/arm/integratorcp.c @@ -585,7 +585,6 @@ static void integratorcp_init(MachineState *machine) Object *cpuobj; ARMCPU *cpu; MemoryRegion *address_space_mem =3D get_system_memory(); - MemoryRegion *ram =3D g_new(MemoryRegion, 1); MemoryRegion *ram_alias =3D g_new(MemoryRegion, 1); qemu_irq pic[32]; DeviceState *dev, *sic, *icp; @@ -605,14 +604,13 @@ static void integratorcp_init(MachineState *machine) =20 cpu =3D ARM_CPU(cpuobj); =20 - memory_region_allocate_system_memory(ram, NULL, "integrator.ram", - ram_size); /* ??? On a real system the first 1Mb is mapped as SSRAM or boot flash= . */ /* ??? RAM should repeat to fill physical memory space. */ /* SDRAM at address zero*/ - memory_region_add_subregion(address_space_mem, 0, ram); + memory_region_add_subregion(address_space_mem, 0, machine->ram); /* And again at address 0x80000000 */ - memory_region_init_alias(ram_alias, NULL, "ram.alias", ram, 0, ram_siz= e); + memory_region_init_alias(ram_alias, NULL, "ram.alias", machine->ram, + 0, ram_size); memory_region_add_subregion(address_space_mem, 0x80000000, ram_alias); =20 dev =3D qdev_create(NULL, TYPE_INTEGRATOR_CM); @@ -660,6 +658,7 @@ static void integratorcp_machine_init(MachineClass *mc) mc->init =3D integratorcp_init; mc->ignore_memory_transaction_failures =3D true; mc->default_cpu_type =3D ARM_CPU_TYPE_NAME("arm926"); + mc->default_ram_id =3D "integrator.ram"; } =20 DEFINE_MACHINE("integratorcp", integratorcp_machine_init) --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581961366603125.22826742672623; Mon, 17 Feb 2020 09:42:46 -0800 (PST) Received: from localhost ([::1]:49484 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kPt-0000D2-2Z for importer@patchew.org; Mon, 17 Feb 2020 12:42:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38241) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kIq-0001XN-E7 for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kIp-0001uM-3t for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:28 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:51929 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kIo-0001u2-Ve for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:27 -0500 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-199-4AlLvmDzPg2nncy68GtrNQ-1; Mon, 17 Feb 2020 12:35:23 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2569B18FE862 for ; Mon, 17 Feb 2020 17:35:22 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 722A59051D; Mon, 17 Feb 2020 17:35:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960926; 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=4Dfb85aPgfwwJ+mWybY0PsNk3IWDbp0ixvgCs4MJYxk=; b=FczoTESsrfYCa5DmoKio+GZcVM1/OLmfx+Jvl/HlpXdajK9PIP2Xoqfb0rUfCpglPEiX0l YQtdmF/IeVhYAqRsodDWj4hIaLWfhSSVQueyzFuT15yU2tujGtSCcXYdJijjybPqzbY9aR gwZjitWG0dFK/ROZ8saf34jT28uzvjY= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 18/79] arm/kzm: drop RAM size fixup Date: Mon, 17 Feb 2020 12:33:51 -0500 Message-Id: <20200217173452.15243-19-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: 4AlLvmDzPg2nncy68GtrNQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" If the user provided too large a RAM size, the code used to complain and trim it to the max size. Now that RAM is allocated by generic code, that's no longer possible, so generate an error and exit instead. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Peter Chubb Reviewed-by: Richard Henderson --- v3: * rephrase commit message in nicer way ("Chubb, Peter (Data61, Kensington NSW)" ) * reword error message and use size_to_str() to pretty print suggested size ("Chubb, Peter (Data61, Kensington NSW)" ) --- hw/arm/kzm.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hw/arm/kzm.c b/hw/arm/kzm.c index 1d5ef289d5..94cbac11de 100644 --- a/hw/arm/kzm.c +++ b/hw/arm/kzm.c @@ -25,6 +25,7 @@ #include "hw/char/serial.h" #include "sysemu/qtest.h" #include "sysemu/sysemu.h" +#include "qemu/cutils.h" =20 /* Memory map for Kzm Emulation Baseboard: * 0x00000000-0x7fffffff See i.MX31 SOC for support @@ -78,10 +79,10 @@ static void kzm_init(MachineState *machine) =20 /* Check the amount of memory is compatible with the SOC */ if (machine->ram_size > (FSL_IMX31_SDRAM0_SIZE + FSL_IMX31_SDRAM1_SIZE= )) { - warn_report("RAM size " RAM_ADDR_FMT " above max supported, " - "reduced to %x", machine->ram_size, - FSL_IMX31_SDRAM0_SIZE + FSL_IMX31_SDRAM1_SIZE); - machine->ram_size =3D FSL_IMX31_SDRAM0_SIZE + FSL_IMX31_SDRAM1_SIZ= E; + char *sz =3D size_to_str(FSL_IMX31_SDRAM0_SIZE + FSL_IMX31_SDRAM1_= SIZE); + error_report("RAM size more than %s is not supported", sz); + g_free(sz); + exit(EXIT_FAILURE); } =20 memory_region_allocate_system_memory(&s->ram, NULL, "kzm.ram", --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581961730184197.46030813976552; Mon, 17 Feb 2020 09:48:50 -0800 (PST) Received: from localhost ([::1]:49580 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kVk-0002dr-K2 for importer@patchew.org; Mon, 17 Feb 2020 12:48:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38224) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kIp-0001VM-F2 for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kIo-0001tt-9u for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:27 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:32975 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kIo-0001tP-4b for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:26 -0500 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-151-BksC2vKfN3m8S_DrtQPz8w-1; Mon, 17 Feb 2020 12:35:24 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 213D318FE860 for ; Mon, 17 Feb 2020 17:35:23 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E5AE90508; Mon, 17 Feb 2020 17:35:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960925; 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=W2lucjeC1vK/ETg4bQp3/tEek3Z9NgL/LGMUgmObzmA=; b=LkKTAkdLUr3pzfo8rvpChvLaMATgAVTGE4sKrp08r2QhcAhZouddAm3pyfGWP582j7FrgU B5vLt+xwBbmXNt7opWN2Ggi+Ba4pkB9osaU8PtSN+1LA0ZXambEg4fnu15JmolappncplL /B+WyorkadvsqX6yYQgOMN6csbGlJR8= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 19/79] arm/kzm: use memdev for RAM Date: Mon, 17 Feb 2020 12:33:52 -0500 Message-Id: <20200217173452.15243-20-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: BksC2vKfN3m8S_DrtQPz8w-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Peter Chubb Reviewed-by: Richard Henderson --- hw/arm/kzm.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/hw/arm/kzm.c b/hw/arm/kzm.c index 94cbac11de..34f6bcb491 100644 --- a/hw/arm/kzm.c +++ b/hw/arm/kzm.c @@ -52,7 +52,6 @@ =20 typedef struct IMX31KZM { FslIMX31State soc; - MemoryRegion ram; MemoryRegion ram_alias; } IMX31KZM; =20 @@ -85,10 +84,8 @@ static void kzm_init(MachineState *machine) exit(EXIT_FAILURE); } =20 - memory_region_allocate_system_memory(&s->ram, NULL, "kzm.ram", - machine->ram_size); memory_region_add_subregion(get_system_memory(), FSL_IMX31_SDRAM0_ADDR, - &s->ram); + machine->ram); =20 /* initialize the alias memory if any */ for (i =3D 0, ram_size =3D machine->ram_size, alias_offset =3D 0; @@ -108,7 +105,8 @@ static void kzm_init(MachineState *machine) =20 if (size < ram[i].size) { memory_region_init_alias(&s->ram_alias, NULL, "ram.alias", - &s->ram, alias_offset, ram[i].size - = size); + machine->ram, + alias_offset, ram[i].size - size); memory_region_add_subregion(get_system_memory(), ram[i].addr + size, &s->ram_alias); } @@ -140,6 +138,7 @@ static void kzm_machine_init(MachineClass *mc) mc->desc =3D "ARM KZM Emulation Baseboard (ARM1136)"; mc->init =3D kzm_init; mc->ignore_memory_transaction_failures =3D true; + mc->default_ram_id =3D "kzm.ram"; } =20 DEFINE_MACHINE("kzm", kzm_machine_init) --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581961853446243.93780517668097; Mon, 17 Feb 2020 09:50:53 -0800 (PST) Received: from localhost ([::1]:49606 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kXj-00067G-Uz for importer@patchew.org; Mon, 17 Feb 2020 12:50:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38248) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kIq-0001YI-Un for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kIp-0001vd-K2 for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:28 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:39095 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kIp-0001uR-Ey for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:27 -0500 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-81-xEnqwN-4NAK0pTmlwse_Zw-1; Mon, 17 Feb 2020 12:35:25 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 454501005513; Mon, 17 Feb 2020 17:35:24 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6B00190508; Mon, 17 Feb 2020 17:35:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960927; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PHuC4/i8RhKr6ZW/nPMVPCCUOUPbmPrGva4aX3bS4eU=; b=QJ7a1Sj9Hy6LKIp90MGGjrcvciLGfVP7Lh2vJEtkMQnlJSDWXCatwDaSNkWhZVlK5t1T2H pUkemukm2n2IK+WKeo7RWfDCWNZDVY/Hwq6p4w+1O47q98wklPspDtmPbMqDSBSqwdAl7i 9s8B1Ke+Aqf7Ypx2/6mq5nys+xVwTdE= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 20/79] arm/mcimx6ul-evk: use memdev for RAM Date: Mon, 17 Feb 2020 12:33:53 -0500 Message-Id: <20200217173452.15243-21-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: xEnqwN-4NAK0pTmlwse_Zw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 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: Paolo Bonzini , jcd@tribudubois.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. PS: remove no longer needed MCIMX6ULEVK Signed-off-by: Igor Mammedov Reviewed-by: Andrew Jones Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- CC: jcd@tribudubois.net --- hw/arm/mcimx6ul-evk.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/hw/arm/mcimx6ul-evk.c b/hw/arm/mcimx6ul-evk.c index e90b393a44..23a71ed378 100644 --- a/hw/arm/mcimx6ul-evk.c +++ b/hw/arm/mcimx6ul-evk.c @@ -19,15 +19,10 @@ #include "qemu/error-report.h" #include "sysemu/qtest.h" =20 -typedef struct { - FslIMX6ULState soc; - MemoryRegion ram; -} MCIMX6ULEVK; - static void mcimx6ul_evk_init(MachineState *machine) { static struct arm_boot_info boot_info; - MCIMX6ULEVK *s =3D g_new0(MCIMX6ULEVK, 1); + FslIMX6ULState *s; int i; =20 if (machine->ram_size > FSL_IMX6UL_MMDC_SIZE) { @@ -43,15 +38,12 @@ static void mcimx6ul_evk_init(MachineState *machine) .nb_cpus =3D machine->smp.cpus, }; =20 - object_initialize_child(OBJECT(machine), "soc", &s->soc, sizeof(s->so= c), - TYPE_FSL_IMX6UL, &error_fatal, NULL); - - object_property_set_bool(OBJECT(&s->soc), true, "realized", &error_fat= al); + s =3D FSL_IMX6UL(object_new(TYPE_FSL_IMX6UL)); + object_property_add_child(OBJECT(machine), "soc", OBJECT(s), &error_fa= tal); + object_property_set_bool(OBJECT(s), true, "realized", &error_fatal); =20 - memory_region_allocate_system_memory(&s->ram, NULL, "mcimx6ul-evk.ram", - machine->ram_size); - memory_region_add_subregion(get_system_memory(), - FSL_IMX6UL_MMDC_ADDR, &s->ram); + memory_region_add_subregion(get_system_memory(), FSL_IMX6UL_MMDC_ADDR, + machine->ram); =20 for (i =3D 0; i < FSL_IMX6UL_NUM_USDHCS; i++) { BusState *bus; @@ -61,7 +53,7 @@ static void mcimx6ul_evk_init(MachineState *machine) =20 di =3D drive_get_next(IF_SD); blk =3D di ? blk_by_legacy_dinfo(di) : NULL; - bus =3D qdev_get_child_bus(DEVICE(&s->soc.usdhc[i]), "sd-bus"); + bus =3D qdev_get_child_bus(DEVICE(&s->usdhc[i]), "sd-bus"); carddev =3D qdev_create(bus, TYPE_SD_CARD); qdev_prop_set_drive(carddev, "drive", blk, &error_fatal); object_property_set_bool(OBJECT(carddev), true, @@ -69,7 +61,7 @@ static void mcimx6ul_evk_init(MachineState *machine) } =20 if (!qtest_enabled()) { - arm_load_kernel(&s->soc.cpu, machine, &boot_info); + arm_load_kernel(&s->cpu, machine, &boot_info); } } =20 @@ -78,5 +70,6 @@ static void mcimx6ul_evk_machine_init(MachineClass *mc) mc->desc =3D "Freescale i.MX6UL Evaluation Kit (Cortex A7)"; mc->init =3D mcimx6ul_evk_init; mc->max_cpus =3D FSL_IMX6UL_NUM_CPUS; + mc->default_ram_id =3D "mcimx6ul-evk.ram"; } DEFINE_MACHINE("mcimx6ul-evk", mcimx6ul_evk_machine_init) --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581961396143855.5752936249075; Mon, 17 Feb 2020 09:43:16 -0800 (PST) Received: from localhost ([::1]:49490 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kQM-0001UZ-Ui for importer@patchew.org; Mon, 17 Feb 2020 12:43:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38270) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kIs-0001aw-6l for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kIq-0001wq-QW for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:30 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:49267 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kIq-0001wb-LL for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:28 -0500 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-257-0PIL5mB5NO-de0vzecQGTw-1; Mon, 17 Feb 2020 12:35:26 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 65DB01800D42; Mon, 17 Feb 2020 17:35:25 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8EC5F90508; Mon, 17 Feb 2020 17:35:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960928; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=duVm+ooNqfwka5z6L8ocGaNTY92wT9VaunOekA0WKpc=; b=e2KzkVY4ypm/zUeWXrHWpzKm/eDQl6/g1c5BvaubilWhVHlpKf+3UdsKprBgP12lLJeYfz LRDM1kF6B0ezFf6zgbWR0pFtaFq2u32jDLpEs7LTc0zVldppLLS3n3lXwQDi1enyuUJ3Zg nlQA1i7/CohWHWsa0xa/Z3pQYlH/H0A= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 21/79] arm/mcimx7d-sabre: use memdev for RAM Date: Mon, 17 Feb 2020 12:33:54 -0500 Message-Id: <20200217173452.15243-22-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: 0PIL5mB5NO-de0vzecQGTw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 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: andrew.smirnov@gmail.com, Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. PS: remove no longer needed MCIMX7Sabre Signed-off-by: Igor Mammedov Reviewed-by: Andrew Jones Reviewed-by: Richard Henderson --- CC: andrew.smirnov@gmail.com --- hw/arm/mcimx7d-sabre.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/hw/arm/mcimx7d-sabre.c b/hw/arm/mcimx7d-sabre.c index 0d1f62d30a..de1e264217 100644 --- a/hw/arm/mcimx7d-sabre.c +++ b/hw/arm/mcimx7d-sabre.c @@ -21,15 +21,10 @@ #include "qemu/error-report.h" #include "sysemu/qtest.h" =20 -typedef struct { - FslIMX7State soc; - MemoryRegion ram; -} MCIMX7Sabre; - static void mcimx7d_sabre_init(MachineState *machine) { static struct arm_boot_info boot_info; - MCIMX7Sabre *s =3D g_new0(MCIMX7Sabre, 1); + FslIMX7State *s; int i; =20 if (machine->ram_size > FSL_IMX7_MMDC_SIZE) { @@ -45,15 +40,12 @@ static void mcimx7d_sabre_init(MachineState *machine) .nb_cpus =3D machine->smp.cpus, }; =20 - object_initialize_child(OBJECT(machine), "soc", - &s->soc, sizeof(s->soc), - TYPE_FSL_IMX7, &error_fatal, NULL); - object_property_set_bool(OBJECT(&s->soc), true, "realized", &error_fat= al); + s =3D FSL_IMX7(object_new(TYPE_FSL_IMX7)); + object_property_add_child(OBJECT(machine), "soc", OBJECT(s), &error_fa= tal); + object_property_set_bool(OBJECT(s), true, "realized", &error_fatal); =20 - memory_region_allocate_system_memory(&s->ram, NULL, "mcimx7d-sabre.ram= ", - machine->ram_size); - memory_region_add_subregion(get_system_memory(), - FSL_IMX7_MMDC_ADDR, &s->ram); + memory_region_add_subregion(get_system_memory(), FSL_IMX7_MMDC_ADDR, + machine->ram); =20 for (i =3D 0; i < FSL_IMX7_NUM_USDHCS; i++) { BusState *bus; @@ -63,7 +55,7 @@ static void mcimx7d_sabre_init(MachineState *machine) =20 di =3D drive_get_next(IF_SD); blk =3D di ? blk_by_legacy_dinfo(di) : NULL; - bus =3D qdev_get_child_bus(DEVICE(&s->soc.usdhc[i]), "sd-bus"); + bus =3D qdev_get_child_bus(DEVICE(&s->usdhc[i]), "sd-bus"); carddev =3D qdev_create(bus, TYPE_SD_CARD); qdev_prop_set_drive(carddev, "drive", blk, &error_fatal); object_property_set_bool(OBJECT(carddev), true, @@ -71,7 +63,7 @@ static void mcimx7d_sabre_init(MachineState *machine) } =20 if (!qtest_enabled()) { - arm_load_kernel(&s->soc.cpu[0], machine, &boot_info); + arm_load_kernel(&s->cpu[0], machine, &boot_info); } } =20 @@ -80,5 +72,6 @@ static void mcimx7d_sabre_machine_init(MachineClass *mc) mc->desc =3D "Freescale i.MX7 DUAL SABRE (Cortex A7)"; mc->init =3D mcimx7d_sabre_init; mc->max_cpus =3D FSL_IMX7_NUM_CPUS; + mc->default_ram_id =3D "mcimx7d-sabre.ram"; } DEFINE_MACHINE("mcimx7d-sabre", mcimx7d_sabre_machine_init) --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15819612488095.230921164903293; Mon, 17 Feb 2020 09:40:48 -0800 (PST) Received: from localhost ([::1]:49448 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kNz-00050n-Ic for importer@patchew.org; Mon, 17 Feb 2020 12:40:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38276) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kIs-0001c4-MD for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kIr-0001xT-FB for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:30 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:27517 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kIr-0001x7-Ah for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:29 -0500 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-124-r--Bw6E1MBCAxLUBdXRS1g-1; Mon, 17 Feb 2020 12:35:27 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 62ACB8017CC for ; Mon, 17 Feb 2020 17:35:26 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id B14E890508; Mon, 17 Feb 2020 17:35:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960928; 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=NXhWbrMAKsZqAUL2XRd14/Ej6oYnxmZJgwHGGyzEyp0=; b=iaS4c2q7TGe+RjBzJxqgzHj5wMysWq6tZqZlTB+0CP93eytxeeK58vxAZ9al7f5E0s4AgG BtRDqOI/GTx5Qws9dIkbqPHfD63+/RHGUN7wMb/QPV39m5C0f13F+h/yE/YfE7rRzC8BgD 1TE5UycBX018zWO6GiISFze784WV+MU= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 22/79] arm/mps2-tz: use memdev for RAM Date: Mon, 17 Feb 2020 12:33:55 -0500 Message-Id: <20200217173452.15243-23-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: r--Bw6E1MBCAxLUBdXRS1g-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. PS: while at it add check for user supplied RAM size and error out if it mismatches board expected value. Signed-off-by: Igor Mammedov Reviewed-by: Andrew Jones Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- v2: * fix format string causing build failure on 32-bit host (Philippe Mathieu-Daud=C3=A9 ) v4: * move default_ram_size to mps2tz_class_init() (Andrew Jones ) --- hw/arm/mps2-tz.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c index f8b620bcc6..a8dea7dde1 100644 --- a/hw/arm/mps2-tz.c +++ b/hw/arm/mps2-tz.c @@ -39,6 +39,7 @@ =20 #include "qemu/osdep.h" #include "qemu/units.h" +#include "qemu/cutils.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "hw/arm/boot.h" @@ -79,7 +80,6 @@ typedef struct { MachineState parent; =20 ARMSSE iotkit; - MemoryRegion psram; MemoryRegion ssram[3]; MemoryRegion ssram1_m; MPS2SCC scc; @@ -388,6 +388,13 @@ static void mps2tz_common_init(MachineState *machine) exit(1); } =20 + if (machine->ram_size !=3D mc->default_ram_size) { + char *sz =3D size_to_str(mc->default_ram_size); + error_report("Invalid RAM size, should be %s", sz); + g_free(sz); + exit(EXIT_FAILURE); + } + sysbus_init_child_obj(OBJECT(machine), "iotkit", &mms->iotkit, sizeof(mms->iotkit), mmc->armsse_type); iotkitdev =3D DEVICE(&mms->iotkit); @@ -458,9 +465,7 @@ static void mps2tz_common_init(MachineState *machine) * tradeoffs. For QEMU they're all just RAM, though. We arbitrarily * call the 16MB our "system memory", as it's the largest lump. */ - memory_region_allocate_system_memory(&mms->psram, - NULL, "mps.ram", 16 * MiB); - memory_region_add_subregion(system_memory, 0x80000000, &mms->psram); + memory_region_add_subregion(system_memory, 0x80000000, machine->ram); =20 /* The overflow IRQs for all UARTs are ORed together. * Tx, Rx and "combined" IRQs are sent to the NVIC separately. @@ -642,6 +647,8 @@ static void mps2tz_class_init(ObjectClass *oc, void *da= ta) =20 mc->init =3D mps2tz_common_init; iic->check =3D mps2_tz_idau_check; + mc->default_ram_size =3D 16 * MiB; + mc->default_ram_id =3D "mps.ram"; } =20 static void mps2tz_an505_class_init(ObjectClass *oc, void *data) --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15819613669351009.8039488152484; Mon, 17 Feb 2020 09:42:46 -0800 (PST) Received: from localhost ([::1]:49486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kPt-0000Fk-Gy for importer@patchew.org; Mon, 17 Feb 2020 12:42:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38289) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kIt-0001eF-IR for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kIs-0001y1-9c for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:31 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:27389 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kIs-0001xf-4m for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:30 -0500 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-250-V1-AGdBNMLaRSXlHs2_XMg-1; Mon, 17 Feb 2020 12:35:28 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5D81D1005513 for ; Mon, 17 Feb 2020 17:35:27 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id ABF7F90508; Mon, 17 Feb 2020 17:35:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960929; 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=TARbjw/itpTQCZ7DvuGTnSgcPuNYiFPqV9t4yEc33Jo=; b=IiuSLGCtW1uMY6YPNwbn9fOea2Ly+hEYmXTNP64BLm5FNqNiIg5T8/hWIk19xZw9ydl1++ oreqJxkiQLY2U7b9OMfgPgAJJwWFQ0T3g84fMtcSiOJzHsR82obqSkrxkWbY9OVkffngC9 9YxZwOxto8gyuY5pZoEJZ0MSrXH4Yu4= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 23/79] arm/mps2: use memdev for RAM Date: Mon, 17 Feb 2020 12:33:56 -0500 Message-Id: <20200217173452.15243-24-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: V1-AGdBNMLaRSXlHs2_XMg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. PS: while at it add check for user supplied RAM size and error out if it mismatches board expected value. Signed-off-by: Igor Mammedov Reviewed-by: Andrew Jones Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- v2: * fix format string causing build failure on 32-bit host (Philippe Mathieu-Daud=C3=A9 ) --- hw/arm/mps2.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c index d002b126d3..f246213206 100644 --- a/hw/arm/mps2.c +++ b/hw/arm/mps2.c @@ -24,6 +24,7 @@ =20 #include "qemu/osdep.h" #include "qemu/units.h" +#include "qemu/cutils.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "hw/arm/boot.h" @@ -55,7 +56,6 @@ typedef struct { MachineState parent; =20 ARMv7MState armv7m; - MemoryRegion psram; MemoryRegion ssram1; MemoryRegion ssram1_m; MemoryRegion ssram23; @@ -118,6 +118,13 @@ static void mps2_common_init(MachineState *machine) exit(1); } =20 + if (machine->ram_size !=3D mc->default_ram_size) { + char *sz =3D size_to_str(mc->default_ram_size); + error_report("Invalid RAM size, should be %s", sz); + g_free(sz); + exit(EXIT_FAILURE); + } + /* The FPGA images have an odd combination of different RAMs, * because in hardware they are different implementations and * connected to different buses, giving varying performance/size @@ -146,9 +153,7 @@ static void mps2_common_init(MachineState *machine) * This is of no use for QEMU so we don't implement it (as if * zbt_boot_ctrl is always zero). */ - memory_region_allocate_system_memory(&mms->psram, - NULL, "mps.ram", 16 * MiB); - memory_region_add_subregion(system_memory, 0x21000000, &mms->psram); + memory_region_add_subregion(system_memory, 0x21000000, machine->ram); =20 switch (mmc->fpga_type) { case FPGA_AN385: @@ -338,6 +343,8 @@ static void mps2_class_init(ObjectClass *oc, void *data) =20 mc->init =3D mps2_common_init; mc->max_cpus =3D 1; + mc->default_ram_size =3D 16 * MiB; + mc->default_ram_id =3D "mps.ram"; } =20 static void mps2_an385_class_init(ObjectClass *oc, void *data) --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581961500421854.7075018637838; Mon, 17 Feb 2020 09:45:00 -0800 (PST) Received: from localhost ([::1]:49514 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kS3-0004uM-7P for importer@patchew.org; Mon, 17 Feb 2020 12:44:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38303) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kIv-0001jN-F9 for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kIu-0001zB-CJ for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:33 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:20132 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kIu-0001yz-88 for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:32 -0500 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-329-5Czmo_FwOgafQKXxbZvd8g-1; Mon, 17 Feb 2020 12:35:29 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8C3C48017CC; Mon, 17 Feb 2020 17:35:28 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id A7D6490508; Mon, 17 Feb 2020 17:35:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960931; 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=Q83ULi7S+JJuG9IWgB8TICDmEb97vSTDtqn1oYVdDF4=; b=g2uhafZCC+FAuESZSz48lRZN7NPY3k7pTjGnxQYW2Rog36V/7toOJsoi+ExAZgJ5TKT5r0 Om4cSf4Q0NN77BQUM9sJ1FBikQt2JKm0XLVo5HS82ulms4pahHfCTEYVmKfc1xwx01b8Xz 0hQagtuzZvEETqDou0Wx8Bu4pgNMNFc= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 24/79] arm/musicpal: use memdev for RAM Date: Mon, 17 Feb 2020 12:33:57 -0500 Message-Id: <20200217173452.15243-25-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: 5Czmo_FwOgafQKXxbZvd8g-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 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: Paolo Bonzini , jan.kiszka@web.de Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. PS: while at it add check for user supplied RAM size and error out if it mismatches board expected value. Signed-off-by: Igor Mammedov Reviewed-by: Andrew Jones Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- v2: * fix format string causing build failure on 32-bit host (Philippe Mathieu-Daud=C3=A9 ) CC: jan.kiszka@web.de --- hw/arm/musicpal.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c index dc551bb0c0..db8b03cb83 100644 --- a/hw/arm/musicpal.c +++ b/hw/arm/musicpal.c @@ -32,6 +32,7 @@ #include "sysemu/runstate.h" #include "exec/address-spaces.h" #include "ui/pixel_ops.h" +#include "qemu/cutils.h" =20 #define MP_MISC_BASE 0x80002000 #define MP_MISC_SIZE 0x00001000 @@ -1589,16 +1590,21 @@ static void musicpal_init(MachineState *machine) int i; unsigned long flash_size; DriveInfo *dinfo; + MachineClass *mc =3D MACHINE_GET_CLASS(machine); MemoryRegion *address_space_mem =3D get_system_memory(); - MemoryRegion *ram =3D g_new(MemoryRegion, 1); MemoryRegion *sram =3D g_new(MemoryRegion, 1); =20 + /* For now we use a fixed - the original - RAM size */ + if (machine->ram_size !=3D mc->default_ram_size) { + char *sz =3D size_to_str(mc->default_ram_size); + error_report("Invalid RAM size, should be %s", sz); + g_free(sz); + exit(EXIT_FAILURE); + } + cpu =3D ARM_CPU(cpu_create(machine->cpu_type)); =20 - /* For now we use a fixed - the original - RAM size */ - memory_region_allocate_system_memory(ram, NULL, "musicpal.ram", - MP_RAM_DEFAULT_SIZE); - memory_region_add_subregion(address_space_mem, 0, ram); + memory_region_add_subregion(address_space_mem, 0, machine->ram); =20 memory_region_init_ram(sram, NULL, "musicpal.sram", MP_SRAM_SIZE, &error_fatal); @@ -1714,6 +1720,8 @@ static void musicpal_machine_init(MachineClass *mc) mc->init =3D musicpal_init; mc->ignore_memory_transaction_failures =3D true; mc->default_cpu_type =3D ARM_CPU_TYPE_NAME("arm926"); + mc->default_ram_size =3D MP_RAM_DEFAULT_SIZE; + mc->default_ram_id =3D "musicpal.ram"; } =20 DEFINE_MACHINE("musicpal", musicpal_machine_init) --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581961647044340.68195940724934; Mon, 17 Feb 2020 09:47:27 -0800 (PST) Received: from localhost ([::1]:49556 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kUP-0000Ea-NT for importer@patchew.org; Mon, 17 Feb 2020 12:47:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38311) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kIw-0001k0-1p for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kIu-0001za-Rm for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:33 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:52670 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kIu-0001zF-NY for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:32 -0500 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-365-p26aPx3ANeurfCag1JYjyg-1; Mon, 17 Feb 2020 12:35:30 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B1382800EB2; Mon, 17 Feb 2020 17:35:29 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id D72099052B; Mon, 17 Feb 2020 17:35:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960932; 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=QYgD/QABUpWQ+6vzaBdpPtq3gBPx5zYDJzfIUZp+3mQ=; b=XEHyukz1I5DRjXDLbsn5blrM5J86KgGiZMAbQ6fJV5B7D/i7JQFYCLFUw4TXJspkmD+/Ma +i6ElhA420AwrdvIR+i2GBO3YXv+4OnF7SMIWLSSBWKiBo1HzmIkL3YxkiHKQEbqVfNgl/ OQotTbWuuYGVK8e/+UwOHYC8y2M+R3U= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 25/79] arm/nseries: use memdev for RAM Date: Mon, 17 Feb 2020 12:33:58 -0500 Message-Id: <20200217173452.15243-26-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: p26aPx3ANeurfCag1JYjyg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 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: Paolo Bonzini 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" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. PS: while at it add check for user supplied RAM size and error out if it mismatches board expected value. Signed-off-by: Igor Mammedov Reviewed-by: Andrew Jones Reviewed-by: Richard Henderson --- v2: * fix format string causing build failure on 32-bit host (Philippe Mathieu-Daud=C3=A9 ) CC: balrogg@gmail.com --- hw/arm/nseries.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c index 3fd196fb30..eae800b5c1 100644 --- a/hw/arm/nseries.c +++ b/hw/arm/nseries.c @@ -47,7 +47,6 @@ =20 /* Nokia N8x0 support */ struct n800_s { - MemoryRegion sdram; struct omap_mpu_state_s *mpu; =20 struct rfbi_chip_s blizzard; @@ -1311,13 +1310,19 @@ static void n8x0_init(MachineState *machine, struct arm_boot_info *binfo, int model) { struct n800_s *s =3D (struct n800_s *) g_malloc0(sizeof(*s)); - uint64_t sdram_size =3D binfo->ram_size; + MachineClass *mc =3D MACHINE_GET_CLASS(machine); =20 - memory_region_allocate_system_memory(&s->sdram, NULL, "omap2.dram", - sdram_size); - memory_region_add_subregion(get_system_memory(), OMAP2_Q2_BASE, &s->sd= ram); + if (machine->ram_size !=3D mc->default_ram_size) { + char *sz =3D size_to_str(mc->default_ram_size); + error_report("Invalid RAM size, should be %s", sz); + g_free(sz); + exit(EXIT_FAILURE); + } + + memory_region_add_subregion(get_system_memory(), OMAP2_Q2_BASE, + machine->ram); =20 - s->mpu =3D omap2420_mpu_init(&s->sdram, machine->cpu_type); + s->mpu =3D omap2420_mpu_init(machine->ram, machine->cpu_type); =20 /* Setup peripherals * @@ -1383,9 +1388,8 @@ static void n8x0_init(MachineState *machine, * * The code above is for loading the `zImage' file from Nokia * images. */ - load_image_targphys(option_rom[0].name, - OMAP2_Q2_BASE + 0x400000, - sdram_size - 0x400000); + load_image_targphys(option_rom[0].name, OMAP2_Q2_BASE + 0x400000, + machine->ram_size - 0x400000); =20 n800_setup_nolo_tags(nolo_tags); cpu_physical_memory_write(OMAP2_SRAM_BASE, nolo_tags, 0x10000); @@ -1395,16 +1399,12 @@ static void n8x0_init(MachineState *machine, =20 static struct arm_boot_info n800_binfo =3D { .loader_start =3D OMAP2_Q2_BASE, - /* Actually two chips of 0x4000000 bytes each */ - .ram_size =3D 0x08000000, .board_id =3D 0x4f7, .atag_board =3D n800_atag_setup, }; =20 static struct arm_boot_info n810_binfo =3D { .loader_start =3D OMAP2_Q2_BASE, - /* Actually two chips of 0x4000000 bytes each */ - .ram_size =3D 0x08000000, /* 0x60c and 0x6bf (WiMAX Edition) have been assigned but are not * used by some older versions of the bootloader and 5555 is used * instead (including versions that shipped with many devices). */ @@ -1431,6 +1431,9 @@ static void n800_class_init(ObjectClass *oc, void *da= ta) mc->default_boot_order =3D ""; mc->ignore_memory_transaction_failures =3D true; mc->default_cpu_type =3D ARM_CPU_TYPE_NAME("arm1136-r2"); + /* Actually two chips of 0x4000000 bytes each */ + mc->default_ram_size =3D 0x08000000; + mc->default_ram_id =3D "omap2.dram"; } =20 static const TypeInfo n800_type =3D { @@ -1448,6 +1451,9 @@ static void n810_class_init(ObjectClass *oc, void *da= ta) mc->default_boot_order =3D ""; mc->ignore_memory_transaction_failures =3D true; mc->default_cpu_type =3D ARM_CPU_TYPE_NAME("arm1136-r2"); + /* Actually two chips of 0x4000000 bytes each */ + mc->default_ram_size =3D 0x08000000; + mc->default_ram_id =3D "omap2.dram"; } =20 static const TypeInfo n810_type =3D { --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581961462175589.1920649895951; Mon, 17 Feb 2020 09:44:22 -0800 (PST) Received: from localhost ([::1]:49508 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kRQ-0003af-Us for importer@patchew.org; Mon, 17 Feb 2020 12:44:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38329) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kIx-0001n2-6a for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kIv-00020D-Va for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:35 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:23869 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kIv-0001zw-RU for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:33 -0500 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-208-wwkQ-sfYNH2UqwzUxzriWA-1; Mon, 17 Feb 2020 12:35:31 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AE5CA18FE861 for ; Mon, 17 Feb 2020 17:35:30 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0798890508; Mon, 17 Feb 2020 17:35:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960933; 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=63OWUwwf6dM9OPd3iFItHyW7Aybp3monauZEOO0p+UI=; b=h/jm+pClU5cIvEdORKkvebLLPiHmA5PYtWINImVkx3FoJB/wFJ154mMlg11gOcHYsauNK2 YPY2eL1LLqsSEGAjDn6GYJ4fpRQHjArIaJedHar//2JJRDYUve2dIjjEUEoJSDrQ1c30kx Bzrag/jPAQi/RKpub2ttO/IbORyd6CM= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 26/79] arm/omap_sx1: use memdev for RAM Date: Mon, 17 Feb 2020 12:33:59 -0500 Message-Id: <20200217173452.15243-27-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: wwkQ-sfYNH2UqwzUxzriWA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. PS: while at it add check for user supplied RAM size and error out if it mismatches board expected value. Signed-off-by: Igor Mammedov Reviewed-by: Andrew Jones Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- v2: * fix format string causing build failure on 32-bit host (Philippe Mathieu-Daud=C3=A9 ) --- hw/arm/omap_sx1.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/hw/arm/omap_sx1.c b/hw/arm/omap_sx1.c index be245714db..2bebab4171 100644 --- a/hw/arm/omap_sx1.c +++ b/hw/arm/omap_sx1.c @@ -35,6 +35,7 @@ #include "sysemu/qtest.h" #include "exec/address-spaces.h" #include "cpu.h" +#include "qemu/cutils.h" =20 /*************************************************************************= ****/ /* Siemens SX1 Cellphone V1 */ @@ -102,8 +103,8 @@ static struct arm_boot_info sx1_binfo =3D { static void sx1_init(MachineState *machine, const int version) { struct omap_mpu_state_s *mpu; + MachineClass *mc =3D MACHINE_GET_CLASS(machine); MemoryRegion *address_space =3D get_system_memory(); - MemoryRegion *dram =3D g_new(MemoryRegion, 1); MemoryRegion *flash =3D g_new(MemoryRegion, 1); MemoryRegion *cs =3D g_new(MemoryRegion, 4); static uint32_t cs0val =3D 0x00213090; @@ -115,15 +116,20 @@ static void sx1_init(MachineState *machine, const int= version) uint32_t flash_size =3D flash0_size; int be; =20 + if (machine->ram_size !=3D mc->default_ram_size) { + char *sz =3D size_to_str(mc->default_ram_size); + error_report("Invalid RAM size, should be %s", sz); + g_free(sz); + exit(EXIT_FAILURE); + } + if (version =3D=3D 2) { flash_size =3D flash2_size; } =20 - memory_region_allocate_system_memory(dram, NULL, "omap1.dram", - sx1_binfo.ram_size); - memory_region_add_subregion(address_space, OMAP_EMIFF_BASE, dram); + memory_region_add_subregion(address_space, OMAP_EMIFF_BASE, machine->r= am); =20 - mpu =3D omap310_mpu_init(dram, machine->cpu_type); + mpu =3D omap310_mpu_init(machine->ram, machine->cpu_type); =20 /* External Flash (EMIFS) */ memory_region_init_ram(flash, NULL, "omap_sx1.flash0-0", flash_size, @@ -223,6 +229,8 @@ static void sx1_machine_v2_class_init(ObjectClass *oc, = void *data) mc->init =3D sx1_init_v2; mc->ignore_memory_transaction_failures =3D true; mc->default_cpu_type =3D ARM_CPU_TYPE_NAME("ti925t"); + mc->default_ram_size =3D sdram_size; + mc->default_ram_id =3D "omap1.dram"; } =20 static const TypeInfo sx1_machine_v2_type =3D { @@ -239,6 +247,8 @@ static void sx1_machine_v1_class_init(ObjectClass *oc, = void *data) mc->init =3D sx1_init_v1; mc->ignore_memory_transaction_failures =3D true; mc->default_cpu_type =3D ARM_CPU_TYPE_NAME("ti925t"); + mc->default_ram_size =3D sdram_size; + mc->default_ram_id =3D "omap1.dram"; } =20 static const TypeInfo sx1_machine_v1_type =3D { --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581961594914312.65660439323995; Mon, 17 Feb 2020 09:46:34 -0800 (PST) Received: from localhost ([::1]:49550 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kTZ-0007HX-IA for importer@patchew.org; Mon, 17 Feb 2020 12:46:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38344) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kIy-0001q1-9Q for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kIx-000217-2n for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:36 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:58404 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kIw-00020k-TB for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:34 -0500 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-107-Ib9Ht7y8NVmL3Vaooct2Fw-1; Mon, 17 Feb 2020 12:35:32 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D08E718FE86A; Mon, 17 Feb 2020 17:35:31 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0347390508; Mon, 17 Feb 2020 17:35:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960934; 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=yivTYIo4hTdSXcYpVGKumeJuTk3evL5uHHQdV8UMqgs=; b=N1p8n9dhDv2dSOG+wo+bDkiNcMnaTRahUMHmZO6Azh0F9TYo4ADascOCAgloMlS70UKROu /1LwdfqgSYxJjqWOJsyeJUP/UhUB5GGGUs2WWQvoXIUcVJqMN1FU4ldqtxFb1Bm4sfdTMA TdHMOGoI9REyDU7I9dEQSxPqEmEZ6gA= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 27/79] arm/palm: use memdev for RAM Date: Mon, 17 Feb 2020 12:34:00 -0500 Message-Id: <20200217173452.15243-28-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: Ib9Ht7y8NVmL3Vaooct2Fw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 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: Paolo Bonzini 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" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. PS: while at it add check for user supplied RAM size and error out if it mismatches board expected value. Signed-off-by: Igor Mammedov Reviewed-by: Andrew Jones Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- v2: * fix format string causing build failure on 32-bit host (Philippe Mathieu-Daud=C3=A9 ) CC: balrogg@gmail.com --- hw/arm/palm.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/hw/arm/palm.c b/hw/arm/palm.c index 72eca8cc55..388b2629a5 100644 --- a/hw/arm/palm.c +++ b/hw/arm/palm.c @@ -31,6 +31,7 @@ #include "hw/loader.h" #include "exec/address-spaces.h" #include "cpu.h" +#include "qemu/cutils.h" =20 static uint64_t static_read(void *opaque, hwaddr offset, unsigned size) { @@ -181,7 +182,6 @@ static void palmte_gpio_setup(struct omap_mpu_state_s *= cpu) =20 static struct arm_boot_info palmte_binfo =3D { .loader_start =3D OMAP_EMIFF_BASE, - .ram_size =3D 0x02000000, .board_id =3D 0x331, }; =20 @@ -195,15 +195,21 @@ static void palmte_init(MachineState *machine) static uint32_t cs2val =3D 0x0000e1a0; static uint32_t cs3val =3D 0xe1a0e1a0; int rom_size, rom_loaded =3D 0; - MemoryRegion *dram =3D g_new(MemoryRegion, 1); + MachineClass *mc =3D MACHINE_GET_CLASS(machine); MemoryRegion *flash =3D g_new(MemoryRegion, 1); MemoryRegion *cs =3D g_new(MemoryRegion, 4); =20 - memory_region_allocate_system_memory(dram, NULL, "omap1.dram", - palmte_binfo.ram_size); - memory_region_add_subregion(address_space_mem, OMAP_EMIFF_BASE, dram); + if (machine->ram_size !=3D mc->default_ram_size) { + char *sz =3D size_to_str(mc->default_ram_size); + error_report("Invalid RAM size, should be %s", sz); + g_free(sz); + exit(EXIT_FAILURE); + } + + memory_region_add_subregion(address_space_mem, OMAP_EMIFF_BASE, + machine->ram); =20 - mpu =3D omap310_mpu_init(dram, machine->cpu_type); + mpu =3D omap310_mpu_init(machine->ram, machine->cpu_type); =20 /* External Flash (EMIFS) */ memory_region_init_ram(flash, NULL, "palmte.flash", flash_size, @@ -265,6 +271,8 @@ static void palmte_machine_init(MachineClass *mc) mc->init =3D palmte_init; mc->ignore_memory_transaction_failures =3D true; mc->default_cpu_type =3D ARM_CPU_TYPE_NAME("ti925t"); + mc->default_ram_size =3D 0x02000000; + mc->default_ram_id =3D "omap1.dram"; } =20 DEFINE_MACHINE("cheetah", palmte_machine_init) --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581961973717731.7035270575856; Mon, 17 Feb 2020 09:52:53 -0800 (PST) Received: from localhost ([::1]:49644 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kZg-0001LQ-EX for importer@patchew.org; Mon, 17 Feb 2020 12:52:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38362) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJ7-00020U-8t for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJ2-00023d-09 for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:44 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:23981 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJ1-00022v-2i for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:39 -0500 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-372-9vUIspsCNEmA6tLHypeMFA-1; Mon, 17 Feb 2020 12:35:33 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 04B7E1005516; Mon, 17 Feb 2020 17:35:33 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 279DF9052B; Mon, 17 Feb 2020 17:35:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960938; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0ZKZGCs2/uZDNVBMwvLYPVTAhzzGibmFvG4GbZ4kRpo=; b=jBFIJXlifts+FjXumVovSbNkBelvPHpaInhssOy/RVZ0KMWczoIPQrBdi5OnPSNH7JfGvs JeIHX93brQckwanzAPxxo3oBaTn/UPNhu8IM91u6J3EcYruqUuREUW1ylLr9r6YKB7hwp0 HliXPs8trDEflvgfScigQfNbCgvZVEc= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 28/79] arm/sabrelite: use memdev for RAM Date: Mon, 17 Feb 2020 12:34:01 -0500 Message-Id: <20200217173452.15243-29-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: 9vUIspsCNEmA6tLHypeMFA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 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: Paolo Bonzini , jcd@tribudubois.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. PS: remove no longer needed IMX6Sabrelite Signed-off-by: Igor Mammedov Reviewed-by: Andrew Jones Reviewed-by: Richard Henderson --- CC: jcd@tribudubois.net --- hw/arm/sabrelite.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/hw/arm/sabrelite.c b/hw/arm/sabrelite.c index 96cc455c5c..e31694bb92 100644 --- a/hw/arm/sabrelite.c +++ b/hw/arm/sabrelite.c @@ -19,11 +19,6 @@ #include "qemu/error-report.h" #include "sysemu/qtest.h" =20 -typedef struct IMX6Sabrelite { - FslIMX6State soc; - MemoryRegion ram; -} IMX6Sabrelite; - static struct arm_boot_info sabrelite_binfo =3D { /* DDR memory start */ .loader_start =3D FSL_IMX6_MMDC_ADDR, @@ -45,7 +40,7 @@ static void sabrelite_reset_secondary(ARMCPU *cpu, =20 static void sabrelite_init(MachineState *machine) { - IMX6Sabrelite *s =3D g_new0(IMX6Sabrelite, 1); + FslIMX6State *s; Error *err =3D NULL; =20 /* Check the amount of memory is compatible with the SOC */ @@ -55,19 +50,16 @@ static void sabrelite_init(MachineState *machine) exit(1); } =20 - object_initialize_child(OBJECT(machine), "soc", &s->soc, sizeof(s->soc= ), - TYPE_FSL_IMX6, &error_abort, NULL); - - object_property_set_bool(OBJECT(&s->soc), true, "realized", &err); + s =3D FSL_IMX6(object_new(TYPE_FSL_IMX6)); + object_property_add_child(OBJECT(machine), "soc", OBJECT(s), &error_fa= tal); + object_property_set_bool(OBJECT(s), true, "realized", &err); if (err !=3D NULL) { error_report("%s", error_get_pretty(err)); exit(1); } =20 - memory_region_allocate_system_memory(&s->ram, NULL, "sabrelite.ram", - machine->ram_size); memory_region_add_subregion(get_system_memory(), FSL_IMX6_MMDC_ADDR, - &s->ram); + machine->ram); =20 { /* @@ -78,7 +70,7 @@ static void sabrelite_init(MachineState *machine) /* Add the sst25vf016b NOR FLASH memory to first SPI */ Object *spi_dev; =20 - spi_dev =3D object_resolve_path_component(OBJECT(&s->soc), "spi1"); + spi_dev =3D object_resolve_path_component(OBJECT(s), "spi1"); if (spi_dev) { SSIBus *spi_bus; =20 @@ -109,7 +101,7 @@ static void sabrelite_init(MachineState *machine) sabrelite_binfo.secondary_cpu_reset_hook =3D sabrelite_reset_secondary; =20 if (!qtest_enabled()) { - arm_load_kernel(&s->soc.cpu[0], machine, &sabrelite_binfo); + arm_load_kernel(&s->cpu[0], machine, &sabrelite_binfo); } } =20 @@ -119,6 +111,7 @@ static void sabrelite_machine_init(MachineClass *mc) mc->init =3D sabrelite_init; mc->max_cpus =3D FSL_IMX6_NUM_CPUS; mc->ignore_memory_transaction_failures =3D true; + mc->default_ram_id =3D "sabrelite.ram"; } =20 DEFINE_MACHINE("sabrelite", sabrelite_machine_init) --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581961465442445.5182279910215; Mon, 17 Feb 2020 09:44:25 -0800 (PST) Received: from localhost ([::1]:49510 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kRT-0003eg-WF for importer@patchew.org; Mon, 17 Feb 2020 12:44:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38397) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJ9-00023q-Sj for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJ8-00026V-95 for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:47 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:27518 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJ6-00023V-TB for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:45 -0500 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-227-N4tep2PjOhCuCcQPGJ3Buw-1; Mon, 17 Feb 2020 12:35:38 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E4A62800D55; Mon, 17 Feb 2020 17:35:36 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4C83890508; Mon, 17 Feb 2020 17:35:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960939; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=478cMgXnQQn6uBqWbiBoJBtEQ56RPg5biorvv/HMFu0=; b=eT9O2/vjgZM9iih7FzCbP8Mo21cn/HrQ0Kxv/P2F+sSW2Izz9DcFtJ6RE79DVYBWvFVd/s sR45IjDeqScCjoDw+FsrXOz2Cl7gla3nSEdxvuQnSvrkWhvOqr6Yce74NGK17D6Kfnxk+M /LOL7mbkP81o0KuK0gDzSVZo1Z8F7U8= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 29/79] arm/raspi: use memdev for RAM Date: Mon, 17 Feb 2020 12:34:02 -0500 Message-Id: <20200217173452.15243-30-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: N4tep2PjOhCuCcQPGJ3Buw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 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: Paolo Bonzini , philmd@redhat.com, Andrew.Baumann@microsoft.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- CC: Andrew.Baumann@microsoft.com CC: philmd@redhat.com v5: * fixed rebase conflicts once more v4: * fixed rebase conflicts --- hw/arm/raspi.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c index 90ad9b8115..acd2bb794d 100644 --- a/hw/arm/raspi.c +++ b/hw/arm/raspi.c @@ -39,7 +39,6 @@ typedef struct RaspiMachineState { MachineState parent_obj; /*< public >*/ BCM283XState soc; - MemoryRegion ram; } RaspiMachineState; =20 typedef struct RaspiMachineClass { @@ -277,16 +276,14 @@ static void raspi_machine_init(MachineState *machine) exit(1); } =20 - /* Allocate and map RAM */ - memory_region_allocate_system_memory(&s->ram, OBJECT(machine), "ram", - machine->ram_size); /* FIXME: Remove when we have custom CPU address space support */ - memory_region_add_subregion_overlap(get_system_memory(), 0, &s->ram, 0= ); + memory_region_add_subregion_overlap(get_system_memory(), 0, + machine->ram, 0); =20 /* Setup the SOC */ object_initialize_child(OBJECT(machine), "soc", &s->soc, sizeof(s->soc= ), board_soc_type(board_rev), &error_abort, NULL); - object_property_add_const_link(OBJECT(&s->soc), "ram", OBJECT(&s->ram), + object_property_add_const_link(OBJECT(&s->soc), "ram", OBJECT(machine-= >ram), &error_abort); object_property_set_int(OBJECT(&s->soc), board_rev, "board-rev", &error_abort); @@ -324,6 +321,7 @@ static void raspi_machine_class_init(ObjectClass *oc, v= oid *data) mc->no_cdrom =3D 1; mc->default_cpus =3D mc->min_cpus =3D mc->max_cpus =3D cores_count(boa= rd_rev); mc->default_ram_size =3D board_ram_size(board_rev); + mc->default_ram_id =3D "ram"; if (board_version(board_rev) =3D=3D 2) { mc->ignore_memory_transaction_failures =3D true; } --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581961595227336.9363518369389; Mon, 17 Feb 2020 09:46:35 -0800 (PST) Received: from localhost ([::1]:49552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kTZ-0007Hz-Uu for importer@patchew.org; Mon, 17 Feb 2020 12:46:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38411) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJA-00024q-Ui for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJ9-00027E-4U for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:48 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:36362 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJ8-00024E-Fi for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:46 -0500 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-102-XNGCFz7qNDGreHlBgjWoeg-1; Mon, 17 Feb 2020 12:35:39 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3CF41107ACCC; Mon, 17 Feb 2020 17:35:38 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3B8A190508; Mon, 17 Feb 2020 17:35:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960941; 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=9b4A0lZw/h9Wb/kMd5CfeuootuMVU7SfyZmqGvGsLZ8=; b=fy+nV43HdJ6zMdq3IoIeZIqdyAi+vRmxLfX7CM56we6PfSB+1bl0LSBWuvBqcHYVslm5YD SMXZNPC98qwUrRuZ7ekVqFn8eMFTJ6+XjjgE5GJlh5gh/bmR+Dmpnl3S2F4ZcvAj3+HJl5 uwK6x1Uh1C7byU24zEQEyEuKN3eVAzM= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 30/79] arm/sbsa-ref: use memdev for RAM Date: Mon, 17 Feb 2020 12:34:03 -0500 Message-Id: <20200217173452.15243-31-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: XNGCFz7qNDGreHlBgjWoeg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 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: Paolo Bonzini , radoslaw.biernacki@linaro.org, leif.lindholm@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- CC: radoslaw.biernacki@linaro.org CC: leif.lindholm@linaro.org --- hw/arm/sbsa-ref.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c index 9b5bcb5634..1cba9fc302 100644 --- a/hw/arm/sbsa-ref.c +++ b/hw/arm/sbsa-ref.c @@ -593,7 +593,6 @@ static void sbsa_ref_init(MachineState *machine) MachineClass *mc =3D MACHINE_GET_CLASS(machine); MemoryRegion *sysmem =3D get_system_memory(); MemoryRegion *secure_sysmem =3D g_new(MemoryRegion, 1); - MemoryRegion *ram =3D g_new(MemoryRegion, 1); bool firmware_loaded; const CPUArchIdList *possible_cpus; int n, sbsa_max_cpus; @@ -685,9 +684,8 @@ static void sbsa_ref_init(MachineState *machine) object_unref(cpuobj); } =20 - memory_region_allocate_system_memory(ram, NULL, "sbsa-ref.ram", - machine->ram_size); - memory_region_add_subregion(sysmem, sbsa_ref_memmap[SBSA_MEM].base, ra= m); + memory_region_add_subregion(sysmem, sbsa_ref_memmap[SBSA_MEM].base, + machine->ram); =20 create_fdt(sms); =20 @@ -785,6 +783,7 @@ static void sbsa_ref_class_init(ObjectClass *oc, void *= data) mc->block_default_type =3D IF_IDE; mc->no_cdrom =3D 1; mc->default_ram_size =3D 1 * GiB; + mc->default_ram_id =3D "sbsa-ref.ram"; mc->default_cpus =3D 4; mc->possible_cpu_arch_ids =3D sbsa_ref_possible_cpu_arch_ids; mc->cpu_index_to_instance_props =3D sbsa_ref_cpu_index_to_props; --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15819617234691003.1518426591705; Mon, 17 Feb 2020 09:48:43 -0800 (PST) Received: from localhost ([::1]:49578 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kVe-0002PR-3v for importer@patchew.org; Mon, 17 Feb 2020 12:48:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38412) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJA-00024s-VR for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJ9-000271-3k for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:48 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:56209 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJ8-000259-8r for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:46 -0500 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-100-dFRhJBMsMruwaD_XsU2HRA-1; Mon, 17 Feb 2020 12:35:40 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3B9F8107ACC5 for ; Mon, 17 Feb 2020 17:35:39 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 88AC29052B; Mon, 17 Feb 2020 17:35:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960943; 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=CzHffLJoIGTtDJ0mx1O5NX1NGymyh6jcUm9NaXSkbXc=; b=Cq1QQan2p3oxDXyhu18wAsOV00n3MuiBNMgcCVYVL1SeOft15rfGLkK4B731caXPDrgyQC Zhk2hYGSjl+A8AhkCXy20VJ3iMTNyQi6KG/gzE1FQRJGOdwAiXgC/gsMowWdZ5eGQR/Kcd nkkZtG64oHEuJNUR/1rBjJrzSe1SYHg= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 31/79] arm/versatilepb: use memdev for RAM Date: Mon, 17 Feb 2020 12:34:04 -0500 Message-Id: <20200217173452.15243-32-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: dFRhJBMsMruwaD_XsU2HRA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- hw/arm/versatilepb.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c index e86af01537..f3c4a50b19 100644 --- a/hw/arm/versatilepb.c +++ b/hw/arm/versatilepb.c @@ -184,7 +184,6 @@ static void versatile_init(MachineState *machine, int b= oard_id) Object *cpuobj; ARMCPU *cpu; MemoryRegion *sysmem =3D get_system_memory(); - MemoryRegion *ram =3D g_new(MemoryRegion, 1); qemu_irq pic[32]; qemu_irq sic[32]; DeviceState *dev, *sysctl; @@ -220,11 +219,9 @@ static void versatile_init(MachineState *machine, int = board_id) =20 cpu =3D ARM_CPU(cpuobj); =20 - memory_region_allocate_system_memory(ram, NULL, "versatile.ram", - machine->ram_size); /* ??? RAM should repeat to fill physical memory space. */ /* SDRAM at address zero. */ - memory_region_add_subregion(sysmem, 0, ram); + memory_region_add_subregion(sysmem, 0, machine->ram); =20 sysctl =3D qdev_create(NULL, "realview_sysctl"); qdev_prop_set_uint32(sysctl, "sys_id", 0x41007004); @@ -398,6 +395,7 @@ static void versatilepb_class_init(ObjectClass *oc, voi= d *data) mc->block_default_type =3D IF_SCSI; mc->ignore_memory_transaction_failures =3D true; mc->default_cpu_type =3D ARM_CPU_TYPE_NAME("arm926"); + mc->default_ram_id =3D "versatile.ram"; } =20 static const TypeInfo versatilepb_type =3D { @@ -415,6 +413,7 @@ static void versatileab_class_init(ObjectClass *oc, voi= d *data) mc->block_default_type =3D IF_SCSI; mc->ignore_memory_transaction_failures =3D true; mc->default_cpu_type =3D ARM_CPU_TYPE_NAME("arm926"); + mc->default_ram_id =3D "versatile.ram"; } =20 static const TypeInfo versatileab_type =3D { --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581961755191222.0741822006405; Mon, 17 Feb 2020 09:49:15 -0800 (PST) Received: from localhost ([::1]:49582 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kW9-0003im-Tn for importer@patchew.org; Mon, 17 Feb 2020 12:49:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38414) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJB-00024u-01 for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJ9-00027P-4l for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:48 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:59256 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJ8-00024v-Eu for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:46 -0500 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-276-JXs9eAuMOlGvkTDOdJb9OQ-1; Mon, 17 Feb 2020 12:35:41 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 355331005513 for ; Mon, 17 Feb 2020 17:35:40 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 849D690508; Mon, 17 Feb 2020 17:35:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960942; 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=RvevJYChloMMUxrh+iovKE1RK2c2j5q1Roqf6/8KVv8=; b=YfhFpDr6lABExSDS5bzlA1saa9boMu6w2Z6GPMeRn48qh2pk8Fce31E1ue1F6m3qJV1UaX kPTuPwJ1pN3lpL6hCXMWhDETPxl98OXYNjc1KcsjOSitm6Lvpl1l19lOtE1741ErkP37zU XFg2630MZM2sdpkw59nBHc6+4e7a+vo= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 32/79] arm/vexpress: use memdev for RAM Date: Mon, 17 Feb 2020 12:34:05 -0500 Message-Id: <20200217173452.15243-33-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: JXs9eAuMOlGvkTDOdJb9OQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- hw/arm/vexpress.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c index 4673a88a8d..ed683eeea5 100644 --- a/hw/arm/vexpress.c +++ b/hw/arm/vexpress.c @@ -273,7 +273,6 @@ static void a9_daughterboard_init(const VexpressMachine= State *vms, { MachineState *machine =3D MACHINE(vms); MemoryRegion *sysmem =3D get_system_memory(); - MemoryRegion *ram =3D g_new(MemoryRegion, 1); MemoryRegion *lowram =3D g_new(MemoryRegion, 1); ram_addr_t low_ram_size; =20 @@ -283,8 +282,6 @@ static void a9_daughterboard_init(const VexpressMachine= State *vms, exit(1); } =20 - memory_region_allocate_system_memory(ram, NULL, "vexpress.highmem", - ram_size); low_ram_size =3D ram_size; if (low_ram_size > 0x4000000) { low_ram_size =3D 0x4000000; @@ -293,9 +290,10 @@ static void a9_daughterboard_init(const VexpressMachin= eState *vms, * address space should in theory be remappable to various * things including ROM or RAM; we always map the RAM there. */ - memory_region_init_alias(lowram, NULL, "vexpress.lowmem", ram, 0, low_= ram_size); + memory_region_init_alias(lowram, NULL, "vexpress.lowmem", machine->ram, + 0, low_ram_size); memory_region_add_subregion(sysmem, 0x0, lowram); - memory_region_add_subregion(sysmem, 0x60000000, ram); + memory_region_add_subregion(sysmem, 0x60000000, machine->ram); =20 /* 0x1e000000 A9MPCore (SCU) private memory region */ init_cpus(machine, cpu_type, TYPE_A9MPCORE_PRIV, 0x1e000000, pic, @@ -360,7 +358,6 @@ static void a15_daughterboard_init(const VexpressMachin= eState *vms, { MachineState *machine =3D MACHINE(vms); MemoryRegion *sysmem =3D get_system_memory(); - MemoryRegion *ram =3D g_new(MemoryRegion, 1); MemoryRegion *sram =3D g_new(MemoryRegion, 1); =20 { @@ -375,10 +372,8 @@ static void a15_daughterboard_init(const VexpressMachi= neState *vms, } } =20 - memory_region_allocate_system_memory(ram, NULL, "vexpress.highmem", - ram_size); /* RAM is from 0x80000000 upwards; there is no low-memory alias for it= . */ - memory_region_add_subregion(sysmem, 0x80000000, ram); + memory_region_add_subregion(sysmem, 0x80000000, machine->ram); =20 /* 0x2c000000 A15MPCore private memory region (GIC) */ init_cpus(machine, cpu_type, TYPE_A15MPCORE_PRIV, @@ -795,6 +790,7 @@ static void vexpress_class_init(ObjectClass *oc, void *= data) mc->init =3D vexpress_common_init; mc->max_cpus =3D 4; mc->ignore_memory_transaction_failures =3D true; + mc->default_ram_id =3D "vexpress.highmem"; } =20 static void vexpress_a9_class_init(ObjectClass *oc, void *data) --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581961723560600.6206818470287; Mon, 17 Feb 2020 09:48:43 -0800 (PST) Received: from localhost ([::1]:49576 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kVe-0002P1-18 for importer@patchew.org; Mon, 17 Feb 2020 12:48:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38413) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJA-00024t-Vx for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJ9-00026t-1L for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:48 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:55914 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJ7-00025Q-AF for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:46 -0500 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-367-AmguJEX4ONGL1ajhfLVr7g-1; Mon, 17 Feb 2020 12:35:42 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3093F1084433 for ; Mon, 17 Feb 2020 17:35:41 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7F9219052B; Mon, 17 Feb 2020 17:35:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960943; 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=6c7e3VO4negn8kO6ZR/EEokiO9+BT1ueyHMoh1nchHg=; b=LAGidSpap1BqK9mpjkR0s3sIchk6501NkT5WoX9aaxoguGNBpqu+K249TtJmly4zj1b+Jm C+XTNf4pQBHq5iDlT3ZohLl2mPHOI23jUdUJBgV12czxOHITix1S0EfVKirA6rzpk2bXoN Kj50scUjFkkTEthp5ZX/EPeLpP+MWzY= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 33/79] arm/virt: use memdev for RAM Date: Mon, 17 Feb 2020 12:34:06 -0500 Message-Id: <20200217173452.15243-34-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: AmguJEX4ONGL1ajhfLVr7g-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and then map memory region provided by MachineState::ram_memdev Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Andrew Jones Reviewed-by: Richard Henderson --- hw/arm/virt.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index f788fe27d6..e591a126e7 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1512,7 +1512,6 @@ static void machvirt_init(MachineState *machine) MemoryRegion *sysmem =3D get_system_memory(); MemoryRegion *secure_sysmem =3D NULL; int n, virt_max_cpus; - MemoryRegion *ram =3D g_new(MemoryRegion, 1); bool firmware_loaded; bool aarch64 =3D true; bool has_ged =3D !vmc->no_ged; @@ -1706,9 +1705,8 @@ static void machvirt_init(MachineState *machine) } } =20 - memory_region_allocate_system_memory(ram, NULL, "mach-virt.ram", - machine->ram_size); - memory_region_add_subregion(sysmem, vms->memmap[VIRT_MEM].base, ram); + memory_region_add_subregion(sysmem, vms->memmap[VIRT_MEM].base, + machine->ram); if (machine->device_memory) { memory_region_add_subregion(sysmem, machine->device_memory->base, &machine->device_memory->mr); @@ -2058,6 +2056,7 @@ static void virt_machine_class_init(ObjectClass *oc, = void *data) hc->unplug_request =3D virt_machine_device_unplug_request_cb; mc->numa_mem_supported =3D true; mc->auto_enable_numa_with_memhp =3D true; + mc->default_ram_id =3D "mach-virt.ram"; } =20 static void virt_instance_init(Object *obj) --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581962004373848.8595814350953; Mon, 17 Feb 2020 09:53:24 -0800 (PST) Received: from localhost ([::1]:49646 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kaB-0002Va-6o for importer@patchew.org; Mon, 17 Feb 2020 12:53:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38457) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJB-000282-Vk for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJA-00028d-Qu for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:49 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:39591 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJ9-00027U-SN for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:48 -0500 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-318-ysuqa3MgM7OQro-sCBJGbw-1; Mon, 17 Feb 2020 12:35:43 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2E51B107ACC9 for ; Mon, 17 Feb 2020 17:35:42 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A50F90508; Mon, 17 Feb 2020 17:35:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960945; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rIFliTm/CceMua2cnSMr1LIhZ8t2dj+zclOUgywBbuA=; b=T+RzNZWhzVsGtjhjKqRnLw06u4+ix3Ii7zbCClWDOpZsKm1kwVGkE0kuiCxaH0qbSPaQsL js2KlSDaMdFOhqD9XMjKOc69EYueTVQv5H8RzlcEgJrhs2CvyHoe2w/YIl/DuVMM7cMmu/ NBqSw7dKtgeEijrlOIG9gWFI1UJ0BVs= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 34/79] arm/xilinx_zynq: drop RAM size fixup Date: Mon, 17 Feb 2020 12:34:07 -0500 Message-Id: <20200217173452.15243-35-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: ysuqa3MgM7OQro-sCBJGbw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If user provided non-sense RAM size, board will complain and continue running with max RAM size supported. Also RAM is going to be allocated by generic code, so it won't be possible for board to fix things up for user. Make it error message and exit to force user fix CLI, instead of accepting non-sense CLI values. Signed-off-by: Igor Mammedov Reviewed-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- hw/arm/xilinx_zynq.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c index 3a0fa5b23f..df950fc400 100644 --- a/hw/arm/xilinx_zynq.c +++ b/hw/arm/xilinx_zynq.c @@ -158,7 +158,6 @@ static inline void zynq_init_spi_flashes(uint32_t base_= addr, qemu_irq irq, =20 static void zynq_init(MachineState *machine) { - ram_addr_t ram_size =3D machine->ram_size; ARMCPU *cpu; MemoryRegion *address_space_mem =3D get_system_memory(); MemoryRegion *ext_ram =3D g_new(MemoryRegion, 1); @@ -168,6 +167,12 @@ static void zynq_init(MachineState *machine) qemu_irq pic[64]; int n; =20 + /* max 2GB ram */ + if (machine->ram_size > 0x80000000) { + error_report("RAM size more than %d is not supported", 0x80000000); + exit(EXIT_FAILURE); + } + cpu =3D ARM_CPU(object_new(machine->cpu_type)); =20 /* By default A9 CPUs have EL3 enabled. This board does not @@ -184,14 +189,9 @@ static void zynq_init(MachineState *machine) &error_fatal); object_property_set_bool(OBJECT(cpu), true, "realized", &error_fatal); =20 - /* max 2GB ram */ - if (ram_size > 0x80000000) { - ram_size =3D 0x80000000; - } - /* DDR remapped to address zero. */ memory_region_allocate_system_memory(ext_ram, NULL, "zynq.ext_ram", - ram_size); + machine->ram_size); memory_region_add_subregion(address_space_mem, 0, ext_ram); =20 /* 256K of on-chip memory */ @@ -300,7 +300,7 @@ static void zynq_init(MachineState *machine) sysbus_connect_irq(busdev, 0, pic[40 - IRQ_OFFSET]); sysbus_mmio_map(busdev, 0, 0xF8007000); =20 - zynq_binfo.ram_size =3D ram_size; + zynq_binfo.ram_size =3D machine->ram_size; zynq_binfo.nb_cpus =3D 1; zynq_binfo.board_id =3D 0xd32; zynq_binfo.loader_start =3D 0; --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581961970492822.0386385906073; Mon, 17 Feb 2020 09:52:50 -0800 (PST) Received: from localhost ([::1]:49641 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kZd-0001DM-9b for importer@patchew.org; Mon, 17 Feb 2020 12:52:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38522) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJJ-0002L2-Hp for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJE-0002CY-Sc for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:57 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:55922 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJE-0002CJ-Nd for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:52 -0500 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-58-9674rs5ZO-qlUtyC7sT2rw-1; Mon, 17 Feb 2020 12:35:44 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2E3C7800D6C for ; Mon, 17 Feb 2020 17:35:43 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7731A90508; Mon, 17 Feb 2020 17:35:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960952; 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=wOoRqXxjeiKVKYqG0clNdTCyG8bZDSCIzwlXeYSDidc=; b=NGuS8Xdbstn1wsB2IXOEEx8vKVdvpDC6WFNkaj36zl7pulJWRE+bTBKnB7nY3iNzIo7Roj AzXGrt1pOdBbKl2ltvtua1ssRLY95o8m06t9Clb7HDEA/WeSYxr4IM9yTmUrQgnHQEVVyx /fl5g52AbmVqVsQmHNaHr2UGmIoSOgs= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 35/79] arm/xilinx_zynq: use memdev for RAM Date: Mon, 17 Feb 2020 12:34:08 -0500 Message-Id: <20200217173452.15243-36-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: 9674rs5ZO-qlUtyC7sT2rw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alistair Francis Reviewed-by: Richard Henderson --- hw/arm/xilinx_zynq.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c index df950fc400..0ef9688c5a 100644 --- a/hw/arm/xilinx_zynq.c +++ b/hw/arm/xilinx_zynq.c @@ -160,7 +160,6 @@ static void zynq_init(MachineState *machine) { ARMCPU *cpu; MemoryRegion *address_space_mem =3D get_system_memory(); - MemoryRegion *ext_ram =3D g_new(MemoryRegion, 1); MemoryRegion *ocm_ram =3D g_new(MemoryRegion, 1); DeviceState *dev; SysBusDevice *busdev; @@ -190,9 +189,7 @@ static void zynq_init(MachineState *machine) object_property_set_bool(OBJECT(cpu), true, "realized", &error_fatal); =20 /* DDR remapped to address zero. */ - memory_region_allocate_system_memory(ext_ram, NULL, "zynq.ext_ram", - machine->ram_size); - memory_region_add_subregion(address_space_mem, 0, ext_ram); + memory_region_add_subregion(address_space_mem, 0, machine->ram); =20 /* 256K of on-chip memory */ memory_region_init_ram(ocm_ram, NULL, "zynq.ocm_ram", 256 * KiB, @@ -318,6 +315,7 @@ static void zynq_machine_init(MachineClass *mc) mc->no_sdcard =3D 1; mc->ignore_memory_transaction_failures =3D true; mc->default_cpu_type =3D ARM_CPU_TYPE_NAME("cortex-a9"); + mc->default_ram_id =3D "zynq.ext_ram"; } =20 DEFINE_MACHINE("xilinx-zynq-a9", zynq_machine_init) --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581961894792316.157686299631; Mon, 17 Feb 2020 09:51:34 -0800 (PST) Received: from localhost ([::1]:49620 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kYP-0007Pk-Jn for importer@patchew.org; Mon, 17 Feb 2020 12:51:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38441) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJB-00027M-MU for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJA-00028M-KJ for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:49 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:58939 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJ9-00026x-SC for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:47 -0500 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-46-JWb0x1xXO1K1D4qWszJqXw-1; Mon, 17 Feb 2020 12:35:44 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 26FFA107ACC9 for ; Mon, 17 Feb 2020 17:35:44 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 751729052B; Mon, 17 Feb 2020 17:35:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960947; 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=fHXhcDK6QFU/yQ/obfXxjyjr9uOty0fUBu33SlNMk0o=; b=DRFPVeGQQUHt7dhV+WJH4IY2J2+fW5jZhr4fdxE+dhlvmwGv+/OI2Pnz8D6nqZwV4HZLFN /SpfUqk8qTv0XEQmQJGagWBerSN3u2fyYO30UIP2Jd3cDtqYC0fi0CJsnqsGCxxrcYXRnt 17BWGvy5Q57U536Sd1RKF7xojvZlvQ0= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 36/79] arm/xlnx-versal-virt: use memdev for RAM Date: Mon, 17 Feb 2020 12:34:09 -0500 Message-Id: <20200217173452.15243-37-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: JWb0x1xXO1K1D4qWszJqXw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- hw/arm/xlnx-versal-virt.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/hw/arm/xlnx-versal-virt.c b/hw/arm/xlnx-versal-virt.c index 462493c467..c137ff4def 100644 --- a/hw/arm/xlnx-versal-virt.c +++ b/hw/arm/xlnx-versal-virt.c @@ -30,7 +30,6 @@ typedef struct VersalVirt { MachineState parent_obj; =20 Versal soc; - MemoryRegion mr_ddr; =20 void *fdt; int fdt_size; @@ -414,12 +413,9 @@ static void versal_virt_init(MachineState *machine) psci_conduit =3D QEMU_PSCI_CONDUIT_SMC; } =20 - memory_region_allocate_system_memory(&s->mr_ddr, NULL, "ddr", - machine->ram_size); - sysbus_init_child_obj(OBJECT(machine), "xlnx-ve", &s->soc, sizeof(s->soc), TYPE_XLNX_VERSAL); - object_property_set_link(OBJECT(&s->soc), OBJECT(&s->mr_ddr), + object_property_set_link(OBJECT(&s->soc), OBJECT(machine->ram), "ddr", &error_abort); object_property_set_int(OBJECT(&s->soc), psci_conduit, "psci-conduit", &error_abort); @@ -473,6 +469,7 @@ static void versal_virt_machine_class_init(ObjectClass = *oc, void *data) mc->max_cpus =3D XLNX_VERSAL_NR_ACPUS; mc->default_cpus =3D XLNX_VERSAL_NR_ACPUS; mc->no_cdrom =3D true; + mc->default_ram_id =3D "ddr"; } =20 static const TypeInfo versal_virt_machine_init_typeinfo =3D { --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581961839000118.26139365565211; Mon, 17 Feb 2020 09:50:39 -0800 (PST) Received: from localhost ([::1]:49602 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kXR-0005vG-QR for importer@patchew.org; Mon, 17 Feb 2020 12:50:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38464) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJC-00028U-4f for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJA-000291-W0 for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:50 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:58825 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJA-00027w-K9 for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:48 -0500 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-19-pIfK2mN6NhqCEp4h28Fh9Q-1; Mon, 17 Feb 2020 12:35:46 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 22231801E66 for ; Mon, 17 Feb 2020 17:35:45 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7193090526; Mon, 17 Feb 2020 17:35:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960947; 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=sqax1ayswofN/3n5dpcmnh3A7K8jp4tGRuywxX8We5o=; b=T7CME+gAiRZ0z9g8HNbw640AgAlWLKJ8BImQgLX7lGupiZNyltkp6K+e0QLmoLBZUHZcfO rUP4Uvm1EYlWvwvq4RzV80LHLODd/OBOqigWKAK887li5o8EncQBamlEk80uqpLe6Mo/0/ TFO9LpMYUVSbUwH+2g23FeqRhLYgaAU= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 37/79] arm/xlnx-zcu102: use memdev for RAM Date: Mon, 17 Feb 2020 12:34:10 -0500 Message-Id: <20200217173452.15243-38-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: pIfK2mN6NhqCEp4h28Fh9Q-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alistair Francis Reviewed-by: Richard Henderson --- hw/arm/xlnx-zcu102.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/hw/arm/xlnx-zcu102.c b/hw/arm/xlnx-zcu102.c index 53cfe7c1f1..bd645ad818 100644 --- a/hw/arm/xlnx-zcu102.c +++ b/hw/arm/xlnx-zcu102.c @@ -28,7 +28,6 @@ typedef struct XlnxZCU102 { MachineState parent_obj; =20 XlnxZynqMPState soc; - MemoryRegion ddr_ram; =20 bool secure; bool virt; @@ -87,13 +86,10 @@ static void xlnx_zcu102_init(MachineState *machine) ram_size); } =20 - memory_region_allocate_system_memory(&s->ddr_ram, NULL, "ddr-ram", - ram_size); - object_initialize_child(OBJECT(machine), "soc", &s->soc, sizeof(s->soc= ), TYPE_XLNX_ZYNQMP, &error_abort, NULL); =20 - object_property_set_link(OBJECT(&s->soc), OBJECT(&s->ddr_ram), + object_property_set_link(OBJECT(&s->soc), OBJECT(machine->ram), "ddr-ram", &error_abort); object_property_set_bool(OBJECT(&s->soc), s->secure, "secure", &error_fatal); @@ -211,6 +207,7 @@ static void xlnx_zcu102_machine_class_init(ObjectClass = *oc, void *data) mc->ignore_memory_transaction_failures =3D true; mc->max_cpus =3D XLNX_ZYNQMP_NUM_APU_CPUS + XLNX_ZYNQMP_NUM_RPU_CPUS; mc->default_cpus =3D XLNX_ZYNQMP_NUM_APU_CPUS; + mc->default_ram_id =3D "ddr-ram"; } =20 static const TypeInfo xlnx_zcu102_machine_init_typeinfo =3D { --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581962065396664.2854354331702; Mon, 17 Feb 2020 09:54:25 -0800 (PST) Received: from localhost ([::1]:49668 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kbA-0004xO-5I for importer@patchew.org; Mon, 17 Feb 2020 12:54:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38470) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJC-000295-Bb for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJB-00029I-4P for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:50 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:31394 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJB-00028Q-01 for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:49 -0500 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-146-bO9fExFdPP2F4vv3dorIXA-1; Mon, 17 Feb 2020 12:35:46 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1FABD18FE861 for ; Mon, 17 Feb 2020 17:35:46 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E11690508; Mon, 17 Feb 2020 17:35:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960948; 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=6vEvAq0R2sJKxUPgDFVRjFjDWtZvCq7XYj2Oy5nAuqQ=; b=ZDA2zAwXgmQv5yFdj5KMNtxYRfpaGFfEEP9mfwcaHbIddF/b/vRyk1blagD3zcki7hhVEU BhCe/MnBBvFV/lUlTPhnnohG+Ai/mefDFg9D+BpSSGtC36oQyWAQ6U2gHPXWHONBvIU5Yg cktQQ7znQ12P037URq31xeqvimJS6k8= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 38/79] s390x/s390-virtio-ccw: use memdev for RAM Date: Mon, 17 Feb 2020 12:34:11 -0500 Message-Id: <20200217173452.15243-39-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: bO9fExFdPP2F4vv3dorIXA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: David Hildenbrand Acked-by: Cornelia Huck Tested-by: Halil Pasic Acked-by: Halil Pasic Reviewed-by: Richard Henderson --- hw/s390x/s390-virtio-ccw.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index e759eb5f83..a89cf4c129 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -154,14 +154,12 @@ static void virtio_ccw_register_hcalls(void) virtio_ccw_hcall_early_printk); } =20 -static void s390_memory_init(ram_addr_t mem_size) +static void s390_memory_init(MemoryRegion *ram) { MemoryRegion *sysmem =3D get_system_memory(); - MemoryRegion *ram =3D g_new(MemoryRegion, 1); Error *local_err =3D NULL; =20 /* allocate RAM for core */ - memory_region_allocate_system_memory(ram, NULL, "s390.ram", mem_size); memory_region_add_subregion(sysmem, 0, ram); =20 /* @@ -245,7 +243,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_size); + s390_memory_init(machine->ram); =20 /* init CPUs (incl. CPU model) early so s390_has_feature() works */ s390_init_cpus(machine); @@ -471,6 +469,7 @@ static void ccw_machine_class_init(ObjectClass *oc, voi= d *data) hc->plug =3D s390_machine_device_plug; hc->unplug_request =3D s390_machine_device_unplug_request; nc->nmi_monitor_handler =3D s390_nmi; + mc->default_ram_id =3D "s390.ram"; } =20 static inline bool machine_get_aes_key_wrap(Object *obj, Error **errp) --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581962095159994.05898797858; Mon, 17 Feb 2020 09:54:55 -0800 (PST) Received: from localhost ([::1]:49670 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kbe-00069g-21 for importer@patchew.org; Mon, 17 Feb 2020 12:54:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38499) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJD-0002Dh-S2 for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJC-0002BB-Qw for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:51 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:56654 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJC-0002Ar-Lf for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:50 -0500 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-59-ssGWkaqaP96Zgjm9k5TgZg-1; Mon, 17 Feb 2020 12:35:48 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1AFA6477 for ; Mon, 17 Feb 2020 17:35:47 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 69CED90508; Mon, 17 Feb 2020 17:35:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960950; 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=YIjZhKcy0NY+VunLuV5ainoemdkOP1H0oXP0UQfYo68=; b=cn2+0aHZ8CZqAu+J0yEklS6xlVj8EJ/sF38FJGfz+yYOEQNVbJnZRJR/nbR9wBTxm2nMXb hX3mgxBEWYe+ipTHduY1Sa7HPwsFXTWOAhB4XatvF+OlLSqyg/OsHZVDHT36NAwRAJ2UuT nB6FvJMQ7E/N7s4ns9IXZzAlzUpuXAM= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 39/79] null-machine: use memdev for RAM Date: Mon, 17 Feb 2020 12:34:12 -0500 Message-Id: <20200217173452.15243-40-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: ssGWkaqaP96Zgjm9k5TgZg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- hw/core/null-machine.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/hw/core/null-machine.c b/hw/core/null-machine.c index 1aa0a9a01a..cb47d9d4f8 100644 --- a/hw/core/null-machine.c +++ b/hw/core/null-machine.c @@ -32,11 +32,8 @@ static void machine_none_init(MachineState *mch) } =20 /* RAM at address zero */ - if (mch->ram_size) { - MemoryRegion *ram =3D g_new(MemoryRegion, 1); - - memory_region_allocate_system_memory(ram, NULL, "ram", mch->ram_si= ze); - memory_region_add_subregion(get_system_memory(), 0, ram); + if (mch->ram) { + memory_region_add_subregion(get_system_memory(), 0, mch->ram); } =20 if (mch->kernel_filename) { @@ -52,6 +49,7 @@ static void machine_none_machine_init(MachineClass *mc) mc->init =3D machine_none_init; mc->max_cpus =3D 1; mc->default_ram_size =3D 0; + mc->default_ram_id =3D "ram"; } =20 DEFINE_MACHINE("none", machine_none_machine_init) --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581962172468159.18335693679262; Mon, 17 Feb 2020 09:56:12 -0800 (PST) Received: from localhost ([::1]:49706 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kct-00005I-82 for importer@patchew.org; Mon, 17 Feb 2020 12:56:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38509) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJE-0002FW-Dx for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJD-0002Bf-EI for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:52 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:24652 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJD-0002BM-9o for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:51 -0500 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-336-rP5WngjFPKOKNcJkRhoUhA-1; Mon, 17 Feb 2020 12:35:49 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 43B2518FE862; Mon, 17 Feb 2020 17:35:48 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 65F3E90508; Mon, 17 Feb 2020 17:35:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960950; 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=mgjKGgjwgxFQMrzaiXh44AtRVimao5JYeGDFjYgxkcg=; b=E/SOqLIjPoFzKY7wXKKi2Z873vl9pvYIrrKP/zquw+liy2NUxhsCwlEDr//K6uNoJGXb5f RMXgJ6K69iOcfJmu7dqPjACP1xJGQUFTOMg+jo9b+Xf/EOQt1tfneU0sx4KwHJ7fW6lKUL kKI1+tooFqtjdCc3+XOYi8A+RRO7P5s= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 40/79] cris/axis_dev88: use memdev for RAM Date: Mon, 17 Feb 2020 12:34:13 -0500 Message-Id: <20200217173452.15243-41-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: rP5WngjFPKOKNcJkRhoUhA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 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: Paolo Bonzini , edgar.iglesias@gmail.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- CC: edgar.iglesias@gmail.com --- hw/cris/axis_dev88.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/hw/cris/axis_dev88.c b/hw/cris/axis_dev88.c index be7760476a..cf6790fd6f 100644 --- a/hw/cris/axis_dev88.c +++ b/hw/cris/axis_dev88.c @@ -249,7 +249,6 @@ static struct cris_load_info li; static void axisdev88_init(MachineState *machine) { - ram_addr_t ram_size =3D machine->ram_size; const char *kernel_filename =3D machine->kernel_filename; const char *kernel_cmdline =3D machine->kernel_cmdline; CRISCPU *cpu; @@ -261,16 +260,12 @@ void axisdev88_init(MachineState *machine) struct etraxfs_dma_client *dma_eth; int i; MemoryRegion *address_space_mem =3D get_system_memory(); - MemoryRegion *phys_ram =3D g_new(MemoryRegion, 1); MemoryRegion *phys_intmem =3D g_new(MemoryRegion, 1); =20 /* init CPUs */ cpu =3D CRIS_CPU(cpu_create(machine->cpu_type)); =20 - /* allocate RAM */ - memory_region_allocate_system_memory(phys_ram, NULL, "axisdev88.ram", - ram_size); - memory_region_add_subregion(address_space_mem, 0x40000000, phys_ram); + memory_region_add_subregion(address_space_mem, 0x40000000, machine->ra= m); =20 /* The ETRAX-FS has 128Kb on chip ram, the docs refer to it as the=20 internal memory. */ @@ -351,6 +346,7 @@ static void axisdev88_machine_init(MachineClass *mc) mc->init =3D axisdev88_init; mc->is_default =3D 1; mc->default_cpu_type =3D CRIS_CPU_TYPE_NAME("crisv32"); + mc->default_ram_id =3D "axisdev88.ram"; } =20 DEFINE_MACHINE("axis-dev88", axisdev88_machine_init) --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581962062208250.23379650035474; Mon, 17 Feb 2020 09:54:22 -0800 (PST) Received: from localhost ([::1]:49666 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kb6-0004p2-RW for importer@patchew.org; Mon, 17 Feb 2020 12:54:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38538) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJK-0002OX-LC for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJJ-0002F5-Jg for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:58 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:46723 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJJ-0002Dx-Fk for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:35:57 -0500 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-78-h9yHfIJCNU61Ie971WvHgQ-1; Mon, 17 Feb 2020 12:35:50 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9A4EA801E70; Mon, 17 Feb 2020 17:35:49 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8E79590508; Mon, 17 Feb 2020 17:35:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960954; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7bQjPmjmI5t2J7a74b5lv7Yb0EzYa4QU01TXt8HTXa4=; b=IGotRxRf5LKdVhw5Y1+T+HefAtDt9btgFvzAW/7fvPnRKhn6Jn9un9omdBRMPi+IhawXBf 5g6aDaePYpRjFIkOwB4SDNjo5fxgEFJojRdCjZhyMMlNg/q6/Lki3qirtHxwUfM1GGtWlZ gHXi/4FEHKAbgCwQKpFRbM165dYdQig= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 41/79] hppa: use memdev for RAM Date: Mon, 17 Feb 2020 12:34:14 -0500 Message-Id: <20200217173452.15243-42-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: h9yHfIJCNU61Ie971WvHgQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 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: Paolo Bonzini , deller@gmx.de, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- CC: rth@twiddle.net CC: deller@gmx.de --- hw/hppa/machine.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index d8755ec422..67181e75ba 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -71,14 +71,11 @@ static void machine_hppa_init(MachineState *machine) uint64_t kernel_entry =3D 0, kernel_low, kernel_high; MemoryRegion *addr_space =3D get_system_memory(); MemoryRegion *rom_region; - MemoryRegion *ram_region; MemoryRegion *cpu_region; long i; unsigned int smp_cpus =3D machine->smp.cpus; SysBusDevice *s; =20 - ram_size =3D machine->ram_size; - /* Create CPUs. */ for (i =3D 0; i < smp_cpus; i++) { char *name =3D g_strdup_printf("cpu%ld-io-eir", i); @@ -97,10 +94,8 @@ static void machine_hppa_init(MachineState *machine) error_report("RAM size is currently restricted to 3GB"); exit(EXIT_FAILURE); } - ram_region =3D g_new(MemoryRegion, 1); - memory_region_allocate_system_memory(ram_region, OBJECT(machine), - "ram", ram_size); - memory_region_add_subregion_overlap(addr_space, 0, ram_region, -1); + memory_region_add_subregion_overlap(addr_space, 0, machine->ram, -1); + =20 /* Init Lasi chip */ lasi_init(addr_space); @@ -298,6 +293,7 @@ static void machine_hppa_machine_init(MachineClass *mc) mc->is_default =3D 1; mc->default_ram_size =3D 512 * MiB; mc->default_boot_order =3D "cd"; + mc->default_ram_id =3D "ram"; } =20 DEFINE_MACHINE("hppa", machine_hppa_machine_init) --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581962168699947.2644060267203; Mon, 17 Feb 2020 09:56:08 -0800 (PST) Received: from localhost ([::1]:49703 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kcp-0008OY-9x for importer@patchew.org; Mon, 17 Feb 2020 12:56:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38551) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJN-0002Xt-VO for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJM-0002Gm-SM for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:01 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:35478 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJM-0002GZ-OG for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:00 -0500 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-221-ZlbrR4CCOG-p98x5hdUxCw-1; Mon, 17 Feb 2020 12:35:57 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 48F5518FE862; Mon, 17 Feb 2020 17:35:56 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id E399390508; Mon, 17 Feb 2020 17:35:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960960; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=P7h+Sr7YmLs9EP+61uL6n2jFUsa/gxvObHWT0NcMDKA=; b=YaRTqMRDL4MBtsM8sztwNEDQTUpUQuc0Y0/cWBcA6wZ/GMp2PsusDMwTjVeTo7PLryPj3z vc+8eDyqlVCXlt0EcozmEHPKXdCn/V08/GAfAwiwRe4/9/2aqfAWGNy0A26bq6gFKcNz7o TTJEkY2V15hrcK4HRA/q/myZojofruw= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 42/79] x86/microvm: use memdev for RAM Date: Mon, 17 Feb 2020 12:34:15 -0500 Message-Id: <20200217173452.15243-43-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: ZlbrR4CCOG-p98x5hdUxCw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 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: Paolo Bonzini , rth@twiddle.net, ehabkost@redhat.com, slp@redhat.com, mst@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- CC: slp@redhat.com CC: pbonzini@redhat.com CC: mst@redhat.com CC: rth@twiddle.net CC: ehabkost@redhat.com --- hw/i386/microvm.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c index d23485108d..38d8e51703 100644 --- a/hw/i386/microvm.c +++ b/hw/i386/microvm.c @@ -167,7 +167,7 @@ static void microvm_memory_init(MicrovmMachineState *mm= s) { MachineState *machine =3D MACHINE(mms); X86MachineState *x86ms =3D X86_MACHINE(mms); - MemoryRegion *ram, *ram_below_4g, *ram_above_4g; + MemoryRegion *ram_below_4g, *ram_above_4g; MemoryRegion *system_memory =3D get_system_memory(); FWCfgState *fw_cfg; ram_addr_t lowmem; @@ -214,12 +214,8 @@ static void microvm_memory_init(MicrovmMachineState *m= ms) x86ms->below_4g_mem_size =3D machine->ram_size; } =20 - ram =3D g_malloc(sizeof(*ram)); - memory_region_allocate_system_memory(ram, NULL, "microvm.ram", - machine->ram_size); - ram_below_4g =3D g_malloc(sizeof(*ram_below_4g)); - memory_region_init_alias(ram_below_4g, NULL, "ram-below-4g", ram, + memory_region_init_alias(ram_below_4g, NULL, "ram-below-4g", machine->= ram, 0, x86ms->below_4g_mem_size); memory_region_add_subregion(system_memory, 0, ram_below_4g); =20 @@ -227,7 +223,8 @@ static void microvm_memory_init(MicrovmMachineState *mm= s) =20 if (x86ms->above_4g_mem_size > 0) { ram_above_4g =3D g_malloc(sizeof(*ram_above_4g)); - memory_region_init_alias(ram_above_4g, NULL, "ram-above-4g", ram, + memory_region_init_alias(ram_above_4g, NULL, "ram-above-4g", + machine->ram, x86ms->below_4g_mem_size, x86ms->above_4g_mem_size); memory_region_add_subregion(system_memory, 0x100000000ULL, @@ -502,6 +499,7 @@ static void microvm_class_init(ObjectClass *oc, void *d= ata) mc->auto_enable_numa_with_memhp =3D false; mc->default_cpu_type =3D TARGET_DEFAULT_CPU_TYPE; mc->nvdimm_supported =3D false; + mc->default_ram_id =3D "microvm.ram"; =20 /* Avoid relying too much on kernel components */ mc->default_kernel_irqchip_split =3D true; --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581961843772605.9622941637294; Mon, 17 Feb 2020 09:50:43 -0800 (PST) Received: from localhost ([::1]:49604 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kXa-0005y8-GV for importer@patchew.org; Mon, 17 Feb 2020 12:50:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38564) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJP-0002bC-5D for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJO-0002HR-2K for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:03 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:32916 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJN-0002H8-Uw for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:02 -0500 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-119-wZ4PrxKUPVybVug5elzGgA-1; Mon, 17 Feb 2020 12:35:58 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C0D85800D50; Mon, 17 Feb 2020 17:35:57 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9233390533; Mon, 17 Feb 2020 17:35:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960961; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nyuoTEj0EQwddChvt7tHdaQd2fKsDMSQelB0wpdXkFM=; b=JPxo0BJHTM5tyY65dO79lgoS/rsxBdaaTXNUZyaA+gosSPgd/ogXSlbVs8Zwxsee3Ohgz6 7rILVljtCaehGOpX0U2bz2c3H9ygoZfprlbnfnGoTf0tYSZktyvXtVRH3XhiQ2n7yC+dzy puD9k7+nb8hHdsU8ZiTSAzL3Okk/eRY= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 43/79] x86/pc: use memdev for RAM Date: Mon, 17 Feb 2020 12:34:16 -0500 Message-Id: <20200217173452.15243-44-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: wZ4PrxKUPVybVug5elzGgA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 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: Paolo Bonzini , rth@twiddle.net, ehabkost@redhat.com, mst@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Reviewed-by: Richard Henderson --- CC: mst@redhat.com CC: pbonzini@redhat.com CC: rth@twiddle.net CC: ehabkost@redhat.com --- hw/i386/pc.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 2ddce4230a..6ab4acb0c6 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -937,7 +937,7 @@ void pc_memory_init(PCMachineState *pcms, MemoryRegion **ram_memory) { int linux_boot, i; - MemoryRegion *ram, *option_rom_mr; + MemoryRegion *option_rom_mr; MemoryRegion *ram_below_4g, *ram_above_4g; FWCfgState *fw_cfg; MachineState *machine =3D MACHINE(pcms); @@ -950,22 +950,20 @@ void pc_memory_init(PCMachineState *pcms, =20 linux_boot =3D (machine->kernel_filename !=3D NULL); =20 - /* Allocate RAM. We allocate it as a single memory region and use - * aliases to address portions of it, mostly for backwards compatibili= ty - * with older qemus that used qemu_ram_alloc(). + /* + * Split single memory region and use aliases to address portions of i= t, + * done for backwards compatibility with older qemus. */ - ram =3D g_malloc(sizeof(*ram)); - memory_region_allocate_system_memory(ram, NULL, "pc.ram", - machine->ram_size); - *ram_memory =3D ram; + *ram_memory =3D machine->ram; ram_below_4g =3D g_malloc(sizeof(*ram_below_4g)); - memory_region_init_alias(ram_below_4g, NULL, "ram-below-4g", ram, + memory_region_init_alias(ram_below_4g, NULL, "ram-below-4g", machine->= ram, 0, x86ms->below_4g_mem_size); memory_region_add_subregion(system_memory, 0, ram_below_4g); e820_add_entry(0, x86ms->below_4g_mem_size, E820_RAM); if (x86ms->above_4g_mem_size > 0) { ram_above_4g =3D g_malloc(sizeof(*ram_above_4g)); - memory_region_init_alias(ram_above_4g, NULL, "ram-above-4g", ram, + memory_region_init_alias(ram_above_4g, NULL, "ram-above-4g", + machine->ram, x86ms->below_4g_mem_size, x86ms->above_4g_mem_size); memory_region_add_subregion(system_memory, 0x100000000ULL, @@ -1952,6 +1950,7 @@ static void pc_machine_class_init(ObjectClass *oc, vo= id *data) mc->default_cpu_type =3D TARGET_DEFAULT_CPU_TYPE; mc->nvdimm_supported =3D true; mc->numa_mem_supported =3D true; + mc->default_ram_id =3D "pc.ram"; =20 object_class_property_add(oc, PC_MACHINE_DEVMEM_REGION_SIZE, "int", pc_machine_get_device_memory_region_size, NULL, --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581961971020998.3339104947308; Mon, 17 Feb 2020 09:52:51 -0800 (PST) Received: from localhost ([::1]:49642 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kZd-0001DT-JL for importer@patchew.org; Mon, 17 Feb 2020 12:52:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38584) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJS-0002ky-Kf for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJR-0002Iy-53 for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:06 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:30517 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJR-0002Ig-15 for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:05 -0500 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-418-oPp4jQ1mNXyRNFQyR2XndQ-1; Mon, 17 Feb 2020 12:36:02 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CCFED8010E8; Mon, 17 Feb 2020 17:36:01 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 14FD490508; Mon, 17 Feb 2020 17:35:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960964; 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=/BGChERklUy9ET1/xfYKQsSexn7mW9WhQm65jUVPUNQ=; b=ipx43e/PD4bUKp2CbnHZInrWR4l3WCqIQq7vbqK803iA1bBhmq5ehK7ficrjvTc83jajbc PnxyxsC9llA8bkG6lxnL1ZOc8Umqn1+0rXxOM9OQmFykkEYlpzS6Hcx/Ub/8AtiwQW6VDV xQ6Igkx0mfHFJBxt1V/uB29JMriURoA= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 44/79] lm32/lm32_boards: use memdev for RAM Date: Mon, 17 Feb 2020 12:34:17 -0500 Message-Id: <20200217173452.15243-45-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: oPp4jQ1mNXyRNFQyR2XndQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 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: Paolo Bonzini , michael@walle.cc, philmd@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. PS: while at it add check for user supplied RAM size and error out if it mismatches board expected value. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- v2: * fix format string causing build failure on 32-bit host (Philippe Mathieu-Daud=C3=A9 ) CC: michael@walle.cc CC: philmd@redhat.com --- hw/lm32/lm32_boards.c | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/hw/lm32/lm32_boards.c b/hw/lm32/lm32_boards.c index d1894adab8..4e0a98c117 100644 --- a/hw/lm32/lm32_boards.c +++ b/hw/lm32/lm32_boards.c @@ -19,6 +19,7 @@ =20 #include "qemu/osdep.h" #include "qemu/units.h" +#include "qemu/cutils.h" #include "qemu/error-report.h" #include "cpu.h" #include "hw/sysbus.h" @@ -75,22 +76,28 @@ static void main_cpu_reset(void *opaque) =20 static void lm32_evr_init(MachineState *machine) { + MachineClass *mc =3D MACHINE_GET_CLASS(machine); const char *kernel_filename =3D machine->kernel_filename; LM32CPU *cpu; CPULM32State *env; DriveInfo *dinfo; MemoryRegion *address_space_mem =3D get_system_memory(); - MemoryRegion *phys_ram =3D g_new(MemoryRegion, 1); qemu_irq irq[32]; ResetInfo *reset_info; int i; =20 + if (machine->ram_size !=3D mc->default_ram_size) { + char *sz =3D size_to_str(mc->default_ram_size); + error_report("Invalid RAM size, should be %s", sz); + g_free(sz); + exit(EXIT_FAILURE); + } + /* memory map */ hwaddr flash_base =3D 0x04000000; size_t flash_sector_size =3D 256 * KiB; size_t flash_size =3D 32 * MiB; hwaddr ram_base =3D 0x08000000; - size_t ram_size =3D 64 * MiB; hwaddr timer0_base =3D 0x80002000; hwaddr uart0_base =3D 0x80006000; hwaddr timer1_base =3D 0x8000a000; @@ -107,9 +114,7 @@ static void lm32_evr_init(MachineState *machine) =20 reset_info->flash_base =3D flash_base; =20 - memory_region_allocate_system_memory(phys_ram, NULL, "lm32_evr.sdram", - ram_size); - memory_region_add_subregion(address_space_mem, ram_base, phys_ram); + memory_region_add_subregion(address_space_mem, ram_base, machine->ram); =20 dinfo =3D drive_get(IF_PFLASH, 0, 0); /* Spansion S29NS128P */ @@ -144,7 +149,7 @@ static void lm32_evr_init(MachineState *machine) =20 if (kernel_size < 0) { kernel_size =3D load_image_targphys(kernel_filename, ram_base, - ram_size); + machine->ram_size); reset_info->bootstrap_pc =3D ram_base; } =20 @@ -159,6 +164,7 @@ static void lm32_evr_init(MachineState *machine) =20 static void lm32_uclinux_init(MachineState *machine) { + MachineClass *mc =3D MACHINE_GET_CLASS(machine); const char *kernel_filename =3D machine->kernel_filename; const char *kernel_cmdline =3D machine->kernel_cmdline; const char *initrd_filename =3D machine->initrd_filename; @@ -166,18 +172,23 @@ static void lm32_uclinux_init(MachineState *machine) CPULM32State *env; DriveInfo *dinfo; MemoryRegion *address_space_mem =3D get_system_memory(); - MemoryRegion *phys_ram =3D g_new(MemoryRegion, 1); qemu_irq irq[32]; HWSetup *hw; ResetInfo *reset_info; int i; =20 + if (machine->ram_size !=3D mc->default_ram_size) { + char *sz =3D size_to_str(mc->default_ram_size); + error_report("Invalid RAM size, should be %s", sz); + g_free(sz); + exit(EXIT_FAILURE); + } + /* memory map */ hwaddr flash_base =3D 0x04000000; size_t flash_sector_size =3D 256 * KiB; size_t flash_size =3D 32 * MiB; hwaddr ram_base =3D 0x08000000; - size_t ram_size =3D 64 * MiB; hwaddr uart0_base =3D 0x80000000; hwaddr timer0_base =3D 0x80002000; hwaddr timer1_base =3D 0x80010000; @@ -200,9 +211,7 @@ static void lm32_uclinux_init(MachineState *machine) =20 reset_info->flash_base =3D flash_base; =20 - memory_region_allocate_system_memory(phys_ram, NULL, - "lm32_uclinux.sdram", ram_size); - memory_region_add_subregion(address_space_mem, ram_base, phys_ram); + memory_region_add_subregion(address_space_mem, ram_base, machine->ram); =20 dinfo =3D drive_get(IF_PFLASH, 0, 0); /* Spansion S29NS128P */ @@ -238,7 +247,7 @@ static void lm32_uclinux_init(MachineState *machine) =20 if (kernel_size < 0) { kernel_size =3D load_image_targphys(kernel_filename, ram_base, - ram_size); + machine->ram_size); reset_info->bootstrap_pc =3D ram_base; } =20 @@ -252,7 +261,7 @@ static void lm32_uclinux_init(MachineState *machine) hw =3D hwsetup_init(); hwsetup_add_cpu(hw, "LM32", 75000000); hwsetup_add_flash(hw, "flash", flash_base, flash_size); - hwsetup_add_ddr_sdram(hw, "ddr_sdram", ram_base, ram_size); + hwsetup_add_ddr_sdram(hw, "ddr_sdram", ram_base, machine->ram_size); hwsetup_add_timer(hw, "timer0", timer0_base, timer0_irq); hwsetup_add_timer(hw, "timer1_dev_only", timer1_base, timer1_irq); hwsetup_add_timer(hw, "timer2_dev_only", timer2_base, timer2_irq); @@ -288,6 +297,8 @@ static void lm32_evr_class_init(ObjectClass *oc, void *= data) mc->init =3D lm32_evr_init; mc->is_default =3D 1; mc->default_cpu_type =3D LM32_CPU_TYPE_NAME("lm32-full"); + mc->default_ram_size =3D 64 * MiB; + mc->default_ram_id =3D "lm32_evr.sdram"; } =20 static const TypeInfo lm32_evr_type =3D { @@ -304,6 +315,8 @@ static void lm32_uclinux_class_init(ObjectClass *oc, vo= id *data) mc->init =3D lm32_uclinux_init; mc->is_default =3D 0; mc->default_cpu_type =3D LM32_CPU_TYPE_NAME("lm32-full"); + mc->default_ram_size =3D 64 * MiB; + mc->default_ram_id =3D "lm32_uclinux.sdram"; } =20 static const TypeInfo lm32_uclinux_type =3D { --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581962260843154.1831927241501; Mon, 17 Feb 2020 09:57:40 -0800 (PST) Received: from localhost ([::1]:49734 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3keJ-0003Yf-Gs for importer@patchew.org; Mon, 17 Feb 2020 12:57:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38593) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJU-0002mg-0E for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJR-0002JK-Tk for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:07 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:24188 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJR-0002J8-Pj for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:05 -0500 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-393-UsKsvr47Nx2Zx6GT04gl7g-1; Mon, 17 Feb 2020 12:36:04 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EF7DE107ACC9; Mon, 17 Feb 2020 17:36:02 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1F2F690508; Mon, 17 Feb 2020 17:36:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960965; 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=AfDrulq357FrWbeD12TUj99TtuCapOUvAuZPqemU0p8=; b=Upm3uhBxfRjRAhLLVi0bQRHHirJ9+qyimsoPIfcV5byCF0PNYreb+drWlSEhLaBg9g4WYx 2ojnhlRyNjoMH3Rn+3Gt+pfutvzhBn91Drg2PeeIo1Rkf+ov7p3MTbDz/UmaIYVX36HUe9 eFdwIcwv5+Zam5brvCaelBt4EIKiGlU= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 45/79] lm32/milkymist: use memdev for RAM Date: Mon, 17 Feb 2020 12:34:18 -0500 Message-Id: <20200217173452.15243-46-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: UsKsvr47Nx2Zx6GT04gl7g-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 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: Paolo Bonzini , michael@walle.cc Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. PS: while at it add check for user supplied RAM size and error out if it mismatches board expected value. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- v2: * fix format string causing build failure on 32-bit host (Philippe Mathieu-Daud=C3=A9 ) v3: * use size_to_str() to pretty print size in MiB (Philippe Mathieu-Daud=C3=A9 ) CC: michael@walle.cc --- hw/lm32/milkymist.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/hw/lm32/milkymist.c b/hw/lm32/milkymist.c index 6d46134232..5c72266e58 100644 --- a/hw/lm32/milkymist.c +++ b/hw/lm32/milkymist.c @@ -36,6 +36,7 @@ #include "hw/display/milkymist_tmu2.h" #include "lm32.h" #include "exec/address-spaces.h" +#include "qemu/cutils.h" =20 #define BIOS_FILENAME "mmone-bios.bin" #define BIOS_OFFSET 0x00860000 @@ -82,6 +83,7 @@ static void main_cpu_reset(void *opaque) static void milkymist_init(MachineState *machine) { + MachineClass *mc =3D MACHINE_GET_CLASS(machine); const char *kernel_filename =3D machine->kernel_filename; const char *kernel_cmdline =3D machine->kernel_cmdline; const char *initrd_filename =3D machine->initrd_filename; @@ -90,22 +92,27 @@ milkymist_init(MachineState *machine) int kernel_size; DriveInfo *dinfo; MemoryRegion *address_space_mem =3D get_system_memory(); - MemoryRegion *phys_sdram =3D g_new(MemoryRegion, 1); qemu_irq irq[32]; int i; char *bios_filename; ResetInfo *reset_info; =20 + if (machine->ram_size !=3D mc->default_ram_size) { + char *sz =3D size_to_str(mc->default_ram_size); + error_report("Invalid RAM size, should be %s", sz); + g_free(sz); + exit(EXIT_FAILURE); + } + /* memory map */ hwaddr flash_base =3D 0x00000000; size_t flash_sector_size =3D 128 * KiB; size_t flash_size =3D 32 * MiB; hwaddr sdram_base =3D 0x40000000; - size_t sdram_size =3D 128 * MiB; =20 hwaddr initrd_base =3D sdram_base + 0x1002000; hwaddr cmdline_base =3D sdram_base + 0x1000000; - size_t initrd_max =3D sdram_size - 0x1002000; + size_t initrd_max =3D machine->ram_size - 0x1002000; =20 reset_info =3D g_malloc0(sizeof(ResetInfo)); =20 @@ -116,9 +123,7 @@ milkymist_init(MachineState *machine) =20 cpu_lm32_set_phys_msb_ignore(env, 1); =20 - memory_region_allocate_system_memory(phys_sdram, NULL, "milkymist.sdra= m", - sdram_size); - memory_region_add_subregion(address_space_mem, sdram_base, phys_sdram); + memory_region_add_subregion(address_space_mem, sdram_base, machine->ra= m); =20 dinfo =3D drive_get(IF_PFLASH, 0, 0); /* Numonyx JS28F256J3F105 */ @@ -183,7 +188,7 @@ milkymist_init(MachineState *machine) =20 if (kernel_size < 0) { kernel_size =3D load_image_targphys(kernel_filename, sdram_bas= e, - sdram_size); + machine->ram_size); reset_info->bootstrap_pc =3D sdram_base; } =20 @@ -216,6 +221,8 @@ static void milkymist_machine_init(MachineClass *mc) mc->init =3D milkymist_init; mc->is_default =3D 0; mc->default_cpu_type =3D LM32_CPU_TYPE_NAME("lm32-full"); + mc->default_ram_size =3D 128 * MiB; + mc->default_ram_id =3D "milkymist.sdram"; } =20 DEFINE_MACHINE("milkymist", milkymist_machine_init) --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581962062163188.70037200104719; Mon, 17 Feb 2020 09:54:22 -0800 (PST) Received: from localhost ([::1]:49664 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kb6-0004p1-KW for importer@patchew.org; Mon, 17 Feb 2020 12:54:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38610) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJW-0002qJ-8t for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJU-0002KZ-5I for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:09 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:41287 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJU-0002Jl-1M for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:08 -0500 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-346-jwsHohBCOz-JhtWarrIHdQ-1; Mon, 17 Feb 2020 12:36:04 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EABD818FE861 for ; Mon, 17 Feb 2020 17:36:03 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 43DD290765; Mon, 17 Feb 2020 17:36:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960966; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Kz1q1tfok4Fs3YULYDAA2L2on8nXONnY7o1MwyQCubk=; b=EHXnEZ9L2lBoAaqcxVS5ghrLPSAUVVOtGcz747ZHt13prYwyw6xKjXYVa+vxFfawL/T3tt TSvg+zHdq1WSyr2ExuJhG+WAQqLj7paaspbCIzTxCRGCg49FI2Cce7tEwUWSka91cCWM13 2cQaUUA6DNZODUQCsb5JSETWImasC+o= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 46/79] m68k/an5206: use memdev for RAM Date: Mon, 17 Feb 2020 12:34:19 -0500 Message-Id: <20200217173452.15243-47-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: jwsHohBCOz-JhtWarrIHdQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Acked-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- hw/m68k/an5206.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/m68k/an5206.c b/hw/m68k/an5206.c index bed43a936d..846f4e40c6 100644 --- a/hw/m68k/an5206.c +++ b/hw/m68k/an5206.c @@ -33,7 +33,6 @@ static void an5206_init(MachineState *machine) uint64_t elf_entry; hwaddr entry; MemoryRegion *address_space_mem =3D get_system_memory(); - MemoryRegion *ram =3D g_new(MemoryRegion, 1); MemoryRegion *sram =3D g_new(MemoryRegion, 1); =20 cpu =3D M68K_CPU(cpu_create(machine->cpu_type)); @@ -46,8 +45,7 @@ static void an5206_init(MachineState *machine) env->rambar0 =3D AN5206_RAMBAR_ADDR | 1; =20 /* DRAM at address zero */ - memory_region_allocate_system_memory(ram, NULL, "an5206.ram", ram_size= ); - memory_region_add_subregion(address_space_mem, 0, ram); + memory_region_add_subregion(address_space_mem, 0, machine->ram); =20 /* Internal SRAM. */ memory_region_init_ram(sram, NULL, "an5206.sram", 512, &error_fatal); @@ -89,6 +87,7 @@ static void an5206_machine_init(MachineClass *mc) mc->desc =3D "Arnewsh 5206"; mc->init =3D an5206_init; mc->default_cpu_type =3D M68K_CPU_TYPE_NAME("m5206"); + mc->default_ram_id =3D "an5206.ram"; } =20 DEFINE_MACHINE("an5206", an5206_machine_init) --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581962170259720.7681849130685; Mon, 17 Feb 2020 09:56:10 -0800 (PST) Received: from localhost ([::1]:49704 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kcr-0008Pl-1E for importer@patchew.org; Mon, 17 Feb 2020 12:56:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38609) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJW-0002pg-8a for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJU-0002Kf-7M for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:09 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:60694 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJU-0002KE-3A for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:08 -0500 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-432-K06PnRfmP1iyZC1I7uLS3Q-1; Mon, 17 Feb 2020 12:36:05 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E4F81DB21 for ; Mon, 17 Feb 2020 17:36:04 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3F2418CCE0; Mon, 17 Feb 2020 17:36:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960967; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R1q6h3NT5cX4nV0zYi5AnwUkQkilMBa/C8ZQ6ySXXME=; b=PgBDHaQhzaL4NGh16ahcMQvfHt7kK0Zrtuvs+D3GwZ262Or6P2nYYRvYsDuznhPFF7FoLZ 1ELPUqoa8SVwPWpJzmHy8+h872QpH6KGtgqRYTeWq+FCOAts0pqxevhrjOMb8ZsF66W7UL O3oDNxbpsYM4RKcZf9kD87MVoNJMCBc= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 47/79] m68k/q800: use memdev for RAM Date: Mon, 17 Feb 2020 12:34:20 -0500 Message-Id: <20200217173452.15243-48-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: K06PnRfmP1iyZC1I7uLS3Q-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Switch to using generic main RAM allocation. To do this set MachineClass::default_ram_id to m68k_mac.ram and use MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Acked-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- hw/m68k/q800.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c index 1e32363688..a4c4bc14cb 100644 --- a/hw/m68k/q800.c +++ b/hw/m68k/q800.c @@ -160,7 +160,6 @@ static void q800_init(MachineState *machine) ram_addr_t initrd_base; int32_t initrd_size; MemoryRegion *rom; - MemoryRegion *ram; MemoryRegion *io; const int io_slice_nb =3D (IO_SIZE / IO_SLICE) - 1; int i; @@ -194,9 +193,7 @@ static void q800_init(MachineState *machine) qemu_register_reset(main_cpu_reset, cpu); =20 /* RAM */ - ram =3D g_malloc(sizeof(*ram)); - memory_region_init_ram(ram, NULL, "m68k_mac.ram", ram_size, &error_abo= rt); - memory_region_add_subregion(get_system_memory(), 0, ram); + memory_region_add_subregion(get_system_memory(), 0, machine->ram); =20 /* * Memory from IO_BASE to IO_BASE + IO_SLICE is repeated @@ -443,6 +440,7 @@ static void q800_machine_class_init(ObjectClass *oc, vo= id *data) mc->max_cpus =3D 1; mc->is_default =3D 0; mc->block_default_type =3D IF_SCSI; + mc->default_ram_id =3D "m68k_mac.ram"; } =20 static const TypeInfo q800_machine_typeinfo =3D { --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15819622380411022.2067173682326; Mon, 17 Feb 2020 09:57:18 -0800 (PST) Received: from localhost ([::1]:49732 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kdw-0002d5-Le for importer@patchew.org; Mon, 17 Feb 2020 12:57:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38633) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJY-0002vn-9f for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJX-0002NO-93 for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:12 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:54608 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJX-0002LG-45 for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:11 -0500 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-299-Yv6j5kfuN7WE98fEZDCOBQ-1; Mon, 17 Feb 2020 12:36:06 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E0F7218FE861 for ; Mon, 17 Feb 2020 17:36:05 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3C0418CCE0; Mon, 17 Feb 2020 17:36:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960969; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=re5n7l+nQ9qrqnNQI25KNrL5OHDn4Vh2MyfxJ2WTulI=; b=BrjH+PEW2FYFBX08gKw51M3CPqQG9xCdRsysQTuogVZC4WwWNClb4Jzxq/xHplnbhb/eCJ uR4/kdc1YzNfdssL9csIONG9jaH9bu0Y4vYn1TAIvUIlCEVQSwHdmhH3g0LqN2HMWNBwqD DCAu2JdkT6nRtZiN4JjzJtFNXPqh1Qs= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 48/79] m68k/mcf5208: use memdev for RAM Date: Mon, 17 Feb 2020 12:34:21 -0500 Message-Id: <20200217173452.15243-49-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: Yv6j5kfuN7WE98fEZDCOBQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Acked-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- hw/m68k/mcf5208.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/m68k/mcf5208.c b/hw/m68k/mcf5208.c index a999c21982..31622c71cb 100644 --- a/hw/m68k/mcf5208.c +++ b/hw/m68k/mcf5208.c @@ -234,7 +234,6 @@ static void mcf5208evb_init(MachineState *machine) qemu_irq *pic; MemoryRegion *address_space_mem =3D get_system_memory(); MemoryRegion *rom =3D g_new(MemoryRegion, 1); - MemoryRegion *ram =3D g_new(MemoryRegion, 1); MemoryRegion *sram =3D g_new(MemoryRegion, 1); =20 cpu =3D M68K_CPU(cpu_create(machine->cpu_type)); @@ -249,8 +248,7 @@ static void mcf5208evb_init(MachineState *machine) memory_region_add_subregion(address_space_mem, 0x00000000, rom); =20 /* DRAM at 0x40000000 */ - memory_region_allocate_system_memory(ram, NULL, "mcf5208.ram", ram_siz= e); - memory_region_add_subregion(address_space_mem, 0x40000000, ram); + memory_region_add_subregion(address_space_mem, 0x40000000, machine->ra= m); =20 /* Internal SRAM. */ memory_region_init_ram(sram, NULL, "mcf5208.sram", 16 * KiB, &error_fa= tal); @@ -354,6 +352,7 @@ static void mcf5208evb_machine_init(MachineClass *mc) mc->init =3D mcf5208evb_init; mc->is_default =3D 1; mc->default_cpu_type =3D M68K_CPU_TYPE_NAME("m5208"); + mc->default_ram_id =3D "mcf5208.ram"; } =20 DEFINE_MACHINE("mcf5208evb", mcf5208evb_machine_init) --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581962264465581.8760101099033; Mon, 17 Feb 2020 09:57:44 -0800 (PST) Received: from localhost ([::1]:49738 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3keN-0003la-8c for importer@patchew.org; Mon, 17 Feb 2020 12:57:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38652) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJb-00033y-6i for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJa-0002RY-6y for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:15 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:20661 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJa-0002RN-3A for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:14 -0500 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-248-2LY1jZQuPNu3uHMgLZMd-g-1; Mon, 17 Feb 2020 12:36:07 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DD743108443C for ; Mon, 17 Feb 2020 17:36:06 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 36B6490526; Mon, 17 Feb 2020 17:36:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960973; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4nUR3zbXNeZiPVJ7LowHY5RCGyU2MLA1BmhXD+QO+cQ=; b=Qr0VfnI0FzswlHxCyFmmwpzjiGF9XSZ7jrUHu9ao3SekM3kiqcoFiRedxaDo/4vGz2H9vI 9XcbW3ae6FSdSdkZ05UVdUsmfZYq9JI9uHBee34LyhnBy3A6L+oN3WyGERanMo5j1TDzLS TJS6au1y3KuKnswra4B+Ye1hZlHwnJA= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 49/79] m68k/next-cube: use memdev for RAM Date: Mon, 17 Feb 2020 12:34:22 -0500 Message-Id: <20200217173452.15243-50-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: 2LY1jZQuPNu3uHMgLZMd-g-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Acked-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- hw/m68k/next-cube.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/m68k/next-cube.c b/hw/m68k/next-cube.c index e5343348d0..cd93d9e367 100644 --- a/hw/m68k/next-cube.c +++ b/hw/m68k/next-cube.c @@ -860,7 +860,6 @@ static void next_cube_init(MachineState *machine) { M68kCPU *cpu; CPUM68KState *env; - MemoryRegion *ram =3D g_new(MemoryRegion, 1); MemoryRegion *rom =3D g_new(MemoryRegion, 1); MemoryRegion *mmiomem =3D g_new(MemoryRegion, 1); MemoryRegion *scrmem =3D g_new(MemoryRegion, 1); @@ -893,8 +892,7 @@ static void next_cube_init(MachineState *machine) memcpy(ns->rtc.ram, rtc_ram2, 32); =20 /* 64MB RAM starting at 0x04000000 */ - memory_region_allocate_system_memory(ram, NULL, "next.ram", ram_size); - memory_region_add_subregion(sysmem, 0x04000000, ram); + memory_region_add_subregion(sysmem, 0x04000000, machine->ram); =20 /* Framebuffer */ dev =3D qdev_create(NULL, TYPE_NEXTFB); @@ -967,6 +965,7 @@ static void next_machine_class_init(ObjectClass *oc, vo= id *data) mc->desc =3D "NeXT Cube"; mc->init =3D next_cube_init; mc->default_ram_size =3D RAM_SIZE; + mc->default_ram_id =3D "next.ram"; mc->default_cpu_type =3D M68K_CPU_TYPE_NAME("m68040"); } =20 --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581962333932455.8494896145895; Mon, 17 Feb 2020 09:58:53 -0800 (PST) Received: from localhost ([::1]:49758 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kfU-00069k-My for importer@patchew.org; Mon, 17 Feb 2020 12:58:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38635) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJY-0002w3-DF for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJX-0002NW-9g for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:12 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:36308 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJX-0002MC-5c for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:11 -0500 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-316-Jt7SIlCoNb2-f5YZ5k2PEw-1; Mon, 17 Feb 2020 12:36:08 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D83EE1084426 for ; Mon, 17 Feb 2020 17:36:07 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 328618CCE0; Mon, 17 Feb 2020 17:36:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960970; 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=SYg7ZBYi6gj1nQP0aLyEqxTXVeao+bU4aAgvkW4CQPE=; b=CpKV6T4ITf0OrIXih5MRMC8C1cv+oKfpC+PrhTxD0PAO+QCJ1rkGFpCGU3HaNeuqKQl+Sg Q3wdm8+Lrp2ZmyK6j/kYgEU7xJz4WX+W8ay/VucKgI56ZoY1JVPBni/AZNP91fnivULcX/ st52rblVks3RcvmADL6UP2SYNaB02rk= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 50/79] mips/boston: use memdev for RAM Date: Mon, 17 Feb 2020 12:34:23 -0500 Message-Id: <20200217173452.15243-51-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: Jt7SIlCoNb2-f5YZ5k2PEw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- hw/mips/boston.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/hw/mips/boston.c b/hw/mips/boston.c index 0df3a7755a..98ecd25e8e 100644 --- a/hw/mips/boston.c +++ b/hw/mips/boston.c @@ -427,7 +427,7 @@ static void boston_mach_init(MachineState *machine) DeviceState *dev; BostonState *s; Error *err =3D NULL; - MemoryRegion *flash, *ddr, *ddr_low_alias, *lcd, *platreg; + MemoryRegion *flash, *ddr_low_alias, *lcd, *platreg; MemoryRegion *sys_mem =3D get_system_memory(); XilinxPCIEHost *pcie2; PCIDevice *ahci; @@ -473,14 +473,12 @@ static void boston_mach_init(MachineState *machine) memory_region_init_rom(flash, NULL, "boston.flash", 128 * MiB, &err); memory_region_add_subregion_overlap(sys_mem, 0x18000000, flash, 0); =20 - ddr =3D g_new(MemoryRegion, 1); - memory_region_allocate_system_memory(ddr, NULL, "boston.ddr", - machine->ram_size); - memory_region_add_subregion_overlap(sys_mem, 0x80000000, ddr, 0); + memory_region_add_subregion_overlap(sys_mem, 0x80000000, machine->ram,= 0); =20 ddr_low_alias =3D g_new(MemoryRegion, 1); memory_region_init_alias(ddr_low_alias, NULL, "boston_low.ddr", - ddr, 0, MIN(machine->ram_size, (256 * MiB))); + machine->ram, 0, + MIN(machine->ram_size, (256 * MiB))); memory_region_add_subregion_overlap(sys_mem, 0, ddr_low_alias, 0); =20 xilinx_pcie_init(sys_mem, 0, @@ -552,6 +550,7 @@ static void boston_mach_class_init(MachineClass *mc) mc->init =3D boston_mach_init; mc->block_default_type =3D IF_IDE; mc->default_ram_size =3D 1 * GiB; + mc->default_ram_id =3D "boston.ddr"; mc->max_cpus =3D 16; mc->default_cpu_type =3D MIPS_CPU_TYPE_NAME("I6400"); } --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581962468497947.238992188713; Mon, 17 Feb 2020 10:01:08 -0800 (PST) Received: from localhost ([::1]:49788 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3khe-0001Li-Qa for importer@patchew.org; Mon, 17 Feb 2020 13:01:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38669) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJe-0003Af-R9 for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJc-0002SW-78 for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:18 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:53360 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJc-0002SH-2u for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:16 -0500 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-200-hOpubZSWOfaK7TM7ENgwmw-1; Mon, 17 Feb 2020 12:36:13 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5F372477; Mon, 17 Feb 2020 17:36:11 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 300C18CCE0; Mon, 17 Feb 2020 17:36:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960975; 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=T62fwz+44QGOSBjuTaJCyeEJhCyqsaRzSSdpkM1CNqg=; b=G0iUFRE91LvDIvQgu+hpa7tI/VSFn88ua48BxrvJ23XA+ZOsQMGQ7mdwfGSSR3DVCuTjW9 u9t9plCSu1390Qn/K2FMLsydd1HXk1o/Q67XTuw/mMBGCAMa7k/dWk0aJbavgZC37hhrid xTm/LN9ka4CrkgA/YMg5B8dATDM34+8= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 51/79] mips/mips_fulong2e: drop RAM size fixup Date: Mon, 17 Feb 2020 12:34:24 -0500 Message-Id: <20200217173452.15243-52-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: hOpubZSWOfaK7TM7ENgwmw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 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: amarkovic@wavecomp.com, Paolo Bonzini , aleksandar.rikalo@rt-rk.com, philmd@redhat.com, aurelien@aurel32.net 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" If user provided non-sense RAM size, board will complain and continue running with max RAM size supported. Also RAM is going to be allocated by generic code, so it won't be possible for board to fix things up for user. Make it error message and exit to force user fix CLI, instead of accepting non-sense CLI values. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- v2: * fix format string cousing build failure on 32-bit host (Philippe Mathieu-Daud=C3=A9 ) v3: * since size is ifxed, just hardcode 256Mb value as text in error message (BALATON Zoltan ) CC: philmd@redhat.com CC: amarkovic@wavecomp.com CC: aurelien@aurel32.net CC: aleksandar.rikalo@rt-rk.com CC: balaton@eik.bme.hu --- hw/mips/mips_fulong2e.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/hw/mips/mips_fulong2e.c b/hw/mips/mips_fulong2e.c index 2e043cbb98..cf00211bd2 100644 --- a/hw/mips/mips_fulong2e.c +++ b/hw/mips/mips_fulong2e.c @@ -296,7 +296,6 @@ static void mips_fulong2e_init(MachineState *machine) MemoryRegion *address_space_mem =3D get_system_memory(); MemoryRegion *ram =3D g_new(MemoryRegion, 1); MemoryRegion *bios =3D g_new(MemoryRegion, 1); - ram_addr_t ram_size =3D machine->ram_size; long bios_size; uint8_t *spd_data; Error *err =3D NULL; @@ -315,10 +314,14 @@ static void mips_fulong2e_init(MachineState *machine) qemu_register_reset(main_cpu_reset, cpu); =20 /* TODO: support more than 256M RAM as highmem */ - ram_size =3D 256 * MiB; + if (machine->ram_size !=3D 256 * MiB) { + error_report("Invalid RAM size, should be 256MB"); + exit(EXIT_FAILURE); + } =20 /* allocate RAM */ - memory_region_allocate_system_memory(ram, NULL, "fulong2e.ram", ram_si= ze); + memory_region_allocate_system_memory(ram, NULL, "fulong2e.ram", + machine->ram_size); memory_region_init_ram(bios, NULL, "fulong2e.bios", BIOS_SIZE, &error_fatal); memory_region_set_readonly(bios, true); @@ -332,7 +335,7 @@ static void mips_fulong2e_init(MachineState *machine) */ =20 if (kernel_filename) { - loaderparams.ram_size =3D ram_size; + loaderparams.ram_size =3D machine->ram_size; loaderparams.kernel_filename =3D kernel_filename; loaderparams.kernel_cmdline =3D kernel_cmdline; loaderparams.initrd_filename =3D initrd_filename; @@ -378,7 +381,7 @@ static void mips_fulong2e_init(MachineState *machine) } =20 /* Populate SPD eeprom data */ - spd_data =3D spd_data_generate(DDR, ram_size, &err); + spd_data =3D spd_data_generate(DDR, machine->ram_size, &err); if (err) { warn_report_err(err); } --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581962262225867.5800815876672; Mon, 17 Feb 2020 09:57:42 -0800 (PST) Received: from localhost ([::1]:49736 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3keK-0003bY-U1 for importer@patchew.org; Mon, 17 Feb 2020 12:57:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38668) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJe-0003Ac-Ql for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJd-0002TD-Mg for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:18 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:52299 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJd-0002Sa-Ie for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:17 -0500 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-99-gJW7BtmePcehJdxz9qLuSQ-1; Mon, 17 Feb 2020 12:36:14 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1016518FE860; Mon, 17 Feb 2020 17:36:13 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id AA6009052B; Mon, 17 Feb 2020 17:36:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960976; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9xulXF2NUVClbIGw/RgPg/ENZpRkn/7VBe9kPPuu1No=; b=LIX0j5NnWglJDiPFaK0UJEGVfNvllO3PzOGzlgB/tGA/FxnJBgps69ZGjKXgerNalH9ong ttnuZcPfo3wJN4QbgECj3mqv2JYd2iYnnflSvzB+xyY5jrPZP6I68szAQeOWR2c0Y5HPLs s8bZ78y94hgGIDOGe2RcRuDrep5pz84= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 52/79] mips/mips_fulong2e: use memdev for RAM Date: Mon, 17 Feb 2020 12:34:25 -0500 Message-Id: <20200217173452.15243-53-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: gJW7BtmePcehJdxz9qLuSQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 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: Paolo Bonzini , aleksandar.rikalo@rt-rk.com, philmd@redhat.com, aurelien@aurel32.net, amarkovic@wavecomp.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- CC: philmd@redhat.com CC: amarkovic@wavecomp.com CC: aurelien@aurel32.net CC: aleksandar.rikalo@rt-rk.com --- hw/mips/mips_fulong2e.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hw/mips/mips_fulong2e.c b/hw/mips/mips_fulong2e.c index cf00211bd2..c373ab066b 100644 --- a/hw/mips/mips_fulong2e.c +++ b/hw/mips/mips_fulong2e.c @@ -294,7 +294,6 @@ static void mips_fulong2e_init(MachineState *machine) const char *initrd_filename =3D machine->initrd_filename; char *filename; MemoryRegion *address_space_mem =3D get_system_memory(); - MemoryRegion *ram =3D g_new(MemoryRegion, 1); MemoryRegion *bios =3D g_new(MemoryRegion, 1); long bios_size; uint8_t *spd_data; @@ -320,13 +319,11 @@ static void mips_fulong2e_init(MachineState *machine) } =20 /* allocate RAM */ - memory_region_allocate_system_memory(ram, NULL, "fulong2e.ram", - machine->ram_size); memory_region_init_ram(bios, NULL, "fulong2e.bios", BIOS_SIZE, &error_fatal); memory_region_set_readonly(bios, true); =20 - memory_region_add_subregion(address_space_mem, 0, ram); + memory_region_add_subregion(address_space_mem, 0, machine->ram); memory_region_add_subregion(address_space_mem, 0x1fc00000LL, bios); =20 /* @@ -402,6 +399,7 @@ static void mips_fulong2e_machine_init(MachineClass *mc) mc->block_default_type =3D IF_IDE; mc->default_cpu_type =3D MIPS_CPU_TYPE_NAME("Loongson-2E"); mc->default_ram_size =3D 256 * MiB; + mc->default_ram_id =3D "fulong2e.ram"; } =20 DEFINE_MACHINE("fulong2e", mips_fulong2e_machine_init) --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581962535941157.9218200590492; Mon, 17 Feb 2020 10:02:15 -0800 (PST) Received: from localhost ([::1]:49806 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kik-0002hs-Lb for importer@patchew.org; Mon, 17 Feb 2020 13:02:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38698) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJf-0003DK-VB for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJe-0002Tv-Qb for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:19 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:47005 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJe-0002TP-Jf for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:18 -0500 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-47-fJuntI5FNlSN9KNRI1jC3A-1; Mon, 17 Feb 2020 12:36:15 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0D0A3100550E for ; Mon, 17 Feb 2020 17:36:14 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5AD548CCE0; Mon, 17 Feb 2020 17:36:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960978; 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=8zRXquUspfaMKxjK/ZwxOgmeva/U7Ez41JClop5CoXQ=; b=MwVU3CF9NvEVG25vbenUNMvjtWbWPp2qjE0rDHYYtAoXgOQMLgsbsaW8GSfI8T5lNOEHEc lYktT8XzsDlu99k+mVh2yrV+LSakXbrFcLu+5lNYZpdF0rAwhzvS5vrUESRAH09Y+9NCzC PKc9V9+A03RWTcbbyv3syebqUhZ9F5k= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 53/79] mips/mips_jazz: use memdev for RAM Date: Mon, 17 Feb 2020 12:34:26 -0500 Message-Id: <20200217173452.15243-54-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: fJuntI5FNlSN9KNRI1jC3A-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/mips/mips_jazz.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hw/mips/mips_jazz.c b/hw/mips/mips_jazz.c index 66fd4d867d..85d49cf155 100644 --- a/hw/mips/mips_jazz.c +++ b/hw/mips/mips_jazz.c @@ -159,7 +159,6 @@ static void mips_jazz_init(MachineState *machine, ISABus *isa_bus; ISADevice *pit; DriveInfo *fds[MAX_FD]; - MemoryRegion *ram =3D g_new(MemoryRegion, 1); MemoryRegion *bios =3D g_new(MemoryRegion, 1); MemoryRegion *bios2 =3D g_new(MemoryRegion, 1); SysBusESPState *sysbus_esp; @@ -191,9 +190,7 @@ static void mips_jazz_init(MachineState *machine, cc->do_transaction_failed =3D mips_jazz_do_transaction_failed; =20 /* allocate RAM */ - memory_region_allocate_system_memory(ram, NULL, "mips_jazz.ram", - machine->ram_size); - memory_region_add_subregion(address_space, 0, ram); + memory_region_add_subregion(address_space, 0, machine->ram); =20 memory_region_init_ram(bios, NULL, "mips_jazz.bios", MAGNUM_BIOS_SIZE, &error_fatal); @@ -393,6 +390,7 @@ static void mips_magnum_class_init(ObjectClass *oc, voi= d *data) mc->init =3D mips_magnum_init; mc->block_default_type =3D IF_SCSI; mc->default_cpu_type =3D MIPS_CPU_TYPE_NAME("R4000"); + mc->default_ram_id =3D "mips_jazz.ram"; } =20 static const TypeInfo mips_magnum_type =3D { @@ -409,6 +407,7 @@ static void mips_pica61_class_init(ObjectClass *oc, voi= d *data) mc->init =3D mips_pica61_init; mc->block_default_type =3D IF_SCSI; mc->default_cpu_type =3D MIPS_CPU_TYPE_NAME("R4000"); + mc->default_ram_id =3D "mips_jazz.ram"; } =20 static const TypeInfo mips_pica61_type =3D { --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581962354968975.3809947552198; Mon, 17 Feb 2020 09:59:14 -0800 (PST) Received: from localhost ([::1]:49764 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kfp-0007BF-Oa for importer@patchew.org; Mon, 17 Feb 2020 12:59:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38695) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJf-0003D7-Ry for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJe-0002U5-SA for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:19 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:54414 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJe-0002TV-OP for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:18 -0500 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-368-Bbn0HPLoNd6WSZgg90MLgA-1; Mon, 17 Feb 2020 12:36:15 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0A1B91005512 for ; Mon, 17 Feb 2020 17:36:15 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 579E68CCE0; Mon, 17 Feb 2020 17:36:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960978; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NJaIgY+bKaOvZlfmkqpwWek60f+o8HnE5o0Knnu1RzA=; b=FqQec9sDPfVq2DIYKSllyNT/gWg1A7afrBxLFfwRlr1zKipPx6S8q4oUA16EbZEMcaQrU5 OZEyNSjm4RIKc9sKCN42nD/eywB7uCLg5rqX52aA+Hg4eEZRJdduUAMQOQY2h1PPXhRYIb U9FYXRihLxAhs4Wa31jtgHtfwgGqZDM= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 54/79] mips/mips_jazz: add max ram size check Date: Mon, 17 Feb 2020 12:34:27 -0500 Message-Id: <20200217173452.15243-55-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: Bbn0HPLoNd6WSZgg90MLgA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" error out in case user asked for more RAM than board supports. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daude --- hw/mips/mips_jazz.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/mips/mips_jazz.c b/hw/mips/mips_jazz.c index 85d49cf155..32fbd10b4e 100644 --- a/hw/mips/mips_jazz.c +++ b/hw/mips/mips_jazz.c @@ -164,6 +164,11 @@ static void mips_jazz_init(MachineState *machine, SysBusESPState *sysbus_esp; ESPState *esp; =20 + if (machine->ram_size > 256 * MiB) { + error_report("RAM size more than 256Mb is not supported"); + exit(EXIT_FAILURE); + } + /* init CPUs */ cpu =3D MIPS_CPU(cpu_create(machine->cpu_type)); env =3D &cpu->env; --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 158196235439079.96759344305087; Mon, 17 Feb 2020 09:59:14 -0800 (PST) Received: from localhost ([::1]:49762 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kfp-00079G-7P for importer@patchew.org; Mon, 17 Feb 2020 12:59:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38701) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJg-0003Do-6a for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJe-0002UE-Ve for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:20 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:39494 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJe-0002Te-RW for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:18 -0500 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-346-AgBlTgDoOZ6aWkpmTiYm-Q-1; Mon, 17 Feb 2020 12:36:16 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0416C477 for ; Mon, 17 Feb 2020 17:36:16 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 52BA48CCE0; Mon, 17 Feb 2020 17:36:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960978; 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=5qDRPQ4TK/v2bK7LIJWDnFv1STpVoUJSi1h4wp28qlU=; b=SUsS4NDnMS7HD6dthUkvJAeCHd5+2FA5IC5b2xOpbvucLpDPTyQTVx7ySAMaYvEDR9wIdx lCKimuX4CLTwg0WuUDK9l+K4QO0pc88lYVYjbDc/UoIWn7UL6qUY7rCKZYb/EkzA3KRQse pSAfoXSTMIZ8FHPjZ6mewIPT51sGjjQ= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 55/79] mips/mips_malta: use memdev for RAM Date: Mon, 17 Feb 2020 12:34:28 -0500 Message-Id: <20200217173452.15243-56-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: AgBlTgDoOZ6aWkpmTiYm-Q-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- hw/mips/mips_malta.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c index 34b76bb6a1..6e7ba9235d 100644 --- a/hw/mips/mips_malta.c +++ b/hw/mips/mips_malta.c @@ -1224,7 +1224,6 @@ void mips_malta_init(MachineState *machine) char *filename; PFlashCFI01 *fl; MemoryRegion *system_memory =3D get_system_memory(); - MemoryRegion *ram_high =3D g_new(MemoryRegion, 1); MemoryRegion *ram_low_preio =3D g_new(MemoryRegion, 1); MemoryRegion *ram_low_postio; MemoryRegion *bios, *bios_copy =3D g_new(MemoryRegion, 1); @@ -1262,13 +1261,11 @@ void mips_malta_init(MachineState *machine) } =20 /* register RAM at high address where it is undisturbed by IO */ - memory_region_allocate_system_memory(ram_high, NULL, "mips_malta.ram", - ram_size); - memory_region_add_subregion(system_memory, 0x80000000, ram_high); + memory_region_add_subregion(system_memory, 0x80000000, machine->ram); =20 /* alias for pre IO hole access */ memory_region_init_alias(ram_low_preio, NULL, "mips_malta_low_preio.ra= m", - ram_high, 0, MIN(ram_size, 256 * MiB)); + machine->ram, 0, MIN(ram_size, 256 * MiB)); memory_region_add_subregion(system_memory, 0, ram_low_preio); =20 /* alias for post IO hole access, if there is enough RAM */ @@ -1276,7 +1273,7 @@ void mips_malta_init(MachineState *machine) ram_low_postio =3D g_new(MemoryRegion, 1); memory_region_init_alias(ram_low_postio, NULL, "mips_malta_low_postio.ram", - ram_high, 512 * MiB, + machine->ram, 512 * MiB, ram_size - 512 * MiB); memory_region_add_subregion(system_memory, 512 * MiB, ram_low_postio); @@ -1448,6 +1445,7 @@ static void mips_malta_machine_init(MachineClass *mc) #else mc->default_cpu_type =3D MIPS_CPU_TYPE_NAME("24Kf"); #endif + mc->default_ram_id =3D "mips_malta.ram"; } =20 DEFINE_MACHINE("malta", mips_malta_machine_init) --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581962657883406.23696663281; Mon, 17 Feb 2020 10:04:17 -0800 (PST) Received: from localhost ([::1]:49840 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kki-0006Cs-Lf for importer@patchew.org; Mon, 17 Feb 2020 13:04:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38720) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJh-0003H0-4G for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJf-0002Uw-Ub for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:21 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:32766 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJf-0002Ua-Qn for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:19 -0500 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-125-HlURYlpcN8-lZWhakf-wbA-1; Mon, 17 Feb 2020 12:36:17 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F3B99800D50 for ; Mon, 17 Feb 2020 17:36:16 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4EED98CCE0; Mon, 17 Feb 2020 17:36:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960979; 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=zAr7XNH7fQkrCNv6s8Lng6uB+GCUGpt2S/bnGKtEZKM=; b=Wv798edJD4KXDV2KTImAezDSPjneTTRr7nbIA7Iv36mrK1zJMRj21/U41VcVanz3oca3P2 PkEalV1DEZ3Z8qvP/7ci2nc1KKn/ba4WEjK1CHXb/VPZP64n7qHGuLG+/kGMnMoTxLgd0+ Z6Yb2VyZIOybgVTi/VjTRUOnFS5Ws5w= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 56/79] mips/mips_mipssim: use memdev for RAM Date: Mon, 17 Feb 2020 12:34:29 -0500 Message-Id: <20200217173452.15243-57-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: HlURYlpcN8-lZWhakf-wbA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- hw/mips/mips_mipssim.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/hw/mips/mips_mipssim.c b/hw/mips/mips_mipssim.c index b934ca9d51..b2555ddb89 100644 --- a/hw/mips/mips_mipssim.c +++ b/hw/mips/mips_mipssim.c @@ -143,14 +143,12 @@ static void mipsnet_init(int base, qemu_irq irq, NICI= nfo *nd) static void mips_mipssim_init(MachineState *machine) { - ram_addr_t ram_size =3D machine->ram_size; const char *kernel_filename =3D machine->kernel_filename; const char *kernel_cmdline =3D machine->kernel_cmdline; const char *initrd_filename =3D machine->initrd_filename; char *filename; MemoryRegion *address_space_mem =3D get_system_memory(); MemoryRegion *isa =3D g_new(MemoryRegion, 1); - MemoryRegion *ram =3D g_new(MemoryRegion, 1); MemoryRegion *bios =3D g_new(MemoryRegion, 1); MIPSCPU *cpu; CPUMIPSState *env; @@ -167,13 +165,11 @@ mips_mipssim_init(MachineState *machine) qemu_register_reset(main_cpu_reset, reset_info); =20 /* Allocate RAM. */ - memory_region_allocate_system_memory(ram, NULL, "mips_mipssim.ram", - ram_size); memory_region_init_ram(bios, NULL, "mips_mipssim.bios", BIOS_SIZE, &error_fatal); memory_region_set_readonly(bios, true); =20 - memory_region_add_subregion(address_space_mem, 0, ram); + memory_region_add_subregion(address_space_mem, 0, machine->ram); =20 /* Map the BIOS / boot exception handler. */ memory_region_add_subregion(address_space_mem, 0x1fc00000LL, bios); @@ -200,7 +196,7 @@ mips_mipssim_init(MachineState *machine) } =20 if (kernel_filename) { - loaderparams.ram_size =3D ram_size; + loaderparams.ram_size =3D machine->ram_size; loaderparams.kernel_filename =3D kernel_filename; loaderparams.kernel_cmdline =3D kernel_cmdline; loaderparams.initrd_filename =3D initrd_filename; @@ -245,6 +241,7 @@ static void mips_mipssim_machine_init(MachineClass *mc) #else mc->default_cpu_type =3D MIPS_CPU_TYPE_NAME("24Kf"); #endif + mc->default_ram_id =3D "mips_mipssim.ram"; } =20 DEFINE_MACHINE("mipssim", mips_mipssim_machine_init) --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581962765145701.540788149198; Mon, 17 Feb 2020 10:06:05 -0800 (PST) Received: from localhost ([::1]:49878 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kmR-0001DT-QX for importer@patchew.org; Mon, 17 Feb 2020 13:06:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38732) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJi-0003K2-49 for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJh-0002Vf-0k for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:22 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:59153 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJg-0002VK-St for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:20 -0500 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-53-EohZX9F3Mu-Alzl8Xx0u9w-1; Mon, 17 Feb 2020 12:36:18 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F0BAC800D55 for ; Mon, 17 Feb 2020 17:36:17 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4B1E18CCE0; Mon, 17 Feb 2020 17:36:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960980; 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=sYXuDbjJcUSvNaDuoVXNHT9Sh856w+KlNFUz7bVm8lU=; b=OgODzL0OnOjjn3DaUj79BPwvplfU6zGg6vZ8byjJr16M4p38y5zFkNlPB7Nof3IUqbhq2f KcIirTzn8vrn2C8jNuUgaaAiB4JhZ8/2HzAFf51ZmUMi/tfih+HTJi8/QcgTsC7PGngBiW E0FMoxUjNlndafye6wzYtGf4q0EEZf4= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 57/79] mips/mips_r4k: use memdev for RAM Date: Mon, 17 Feb 2020 12:34:30 -0500 Message-Id: <20200217173452.15243-58-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: EohZX9F3Mu-Alzl8Xx0u9w-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/mips/mips_r4k.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/hw/mips/mips_r4k.c b/hw/mips/mips_r4k.c index b2aec434c3..258cd91578 100644 --- a/hw/mips/mips_r4k.c +++ b/hw/mips/mips_r4k.c @@ -171,13 +171,11 @@ static const int sector_len =3D 32 * KiB; static void mips_r4k_init(MachineState *machine) { - ram_addr_t ram_size =3D machine->ram_size; const char *kernel_filename =3D machine->kernel_filename; const char *kernel_cmdline =3D machine->kernel_cmdline; const char *initrd_filename =3D machine->initrd_filename; char *filename; MemoryRegion *address_space_mem =3D get_system_memory(); - MemoryRegion *ram =3D g_new(MemoryRegion, 1); MemoryRegion *bios; MemoryRegion *iomem =3D g_new(MemoryRegion, 1); MemoryRegion *isa_io =3D g_new(MemoryRegion, 1); @@ -203,14 +201,12 @@ void mips_r4k_init(MachineState *machine) qemu_register_reset(main_cpu_reset, reset_info); =20 /* allocate RAM */ - if (ram_size > 256 * MiB) { + if (machine->ram_size > 256 * MiB) { error_report("Too much memory for this machine: %" PRId64 "MB," " maximum 256MB", ram_size / MiB); exit(1); } - memory_region_allocate_system_memory(ram, NULL, "mips_r4k.ram", ram_si= ze); - - memory_region_add_subregion(address_space_mem, 0, ram); + memory_region_add_subregion(address_space_mem, 0, machine->ram); =20 memory_region_init_io(iomem, NULL, &mips_qemu_ops, NULL, "mips-qemu", 0x10000); @@ -261,7 +257,7 @@ void mips_r4k_init(MachineState *machine) g_free(filename); =20 if (kernel_filename) { - loaderparams.ram_size =3D ram_size; + loaderparams.ram_size =3D machine->ram_size; loaderparams.kernel_filename =3D kernel_filename; loaderparams.kernel_cmdline =3D kernel_cmdline; loaderparams.initrd_filename =3D initrd_filename; @@ -316,7 +312,7 @@ static void mips_machine_init(MachineClass *mc) #else mc->default_cpu_type =3D MIPS_CPU_TYPE_NAME("24Kf"); #endif - + mc->default_ram_id =3D "mips_r4k.ram"; } =20 DEFINE_MACHINE("mips", mips_machine_init) --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581962666150963.1592860555019; Mon, 17 Feb 2020 10:04:26 -0800 (PST) Received: from localhost ([::1]:49844 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kkq-0006UH-R5 for importer@patchew.org; Mon, 17 Feb 2020 13:04:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38743) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJj-0003Mf-38 for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJh-0002WK-Ua for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:22 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:55078 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJh-0002W0-QT for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:21 -0500 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-332-dXRm9iUFNcai2679vC9few-1; Mon, 17 Feb 2020 12:36:19 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EEDD4477 for ; Mon, 17 Feb 2020 17:36:18 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4AAAD8CCE0; Mon, 17 Feb 2020 17:36:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960981; 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=/0rnMnrfVOQVq8Dbi8QkTyx24LM2BYcTHXIBH2VrpGM=; b=fb4/oZKH4PvDi5W3Eb+XdXQu+YhwEluKT6s/vHiO9trRCMmWO9GJAUsCBw+/DGB38BC/Ta OEnLfJ/ha/SrOU342VgQ/WeP2XPGdp2EJUgz1CjCvllvMBlif/OK38O5gD9uJxMEhCwIh8 7BODZiu5zLmn3gmoPksCH8LAXI5Aqcs= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 58/79] ppc/e500: drop RAM size fixup Date: Mon, 17 Feb 2020 12:34:31 -0500 Message-Id: <20200217173452.15243-59-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: dXRm9iUFNcai2679vC9few-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" If user provided non-sense RAM size, board will complain and continue running with max RAM size supported. Also RAM is going to be allocated by generic code, so it won't be possible for board to fix things up for user. Make it error message and exit to force user fix CLI, instead of accepting non-sense CLI values. While at it, replace usage of global ram_size with machine->ram_size Signed-off-by: Igor Mammedov Acked-by: David Gibson Reviewed-by: Richard Henderson --- v2: * fix format string cousing build failure on 32-bit host (Philippe Mathieu-Daud=C3=A9 ) --- hw/ppc/e500.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index 886442e54f..960024b611 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -906,12 +906,14 @@ void ppce500_init(MachineState *machine) =20 env =3D firstenv; =20 - /* Fixup Memory size on a alignment boundary */ - ram_size &=3D ~(RAM_SIZES_ALIGN - 1); - machine->ram_size =3D ram_size; + if (!QEMU_IS_ALIGNED(machine->ram_size, RAM_SIZES_ALIGN)) { + error_report("RAM size must be multiple of %" PRIu64, RAM_SIZES_AL= IGN); + exit(EXIT_FAILURE); + } =20 /* Register Memory */ - memory_region_allocate_system_memory(ram, NULL, "mpc8544ds.ram", ram_s= ize); + memory_region_allocate_system_memory(ram, NULL, "mpc8544ds.ram", + machine->ram_size); memory_region_add_subregion(address_space_mem, 0, ram); =20 dev =3D qdev_create(NULL, "e500-ccsr"); @@ -1083,7 +1085,7 @@ void ppce500_init(MachineState *machine) kernel_base =3D cur_base; kernel_size =3D load_image_targphys(machine->kernel_filename, cur_base, - ram_size - cur_base); + machine->ram_size - cur_base); if (kernel_size < 0) { error_report("could not load kernel '%s'", machine->kernel_filename); @@ -1097,7 +1099,7 @@ void ppce500_init(MachineState *machine) if (machine->initrd_filename) { initrd_base =3D (cur_base + INITRD_LOAD_PAD) & ~INITRD_PAD_MASK; initrd_size =3D load_image_targphys(machine->initrd_filename, init= rd_base, - ram_size - initrd_base); + machine->ram_size - initrd_base); =20 if (initrd_size < 0) { error_report("could not load initial ram disk '%s'", @@ -1115,7 +1117,7 @@ void ppce500_init(MachineState *machine) * ensures enough space between kernel and initrd. */ dt_base =3D (loadaddr + payload_size + DTC_LOAD_PAD) & ~DTC_PAD_MASK; - if (dt_base + DTB_MAX_SIZE > ram_size) { + if (dt_base + DTB_MAX_SIZE > machine->ram_size) { error_report("not enough memory for device tree"); exit(1); } --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15819627742171016.6647094711233; Mon, 17 Feb 2020 10:06:14 -0800 (PST) Received: from localhost ([::1]:49882 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kma-0001YV-V5 for importer@patchew.org; Mon, 17 Feb 2020 13:06:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38754) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJk-0003Rs-H2 for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJj-0002XD-BB for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:24 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:31411 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJj-0002Ww-76 for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:23 -0500 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-30-QtbycJLbPuiZZRduRjJCnw-1; Mon, 17 Feb 2020 12:36:20 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EA21618FE862 for ; Mon, 17 Feb 2020 17:36:19 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 45CB090526; Mon, 17 Feb 2020 17:36:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960982; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8pIeuj771i4fh6siWyKf4GMPb0/HQoeSenOWEdqOu68=; b=iO/AfAKCxY+/mMODaNZTMTE147GwWsx+TjTZ7otaOhvSJFMZUQHLiwpJv0wYTJEvSdK1hA Sh8GOheFXuFrb1cleAQMFt20ONVxri39U6rvQkh0k5QomaUoiok8ys6F97r88uKrcxOBVP wxgIyTmZmz6+PR9G3JyJhtlPZyDrRwg= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 59/79] ppc/e500: use memdev for RAM Date: Mon, 17 Feb 2020 12:34:32 -0500 Message-Id: <20200217173452.15243-60-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: QtbycJLbPuiZZRduRjJCnw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Acked-by: David Gibson Reviewed-by: Richard Henderson --- hw/ppc/e500.c | 5 +---- hw/ppc/e500plat.c | 1 + hw/ppc/mpc8544ds.c | 1 + 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index 960024b611..d5dfe9fb84 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -831,7 +831,6 @@ static void ppce500_power_off(void *opaque, int line, i= nt on) void ppce500_init(MachineState *machine) { MemoryRegion *address_space_mem =3D get_system_memory(); - MemoryRegion *ram =3D g_new(MemoryRegion, 1); PPCE500MachineState *pms =3D PPCE500_MACHINE(machine); const PPCE500MachineClass *pmc =3D PPCE500_MACHINE_GET_CLASS(machine); PCIBus *pci_bus; @@ -912,9 +911,7 @@ void ppce500_init(MachineState *machine) } =20 /* Register Memory */ - memory_region_allocate_system_memory(ram, NULL, "mpc8544ds.ram", - machine->ram_size); - memory_region_add_subregion(address_space_mem, 0, ram); + memory_region_add_subregion(address_space_mem, 0, machine->ram); =20 dev =3D qdev_create(NULL, "e500-ccsr"); object_property_add_child(qdev_get_machine(), "e500-ccsr", diff --git a/hw/ppc/e500plat.c b/hw/ppc/e500plat.c index 7078386300..bddd5e7c48 100644 --- a/hw/ppc/e500plat.c +++ b/hw/ppc/e500plat.c @@ -97,6 +97,7 @@ static void e500plat_machine_class_init(ObjectClass *oc, = void *data) mc->init =3D e500plat_init; mc->max_cpus =3D 32; mc->default_cpu_type =3D POWERPC_CPU_TYPE_NAME("e500v2_v30"); + mc->default_ram_id =3D "mpc8544ds.ram"; machine_class_allow_dynamic_sysbus_dev(mc, TYPE_ETSEC_COMMON); } =20 diff --git a/hw/ppc/mpc8544ds.c b/hw/ppc/mpc8544ds.c index c2c5e11fa1..81177505f0 100644 --- a/hw/ppc/mpc8544ds.c +++ b/hw/ppc/mpc8544ds.c @@ -55,6 +55,7 @@ static void e500plat_machine_class_init(ObjectClass *oc, = void *data) mc->init =3D mpc8544ds_init; mc->max_cpus =3D 15; mc->default_cpu_type =3D POWERPC_CPU_TYPE_NAME("e500v2_v30"); + mc->default_ram_id =3D "mpc8544ds.ram"; } =20 #define TYPE_MPC8544DS_MACHINE MACHINE_TYPE_NAME("mpc8544ds") --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581962892312633.8726153929248; Mon, 17 Feb 2020 10:08:12 -0800 (PST) Received: from localhost ([::1]:49912 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3koU-0005Qk-Ua for importer@patchew.org; Mon, 17 Feb 2020 13:08:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38785) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJn-0003ZK-BN for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJm-0002Yr-B2 for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:27 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:25929 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJm-0002YU-7E for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:26 -0500 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-204-N20GXbolPzequCi6_xKiow-1; Mon, 17 Feb 2020 12:36:21 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E578C800D55 for ; Mon, 17 Feb 2020 17:36:20 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 410739052B; Mon, 17 Feb 2020 17:36:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960985; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XvszvxXv1yozaq7K8aTlpX8tkYNlPmoB+INlrIrhk5I=; b=bHp0JAWwH2GJzxhf3YQu1aJnvhwJoKlKGbo1KlssB602y0U/Ed1wZh3nMq1+vc9JwqPfVG lxhfwZD3zLQvmvLzrbYxpqQEIFHpVC5WtSQX3Vfnzg7d1osldjLFe3G2HBFCsEHOrZHDd1 Bh2eGapVwkRcghwfyZL1EZbQgWYs9ok= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 60/79] ppc/mac_newworld: use memdev for RAM Date: Mon, 17 Feb 2020 12:34:33 -0500 Message-Id: <20200217173452.15243-61-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: N20GXbolPzequCi6_xKiow-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Acked-by: David Gibson Acked-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- hw/ppc/mac_newworld.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c index 464d012103..b8189bf7a4 100644 --- a/hw/ppc/mac_newworld.c +++ b/hw/ppc/mac_newworld.c @@ -118,7 +118,7 @@ static void ppc_core99_init(MachineState *machine) char *filename; IrqLines *openpic_irqs; int linux_boot, i, j, k; - MemoryRegion *ram =3D g_new(MemoryRegion, 1), *bios =3D g_new(MemoryRe= gion, 1); + MemoryRegion *bios =3D g_new(MemoryRegion, 1); hwaddr kernel_base, initrd_base, cmdline_base =3D 0; long kernel_size, initrd_size; UNINHostState *uninorth_pci; @@ -152,8 +152,7 @@ static void ppc_core99_init(MachineState *machine) } =20 /* allocate RAM */ - memory_region_allocate_system_memory(ram, NULL, "ppc_core99.ram", ram_= size); - memory_region_add_subregion(get_system_memory(), 0, ram); + memory_region_add_subregion(get_system_memory(), 0, machine->ram); =20 /* allocate and load BIOS */ memory_region_init_ram(bios, NULL, "ppc_core99.bios", BIOS_SIZE, @@ -586,6 +585,7 @@ static void core99_machine_class_init(ObjectClass *oc, = void *data) #else mc->default_cpu_type =3D POWERPC_CPU_TYPE_NAME("7400_v2.9"); #endif + mc->default_ram_id =3D "ppc_core99.ram"; mc->ignore_boot_device_suffixes =3D true; fwc->get_dev_path =3D core99_fw_dev_path; } --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581962882603999.8727239464044; Mon, 17 Feb 2020 10:08:02 -0800 (PST) Received: from localhost ([::1]:49908 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3koL-00057J-Cw for importer@patchew.org; Mon, 17 Feb 2020 13:08:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38766) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJm-0003XB-8R for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJl-0002Y8-5j for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:26 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:39971 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJl-0002Xs-1k for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:25 -0500 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-394-UkhsQd54MfenvvXh64EDTg-1; Mon, 17 Feb 2020 12:36:22 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E23FCDB20 for ; Mon, 17 Feb 2020 17:36:21 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3CA2F90526; Mon, 17 Feb 2020 17:36:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960984; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Y8OXOFlUy6HW7z5mxWmXiuD5eqJHRIK5b2zLHi4H+VY=; b=QtRQ79ixB3BhtE+rlZDnLmZJlTrkRoqyHuZBnaJsn+I+TRDcmFoT9YPLQijvmG6gd+FOhE H0Q4xoGGH6T6dFUaGuDKDhpLyALCrqFEIA7fcnEAYOzWKQ7UzoZ70TbexcYYfh9rTvjlGz 0ZYrJpebPbEmKagSHVI1AG7qcnLNOSE= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 61/79] ppc/mac_oldworld: use memdev for RAM Date: Mon, 17 Feb 2020 12:34:34 -0500 Message-Id: <20200217173452.15243-62-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: UkhsQd54MfenvvXh64EDTg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Acked-by: David Gibson Acked-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- hw/ppc/mac_oldworld.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c index 7318d7e9b4..66e434bba3 100644 --- a/hw/ppc/mac_oldworld.c +++ b/hw/ppc/mac_oldworld.c @@ -91,7 +91,6 @@ static void ppc_heathrow_init(MachineState *machine) CPUPPCState *env =3D NULL; char *filename; int linux_boot, i; - MemoryRegion *ram =3D g_new(MemoryRegion, 1); MemoryRegion *bios =3D g_new(MemoryRegion, 1); uint32_t kernel_base, initrd_base, cmdline_base =3D 0; int32_t kernel_size, initrd_size; @@ -127,9 +126,7 @@ static void ppc_heathrow_init(MachineState *machine) exit(1); } =20 - memory_region_allocate_system_memory(ram, NULL, "ppc_heathrow.ram", - ram_size); - memory_region_add_subregion(sysmem, 0, ram); + memory_region_add_subregion(sysmem, 0, machine->ram); =20 /* allocate and load BIOS */ memory_region_init_ram(bios, NULL, "ppc_heathrow.bios", BIOS_SIZE, @@ -446,6 +443,7 @@ static void heathrow_class_init(ObjectClass *oc, void *= data) mc->default_cpu_type =3D POWERPC_CPU_TYPE_NAME("750_v3.1"); mc->default_display =3D "std"; mc->ignore_boot_device_suffixes =3D true; + mc->default_ram_id =3D "ppc_heathrow.ram"; fwc->get_dev_path =3D heathrow_fw_dev_path; } =20 --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581962536278651.8735440814086; Mon, 17 Feb 2020 10:02:16 -0800 (PST) Received: from localhost ([::1]:49804 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kik-0002hV-UB for importer@patchew.org; Mon, 17 Feb 2020 13:02:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38783) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJn-0003ZD-3l for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJm-0002Yf-0F for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:27 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:42002 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJl-0002YK-SW for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:25 -0500 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-233-AbI7GZU1NUGnwOkmmLowrw-1; Mon, 17 Feb 2020 12:36:23 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DF371800D55 for ; Mon, 17 Feb 2020 17:36:22 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3924890508; Mon, 17 Feb 2020 17:36:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960985; 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=fSUAjMpxIWZDJIVwcTzfmeK2PwZsmqRdAmRJhHEnCiA=; b=FTU+SZW6pb6xfudwi7732G1zDEa4pOzBGwva3r60emEjQMWnDaSxqjhGW43PKiZQ/3w5dm PsXHNpOP6igCd0T+FBB7DwiR0+qgjLmt1IZXibmAWFi3p03EZ80tEnVxkup2/qGr45qzvx H0S7cHbWGxWpbTlQdsTKOn2VfP5LZeY= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 62/79] ppc/pnv: use memdev for RAM Date: Mon, 17 Feb 2020 12:34:35 -0500 Message-Id: <20200217173452.15243-63-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: AbI7GZU1NUGnwOkmmLowrw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Acked-by: David Gibson Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Richard Henderson --- hw/ppc/pnv.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index 139c857b1e..ea20a1dc3e 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -690,7 +690,6 @@ static void pnv_init(MachineState *machine) { PnvMachineState *pnv =3D PNV_MACHINE(machine); MachineClass *mc =3D MACHINE_GET_CLASS(machine); - MemoryRegion *ram; char *fw_filename; long fw_size; int i; @@ -702,11 +701,7 @@ static void pnv_init(MachineState *machine) if (machine->ram_size < (1 * GiB)) { warn_report("skiboot may not work with < 1GB of RAM"); } - - ram =3D g_new(MemoryRegion, 1); - memory_region_allocate_system_memory(ram, NULL, "pnv.ram", - machine->ram_size); - memory_region_add_subregion(get_system_memory(), 0, ram); + memory_region_add_subregion(get_system_memory(), 0, machine->ram); =20 /* * Create our simple PNOR device @@ -1976,6 +1971,7 @@ static void pnv_machine_class_init(ObjectClass *oc, v= oid *data) * enough to fit the maximum initrd size at it's load address */ mc->default_ram_size =3D INITRD_LOAD_ADDR + INITRD_MAX_SIZE; + mc->default_ram_id =3D "pnv.ram"; ispc->print_info =3D pnv_pic_print_info; =20 object_class_property_add_bool(oc, "hb-mode", --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581963077875659.1754273109514; Mon, 17 Feb 2020 10:11:17 -0800 (PST) Received: from localhost ([::1]:49992 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3krU-0003uW-KS for importer@patchew.org; Mon, 17 Feb 2020 13:11:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38807) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJp-0003b4-OH for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJn-0002au-T5 for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:29 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:28456 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJn-0002aD-P8 for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:27 -0500 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-254-6k9nDoTANu6AWssw2Evq7Q-1; Mon, 17 Feb 2020 12:36:24 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DB8DC107ACC5 for ; Mon, 17 Feb 2020 17:36:23 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3568890508; Mon, 17 Feb 2020 17:36:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960987; 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=CzaMa2kKWhTRzRdtdwV2dqaoAh9/kN9hd9AXbgTURto=; b=Y+4CtUUfzmjNzy+hnIJPujdtMJQF18Ws+q+ZR39UnEUBVLAO1DAtRlmx12Loh6u15+zj7J YdvdIxYyxFBpNu21ebemWnz6Wd7q2Kcqyfs6uLUWR3k7I+tcXnGbLSJrkFMK+QLWRY24NZ VKEiSRr3USqNDZ3KaHGYX/10CJWAmYI= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 63/79] ppc/ppc405_boards: add RAM size checks Date: Mon, 17 Feb 2020 12:34:36 -0500 Message-Id: <20200217173452.15243-64-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: 6k9nDoTANu6AWssw2Evq7Q-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" If user provided non-sense RAM size, board will ignore it and continue running with fixed RAM size. Also RAM is going to be allocated by generic code, so it won't be possible for board to fix CLI. Make it error message and exit to force user fix CLI, instead of accepting non-sense CLI values. PS: move fixed RAM size into mc->default_ram_size, so that generic code will know how much to allocate. Signed-off-by: Igor Mammedov Acked-by: David Gibson Reviewed-by: Richard Henderson --- v2: * fix format string causing build failure on 32-bit host (Philippe Mathieu-Daud=C3=A9 ) v3: * use size_to_str() to pretty print size in MiB (Philippe Mathieu-Daud=C3=A9 / BALATON Zoltan ) --- hw/ppc/ppc405_boards.c | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/hw/ppc/ppc405_boards.c b/hw/ppc/ppc405_boards.c index 1f721feed6..057882a5d2 100644 --- a/hw/ppc/ppc405_boards.c +++ b/hw/ppc/ppc405_boards.c @@ -40,6 +40,7 @@ #include "qemu/error-report.h" #include "hw/loader.h" #include "exec/address-spaces.h" +#include "qemu/cutils.h" =20 #define BIOS_FILENAME "ppc405_rom.bin" #define BIOS_SIZE (2 * MiB) @@ -137,7 +138,7 @@ static void ref405ep_fpga_init(MemoryRegion *sysmem, ui= nt32_t base) =20 static void ref405ep_init(MachineState *machine) { - ram_addr_t ram_size =3D machine->ram_size; + MachineClass *mc =3D MACHINE_GET_CLASS(machine); const char *kernel_filename =3D machine->kernel_filename; const char *kernel_cmdline =3D machine->kernel_cmdline; const char *initrd_filename =3D machine->initrd_filename; @@ -161,15 +162,21 @@ static void ref405ep_init(MachineState *machine) DriveInfo *dinfo; MemoryRegion *sysmem =3D get_system_memory(); =20 + if (machine->ram_size !=3D mc->default_ram_size) { + char *sz =3D size_to_str(mc->default_ram_size); + error_report("Invalid RAM size, should be %s", sz); + g_free(sz); + exit(EXIT_FAILURE); + } + /* XXX: fix this */ memory_region_allocate_system_memory(&ram_memories[0], NULL, "ef405ep.= ram", - 0x08000000); + machine->ram_size); ram_bases[0] =3D 0; - ram_sizes[0] =3D 0x08000000; + ram_sizes[0] =3D machine->ram_size; memory_region_init(&ram_memories[1], NULL, "ef405ep.ram1", 0); ram_bases[1] =3D 0x00000000; ram_sizes[1] =3D 0x00000000; - ram_size =3D 128 * MiB; env =3D ppc405ep_init(sysmem, ram_memories, ram_bases, ram_sizes, 33333333, &pic, kernel_filename =3D=3D NULL ? 0 : = 1); /* allocate SRAM */ @@ -227,7 +234,7 @@ static void ref405ep_init(MachineState *machine) if (linux_boot) { memset(&bd, 0, sizeof(bd)); bd.bi_memstart =3D 0x00000000; - bd.bi_memsize =3D ram_size; + bd.bi_memsize =3D machine->ram_size; bd.bi_flashstart =3D -bios_size; bd.bi_flashsize =3D -bios_size; bd.bi_flashoffset =3D 0; @@ -255,7 +262,7 @@ static void ref405ep_init(MachineState *machine) kernel_base =3D KERNEL_LOAD_ADDR; /* now we can load the kernel */ kernel_size =3D load_image_targphys(kernel_filename, kernel_base, - ram_size - kernel_base); + machine->ram_size - kernel_base); if (kernel_size < 0) { error_report("could not load kernel '%s'", kernel_filename); exit(1); @@ -266,7 +273,7 @@ static void ref405ep_init(MachineState *machine) if (initrd_filename) { initrd_base =3D INITRD_LOAD_ADDR; initrd_size =3D load_image_targphys(initrd_filename, initrd_ba= se, - ram_size - initrd_base); + machine->ram_size - initrd_b= ase); if (initrd_size < 0) { error_report("could not load initial ram disk '%s'", initrd_filename); @@ -304,6 +311,7 @@ static void ref405ep_class_init(ObjectClass *oc, void *= data) =20 mc->desc =3D "ref405ep"; mc->init =3D ref405ep_init; + mc->default_ram_size =3D 0x08000000; } =20 static const TypeInfo ref405ep_type =3D { @@ -408,7 +416,7 @@ static void taihu_cpld_init(MemoryRegion *sysmem, uint3= 2_t base) =20 static void taihu_405ep_init(MachineState *machine) { - ram_addr_t ram_size =3D machine->ram_size; + MachineClass *mc =3D MACHINE_GET_CLASS(machine); const char *kernel_filename =3D machine->kernel_filename; const char *initrd_filename =3D machine->initrd_filename; char *filename; @@ -425,10 +433,14 @@ static void taihu_405ep_init(MachineState *machine) int fl_idx; DriveInfo *dinfo; =20 - /* RAM is soldered to the board so the size cannot be changed */ - ram_size =3D 0x08000000; + if (machine->ram_size !=3D mc->default_ram_size) { + char *sz =3D size_to_str(mc->default_ram_size); + error_report("Invalid RAM size, should be %s", sz); + g_free(sz); + exit(EXIT_FAILURE); + } memory_region_allocate_system_memory(ram, NULL, "taihu_405ep.ram", - ram_size); + machine->ram_size); =20 ram_bases[0] =3D 0; ram_sizes[0] =3D 0x04000000; @@ -500,7 +512,7 @@ static void taihu_405ep_init(MachineState *machine) kernel_base =3D KERNEL_LOAD_ADDR; /* now we can load the kernel */ kernel_size =3D load_image_targphys(kernel_filename, kernel_base, - ram_size - kernel_base); + machine->ram_size - kernel_base); if (kernel_size < 0) { error_report("could not load kernel '%s'", kernel_filename); exit(1); @@ -509,7 +521,7 @@ static void taihu_405ep_init(MachineState *machine) if (initrd_filename) { initrd_base =3D INITRD_LOAD_ADDR; initrd_size =3D load_image_targphys(initrd_filename, initrd_ba= se, - ram_size - initrd_base); + machine->ram_size - initrd_b= ase); if (initrd_size < 0) { error_report("could not load initial ram disk '%s'", initrd_filename); @@ -533,6 +545,7 @@ static void taihu_class_init(ObjectClass *oc, void *dat= a) =20 mc->desc =3D "taihu"; mc->init =3D taihu_405ep_init; + mc->default_ram_size =3D 0x08000000; } =20 static const TypeInfo taihu_type =3D { --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581962987725885.2981572463008; Mon, 17 Feb 2020 10:09:47 -0800 (PST) Received: from localhost ([::1]:49950 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kq2-0000Q8-5l for importer@patchew.org; Mon, 17 Feb 2020 13:09:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38808) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJp-0003b5-OY for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJo-0002bS-84 for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:29 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:20472 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJo-0002aq-4O for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:28 -0500 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-292-7xSRNQVGM6O5ZD-iqE50iQ-1; Mon, 17 Feb 2020 12:36:25 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D6A06DB2D for ; Mon, 17 Feb 2020 17:36:24 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3250690508; Mon, 17 Feb 2020 17:36:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960987; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=U9RXjzAFMlQ04LRxPud2paweRUI+0ipi3VFGhmf1S1M=; b=Lnlnwwj2UBegm8MyzKtoAZPuapJ54oJ/oCJY02eco//tbwH37S5fFK16Dm/M2zp81E6Eyt 49s0QsiQ3Xon3nxl2jpm/0hx6zn8J+7UQM61uLCpIfUeYtdq2jChKFTo6G6LbcbvpT2TG1 kVhT5HAuqaNNQ5xjhBjY6pNfX8rBJWA= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 64/79] ppc/ppc405_boards: use memdev for RAM Date: Mon, 17 Feb 2020 12:34:37 -0500 Message-Id: <20200217173452.15243-65-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: 7xSRNQVGM6O5ZD-iqE50iQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. PS: in ref405ep alias RAM into ram_memories[] to avoid re-factoring its user ppc405ep_init(), which would be invasive and out of scope this patch. Signed-off-by: Igor Mammedov Acked-by: David Gibson Reviewed-by: Richard Henderson --- hw/ppc/ppc405_boards.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/hw/ppc/ppc405_boards.c b/hw/ppc/ppc405_boards.c index 057882a5d2..f9c5b7791e 100644 --- a/hw/ppc/ppc405_boards.c +++ b/hw/ppc/ppc405_boards.c @@ -170,8 +170,8 @@ static void ref405ep_init(MachineState *machine) } =20 /* XXX: fix this */ - memory_region_allocate_system_memory(&ram_memories[0], NULL, "ef405ep.= ram", - machine->ram_size); + memory_region_init_alias(&ram_memories[0], NULL, "ef405ep.ram.alias", + machine->ram, 0, machine->ram_size); ram_bases[0] =3D 0; ram_sizes[0] =3D machine->ram_size; memory_region_init(&ram_memories[1], NULL, "ef405ep.ram1", 0); @@ -312,6 +312,7 @@ static void ref405ep_class_init(ObjectClass *oc, void *= data) mc->desc =3D "ref405ep"; mc->init =3D ref405ep_init; mc->default_ram_size =3D 0x08000000; + mc->default_ram_id =3D "ef405ep.ram"; } =20 static const TypeInfo ref405ep_type =3D { @@ -424,7 +425,6 @@ static void taihu_405ep_init(MachineState *machine) MemoryRegion *sysmem =3D get_system_memory(); MemoryRegion *bios; MemoryRegion *ram_memories =3D g_new(MemoryRegion, 2); - MemoryRegion *ram =3D g_malloc0(sizeof(*ram)); hwaddr ram_bases[2], ram_sizes[2]; long bios_size; target_ulong kernel_base, initrd_base; @@ -439,18 +439,16 @@ static void taihu_405ep_init(MachineState *machine) g_free(sz); exit(EXIT_FAILURE); } - memory_region_allocate_system_memory(ram, NULL, "taihu_405ep.ram", - machine->ram_size); =20 ram_bases[0] =3D 0; ram_sizes[0] =3D 0x04000000; memory_region_init_alias(&ram_memories[0], NULL, - "taihu_405ep.ram-0", ram, ram_bases[0], + "taihu_405ep.ram-0", machine->ram, ram_bases[= 0], ram_sizes[0]); ram_bases[1] =3D 0x04000000; ram_sizes[1] =3D 0x04000000; memory_region_init_alias(&ram_memories[1], NULL, - "taihu_405ep.ram-1", ram, ram_bases[1], + "taihu_405ep.ram-1", machine->ram, ram_bases[= 1], ram_sizes[1]); ppc405ep_init(sysmem, ram_memories, ram_bases, ram_sizes, 33333333, &pic, kernel_filename =3D=3D NULL ? 0 : 1); @@ -546,6 +544,7 @@ static void taihu_class_init(ObjectClass *oc, void *dat= a) mc->desc =3D "taihu"; mc->init =3D taihu_405ep_init; mc->default_ram_size =3D 0x08000000; + mc->default_ram_id =3D "ef405ep.ram"; } =20 static const TypeInfo taihu_type =3D { --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581963265134184.7786214767807; Mon, 17 Feb 2020 10:14:25 -0800 (PST) Received: from localhost ([::1]:50052 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kuV-0002Gu-Hh for importer@patchew.org; Mon, 17 Feb 2020 13:14:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38834) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJr-0003dA-Py for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJp-0002cj-Tp for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:31 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:27791 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJp-0002cH-NV for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:29 -0500 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-315-fgnx6BP9MRqMTMlnR0Qk4A-1; Mon, 17 Feb 2020 12:36:26 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D1BEF107ACC9 for ; Mon, 17 Feb 2020 17:36:25 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D3F990508; Mon, 17 Feb 2020 17:36:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960989; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sHWMUFa73lTUQEd0sw2Y9Y0Wd20BoHklb9WnclL5faA=; b=bLMLFpEMkCBmqsBg8mgiScBiO1QpvMJQZ8ycBK5XX7rPWbjGaUT6Q5Zfb+NdIlcETEqIhl rUqWUYJ1+ZTPQQ8+6mdqMSHJ3IcKTJ2FSOTrZ+hI6oHrOtkVeYe6is0fDU/rkDolAVIZ6U B2+r4x/uy947JMYhtHY6rreotwfcaIQ= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 65/79] ppc/{ppc440_bamboo, sam460ex}: drop RAM size fixup Date: Mon, 17 Feb 2020 12:34:38 -0500 Message-Id: <20200217173452.15243-66-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: fgnx6BP9MRqMTMlnR0Qk4A-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If user provided non-sense RAM size, board will complain and continue running with max RAM size supported or sometimes crash like this: %QEMU -M bamboo -m 1 exec.c:1926: find_ram_offset: Assertion `size !=3D 0' failed. Aborted (core dumped) Also RAM is going to be allocated by generic code, so it won't be possible for board to fix things up for user. Make it error message and exit to force user fix CLI, instead of accepting non-sense CLI values. That also fixes crash issue, since wrongly calculated size isn't used to allocate RAM Signed-off-by: Igor Mammedov Reviewed-by: BALATON Zoltan Acked-by: David Gibson --- v2: * s/ppc4xx_sdram_adjust/ppc4xx_sdram_prep/ (BALATON Zoltan ) * print possible valid ram size id not all RAM was distributed * initialize ram_bases/ram_bases at the same time we are checking that user supplied RAM would fit available banks and drop nested loop that were duplicating the same calculations. * coincidentally fix crash when -m is less than minimal bank size v3: * s/ppc4xx_sdram_prep/ppc4xx_sdram_banks/ (BALATON Zoltan ) * fix subject line in commit message v3.1: * add lost 'break' statement in 'j' loop v3.2: * replace global ram_size with machine->ram_size in ppc4xx_sdram_banks() = call * add a comment about the expected sorting order within sdram_bank_sizes[] (BALATON Zoltan ) --- include/hw/ppc/ppc4xx.h | 9 +++---- hw/ppc/ppc440_bamboo.c | 11 +++----- hw/ppc/ppc4xx_devs.c | 60 ++++++++++++++++++++++------------------- hw/ppc/sam460ex.c | 5 ++-- 4 files changed, 42 insertions(+), 43 deletions(-) diff --git a/include/hw/ppc/ppc4xx.h b/include/hw/ppc/ppc4xx.h index 7d82259051..b8c8f324b4 100644 --- a/include/hw/ppc/ppc4xx.h +++ b/include/hw/ppc/ppc4xx.h @@ -42,11 +42,10 @@ enum { qemu_irq *ppcuic_init (CPUPPCState *env, qemu_irq *irqs, uint32_t dcr_base, int has_ssr, int has_vr); =20 -ram_addr_t ppc4xx_sdram_adjust(ram_addr_t ram_size, int nr_banks, - MemoryRegion ram_memories[], - hwaddr ram_bases[], - hwaddr ram_sizes[], - const ram_addr_t sdram_bank_sizes[]); +void ppc4xx_sdram_banks(ram_addr_t ram_size, int nr_banks, + MemoryRegion ram_memories[], + hwaddr ram_bases[], hwaddr ram_sizes[], + const ram_addr_t sdram_bank_sizes[]); =20 void ppc4xx_sdram_init (CPUPPCState *env, qemu_irq irq, int nbanks, MemoryRegion ram_memories[], diff --git a/hw/ppc/ppc440_bamboo.c b/hw/ppc/ppc440_bamboo.c index da777ef9c2..7e3bc0ec7f 100644 --- a/hw/ppc/ppc440_bamboo.c +++ b/hw/ppc/ppc440_bamboo.c @@ -158,7 +158,6 @@ static void main_cpu_reset(void *opaque) =20 static void bamboo_init(MachineState *machine) { - ram_addr_t ram_size =3D machine->ram_size; const char *kernel_filename =3D machine->kernel_filename; const char *kernel_cmdline =3D machine->kernel_cmdline; const char *initrd_filename =3D machine->initrd_filename; @@ -203,10 +202,8 @@ static void bamboo_init(MachineState *machine) /* SDRAM controller */ memset(ram_bases, 0, sizeof(ram_bases)); memset(ram_sizes, 0, sizeof(ram_sizes)); - ram_size =3D ppc4xx_sdram_adjust(ram_size, PPC440EP_SDRAM_NR_BANKS, - ram_memories, - ram_bases, ram_sizes, - ppc440ep_sdram_bank_sizes); + ppc4xx_sdram_banks(machine->ram_size, PPC440EP_SDRAM_NR_BANKS, ram_mem= ories, + ram_bases, ram_sizes, ppc440ep_sdram_bank_sizes); /* XXX 440EP's ECC interrupts are on UIC1, but we've only created UIC0= . */ ppc4xx_sdram_init(env, pic[14], PPC440EP_SDRAM_NR_BANKS, ram_memories, ram_bases, ram_sizes, 1); @@ -268,7 +265,7 @@ static void bamboo_init(MachineState *machine) /* Load initrd. */ if (initrd_filename) { initrd_size =3D load_image_targphys(initrd_filename, RAMDISK_ADDR, - ram_size - RAMDISK_ADDR); + machine->ram_size - RAMDISK_ADDR= ); =20 if (initrd_size < 0) { error_report("could not load ram disk '%s' at %x", @@ -279,7 +276,7 @@ static void bamboo_init(MachineState *machine) =20 /* If we're loading a kernel directly, we must load the device tree to= o. */ if (kernel_filename) { - if (bamboo_load_device_tree(FDT_ADDR, ram_size, RAMDISK_ADDR, + if (bamboo_load_device_tree(FDT_ADDR, machine->ram_size, RAMDISK_A= DDR, initrd_size, kernel_cmdline) < 0) { error_report("couldn't load device tree"); exit(1); diff --git a/hw/ppc/ppc4xx_devs.c b/hw/ppc/ppc4xx_devs.c index c2e50138aa..d89008a2a4 100644 --- a/hw/ppc/ppc4xx_devs.c +++ b/hw/ppc/ppc4xx_devs.c @@ -668,21 +668,22 @@ void ppc4xx_sdram_init (CPUPPCState *env, qemu_irq ir= q, int nbanks, =20 /* Fill in consecutive SDRAM banks with 'ram_size' bytes of memory. * - * sdram_bank_sizes[] must be 0-terminated. + * sdram_bank_sizes[] must be in descending order, that is sizes[i] > size= s[i+1] + * and must be 0-terminated. * * The 4xx SDRAM controller supports a small number of banks, and each bank * must be one of a small set of sizes. The number of banks and the suppor= ted * sizes varies by SoC. */ -ram_addr_t ppc4xx_sdram_adjust(ram_addr_t ram_size, int nr_banks, - MemoryRegion ram_memories[], - hwaddr ram_bases[], - hwaddr ram_sizes[], - const ram_addr_t sdram_bank_sizes[]) +void ppc4xx_sdram_banks(ram_addr_t ram_size, int nr_banks, + MemoryRegion ram_memories[], + hwaddr ram_bases[], hwaddr ram_sizes[], + const ram_addr_t sdram_bank_sizes[]) { MemoryRegion *ram =3D g_malloc0(sizeof(*ram)); ram_addr_t size_left =3D ram_size; ram_addr_t base =3D 0; ram_addr_t bank_size; + int last_bank =3D 0; int i; int j; =20 @@ -690,7 +691,12 @@ ram_addr_t ppc4xx_sdram_adjust(ram_addr_t ram_size, in= t nr_banks, for (j =3D 0; sdram_bank_sizes[j] !=3D 0; j++) { bank_size =3D sdram_bank_sizes[j]; if (bank_size <=3D size_left) { + ram_bases[i] =3D base; + ram_sizes[i] =3D bank_size; + base +=3D bank_size; size_left -=3D bank_size; + last_bank =3D i; + break; } } if (!size_left) { @@ -699,34 +705,32 @@ ram_addr_t ppc4xx_sdram_adjust(ram_addr_t ram_size, i= nt nr_banks, } } =20 - ram_size -=3D size_left; if (size_left) { - error_report("Truncating memory to %" PRId64 " MiB to fit SDRAM" - " controller limits", ram_size / MiB); + ram_addr_t used_size =3D ram_size - size_left; + GString *s =3D g_string_new(NULL); + + for (i =3D 0; sdram_bank_sizes[i]; i++) { + g_string_append_printf(s, "%" PRIi64 "%s", + sdram_bank_sizes[i] / MiB, + sdram_bank_sizes[i + 1] ? " ," : ""); + } + error_report("Max %d banks of %s MB DIMM/bank supported", + nr_banks, s->str); + error_report("Possible valid RAM size: %" PRIi64, + used_size ? used_size / MiB : sdram_bank_sizes[i - 1] / MiB); + + g_string_free(s, true); + exit(EXIT_FAILURE); } =20 memory_region_allocate_system_memory(ram, NULL, "ppc4xx.sdram", ram_si= ze); =20 - size_left =3D ram_size; - for (i =3D 0; i < nr_banks && size_left; i++) { - for (j =3D 0; sdram_bank_sizes[j] !=3D 0; j++) { - bank_size =3D sdram_bank_sizes[j]; - - if (bank_size <=3D size_left) { - char name[32]; - snprintf(name, sizeof(name), "ppc4xx.sdram%d", i); - memory_region_init_alias(&ram_memories[i], NULL, name, ram, - base, bank_size); - ram_bases[i] =3D base; - ram_sizes[i] =3D bank_size; - base +=3D bank_size; - size_left -=3D bank_size; - break; - } - } + for (i =3D 0; i <=3D last_bank; i++) { + char name[32]; + snprintf(name, sizeof(name), "ppc4xx.sdram%d", i); + memory_region_init_alias(&ram_memories[i], NULL, name, ram, + ram_bases[i], ram_sizes[i]); } - - return ram_size; } =20 /*************************************************************************= ****/ diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c index 89bc70eb94..17d40bd672 100644 --- a/hw/ppc/sam460ex.c +++ b/hw/ppc/sam460ex.c @@ -324,9 +324,8 @@ static void sam460ex_init(MachineState *machine) /* SDRAM controller */ /* put all RAM on first bank because board has one slot * and firmware only checks that */ - machine->ram_size =3D ppc4xx_sdram_adjust(machine->ram_size, 1, - ram_memories, ram_bases, ram_sizes, - ppc460ex_sdram_bank_sizes); + ppc4xx_sdram_banks(machine->ram_size, 1, ram_memories, ram_bases, ram_= sizes, + ppc460ex_sdram_bank_sizes); =20 /* FIXME: does 460EX have ECC interrupts? */ ppc440_sdram_init(env, SDRAM_NR_BANKS, ram_memories, --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15819629837811009.2446286651625; Mon, 17 Feb 2020 10:09:43 -0800 (PST) Received: from localhost ([::1]:49944 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kpy-00008x-E0 for importer@patchew.org; Mon, 17 Feb 2020 13:09:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38835) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJr-0003dB-QN for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJq-0002cx-9y for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:31 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:46093 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJq-0002cd-60 for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:30 -0500 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-172-EaSWewPcOxa5mGEziQAc4A-1; Mon, 17 Feb 2020 12:36:27 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D0732DB22 for ; Mon, 17 Feb 2020 17:36:26 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2901490533; Mon, 17 Feb 2020 17:36:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960989; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fIvXF1g7RR3fK96YF93V0MMaB2ZgeTiydFjTSzEIFLU=; b=AJSC6tshh7sLG/3n+0G02kXDy1LltmCFYisQNhqoHYnRQE0HzAQgDxFQN+WVgGiNcHUYjK 9+hmOf7ooySzLM1M0steVzD4CuWYtTjaxWFt/PrJzwl9Dm1++NUCf2eSBny34mn65KcF4D d6C+OFuagryzRscUrMe14Hr7ZnVMcDM= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 66/79] ppc/{ppc440_bamboo, sam460ex}: use memdev for RAM Date: Mon, 17 Feb 2020 12:34:39 -0500 Message-Id: <20200217173452.15243-67-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: EaSWewPcOxa5mGEziQAc4A-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: BALATON Zoltan Acked-by: David Gibson --- v3: * drop ram_size from comment above ppc4xx_sdram_banks (BALATON Zoltan ) * move memory alias initialization into the same loop where RAM is split on banks. (BALATON Zoltan ) v3.1 * rebase on top of previous patch due to changed context --- include/hw/ppc/ppc4xx.h | 2 +- hw/ppc/ppc440_bamboo.c | 3 ++- hw/ppc/ppc4xx_devs.c | 25 +++++++++---------------- hw/ppc/sam460ex.c | 3 ++- 4 files changed, 14 insertions(+), 19 deletions(-) diff --git a/include/hw/ppc/ppc4xx.h b/include/hw/ppc/ppc4xx.h index b8c8f324b4..cc19c8da5b 100644 --- a/include/hw/ppc/ppc4xx.h +++ b/include/hw/ppc/ppc4xx.h @@ -42,7 +42,7 @@ enum { qemu_irq *ppcuic_init (CPUPPCState *env, qemu_irq *irqs, uint32_t dcr_base, int has_ssr, int has_vr); =20 -void ppc4xx_sdram_banks(ram_addr_t ram_size, int nr_banks, +void ppc4xx_sdram_banks(MemoryRegion *ram, int nr_banks, MemoryRegion ram_memories[], hwaddr ram_bases[], hwaddr ram_sizes[], const ram_addr_t sdram_bank_sizes[]); diff --git a/hw/ppc/ppc440_bamboo.c b/hw/ppc/ppc440_bamboo.c index 7e3bc0ec7f..4c5e9e4373 100644 --- a/hw/ppc/ppc440_bamboo.c +++ b/hw/ppc/ppc440_bamboo.c @@ -202,7 +202,7 @@ static void bamboo_init(MachineState *machine) /* SDRAM controller */ memset(ram_bases, 0, sizeof(ram_bases)); memset(ram_sizes, 0, sizeof(ram_sizes)); - ppc4xx_sdram_banks(machine->ram_size, PPC440EP_SDRAM_NR_BANKS, ram_mem= ories, + ppc4xx_sdram_banks(machine->ram, PPC440EP_SDRAM_NR_BANKS, ram_memories, ram_bases, ram_sizes, ppc440ep_sdram_bank_sizes); /* XXX 440EP's ECC interrupts are on UIC1, but we've only created UIC0= . */ ppc4xx_sdram_init(env, pic[14], PPC440EP_SDRAM_NR_BANKS, ram_memories, @@ -289,6 +289,7 @@ static void bamboo_machine_init(MachineClass *mc) mc->desc =3D "bamboo"; mc->init =3D bamboo_init; mc->default_cpu_type =3D POWERPC_CPU_TYPE_NAME("440epb"); + mc->default_ram_id =3D "ppc4xx.sdram"; } =20 DEFINE_MACHINE("bamboo", bamboo_machine_init) diff --git a/hw/ppc/ppc4xx_devs.c b/hw/ppc/ppc4xx_devs.c index d89008a2a4..0e2f81c4f7 100644 --- a/hw/ppc/ppc4xx_devs.c +++ b/hw/ppc/ppc4xx_devs.c @@ -666,7 +666,7 @@ void ppc4xx_sdram_init (CPUPPCState *env, qemu_irq irq,= int nbanks, sdram_map_bcr(sdram); } =20 -/* Fill in consecutive SDRAM banks with 'ram_size' bytes of memory. +/* Split RAM between SDRAM banks. * * sdram_bank_sizes[] must be in descending order, that is sizes[i] > size= s[i+1] * and must be 0-terminated. @@ -674,16 +674,14 @@ void ppc4xx_sdram_init (CPUPPCState *env, qemu_irq ir= q, int nbanks, * The 4xx SDRAM controller supports a small number of banks, and each bank * must be one of a small set of sizes. The number of banks and the suppor= ted * sizes varies by SoC. */ -void ppc4xx_sdram_banks(ram_addr_t ram_size, int nr_banks, +void ppc4xx_sdram_banks(MemoryRegion *ram, int nr_banks, MemoryRegion ram_memories[], hwaddr ram_bases[], hwaddr ram_sizes[], const ram_addr_t sdram_bank_sizes[]) { - MemoryRegion *ram =3D g_malloc0(sizeof(*ram)); - ram_addr_t size_left =3D ram_size; + ram_addr_t size_left =3D memory_region_size(ram); ram_addr_t base =3D 0; ram_addr_t bank_size; - int last_bank =3D 0; int i; int j; =20 @@ -691,11 +689,15 @@ void ppc4xx_sdram_banks(ram_addr_t ram_size, int nr_b= anks, for (j =3D 0; sdram_bank_sizes[j] !=3D 0; j++) { bank_size =3D sdram_bank_sizes[j]; if (bank_size <=3D size_left) { + char name[32]; + ram_bases[i] =3D base; ram_sizes[i] =3D bank_size; base +=3D bank_size; size_left -=3D bank_size; - last_bank =3D i; + snprintf(name, sizeof(name), "ppc4xx.sdram%d", i); + memory_region_init_alias(&ram_memories[i], NULL, name, ram, + ram_bases[i], ram_sizes[i]); break; } } @@ -706,7 +708,7 @@ void ppc4xx_sdram_banks(ram_addr_t ram_size, int nr_ban= ks, } =20 if (size_left) { - ram_addr_t used_size =3D ram_size - size_left; + ram_addr_t used_size =3D memory_region_size(ram) - size_left; GString *s =3D g_string_new(NULL); =20 for (i =3D 0; sdram_bank_sizes[i]; i++) { @@ -722,15 +724,6 @@ void ppc4xx_sdram_banks(ram_addr_t ram_size, int nr_ba= nks, g_string_free(s, true); exit(EXIT_FAILURE); } - - memory_region_allocate_system_memory(ram, NULL, "ppc4xx.sdram", ram_si= ze); - - for (i =3D 0; i <=3D last_bank; i++) { - char name[32]; - snprintf(name, sizeof(name), "ppc4xx.sdram%d", i); - memory_region_init_alias(&ram_memories[i], NULL, name, ram, - ram_bases[i], ram_sizes[i]); - } } =20 /*************************************************************************= ****/ diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c index 17d40bd672..898453cf30 100644 --- a/hw/ppc/sam460ex.c +++ b/hw/ppc/sam460ex.c @@ -324,7 +324,7 @@ static void sam460ex_init(MachineState *machine) /* SDRAM controller */ /* put all RAM on first bank because board has one slot * and firmware only checks that */ - ppc4xx_sdram_banks(machine->ram_size, 1, ram_memories, ram_bases, ram_= sizes, + ppc4xx_sdram_banks(machine->ram, 1, ram_memories, ram_bases, ram_sizes, ppc460ex_sdram_bank_sizes); =20 /* FIXME: does 460EX have ECC interrupts? */ @@ -484,6 +484,7 @@ static void sam460ex_machine_init(MachineClass *mc) mc->init =3D sam460ex_init; mc->default_cpu_type =3D POWERPC_CPU_TYPE_NAME("460exb"); mc->default_ram_size =3D 512 * MiB; + mc->default_ram_id =3D "ppc4xx.sdram"; } =20 DEFINE_MACHINE("sam460ex", sam460ex_machine_init) --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581963176458188.79403202602418; Mon, 17 Feb 2020 10:12:56 -0800 (PST) Received: from localhost ([::1]:50018 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kt4-0007Ki-V5 for importer@patchew.org; Mon, 17 Feb 2020 13:12:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38837) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJr-0003dC-RV for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJq-0002dI-SI for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:31 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:42132 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJq-0002d1-Ny for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:30 -0500 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-340-5m-wUFkYMQ6F0IeCKeY3nA-1; Mon, 17 Feb 2020 12:36:28 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C9CBA107ACC9 for ; Mon, 17 Feb 2020 17:36:27 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2543990508; Mon, 17 Feb 2020 17:36:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960990; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ALdsFHaSncoT5P5lOxD8hBgsT58iHQkPe79Km8jm72U=; b=bRCWCHK2wNIkML2TQDExXw0BYkq2Yx2I/BQI79acVvNBi3T97toxeLtvgwdKeX8heJ6hJ7 YW33jipPZUyfZfIpdh3nBPRY4IeBVHYOFibbxVME/4pqfz16YaGsrymESmoHKpo9i3stWy haZkFm7GuN0vGUbptVH6lveqmqwilv4= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 67/79] ppc/spapr: use memdev for RAM Date: Mon, 17 Feb 2020 12:34:40 -0500 Message-Id: <20200217173452.15243-68-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: 5m-wUFkYMQ6F0IeCKeY3nA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Acked-by: David Gibson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- hw/ppc/spapr.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index c9b2e0a5e0..4d90f99195 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2634,7 +2634,6 @@ static void spapr_machine_init(MachineState *machine) PCIHostState *phb; int i; MemoryRegion *sysmem =3D get_system_memory(); - MemoryRegion *ram =3D g_new(MemoryRegion, 1); hwaddr node0_size =3D spapr_node0_size(machine); long load_limit, fw_size; char *filename; @@ -2813,10 +2812,8 @@ static void spapr_machine_init(MachineState *machine) kvmppc_enable_h_page_init(); } =20 - /* allocate RAM */ - memory_region_allocate_system_memory(ram, NULL, "ppc_spapr.ram", - machine->ram_size); - memory_region_add_subregion(sysmem, 0, ram); + /* map RAM */ + memory_region_add_subregion(sysmem, 0, machine->ram); =20 /* always allocate the device memory information */ machine->device_memory =3D g_malloc0(sizeof(*machine->device_memory)); @@ -4400,6 +4397,7 @@ static void spapr_machine_class_init(ObjectClass *oc,= void *data) mc->no_parallel =3D 1; mc->default_boot_order =3D ""; mc->default_ram_size =3D 512 * MiB; + mc->default_ram_id =3D "ppc_spapr.ram"; mc->default_display =3D "std"; mc->kvm_type =3D spapr_kvm_type; machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SPAPR_PCI_HOST_BRIDGE); --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 158196235401960.11052453119419; Mon, 17 Feb 2020 09:59:14 -0800 (PST) Received: from localhost ([::1]:49760 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kfo-00079A-KB for importer@patchew.org; Mon, 17 Feb 2020 12:59:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38857) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJu-0003g3-U4 for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJt-0002ev-P1 for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:34 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:36074 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJt-0002ef-Kw for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:33 -0500 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-181-36qQfUi7OOybrIldKBrcqw-1; Mon, 17 Feb 2020 12:36:29 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C67F2100EE01 for ; Mon, 17 Feb 2020 17:36:28 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 212E990508; Mon, 17 Feb 2020 17:36:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960993; 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=z1bWrUj/KCwwnuvPpGGXlz+J/CysSxEzX45M5DJZmtI=; b=K2lrCawDiU2lf2p2eCsTSYwmm9p/qSC9UQARDS5BUVbRQHyU3kRVejobpCbtjRMn2PmlKc CEObm7M4qBbJrCQqWY5td0X7qf/yLWaDZXDgV+bKh/Z2cWfxF2aPHnYmtHVB+yDSIgWDJq mh6jrvcEpJDyvP0B9vdzOXzv/VXEsoA= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 68/79] ppc/virtex_ml507: use memdev for RAM Date: Mon, 17 Feb 2020 12:34:41 -0500 Message-Id: <20200217173452.15243-69-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: 36qQfUi7OOybrIldKBrcqw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Acked-by: David Gibson Reviewed-by: Richard Henderson --- hw/ppc/virtex_ml507.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c index 91dd00ee91..b6f4507dcf 100644 --- a/hw/ppc/virtex_ml507.c +++ b/hw/ppc/virtex_ml507.c @@ -193,7 +193,6 @@ static int xilinx_load_device_tree(hwaddr addr, =20 static void virtex_init(MachineState *machine) { - ram_addr_t ram_size =3D machine->ram_size; const char *kernel_filename =3D machine->kernel_filename; const char *kernel_cmdline =3D machine->kernel_cmdline; hwaddr initrd_base =3D 0; @@ -204,7 +203,6 @@ static void virtex_init(MachineState *machine) CPUPPCState *env; hwaddr ram_base =3D 0; DriveInfo *dinfo; - MemoryRegion *phys_ram =3D g_new(MemoryRegion, 1); qemu_irq irq[32], *cpu_irq; int kernel_size; int i; @@ -221,8 +219,7 @@ static void virtex_init(MachineState *machine) =20 qemu_register_reset(main_cpu_reset, cpu); =20 - memory_region_allocate_system_memory(phys_ram, NULL, "ram", ram_size); - memory_region_add_subregion(address_space_mem, ram_base, phys_ram); + memory_region_add_subregion(address_space_mem, ram_base, machine->ram); =20 dinfo =3D drive_get(IF_PFLASH, 0, 0); pflash_cfi01_register(PFLASH_BASEADDR, "virtex.flash", FLASH_SIZE, @@ -265,7 +262,7 @@ static void virtex_init(MachineState *machine) /* If we failed loading ELF's try a raw image. */ kernel_size =3D load_image_targphys(kernel_filename, boot_offset, - ram_size); + machine->ram_size); boot_info.bootstrap_pc =3D boot_offset; high =3D boot_info.bootstrap_pc + kernel_size + 8192; } @@ -276,7 +273,7 @@ static void virtex_init(MachineState *machine) if (machine->initrd_filename) { initrd_base =3D high =3D ROUND_UP(high, 4); initrd_size =3D load_image_targphys(machine->initrd_filename, - high, ram_size - high); + high, machine->ram_size - hi= gh); =20 if (initrd_size < 0) { error_report("couldn't load ram disk '%s'", @@ -290,7 +287,7 @@ static void virtex_init(MachineState *machine) boot_info.fdt =3D high + (8192 * 2); boot_info.fdt &=3D ~8191; =20 - xilinx_load_device_tree(boot_info.fdt, ram_size, + xilinx_load_device_tree(boot_info.fdt, machine->ram_size, initrd_base, initrd_size, kernel_cmdline); } @@ -302,6 +299,7 @@ static void virtex_machine_init(MachineClass *mc) mc->desc =3D "Xilinx Virtex ML507 reference design"; mc->init =3D virtex_init; mc->default_cpu_type =3D POWERPC_CPU_TYPE_NAME("440-xilinx"); + mc->default_ram_id =3D "ram"; } =20 DEFINE_MACHINE("virtex-ml507", virtex_machine_init) --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581962535976119.21143221210309; Mon, 17 Feb 2020 10:02:15 -0800 (PST) Received: from localhost ([::1]:49802 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kik-0002gM-Fe for importer@patchew.org; Mon, 17 Feb 2020 13:02:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38869) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJv-0003gJ-VY for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJv-0002fi-0i for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:35 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:50341 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJu-0002fI-TK for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:34 -0500 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-234-UD4j8GO1OHycouYoO1YSJQ-1; Mon, 17 Feb 2020 12:36:30 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C1BF31800D42 for ; Mon, 17 Feb 2020 17:36:29 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1CB1F90508; Mon, 17 Feb 2020 17:36:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960994; 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=/m58/qnxvLrl2k6UTennlcnVEGu6GwdBivQUTjdWb0A=; b=QR2KIjrTB1JBlJpxMBnavugOgVUjmI2Hff9oRpjvGIqfGAZ5vpdwNtDxa2Dd4fvmE4PQK0 iuMv2rtu2fxyeeHHVGZTU9BdB1GY2xLsBMeiBAfKki8nHtfUo3HbxNhYqPz93HEZKc/z7q TQVUe0EKNWJ++TMpufqcBL0h4C+Ucow= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 69/79] sparc/leon3: use memdev for RAM Date: Mon, 17 Feb 2020 12:34:42 -0500 Message-Id: <20200217173452.15243-70-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: UD4j8GO1OHycouYoO1YSJQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- hw/sparc/leon3.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/sparc/leon3.c b/hw/sparc/leon3.c index f5a087dd86..5fa58aa55f 100644 --- a/hw/sparc/leon3.c +++ b/hw/sparc/leon3.c @@ -189,7 +189,6 @@ static void leon3_generic_hw_init(MachineState *machine) SPARCCPU *cpu; CPUSPARCState *env; MemoryRegion *address_space_mem =3D get_system_memory(); - MemoryRegion *ram =3D g_new(MemoryRegion, 1); MemoryRegion *prom =3D g_new(MemoryRegion, 1); int ret; char *filename; @@ -251,8 +250,8 @@ static void leon3_generic_hw_init(MachineState *machine) exit(1); } =20 - memory_region_allocate_system_memory(ram, NULL, "leon3.ram", ram_size); - memory_region_add_subregion(address_space_mem, LEON3_RAM_OFFSET, ram); + memory_region_add_subregion(address_space_mem, LEON3_RAM_OFFSET, + machine->ram); =20 /* Allocate BIOS */ prom_size =3D 8 * MiB; @@ -358,6 +357,7 @@ static void leon3_generic_machine_init(MachineClass *mc) mc->desc =3D "Leon-3 generic"; mc->init =3D leon3_generic_hw_init; mc->default_cpu_type =3D SPARC_CPU_TYPE_NAME("LEON3"); + mc->default_ram_id =3D "leon3.ram"; } =20 DEFINE_MACHINE("leon3_generic", leon3_generic_machine_init) --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581963379776399.0290868817526; Mon, 17 Feb 2020 10:16:19 -0800 (PST) Received: from localhost ([::1]:50136 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kwM-0005wu-HW for importer@patchew.org; Mon, 17 Feb 2020 13:16:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38878) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJw-0003iL-OP for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJv-0002fu-4Q for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:36 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:37750 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJv-0002fR-0l for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:35 -0500 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-327-Ff5WllfrMTqov6HMO9wQRQ-1; Mon, 17 Feb 2020 12:36:32 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AD4298010EB; Mon, 17 Feb 2020 17:36:31 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 18DF2909E3; Mon, 17 Feb 2020 17:36:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960994; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qZT5jLcUlmYpj/1Qjcyd5kuyS2wd9rU3u+uSQJBz/Xk=; b=PP3m+tK81RTh9DQT1WYjlHql0w5jGC4dGexGDM7a67dKpeuFgCmxpmGeLbPH7t4eDKzvwA 4nEDSz0L790svTbnEj7PMl7x9eGwbCFJZuEu8cQ9UviTYtgQVvzyLj9hGkv2YfP8XNhz17 +05rZ/YgoqykJNtFbrdGIEWbzCc5jI4= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 70/79] sparc/sun4m: use memdev for RAM Date: Mon, 17 Feb 2020 12:34:43 -0500 Message-Id: <20200217173452.15243-71-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: Ff5WllfrMTqov6HMO9wQRQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 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: Paolo Bonzini , Mark Cave-Ayland , atar4qemu@gmail.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Patch moves ram size check into sun4m_hw_init() and drops ram_init() moving remainder to sun4m_hw_init() as well, as it was the only place that called it. Also it rewrites impl. of RamDevice a little bit, which could serve as an example of frontend device for RAM backend. (Caveats are: 1. it doesn't check for memdev backend being mapped since it's been usurped by generic machine to handle majority of machines which don't have RAM frontend device 2. it still lacks 'addr' property and still has hardcoded sysbus_mmio_map() in board init. If done right, board should set 'addr' property and bus/machine plug handler should map it during device realize time. ) Further improvements were left as exercise for the future, since frontends are out scope of RAM conversion to memdev. Signed-off-by: Igor Mammedov --- v4: * 'machine: introduce memory-backend property' patch changed 'memory-backend' property from link to backend id to allow for delayed initialization. Take that in account and add resolving machine->ram_memdev_id into backend pointer efore setting link on RamDevice. CC: Mark Cave-Ayland CC: atar4qemu@gmail.com --- hw/sparc/sun4m.c | 74 ++++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c index 25e96db5ca..f5bf95fc9f 100644 --- a/hw/sparc/sun4m.c +++ b/hw/sparc/sun4m.c @@ -777,63 +777,42 @@ static const TypeInfo prom_info =3D { =20 typedef struct RamDevice { SysBusDevice parent_obj; - - MemoryRegion ram; - uint64_t size; + HostMemoryBackend *memdev; } RamDevice; =20 /* System RAM */ static void ram_realize(DeviceState *dev, Error **errp) { RamDevice *d =3D SUN4M_RAM(dev); - SysBusDevice *sbd =3D SYS_BUS_DEVICE(dev); + MemoryRegion *ram =3D host_memory_backend_get_memory(d->memdev); =20 - memory_region_allocate_system_memory(&d->ram, OBJECT(d), "sun4m.ram", - d->size); - sysbus_init_mmio(sbd, &d->ram); + sysbus_init_mmio(SYS_BUS_DEVICE(dev), ram); } =20 -static void ram_init(hwaddr addr, ram_addr_t RAM_size, - uint64_t max_mem) +static void ram_initfn(Object *obj) { - DeviceState *dev; - SysBusDevice *s; - RamDevice *d; - - /* allocate RAM */ - if ((uint64_t)RAM_size > max_mem) { - error_report("Too much memory for this machine: %" PRId64 "," - " maximum %" PRId64, - RAM_size / MiB, max_mem / MiB); - exit(1); - } - dev =3D qdev_create(NULL, "memory"); - s =3D SYS_BUS_DEVICE(dev); - - d =3D SUN4M_RAM(dev); - d->size =3D RAM_size; - qdev_init_nofail(dev); - - sysbus_mmio_map(s, 0, addr); + RamDevice *d =3D SUN4M_RAM(obj); + object_property_add_link(obj, "memdev", TYPE_MEMORY_BACKEND, + (Object **)&d->memdev, + object_property_allow_set_link, + OBJ_PROP_LINK_STRONG, &error_abort); + object_property_set_description(obj, "memdev", "Set RAM backend" + "Valid value is ID of a hostmem backen= d", + &error_abort); } =20 -static Property ram_properties[] =3D { - DEFINE_PROP_UINT64("size", RamDevice, size, 0), - DEFINE_PROP_END_OF_LIST(), -}; - static void ram_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); =20 dc->realize =3D ram_realize; - device_class_set_props(dc, ram_properties); } =20 static const TypeInfo ram_info =3D { .name =3D TYPE_SUN4M_MEMORY, .parent =3D TYPE_SYS_BUS_DEVICE, .instance_size =3D sizeof(RamDevice), + .instance_init =3D ram_initfn, .class_init =3D ram_class_init, }; =20 @@ -879,6 +858,15 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hw= def, SysBusDevice *s; unsigned int smp_cpus =3D machine->smp.cpus; unsigned int max_cpus =3D machine->smp.max_cpus; + Object *ram_memdev =3D object_resolve_path_type(machine->ram_memdev_id, + TYPE_MEMORY_BACKEND, NUL= L); + + if (machine->ram_size > hwdef->max_mem) { + error_report("Too much memory for this machine: %" PRId64 "," + " maximum %" PRId64, + machine->ram_size / MiB, hwdef->max_mem / MiB); + exit(1); + } =20 /* init CPUs */ for(i =3D 0; i < smp_cpus; i++) { @@ -888,9 +876,12 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hw= def, for (i =3D smp_cpus; i < MAX_CPUS; i++) cpu_irqs[i] =3D qemu_allocate_irqs(dummy_cpu_set_irq, NULL, MAX_PI= LS); =20 + /* Create and map RAM frontend */ + dev =3D qdev_create(NULL, "memory"); + object_property_set_link(OBJECT(dev), ram_memdev, "memdev", &error_fat= al); + qdev_init_nofail(dev); + sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0); =20 - /* set up devices */ - ram_init(0, machine->ram_size, hwdef->max_mem); /* models without ECC don't trap when missing ram is accessed */ if (!hwdef->ecc_base) { empty_slot_init(machine->ram_size, hwdef->max_mem - machine->ram_s= ize); @@ -1078,7 +1069,7 @@ static void sun4m_hw_init(const struct sun4m_hwdef *h= wdef, =20 fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, (uint16_t)smp_cpus); fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)max_cpus); - fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size); + fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)machine->ram_size); fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, hwdef->machine_id); fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_DEPTH, graphic_depth); fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_WIDTH, graphic_width); @@ -1415,6 +1406,7 @@ static void ss5_class_init(ObjectClass *oc, void *dat= a) mc->default_boot_order =3D "c"; mc->default_cpu_type =3D SPARC_CPU_TYPE_NAME("Fujitsu-MB86904"); mc->default_display =3D "tcx"; + mc->default_ram_id =3D "sun4m.ram"; } =20 static const TypeInfo ss5_type =3D { @@ -1434,6 +1426,7 @@ static void ss10_class_init(ObjectClass *oc, void *da= ta) mc->default_boot_order =3D "c"; mc->default_cpu_type =3D SPARC_CPU_TYPE_NAME("TI-SuperSparc-II"); mc->default_display =3D "tcx"; + mc->default_ram_id =3D "sun4m.ram"; } =20 static const TypeInfo ss10_type =3D { @@ -1453,6 +1446,7 @@ static void ss600mp_class_init(ObjectClass *oc, void = *data) mc->default_boot_order =3D "c"; mc->default_cpu_type =3D SPARC_CPU_TYPE_NAME("TI-SuperSparc-II"); mc->default_display =3D "tcx"; + mc->default_ram_id =3D "sun4m.ram"; } =20 static const TypeInfo ss600mp_type =3D { @@ -1472,6 +1466,7 @@ static void ss20_class_init(ObjectClass *oc, void *da= ta) mc->default_boot_order =3D "c"; mc->default_cpu_type =3D SPARC_CPU_TYPE_NAME("TI-SuperSparc-II"); mc->default_display =3D "tcx"; + mc->default_ram_id =3D "sun4m.ram"; } =20 static const TypeInfo ss20_type =3D { @@ -1490,6 +1485,7 @@ static void voyager_class_init(ObjectClass *oc, void = *data) mc->default_boot_order =3D "c"; mc->default_cpu_type =3D SPARC_CPU_TYPE_NAME("Fujitsu-MB86904"); mc->default_display =3D "tcx"; + mc->default_ram_id =3D "sun4m.ram"; } =20 static const TypeInfo voyager_type =3D { @@ -1508,6 +1504,7 @@ static void ss_lx_class_init(ObjectClass *oc, void *d= ata) mc->default_boot_order =3D "c"; mc->default_cpu_type =3D SPARC_CPU_TYPE_NAME("TI-MicroSparc-I"); mc->default_display =3D "tcx"; + mc->default_ram_id =3D "sun4m.ram"; } =20 static const TypeInfo ss_lx_type =3D { @@ -1526,6 +1523,7 @@ static void ss4_class_init(ObjectClass *oc, void *dat= a) mc->default_boot_order =3D "c"; mc->default_cpu_type =3D SPARC_CPU_TYPE_NAME("Fujitsu-MB86904"); mc->default_display =3D "tcx"; + mc->default_ram_id =3D "sun4m.ram"; } =20 static const TypeInfo ss4_type =3D { @@ -1544,6 +1542,7 @@ static void scls_class_init(ObjectClass *oc, void *da= ta) mc->default_boot_order =3D "c"; mc->default_cpu_type =3D SPARC_CPU_TYPE_NAME("TI-MicroSparc-I"); mc->default_display =3D "tcx"; + mc->default_ram_id =3D "sun4m.ram"; } =20 static const TypeInfo scls_type =3D { @@ -1562,6 +1561,7 @@ static void sbook_class_init(ObjectClass *oc, void *d= ata) mc->default_boot_order =3D "c"; mc->default_cpu_type =3D SPARC_CPU_TYPE_NAME("TI-MicroSparc-I"); mc->default_display =3D "tcx"; + mc->default_ram_id =3D "sun4m.ram"; } =20 static const TypeInfo sbook_type =3D { --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581963171523885.1204102128343; Mon, 17 Feb 2020 10:12:51 -0800 (PST) Received: from localhost ([::1]:50010 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kt0-00078W-CI for importer@patchew.org; Mon, 17 Feb 2020 13:12:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38923) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kK1-0003yb-Ra for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kK0-0002iw-SF for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:41 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:56351 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kK0-0002ih-OW for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:40 -0500 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-72-ApSn3NXhOQSN0QZWV38j3g-1; Mon, 17 Feb 2020 12:36:33 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AD35818FE870 for ; Mon, 17 Feb 2020 17:36:32 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 034939052B; Mon, 17 Feb 2020 17:36:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581961000; 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=jieUhX9yQNqUln14pUvpvohvwUkdO1rNW66q9YQvvbI=; b=YIJwRmu+duvba08b+6UI3CuJrol57Rf46a6Mzz6lBHCx29s61AtP+8foLKnB7jH2gR0COw 8bmpDAPflWV3+oXV0Q/Be/uU7D3YOYbTJww3dVlncs9BxekahRVWHZbsOaxN2g+ePPRdIF hcMJsYn1jbkWIZhmTR6TBKiYcIHMf1M= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 71/79] sparc/niagara: use memdev for RAM Date: Mon, 17 Feb 2020 12:34:44 -0500 Message-Id: <20200217173452.15243-72-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: ApSn3NXhOQSN0QZWV38j3g-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- hw/sparc64/niagara.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/hw/sparc64/niagara.c b/hw/sparc64/niagara.c index 5eb2d097b9..ab5ef8c5b3 100644 --- a/hw/sparc64/niagara.c +++ b/hw/sparc64/niagara.c @@ -40,7 +40,6 @@ =20 typedef struct NiagaraBoardState { MemoryRegion hv_ram; - MemoryRegion partition_ram; MemoryRegion nvram; MemoryRegion md_rom; MemoryRegion hv_rom; @@ -111,11 +110,8 @@ static void niagara_init(MachineState *machine) NIAGARA_HV_RAM_SIZE, &error_fatal); memory_region_add_subregion(sysmem, NIAGARA_HV_RAM_BASE, &s->hv_ram); =20 - memory_region_allocate_system_memory(&s->partition_ram, NULL, - "sun4v-partition.ram", - machine->ram_size); memory_region_add_subregion(sysmem, NIAGARA_PARTITION_RAM_BASE, - &s->partition_ram); + machine->ram); =20 memory_region_init_ram(&s->nvram, NULL, "sun4v.nvram", NIAGARA_NVRAM_S= IZE, &error_fatal); @@ -173,6 +169,7 @@ static void niagara_class_init(ObjectClass *oc, void *d= ata) mc->max_cpus =3D 1; /* XXX for now */ mc->default_boot_order =3D "c"; mc->default_cpu_type =3D SPARC_CPU_TYPE_NAME("Sun-UltraSparc-T1"); + mc->default_ram_id =3D "sun4v-partition.ram"; } =20 static const TypeInfo niagara_type =3D { --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581963073154470.78302654677327; Mon, 17 Feb 2020 10:11:13 -0800 (PST) Received: from localhost ([::1]:49984 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3krP-0003fx-Pz for importer@patchew.org; Mon, 17 Feb 2020 13:11:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38891) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kJy-0003oG-BG for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kJx-0002gz-5u for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:38 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:39294 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJx-0002gg-28 for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:37 -0500 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-64-uo_zm8BbPi6MAUMtAOq1Eg-1; Mon, 17 Feb 2020 12:36:34 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CFCBB8010EB for ; Mon, 17 Feb 2020 17:36:33 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0132A9052B; Mon, 17 Feb 2020 17:36:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960996; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+X4nAmZsEYaa+MdsB8sT2kQiPHAaQcvngMkKaDEqiPQ=; b=ILb5fVt2S8DsV7iP9zQOhfzvMHtvTYeHbujLKH7K3X6HMh3E5Ih+UeEaY/wFNxIx1BT4+y Y7xjZhwAx9RvAVXlKWT73vbkV8yG5fpCxvV4LnSVHgnunRhgu1ards2CZ2oB4Z1mEvAxD5 paE9UFD05F7Co3+tuYzSfaQqLkbET2Q= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 72/79] remove no longer used memory_region_allocate_system_memory() Date: Mon, 17 Feb 2020 12:34:45 -0500 Message-Id: <20200217173452.15243-73-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: uo_zm8BbPi6MAUMtAOq1Eg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 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: Paolo Bonzini , ehabkost@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" all boards were switched to using memdev backend for main RAM, so we can drop no longer used memory_region_allocate_system_memory() Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Tested-by: Philippe Mathieu-Daud=C3=A9 --- CC: ehabkost@redhat.com CC: pbonzini@redhat.com --- include/hw/boards.h | 32 -------------------------------- hw/core/numa.c | 34 ---------------------------------- 2 files changed, 66 deletions(-) diff --git a/include/hw/boards.h b/include/hw/boards.h index ae2b60fb5e..142b86d0ae 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -12,38 +12,6 @@ #include "qom/object.h" #include "hw/core/cpu.h" =20 -/** - * memory_region_allocate_system_memory - Allocate a board's main memory - * @mr: the #MemoryRegion to be initialized - * @owner: the object that tracks the region's reference count - * @name: name of the memory region - * @ram_size: size of the region in bytes - * - * This function allocates the main memory for a board model, and - * initializes @mr appropriately. It also arranges for the memory - * to be migrated (by calling vmstate_register_ram_global()). - * - * Memory allocated via this function will be backed with the memory - * backend the user provided using "-mem-path" or "-numa node,memdev=3D..." - * if appropriate; this is typically used to cause host huge pages to be - * used. This function should therefore be called by a board exactly once, - * for the primary or largest RAM area it implements. - * - * For boards where the major RAM is split into two parts in the memory - * map, you can deal with this by calling memory_region_allocate_system_me= mory() - * once to get a MemoryRegion with enough RAM for both parts, and then - * creating alias MemoryRegions via memory_region_init_alias() which - * alias into different parts of the RAM MemoryRegion and can be mapped - * into the memory map in the appropriate places. - * - * Smaller pieces of memory (display RAM, static RAMs, etc) don't need - * to be backed via the -mem-path memory backend and can simply - * be created via memory_region_init_ram(). - */ -void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner, - const char *name, - uint64_t ram_size); - #define TYPE_MACHINE_SUFFIX "-machine" =20 /* Machine class name that needs to be used for class-name-based machine diff --git a/hw/core/numa.c b/hw/core/numa.c index e6baf2c33e..316bc50d75 100644 --- a/hw/core/numa.c +++ b/hw/core/numa.c @@ -806,40 +806,6 @@ void numa_cpu_pre_plug(const CPUArchId *slot, DeviceSt= ate *dev, Error **errp) } } =20 -static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner, - const char *name, - uint64_t ram_size) -{ - if (mem_path) { -#ifdef __linux__ - memory_region_init_ram_from_file(mr, owner, name, ram_size, 0, 0, - mem_path, &error_fatal); -#else - fprintf(stderr, "-mem-path not supported on this host\n"); - exit(1); -#endif - } else { - memory_region_init_ram_nomigrate(mr, owner, name, ram_size, &error= _fatal); - } - vmstate_register_ram_global(mr); -} - -void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner, - const char *name, - uint64_t ram_size) -{ - MachineState *ms =3D MACHINE(qdev_get_machine()); - - if (ms->numa_state =3D=3D NULL || - ms->numa_state->num_nodes =3D=3D 0 || numa_uses_legacy_mem()) { - allocate_system_memory_nonnuma(mr, owner, name, ram_size); - return; - } - - memory_region_init(mr, owner, name, ram_size); - numa_init_memdev_container(ms, mr); -} - static void numa_stat_memory_devices(NumaNodeMem node_mem[]) { MemoryDeviceInfoList *info_list =3D qmp_memory_device_list(); --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581962658241907.8290045172128; Mon, 17 Feb 2020 10:04:18 -0800 (PST) Received: from localhost ([::1]:49838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kki-0006B8-Rl for importer@patchew.org; Mon, 17 Feb 2020 13:04:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38928) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kK2-0003zm-9p for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kK1-0002jJ-1u for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:42 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:52860 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kK0-0002io-UM for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:41 -0500 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-198-aVCB5nV1NDiKoaVnzoHrkA-1; Mon, 17 Feb 2020 12:36:37 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 607E98018A8; Mon, 17 Feb 2020 17:36:36 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 24A218CCE0; Mon, 17 Feb 2020 17:36:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581961000; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JqVgcvodDQRVlGz7Bgh4slriIN7j5r9clqzVosAArjg=; b=QJl2uMUI1txRgXv+6wGoRqNntl6doMvHktHDT93XkZVY7qfoeXu3SJrJGcPzWjx4nj9PyM g0EOi4ClVFywqxh5vF1fz0hEW899MX16mZgBKQbrvxixXwBt29T4I0ric1Ue7g9SIQDtVn R+EVm+zF6+bCdVAq1Km8S8BuAVhkS+o= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 73/79] exec: cleanup qemu_minrampagesize()/qemu_maxrampagesize() Date: Mon, 17 Feb 2020 12:34:46 -0500 Message-Id: <20200217173452.15243-74-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: aVCB5nV1NDiKoaVnzoHrkA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 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: thuth@redhat.com, aik@ozlabs.ru, mdroth@linux.vnet.ibm.com, qemu-ppc@nongnu.org, Paolo Bonzini , rth@twiddle.net, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Since all RAM is backed by hostmem backends, drop global -mem-path invariant and simplify code. Signed-off-by: Igor Mammedov Reviewed-by: David Gibson Reviewed-by: Richard Henderson --- v4: * fix access to uninitialized pagesize/hpsize (David Gibson ) CC: thuth@redhat.com CC: aik@ozlabs.ru CC: mdroth@linux.vnet.ibm.com CC: david@gibson.dropbear.id.au CC: qemu-ppc@nongnu.org CC: pbonzini@redhat.com CC: rth@twiddle.net --- exec.c | 49 ++++--------------------------------------------- 1 file changed, 4 insertions(+), 45 deletions(-) diff --git a/exec.c b/exec.c index 8e9cc3b47c..d85a8689d4 100644 --- a/exec.c +++ b/exec.c @@ -1667,59 +1667,18 @@ static int find_max_backend_pagesize(Object *obj, v= oid *opaque) long qemu_minrampagesize(void) { long hpsize =3D LONG_MAX; - long mainrampagesize; - Object *memdev_root; - MachineState *ms =3D MACHINE(qdev_get_machine()); - - mainrampagesize =3D qemu_mempath_getpagesize(mem_path); - - /* it's possible we have memory-backend objects with - * hugepage-backed RAM. these may get mapped into system - * address space via -numa parameters or memory hotplug - * hooks. we want to take these into account, but we - * also want to make sure these supported hugepage - * sizes are applicable across the entire range of memory - * we may boot from, so we take the min across all - * backends, and assume normal pages in cases where a - * backend isn't backed by hugepages. - */ - memdev_root =3D object_resolve_path("/objects", NULL); - if (memdev_root) { - object_child_foreach(memdev_root, find_min_backend_pagesize, &hpsi= ze); - } - if (hpsize =3D=3D LONG_MAX) { - /* No additional memory regions found =3D=3D> Report main RAM page= size */ - return mainrampagesize; - } - - /* If NUMA is disabled or the NUMA nodes are not backed with a - * memory-backend, then there is at least one node using "normal" RAM, - * so if its page size is smaller we have got to report that size inst= ead. - */ - if (hpsize > mainrampagesize && - (ms->numa_state =3D=3D NULL || - ms->numa_state->num_nodes =3D=3D 0 || - ms->numa_state->nodes[0].node_memdev =3D=3D NULL)) { - static bool warned; - if (!warned) { - error_report("Huge page support disabled (n/a for main memory)= ."); - warned =3D true; - } - return mainrampagesize; - } + Object *memdev_root =3D object_resolve_path("/objects", NULL); =20 + object_child_foreach(memdev_root, find_min_backend_pagesize, &hpsize); return hpsize; } =20 long qemu_maxrampagesize(void) { - long pagesize =3D qemu_mempath_getpagesize(mem_path); + long pagesize =3D 0; Object *memdev_root =3D object_resolve_path("/objects", NULL); =20 - if (memdev_root) { - object_child_foreach(memdev_root, find_max_backend_pagesize, - &pagesize); - } + object_child_foreach(memdev_root, find_max_backend_pagesize, &pagesize= ); return pagesize; } #else --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581963483415276.94544952772105; Mon, 17 Feb 2020 10:18:03 -0800 (PST) Received: from localhost ([::1]:50164 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3ky2-0000PO-4Y for importer@patchew.org; Mon, 17 Feb 2020 13:18:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38905) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kK1-0003w5-0k for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kK0-0002iP-1U for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:40 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:34559 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kJz-0002iC-Tw for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:39 -0500 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-290-50wj85t7Pz6T52yGeHhPHw-1; Mon, 17 Feb 2020 12:36:38 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5C45B800D53 for ; Mon, 17 Feb 2020 17:36:37 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id AA1B68CCE0; Mon, 17 Feb 2020 17:36:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581960999; 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=L7LXoExNmpBdheeNqAniqkn04JcDCo9j4BVlvTo+YDI=; b=ilI0Dyqplf5o63r2bZnaSXY/8/98NthYSupHmwJ6JhRW4HSnHSz+yJ4dFMCOUhJpZMFvR/ 6TIysi1IliBEynp6W56PlgDlkuzD72o7oeafoVOsqUefQqrLuQcVyJH5teVJF1XUhZ37ZP TUTLLsQ1nC/jn95raXJdYNBFS3dCFrE= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 74/79] exec: drop bogus mem_path from qemu_ram_alloc_from_fd() Date: Mon, 17 Feb 2020 12:34:47 -0500 Message-Id: <20200217173452.15243-75-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: 50wj85t7Pz6T52yGeHhPHw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Function will report error that will mention global mem_path, which was valid the only if legacy -mem-path was used and only in case of main RAM. However it doesn't work with hostmem backends (for example: " qemu: -object memory-backend-file,id=3Dram0,size=3D128M,mem-path=3Dfoo: backing store (null) size 0x200000 does not match 'size' option 0x80000= 00 ") and couldn't possibly work in general FD case the function is supposed to handle. Taking in account that main RAM was converted into memory-backend-foo object, there is no point in printing file name (from inappropriate place) as failing path is a part of backend's error message. Hence drop bogus mem_path usage from qemu_ram_alloc_from_fd(), it's a job of its user to add file name to error message if applicable. Signed-off-by: Igor Mammedov Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Richard Henderson --- exec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exec.c b/exec.c index d85a8689d4..6ebff8bd3a 100644 --- a/exec.c +++ b/exec.c @@ -2307,9 +2307,9 @@ RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, Mem= oryRegion *mr, size =3D HOST_PAGE_ALIGN(size); file_size =3D get_file_size(fd); if (file_size > 0 && file_size < size) { - error_setg(errp, "backing store %s size 0x%" PRIx64 + error_setg(errp, "backing store size 0x%" PRIx64 " does not match 'size' option 0x" RAM_ADDR_FMT, - mem_path, file_size, size); + file_size, size); return NULL; } =20 --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581963268553199.7112329175335; Mon, 17 Feb 2020 10:14:28 -0800 (PST) Received: from localhost ([::1]:50054 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kuZ-0002R4-DK for importer@patchew.org; Mon, 17 Feb 2020 13:14:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38949) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kK3-00043B-Fd for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kK2-0002kH-Es for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:43 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:32140 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kK2-0002jz-BB for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:42 -0500 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-203-T48SsHT5N9OBmiYv_kNFTA-1; Mon, 17 Feb 2020 12:36:39 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5E71B100EE05 for ; Mon, 17 Feb 2020 17:36:38 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id A53AF8CCE0; Mon, 17 Feb 2020 17:36:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581961001; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mxC5ah1MMUC3SMYaZt/Nb09UfouV47cIxlszvEKWoVs=; b=CKBBaSIToSW69Hu9b25V+2CqvDeuS9YtaoL1nA3033NkDvAU+p254MCIZa1DjIzN108a2R df/opCJY9Gh0phl3CE8s4aFhHmd5Mf60jDceM6EBY8/HctMdnEZyXmTAcX0Jm9bmWnycvB M66FkJ9MAkkff7s0gKGedBLpsekZ7TE= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 75/79] make mem_path local variable Date: Mon, 17 Feb 2020 12:34:48 -0500 Message-Id: <20200217173452.15243-76-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: T48SsHT5N9OBmiYv_kNFTA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" It's no longer used anywhere beside main(), so make it local variable that is used for CLI compat purposes to keep -mem-path option working. Under hood QEMU will use it to create memory-backend-file,mem-path=3D... backend and use its MemoryRegion as main RAM. Signed-off-by: Igor Mammedov Reviewed-by: Richard Henderson --- CC: pbonzini@redhat.com --- include/sysemu/sysemu.h | 1 - vl.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index c0678c1ca3..ae78b2a122 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -50,7 +50,6 @@ extern uint8_t *boot_splash_filedata; extern bool enable_mlock; extern bool enable_cpu_pm; extern QEMUClockType rtc_clock; -extern const char *mem_path; extern int mem_prealloc; =20 #define MAX_OPTION_ROMS 16 diff --git a/vl.c b/vl.c index a7edcba094..15cc5bd565 100644 --- a/vl.c +++ b/vl.c @@ -140,7 +140,6 @@ enum vga_retrace_method vga_retrace_method =3D VGA_RETR= ACE_DUMB; int display_opengl; const char* keyboard_layout =3D NULL; ram_addr_t ram_size; -const char *mem_path =3D NULL; int mem_prealloc =3D 0; /* force preallocation of physical target memory */ bool enable_mlock =3D false; bool enable_cpu_pm =3D false; @@ -2883,6 +2882,7 @@ int main(int argc, char **argv, char **envp) Error *err =3D NULL; bool list_data_dirs =3D false; char *dir, **dirs; + const char *mem_path =3D NULL; BlockdevOptionsQueue bdo_queue =3D QSIMPLEQ_HEAD_INITIALIZER(bdo_queue= ); QemuPluginList plugin_list =3D QTAILQ_HEAD_INITIALIZER(plugin_list); =20 --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581962801137936.2808669893433; Mon, 17 Feb 2020 10:06:41 -0800 (PST) Received: from localhost ([::1]:49884 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kn1-0002aX-RL for importer@patchew.org; Mon, 17 Feb 2020 13:06:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38959) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kK4-00046j-Me for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kK3-0002kj-2k for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:44 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:28258 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kK2-0002kU-V1 for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:43 -0500 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-158-tNumtKOaMj6Pc3gdy4BiSA-1; Mon, 17 Feb 2020 12:36:40 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7D1D38010EB for ; Mon, 17 Feb 2020 17:36:39 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id A2D1D8CCE0; Mon, 17 Feb 2020 17:36:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581961002; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QkmHNGF0kUn2HU7S3GOFvwkJsekL3iXycc+SpG5kyN8=; b=LfDryBOfyHcP9DlPoH5eZyS1DlJ15T29DjTF5CBmhuL8/Pa5tyt0nL1JFXZQfOb21x2kqg Lqc8xdGi9oEQBrAPBIm5eyZpEou+IFoxqxZhsfDaUb7mi/py85IpqhkapWdawu9vHvqBXB IdYUq+fyXUrByKsOhx3TH1j8SIINrgs= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 76/79] hostmem: introduce "prealloc-threads" property Date: Mon, 17 Feb 2020 12:34:49 -0500 Message-Id: <20200217173452.15243-77-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: tNumtKOaMj6Pc3gdy4BiSA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 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: Paolo Bonzini , ehabkost@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" the property will allow user to specify number of threads to use in pre-allocation stage. It also will allow to reduce implicit hostmem dependency on current_machine. On object creation it will default to 1, but via machine compat property it will be updated to MachineState::smp::cpus to keep current behavior for hostmem and main RAM (which is now also hostmem based). Signed-off-by: Igor Mammedov --- v3: - use object_register_sugar_prop() instead of directly hacking compat_props (Paolo Bonzini ) - fix TODO description CC: pbonzini@redhat.com CC: ehabkost@redhat.com --- include/sysemu/hostmem.h | 2 ++ backends/hostmem.c | 43 ++++++++++++++++++++++++++++++++++++---- vl.c | 14 +++++++++---- 3 files changed, 51 insertions(+), 8 deletions(-) diff --git a/include/sysemu/hostmem.h b/include/sysemu/hostmem.h index 5db0d668ec..bdf86665ab 100644 --- a/include/sysemu/hostmem.h +++ b/include/sysemu/hostmem.h @@ -61,6 +61,7 @@ struct HostMemoryBackendClass { * @parent: opaque parent object container * @size: amount of memory backend provides * @mr: MemoryRegion representing host memory belonging to backend + * @prealloc_threads: number of threads to be used for preallocatining RAM */ struct HostMemoryBackend { /* private */ @@ -70,6 +71,7 @@ struct HostMemoryBackend { uint64_t size; bool merge, dump, use_canonical_path; bool prealloc, force_prealloc, is_mapped, share; + uint32_t prealloc_threads; DECLARE_BITMAP(host_nodes, MAX_NODES + 1); HostMemPolicy policy; =20 diff --git a/backends/hostmem.c b/backends/hostmem.c index e773bdfa6e..0988986016 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -223,7 +223,6 @@ static void host_memory_backend_set_prealloc(Object *ob= j, bool value, { Error *local_err =3D NULL; HostMemoryBackend *backend =3D MEMORY_BACKEND(obj); - MachineState *ms =3D MACHINE(qdev_get_machine()); =20 if (backend->force_prealloc) { if (value) { @@ -243,7 +242,7 @@ static void host_memory_backend_set_prealloc(Object *ob= j, bool value, void *ptr =3D memory_region_get_ram_ptr(&backend->mr); uint64_t sz =3D memory_region_size(&backend->mr); =20 - os_mem_prealloc(fd, ptr, sz, ms->smp.cpus, &local_err); + os_mem_prealloc(fd, ptr, sz, backend->prealloc_threads, &local_err= ); if (local_err) { error_propagate(errp, local_err); return; @@ -252,14 +251,45 @@ static void host_memory_backend_set_prealloc(Object *= obj, bool value, } } =20 +static void host_memory_backend_get_prealloc_threads(Object *obj, Visitor = *v, + const char *name, void *opaque, Error **errp) +{ + HostMemoryBackend *backend =3D MEMORY_BACKEND(obj); + visit_type_uint32(v, name, &backend->prealloc_threads, errp); +} + +static void host_memory_backend_set_prealloc_threads(Object *obj, Visitor = *v, + const char *name, void *opaque, Error **errp) +{ + HostMemoryBackend *backend =3D MEMORY_BACKEND(obj); + Error *local_err =3D NULL; + uint32_t value; + + visit_type_uint32(v, name, &value, &local_err); + if (local_err) { + goto out; + } + if (value <=3D 0) { + error_setg(&local_err, + "property '%s' of %s doesn't take value '%d'", + name, object_get_typename(obj), value); + goto out; + } + backend->prealloc_threads =3D value; +out: + error_propagate(errp, local_err); +} + static void host_memory_backend_init(Object *obj) { HostMemoryBackend *backend =3D MEMORY_BACKEND(obj); MachineState *machine =3D MACHINE(qdev_get_machine()); =20 + /* TODO: convert access to globals to compat properties */ backend->merge =3D machine_mem_merge(machine); backend->dump =3D machine_dump_guest_core(machine); backend->prealloc =3D mem_prealloc; + backend->prealloc_threads =3D 1; } =20 static void host_memory_backend_post_init(Object *obj) @@ -313,7 +343,6 @@ host_memory_backend_memory_complete(UserCreatable *uc, = Error **errp) { HostMemoryBackend *backend =3D MEMORY_BACKEND(uc); HostMemoryBackendClass *bc =3D MEMORY_BACKEND_GET_CLASS(uc); - MachineState *ms =3D MACHINE(qdev_get_machine()); Error *local_err =3D NULL; void *ptr; uint64_t sz; @@ -378,7 +407,7 @@ host_memory_backend_memory_complete(UserCreatable *uc, = Error **errp) */ if (backend->prealloc) { os_mem_prealloc(memory_region_get_fd(&backend->mr), ptr, sz, - ms->smp.cpus, &local_err); + backend->prealloc_threads, &local_err); if (local_err) { goto out; } @@ -456,6 +485,12 @@ host_memory_backend_class_init(ObjectClass *oc, void *= data) host_memory_backend_set_prealloc, &error_abort); object_class_property_set_description(oc, "prealloc", "Preallocate memory", &error_abort); + object_class_property_add(oc, "prealloc-threads", "int", + host_memory_backend_get_prealloc_threads, + host_memory_backend_set_prealloc_threads, + NULL, NULL, &error_abort); + object_class_property_set_description(oc, "prealloc-threads", + "Number of CPU threads to use for prealloc", &error_abort); object_class_property_add(oc, "size", "int", host_memory_backend_get_size, host_memory_backend_set_size, diff --git a/vl.c b/vl.c index 15cc5bd565..afc682e168 100644 --- a/vl.c +++ b/vl.c @@ -2828,8 +2828,7 @@ static void configure_accelerators(const char *progna= me) } } =20 -static void create_default_memdev(MachineState *ms, const char *path, - bool prealloc) +static void create_default_memdev(MachineState *ms, const char *path) { Object *obj; MachineClass *mc =3D MACHINE_GET_CLASS(ms); @@ -2838,7 +2837,6 @@ static void create_default_memdev(MachineState *ms, c= onst char *path, if (path) { object_property_set_str(obj, path, "mem-path", &error_fatal); } - object_property_set_bool(obj, prealloc, "prealloc", &error_fatal); object_property_set_int(obj, ms->ram_size, "size", &error_fatal); object_property_add_child(object_get_objects_root(), mc->default_ram_i= d, obj, &error_fatal); @@ -3980,6 +3978,14 @@ int main(int argc, char **argv, char **envp) exit(1); } =20 + if (mem_prealloc) { + char *val; + + val =3D g_strdup_printf("%d", current_machine->smp.cpus); + object_register_sugar_prop("memory-backend", "prealloc-threads", v= al); + g_free(val); + } + /* * Get the default machine options from the machine if it is not alrea= dy * specified either by the configuration file or by the command line. @@ -4307,7 +4313,7 @@ int main(int argc, char **argv, char **envp) =20 if (machine_class->default_ram_id && current_machine->ram_size && numa_uses_legacy_mem() && !current_machine->ram_memdev_id) { - create_default_memdev(current_machine, mem_path, mem_prealloc); + create_default_memdev(current_machine, mem_path); } /* do monitor/qmp handling at preconfig state if requested */ main_loop(); --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581962888540737.0705772709905; Mon, 17 Feb 2020 10:08:08 -0800 (PST) Received: from localhost ([::1]:49910 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3koQ-0005Gh-5V for importer@patchew.org; Mon, 17 Feb 2020 13:08:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38992) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kK8-0004GH-1D for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kK6-0002mj-GZ for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:47 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:34953 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kK6-0002mO-Cb for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:46 -0500 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-171-GoybkBNwNHa0e_x1vFXxTw-1; Mon, 17 Feb 2020 12:36:42 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F2BBC107ACCA; Mon, 17 Feb 2020 17:36:40 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id C7ED090526; Mon, 17 Feb 2020 17:36:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581961006; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u3WBhgws+9q12DLm3vWAGIUjNMO7VThSDD1VZwcJLcQ=; b=OHPz8a/m2lTLEkbiQRFdgsM1Co7K4Lff8z0G94dCMCkfNg4zbEpQECmni/fY7cOW68+4uE mIWtNbepwAWYk26F0bFhHEDhDq45XZ/7sWpJecTWJ8r7CqreN4wCLWeTUyu9uX3Hv51mLz DBUe6uxBtW8fdjKA6E9WtE2toMeGPNY= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 77/79] hostmem: fix strict bind policy Date: Mon, 17 Feb 2020 12:34:50 -0500 Message-Id: <20200217173452.15243-78-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: GoybkBNwNHa0e_x1vFXxTw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 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: pasic@linux.ibm.com, Paolo Bonzini , ehabkost@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When option -mem-prealloc is used with one or more memory-backend objects, created backends may not obey configured bind policy or creation may fail after kernel attempts to move pages according to bind policy. Reason is in file_ram_alloc(), which will pre-allocate any descriptor based RAM if global mem_prealloc !=3D 0 and that happens way before bind policy is applied to memory range. One way to fix it would be to extend memory_region_foo() API and add more invariants that could broken later due implicit dependencies that's hard to track. Another approach is to drop adhoc main RAM allocation and consolidate it around memory-backend. That allows to have single place that allocates guest RAM (main and memdev) in the same way and then global mem_prealloc could be replaced by backend's property[s] that will affect created memory-backend objects but only in correct order this time. With main RAM now converted to hostmem backends, there is no point in keeping global mem_prealloc around, so alias -mem-prealloc to "memory-backend.prealloc=3Don" machine compat[*] property and make mem_prealloc a local variable to only stir registration of compat property. *) currently user accessible -global works only with DEVICE based objects and extra work is needed to make it work with hostmem backends. But that is convenience option and out of scope of this already huge refactoring. Hence machine compat properties were used. Signed-off-by: Igor Mammedov --- v3: - use object_register_sugar_prop() instead of directly hacking compat_props (Paolo Bonzini ) CC: pbonzini@redhat.com CC: ehabkost@redhat.com CC: rth@twiddle.net CC: pasic@linux.ibm.com --- include/sysemu/hostmem.h | 2 +- include/sysemu/sysemu.h | 1 - backends/hostmem-file.c | 1 - backends/hostmem-memfd.c | 1 - backends/hostmem.c | 12 +----------- exec.c | 11 ----------- vl.c | 3 ++- 7 files changed, 4 insertions(+), 27 deletions(-) diff --git a/include/sysemu/hostmem.h b/include/sysemu/hostmem.h index bdf86665ab..8276e53683 100644 --- a/include/sysemu/hostmem.h +++ b/include/sysemu/hostmem.h @@ -70,7 +70,7 @@ struct HostMemoryBackend { /* protected */ uint64_t size; bool merge, dump, use_canonical_path; - bool prealloc, force_prealloc, is_mapped, share; + bool prealloc, is_mapped, share; uint32_t prealloc_threads; DECLARE_BITMAP(host_nodes, MAX_NODES + 1); HostMemPolicy policy; diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index ae78b2a122..55bdd57a9b 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -50,7 +50,6 @@ extern uint8_t *boot_splash_filedata; extern bool enable_mlock; extern bool enable_cpu_pm; extern QEMUClockType rtc_clock; -extern int mem_prealloc; =20 #define MAX_OPTION_ROMS 16 typedef struct QEMUOptionRom { diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c index cb319a9157..c8c355f5aa 100644 --- a/backends/hostmem-file.c +++ b/backends/hostmem-file.c @@ -51,7 +51,6 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Err= or **errp) return; } =20 - backend->force_prealloc =3D mem_prealloc; name =3D host_memory_backend_get_name(backend); memory_region_init_ram_from_file(&backend->mr, OBJECT(backend), name, diff --git a/backends/hostmem-memfd.c b/backends/hostmem-memfd.c index 26070b425e..74ba9879c4 100644 --- a/backends/hostmem-memfd.c +++ b/backends/hostmem-memfd.c @@ -45,7 +45,6 @@ memfd_backend_memory_alloc(HostMemoryBackend *backend, Er= ror **errp) return; } =20 - backend->force_prealloc =3D mem_prealloc; fd =3D qemu_memfd_create(TYPE_MEMORY_BACKEND_MEMFD, backend->size, m->hugetlb, m->hugetlbsize, m->seal ? F_SEAL_GROW | F_SEAL_SHRINK | F_SEAL_SEAL : 0, diff --git a/backends/hostmem.c b/backends/hostmem.c index 0988986016..a70867b255 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -215,7 +215,7 @@ static bool host_memory_backend_get_prealloc(Object *ob= j, Error **errp) { HostMemoryBackend *backend =3D MEMORY_BACKEND(obj); =20 - return backend->prealloc || backend->force_prealloc; + return backend->prealloc; } =20 static void host_memory_backend_set_prealloc(Object *obj, bool value, @@ -224,14 +224,6 @@ static void host_memory_backend_set_prealloc(Object *o= bj, bool value, Error *local_err =3D NULL; HostMemoryBackend *backend =3D MEMORY_BACKEND(obj); =20 - if (backend->force_prealloc) { - if (value) { - error_setg(errp, - "remove -mem-prealloc to use the prealloc property"= ); - return; - } - } - if (!host_memory_backend_mr_inited(backend)) { backend->prealloc =3D value; return; @@ -288,8 +280,6 @@ static void host_memory_backend_init(Object *obj) /* TODO: convert access to globals to compat properties */ backend->merge =3D machine_mem_merge(machine); backend->dump =3D machine_dump_guest_core(machine); - backend->prealloc =3D mem_prealloc; - backend->prealloc_threads =3D 1; } =20 static void host_memory_backend_post_init(Object *obj) diff --git a/exec.c b/exec.c index 6ebff8bd3a..8c0258a7ae 100644 --- a/exec.c +++ b/exec.c @@ -1801,8 +1801,6 @@ static void *file_ram_alloc(RAMBlock *block, bool truncate, Error **errp) { - Error *err =3D NULL; - MachineState *ms =3D MACHINE(qdev_get_machine()); void *area; =20 block->page_size =3D qemu_fd_getpagesize(fd); @@ -1858,15 +1856,6 @@ static void *file_ram_alloc(RAMBlock *block, return NULL; } =20 - if (mem_prealloc) { - os_mem_prealloc(fd, area, memory, ms->smp.cpus, &err); - if (err) { - error_propagate(errp, err); - qemu_ram_munmap(fd, area, memory); - return NULL; - } - } - block->fd =3D fd; return area; } diff --git a/vl.c b/vl.c index afc682e168..54857f7afa 100644 --- a/vl.c +++ b/vl.c @@ -140,7 +140,6 @@ enum vga_retrace_method vga_retrace_method =3D VGA_RETR= ACE_DUMB; int display_opengl; const char* keyboard_layout =3D NULL; ram_addr_t ram_size; -int mem_prealloc =3D 0; /* force preallocation of physical target memory */ bool enable_mlock =3D false; bool enable_cpu_pm =3D false; int nb_nics; @@ -2883,6 +2882,7 @@ int main(int argc, char **argv, char **envp) const char *mem_path =3D NULL; BlockdevOptionsQueue bdo_queue =3D QSIMPLEQ_HEAD_INITIALIZER(bdo_queue= ); QemuPluginList plugin_list =3D QTAILQ_HEAD_INITIALIZER(plugin_list); + int mem_prealloc =3D 0; /* force preallocation of physical target memo= ry */ =20 os_set_line_buffering(); =20 @@ -3984,6 +3984,7 @@ int main(int argc, char **argv, char **envp) val =3D g_strdup_printf("%d", current_machine->smp.cpus); object_register_sugar_prop("memory-backend", "prealloc-threads", v= al); g_free(val); + object_register_sugar_prop("memory-backend", "prealloc", "on"); } =20 /* --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581962659312962.1971940386545; Mon, 17 Feb 2020 10:04:19 -0800 (PST) Received: from localhost ([::1]:49842 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kkj-0006EF-Ov for importer@patchew.org; Mon, 17 Feb 2020 13:04:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38974) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kK6-0004Ct-SZ for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kK5-0002m0-8p for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:46 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:59300 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kK5-0002lk-4V for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:45 -0500 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-210-U6oVrbhbPbWamFGw87Csog-1; Mon, 17 Feb 2020 12:36:42 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EE9C7DB21 for ; Mon, 17 Feb 2020 17:36:41 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 490F78CCE0; Mon, 17 Feb 2020 17:36:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581961004; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6/NXe3JPSlqAR4NMBD65VMmv2XKlodkIVj9Cj3EHGXg=; b=a3QlLMC/4a7vyQoUZVUraffTAR1p4jZ6H32gGqsZBWz7+Cma5UMOsErMN2Q8xm3AxPlhLL gyrE/3nSoZDNNKOPIqo/NawoxHJmKIOw5vRk3fruT0SjFNkjL1tFziIVStc8xn67xdlgAb CwZMxjL4dciBuDHrRv/LHjNNzAZgPGE= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 78/79] tests/numa-test: make top level args dynamic and g_autofree(cli) cleanups Date: Mon, 17 Feb 2020 12:34:51 -0500 Message-Id: <20200217173452.15243-79-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: U6oVrbhbPbWamFGw87Csog-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Use GString to pass argument to make_cli() so that it would be easy to dynamically change test case arguments from main(). The follow up patch will use it to change RAM size options depending on target. While at it cleanup 'cli' freeing, using g_autofree annotation. Signed-off-by: Igor Mammedov Reviewed-by: Thomas Huth --- v3: * s/strcmp/g_str_equal/ (Thomas Huth ) * use pair make_cli/qtest_init instead of qtest_initf PS: made as a separate patch so it won't clutter followup testcase changes. v4: * use g_string_new(NULL) instead of g_string_new("") (Thomas Huth ) --- tests/qtest/numa-test.c | 108 ++++++++++++++++++++-------------------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/tests/qtest/numa-test.c b/tests/qtest/numa-test.c index 17dd807d2a..35999ea28f 100644 --- a/tests/qtest/numa-test.c +++ b/tests/qtest/numa-test.c @@ -14,16 +14,16 @@ #include "qapi/qmp/qdict.h" #include "qapi/qmp/qlist.h" =20 -static char *make_cli(const char *generic_cli, const char *test_cli) +static char *make_cli(const GString *generic_cli, const char *test_cli) { - return g_strdup_printf("%s %s", generic_cli ? generic_cli : "", test_c= li); + return g_strdup_printf("%s %s", generic_cli->str, test_cli); } =20 static void test_mon_explicit(const void *data) { - char *s; - char *cli; QTestState *qts; + g_autofree char *s =3D NULL; + g_autofree char *cli =3D NULL; =20 cli =3D make_cli(data, "-smp 8 " "-numa node,nodeid=3D0,cpus=3D0-3 " @@ -33,17 +33,15 @@ static void test_mon_explicit(const void *data) s =3D qtest_hmp(qts, "info numa"); g_assert(strstr(s, "node 0 cpus: 0 1 2 3")); g_assert(strstr(s, "node 1 cpus: 4 5 6 7")); - g_free(s); =20 qtest_quit(qts); - g_free(cli); } =20 static void test_mon_default(const void *data) { - char *s; - char *cli; QTestState *qts; + g_autofree char *s =3D NULL; + g_autofree char *cli =3D NULL; =20 cli =3D make_cli(data, "-smp 8 -numa node -numa node"); qts =3D qtest_init(cli); @@ -51,17 +49,15 @@ static void test_mon_default(const void *data) s =3D qtest_hmp(qts, "info numa"); g_assert(strstr(s, "node 0 cpus: 0 2 4 6")); g_assert(strstr(s, "node 1 cpus: 1 3 5 7")); - g_free(s); =20 qtest_quit(qts); - g_free(cli); } =20 static void test_mon_partial(const void *data) { - char *s; - char *cli; QTestState *qts; + g_autofree char *s =3D NULL; + g_autofree char *cli =3D NULL; =20 cli =3D make_cli(data, "-smp 8 " "-numa node,nodeid=3D0,cpus=3D0-1 " @@ -71,10 +67,8 @@ static void test_mon_partial(const void *data) s =3D qtest_hmp(qts, "info numa"); g_assert(strstr(s, "node 0 cpus: 0 1 2 3 6 7")); g_assert(strstr(s, "node 1 cpus: 4 5")); - g_free(s); =20 qtest_quit(qts); - g_free(cli); } =20 static QList *get_cpus(QTestState *qts, QDict **resp) @@ -87,11 +81,11 @@ static QList *get_cpus(QTestState *qts, QDict **resp) =20 static void test_query_cpus(const void *data) { - char *cli; QDict *resp; QList *cpus; QObject *e; QTestState *qts; + g_autofree char *cli =3D NULL; =20 cli =3D make_cli(data, "-smp 8 -numa node,cpus=3D0-3 -numa node,cpus= =3D4-7"); qts =3D qtest_init(cli); @@ -120,16 +114,15 @@ static void test_query_cpus(const void *data) =20 qobject_unref(resp); qtest_quit(qts); - g_free(cli); } =20 static void pc_numa_cpu(const void *data) { - char *cli; QDict *resp; QList *cpus; QObject *e; QTestState *qts; + g_autofree char *cli =3D NULL; =20 cli =3D make_cli(data, "-cpu pentium -smp 8,sockets=3D2,cores=3D2,thre= ads=3D2 " "-numa node,nodeid=3D0 -numa node,nodeid=3D1 " @@ -174,16 +167,15 @@ static void pc_numa_cpu(const void *data) =20 qobject_unref(resp); qtest_quit(qts); - g_free(cli); } =20 static void spapr_numa_cpu(const void *data) { - char *cli; QDict *resp; QList *cpus; QObject *e; QTestState *qts; + g_autofree char *cli =3D NULL; =20 cli =3D make_cli(data, "-smp 4,cores=3D4 " "-numa node,nodeid=3D0 -numa node,nodeid=3D1 " @@ -220,16 +212,15 @@ static void spapr_numa_cpu(const void *data) =20 qobject_unref(resp); qtest_quit(qts); - g_free(cli); } =20 static void aarch64_numa_cpu(const void *data) { - char *cli; QDict *resp; QList *cpus; QObject *e; QTestState *qts; + g_autofree char *cli =3D NULL; =20 cli =3D make_cli(data, "-smp 2 " "-numa node,nodeid=3D0 -numa node,nodeid=3D1 " @@ -264,7 +255,6 @@ static void aarch64_numa_cpu(const void *data) =20 qobject_unref(resp); qtest_quit(qts); - g_free(cli); } =20 static void pc_dynamic_cpu_cfg(const void *data) @@ -273,9 +263,10 @@ static void pc_dynamic_cpu_cfg(const void *data) QDict *resp; QList *cpus; QTestState *qs; + g_autofree char *cli =3D NULL; =20 - qs =3D qtest_initf("%s -nodefaults --preconfig -smp 2", - data ? (char *)data : ""); + cli =3D make_cli(data, "-nodefaults --preconfig -smp 2"); + qs =3D qtest_init(cli); =20 /* create 2 numa nodes */ g_assert(!qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node'," @@ -329,16 +320,19 @@ static void pc_dynamic_cpu_cfg(const void *data) =20 static void pc_hmat_build_cfg(const void *data) { - QTestState *qs =3D qtest_initf("%s -nodefaults --preconfig -machine hm= at=3Don " - "-smp 2,sockets=3D2 " - "-m 128M,slots=3D2,maxmem=3D1G " - "-object memory-backend-ram,size=3D64M,id=3Dm0 " - "-object memory-backend-ram,size=3D64M,id=3Dm1 " - "-numa node,nodeid=3D0,memdev=3Dm0 " - "-numa node,nodeid=3D1,memdev=3Dm1,initiator=3D0 " - "-numa cpu,node-id=3D0,socket-id=3D0 " - "-numa cpu,node-id=3D0,socket-id=3D1", - data ? (char *)data : ""); + QTestState *qs; + g_autofree char *cli =3D NULL; + + cli =3D make_cli(data, "-nodefaults --preconfig -machine hmat=3Don " + "-smp 2,sockets=3D2 " + "-m 128M,slots=3D2,maxmem=3D1G " + "-object memory-backend-ram,size=3D64M,id=3Dm0 " + "-object memory-backend-ram,size=3D64M,id=3Dm1 " + "-numa node,nodeid=3D0,memdev=3Dm0 " + "-numa node,nodeid=3D1,memdev=3Dm1,initiator=3D0 " + "-numa cpu,node-id=3D0,socket-id=3D0 " + "-numa cpu,node-id=3D0,socket-id=3D1"); + qs =3D qtest_init(cli); =20 /* Fail: Initiator should be less than the number of nodes */ g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," @@ -455,13 +449,16 @@ static void pc_hmat_build_cfg(const void *data) =20 static void pc_hmat_off_cfg(const void *data) { - QTestState *qs =3D qtest_initf("%s -nodefaults --preconfig " - "-smp 2,sockets=3D2 " - "-m 128M,slots=3D2,maxmem=3D1G " - "-object memory-backend-ram,size=3D64M,id=3Dm0 " - "-object memory-backend-ram,size=3D64M,id=3Dm1 " - "-numa node,nodeid=3D0,memdev=3Dm0", - data ? (char *)data : ""); + QTestState *qs; + g_autofree char *cli =3D NULL; + + cli =3D make_cli(data, "-nodefaults --preconfig " + "-smp 2,sockets=3D2 " + "-m 128M,slots=3D2,maxmem=3D1G " + "-object memory-backend-ram,size=3D64M,id=3Dm0 " + "-object memory-backend-ram,size=3D64M,id=3Dm1 " + "-numa node,nodeid=3D0,memdev=3Dm0"); + qs =3D qtest_init(cli); =20 /* * Fail: Enable HMAT with -machine hmat=3Don @@ -491,16 +488,19 @@ static void pc_hmat_off_cfg(const void *data) =20 static void pc_hmat_erange_cfg(const void *data) { - QTestState *qs =3D qtest_initf("%s -nodefaults --preconfig -machine hm= at=3Don " - "-smp 2,sockets=3D2 " - "-m 128M,slots=3D2,maxmem=3D1G " - "-object memory-backend-ram,size=3D64M,id=3Dm0 " - "-object memory-backend-ram,size=3D64M,id=3Dm1 " - "-numa node,nodeid=3D0,memdev=3Dm0 " - "-numa node,nodeid=3D1,memdev=3Dm1,initiator=3D0 " - "-numa cpu,node-id=3D0,socket-id=3D0 " - "-numa cpu,node-id=3D0,socket-id=3D1", - data ? (char *)data : ""); + QTestState *qs; + g_autofree char *cli =3D NULL; + + cli =3D make_cli(data, "-nodefaults --preconfig -machine hmat=3Don " + "-smp 2,sockets=3D2 " + "-m 128M,slots=3D2,maxmem=3D1G " + "-object memory-backend-ram,size=3D64M,id=3Dm0 " + "-object memory-backend-ram,size=3D64M,id=3Dm1 " + "-numa node,nodeid=3D0,memdev=3Dm0 " + "-numa node,nodeid=3D1,memdev=3Dm1,initiator=3D0 " + "-numa cpu,node-id=3D0,socket-id=3D0 " + "-numa cpu,node-id=3D0,socket-id=3D1"); + qs =3D qtest_init(cli); =20 /* Can't store the compressed latency */ g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-no= de'," @@ -539,11 +539,11 @@ static void pc_hmat_erange_cfg(const void *data) =20 int main(int argc, char **argv) { - const char *args =3D NULL; + g_autoptr(GString) args =3D g_string_new(NULL); const char *arch =3D qtest_get_arch(); =20 - if (strcmp(arch, "aarch64") =3D=3D 0) { - args =3D "-machine virt"; + if (g_str_equal(arch, "aarch64")) { + g_string_append(args, " -machine virt"); } =20 g_test_init(&argc, &argv, NULL); --=20 2.18.1 From nobody Sat Feb 7 09:30:26 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581962768837279.1023460139245; Mon, 17 Feb 2020 10:06:08 -0800 (PST) Received: from localhost ([::1]:49880 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kmV-0001Ih-IL for importer@patchew.org; Mon, 17 Feb 2020 13:06:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38985) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kK7-0004Em-Ha for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kK6-0002mU-6h for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:47 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:33955 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3kK6-0002mG-2d for qemu-devel@nongnu.org; Mon, 17 Feb 2020 12:36:46 -0500 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-119-CWR0QveINwuXkqTy-jyhFQ-1; Mon, 17 Feb 2020 12:36:43 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id ED064800D50 for ; Mon, 17 Feb 2020 17:36:42 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 44D6090526; Mon, 17 Feb 2020 17:36:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581961005; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=C1rQtEFE0T2D1DVnx5qJt3zzo5C6lVaBidKgVyMKQ4Y=; b=S2lbGu9vjvSIg+925ABs6PKWGEQATrEOChIu/AqpdatjIYVR2AGb//OjEbNGAiNRGHWH8e DUbNDiCGHhxkXHfUKEX9Crh3rukQlNYIPicIfbT8ZGnvh/ie+oAPEP6EdCw3iOnDjFVhAv 4MLjvMIjjZi2nwanWEAYgld9jpLSrfg= From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v5 79/79] tests:numa-test: use explicit memdev to specify node RAM Date: Mon, 17 Feb 2020 12:34:52 -0500 Message-Id: <20200217173452.15243-80-imammedo@redhat.com> In-Reply-To: <20200217173452.15243-1-imammedo@redhat.com> References: <20200217173452.15243-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: CWR0QveINwuXkqTy-jyhFQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Follow up patches will remove automatic RAM distribution between nodes and will make default machine types require "memdev" option instead of legacy "mem" option. Make tests to follow new rules and add an additional test for legacy "mem" option on old machine type, to make sure it won't regress in the future. Signed-off-by: Igor Mammedov Acked-by: Thomas Huth --- v3: * s/strcmp/g_str_equal/ * put -object lines before -m (Thomas Huth ) * drop new test_pc_legacy_mem(), due to dropping "numa: forbid '-numa node,mem' for 5.0 and newer machine types" it will be posted later, when libvirt side is prepared for disabled '-numa node,mem' (hopefully 5.1) --- tests/qtest/numa-test.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/tests/qtest/numa-test.c b/tests/qtest/numa-test.c index 35999ea28f..2f9b7f663a 100644 --- a/tests/qtest/numa-test.c +++ b/tests/qtest/numa-test.c @@ -25,9 +25,8 @@ static void test_mon_explicit(const void *data) g_autofree char *s =3D NULL; g_autofree char *cli =3D NULL; =20 - cli =3D make_cli(data, "-smp 8 " - "-numa node,nodeid=3D0,cpus=3D0-3 " - "-numa node,nodeid=3D1,cpus=3D4-7 "); + cli =3D make_cli(data, "-smp 8 -numa node,nodeid=3D0,memdev=3Dram,cpus= =3D0-3 " + "-numa node,nodeid=3D1,cpus=3D4-7"); qts =3D qtest_init(cli); =20 s =3D qtest_hmp(qts, "info numa"); @@ -37,13 +36,13 @@ static void test_mon_explicit(const void *data) qtest_quit(qts); } =20 -static void test_mon_default(const void *data) +static void test_def_cpu_split(const void *data) { QTestState *qts; g_autofree char *s =3D NULL; g_autofree char *cli =3D NULL; =20 - cli =3D make_cli(data, "-smp 8 -numa node -numa node"); + cli =3D make_cli(data, "-smp 8 -numa node,memdev=3Dram -numa node"); qts =3D qtest_init(cli); =20 s =3D qtest_hmp(qts, "info numa"); @@ -60,7 +59,7 @@ static void test_mon_partial(const void *data) g_autofree char *cli =3D NULL; =20 cli =3D make_cli(data, "-smp 8 " - "-numa node,nodeid=3D0,cpus=3D0-1 " + "-numa node,nodeid=3D0,memdev=3Dram,cpus=3D0-1 " "-numa node,nodeid=3D1,cpus=3D4-5 "); qts =3D qtest_init(cli); =20 @@ -87,7 +86,8 @@ static void test_query_cpus(const void *data) QTestState *qts; g_autofree char *cli =3D NULL; =20 - cli =3D make_cli(data, "-smp 8 -numa node,cpus=3D0-3 -numa node,cpus= =3D4-7"); + cli =3D make_cli(data, "-smp 8 -numa node,memdev=3Dram,cpus=3D0-3 " + "-numa node,cpus=3D4-7"); qts =3D qtest_init(cli); cpus =3D get_cpus(qts, &resp); g_assert(cpus); @@ -125,7 +125,7 @@ static void pc_numa_cpu(const void *data) g_autofree char *cli =3D NULL; =20 cli =3D make_cli(data, "-cpu pentium -smp 8,sockets=3D2,cores=3D2,thre= ads=3D2 " - "-numa node,nodeid=3D0 -numa node,nodeid=3D1 " + "-numa node,nodeid=3D0,memdev=3Dram -numa node,nodeid=3D1 " "-numa cpu,node-id=3D1,socket-id=3D0 " "-numa cpu,node-id=3D0,socket-id=3D1,core-id=3D0 " "-numa cpu,node-id=3D0,socket-id=3D1,core-id=3D1,thread-id=3D0 " @@ -178,7 +178,7 @@ static void spapr_numa_cpu(const void *data) g_autofree char *cli =3D NULL; =20 cli =3D make_cli(data, "-smp 4,cores=3D4 " - "-numa node,nodeid=3D0 -numa node,nodeid=3D1 " + "-numa node,nodeid=3D0,memdev=3Dram -numa node,nodeid=3D1 " "-numa cpu,node-id=3D0,core-id=3D0 " "-numa cpu,node-id=3D0,core-id=3D1 " "-numa cpu,node-id=3D0,core-id=3D2 " @@ -223,7 +223,7 @@ static void aarch64_numa_cpu(const void *data) g_autofree char *cli =3D NULL; =20 cli =3D make_cli(data, "-smp 2 " - "-numa node,nodeid=3D0 -numa node,nodeid=3D1 " + "-numa node,nodeid=3D0,memdev=3Dram -numa node,nodeid=3D1 " "-numa cpu,node-id=3D1,thread-id=3D0 " "-numa cpu,node-id=3D0,thread-id=3D1"); qts =3D qtest_init(cli); @@ -270,7 +270,7 @@ static void pc_dynamic_cpu_cfg(const void *data) =20 /* create 2 numa nodes */ g_assert(!qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node'," - " 'arguments': { 'type': 'node', 'nodeid': 0 } }"))); + " 'arguments': { 'type': 'node', 'nodeid': 0, 'memdev': 'ram' } }"= ))); g_assert(!qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node'," " 'arguments': { 'type': 'node', 'nodeid': 1 } }"))); =20 @@ -542,13 +542,19 @@ int main(int argc, char **argv) g_autoptr(GString) args =3D g_string_new(NULL); const char *arch =3D qtest_get_arch(); =20 + if (g_str_equal(arch, "ppc64")) { + g_string_append(args, " -object memory-backend-ram,id=3Dram,size= =3D512M"); + } else { + g_string_append(args, " -object memory-backend-ram,id=3Dram,size= =3D128M"); + } + if (g_str_equal(arch, "aarch64")) { g_string_append(args, " -machine virt"); } =20 g_test_init(&argc, &argv, NULL); =20 - qtest_add_data_func("/numa/mon/default", args, test_mon_default); + qtest_add_data_func("/numa/mon/cpus/default", args, test_def_cpu_split= ); qtest_add_data_func("/numa/mon/cpus/explicit", args, test_mon_explicit= ); qtest_add_data_func("/numa/mon/cpus/partial", args, test_mon_partial); qtest_add_data_func("/numa/qmp/cpus/query-cpus", args, test_query_cpus= ); --=20 2.18.1