From nobody Mon Feb 9 17:24:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1505465260817272.6399586636953; Fri, 15 Sep 2017 01:47:40 -0700 (PDT) Received: from localhost ([::1]:51980 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsmHj-0005xE-WA for importer@patchew.org; Fri, 15 Sep 2017 04:47:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38268) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsmB9-00071d-On for qemu-devel@nongnu.org; Fri, 15 Sep 2017 04:40:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dsmB7-0002Yr-DQ for qemu-devel@nongnu.org; Fri, 15 Sep 2017 04:40:51 -0400 Received: from ozlabs.ru ([107.173.13.209]:44668) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsmB7-0002Ql-4J for qemu-devel@nongnu.org; Fri, 15 Sep 2017 04:40:49 -0400 Received: from vpl1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id 913133A60065; Fri, 15 Sep 2017 04:42:02 -0400 (EDT) From: Alexey Kardashevskiy To: qemu-devel@nongnu.org Date: Fri, 15 Sep 2017 18:40:29 +1000 Message-Id: <20170915084030.40988-13-aik@ozlabs.ru> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170915084030.40988-1-aik@ozlabs.ru> References: <20170915084030.40988-1-aik@ozlabs.ru> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 107.173.13.209 Subject: [Qemu-devel] [PATCH qemu v2 12/13] memory: Get rid of address_space_init_shareable X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexey Kardashevskiy , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Since FlatViews are shared now and ASes not, this gets rid of address_space_init_shareable(). Signed-off-by: Alexey Kardashevskiy --- Squash to the previous one? It is a separate patch to make review easier, mostly. --- include/exec/memory.h | 17 ----------------- include/hw/arm/armv7m.h | 2 +- cpus.c | 5 +++-- hw/arm/armv7m.c | 9 ++++----- memory.c | 10 ---------- target/arm/cpu.c | 16 ++++++++-------- target/i386/cpu.c | 5 +++-- 7 files changed, 19 insertions(+), 45 deletions(-) diff --git a/include/exec/memory.h b/include/exec/memory.h index 04993f8eca..a550dc21e5 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -1584,23 +1584,6 @@ MemTxResult memory_region_dispatch_write(MemoryRegio= n *mr, void address_space_init(AddressSpace *as, MemoryRegion *root, const char *= name); =20 /** - * address_space_init_shareable: return an address space for a memory regi= on, - * creating it if it does not already exist - * - * @root: a #MemoryRegion that routes addresses for the address space - * @name: an address space name. The name is only used for debugging - * output. - * - * This function will return a pointer to an existing AddressSpace - * which was initialized with the specified MemoryRegion, or it will - * create and initialize one if it does not already exist. The ASes - * are reference-counted, so the memory will be freed automatically - * when the AddressSpace is destroyed via address_space_destroy. - */ -AddressSpace *address_space_init_shareable(MemoryRegion *root, - const char *name); - -/** * address_space_destroy: destroy an address space * * Releases all resources associated with an address space. After an addr= ess space diff --git a/include/hw/arm/armv7m.h b/include/hw/arm/armv7m.h index 10eb058027..008000fe11 100644 --- a/include/hw/arm/armv7m.h +++ b/include/hw/arm/armv7m.h @@ -21,7 +21,7 @@ typedef struct { SysBusDevice parent_obj; /*< public >*/ =20 - AddressSpace *source_as; + AddressSpace source_as; MemoryRegion iomem; uint32_t base; MemoryRegion *source_memory; diff --git a/cpus.c b/cpus.c index 9bed61eefc..c9a624003a 100644 --- a/cpus.c +++ b/cpus.c @@ -1764,8 +1764,9 @@ void qemu_init_vcpu(CPUState *cpu) /* If the target cpu hasn't set up any address spaces itself, * give it the default one. */ - AddressSpace *as =3D address_space_init_shareable(cpu->memory, - "cpu-memory"); + AddressSpace *as =3D g_new0(AddressSpace, 1); + + address_space_init(as, cpu->memory, "cpu-memory"); cpu->num_ases =3D 1; cpu_address_space_init(cpu, as, 0); } diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c index b64a409b40..4900339646 100644 --- a/hw/arm/armv7m.c +++ b/hw/arm/armv7m.c @@ -41,7 +41,7 @@ static MemTxResult bitband_read(void *opaque, hwaddr offs= et, =20 /* Find address in underlying memory and round down to multiple of siz= e */ addr =3D bitband_addr(s, offset) & (-size); - res =3D address_space_read(s->source_as, addr, attrs, buf, size); + res =3D address_space_read(&s->source_as, addr, attrs, buf, size); if (res) { return res; } @@ -66,7 +66,7 @@ static MemTxResult bitband_write(void *opaque, hwaddr off= set, uint64_t value, =20 /* Find address in underlying memory and round down to multiple of siz= e */ addr =3D bitband_addr(s, offset) & (-size); - res =3D address_space_read(s->source_as, addr, attrs, buf, size); + res =3D address_space_read(&s->source_as, addr, attrs, buf, size); if (res) { return res; } @@ -79,7 +79,7 @@ static MemTxResult bitband_write(void *opaque, hwaddr off= set, uint64_t value, } else { buf[bitpos >> 3] &=3D ~bit; } - return address_space_write(s->source_as, addr, attrs, buf, size); + return address_space_write(&s->source_as, addr, attrs, buf, size); } =20 static const MemoryRegionOps bitband_ops =3D { @@ -111,8 +111,7 @@ static void bitband_realize(DeviceState *dev, Error **e= rrp) return; } =20 - s->source_as =3D address_space_init_shareable(s->source_memory, - "bitband-source"); + address_space_init(&s->source_as, s->source_memory, "bitband-source"); } =20 /* Board init. */ diff --git a/memory.c b/memory.c index f3da9379df..06052e63a0 100644 --- a/memory.c +++ b/memory.c @@ -2793,16 +2793,6 @@ static void do_address_space_destroy(AddressSpace *a= s) g_free(as); } =20 -AddressSpace *address_space_init_shareable(MemoryRegion *root, const char = *name) -{ - AddressSpace *as; - - as =3D g_malloc0(sizeof *as); - address_space_init(as, root, name); - - return as; -} - void address_space_destroy(AddressSpace *as) { /* Flush out anything from MemoryListeners listening in on this */ diff --git a/target/arm/cpu.c b/target/arm/cpu.c index a1acce3c7a..8874763b4b 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -678,6 +678,9 @@ static void arm_cpu_realizefn(DeviceState *dev, Error *= *errp) CPUARMState *env =3D &cpu->env; int pagebits; Error *local_err =3D NULL; +#ifndef CONFIG_USER_ONLY + AddressSpace *as; +#endif =20 cpu_exec_realizefn(cs, &local_err); if (local_err !=3D NULL) { @@ -868,24 +871,21 @@ static void arm_cpu_realizefn(DeviceState *dev, Error= **errp) =20 #ifndef CONFIG_USER_ONLY if (cpu->has_el3 || arm_feature(env, ARM_FEATURE_M_SECURITY)) { - AddressSpace *as; + as =3D g_new0(AddressSpace, 1); =20 cs->num_ases =3D 2; =20 if (!cpu->secure_memory) { cpu->secure_memory =3D cs->memory; } - as =3D address_space_init_shareable(cpu->secure_memory, - "cpu-secure-memory"); + address_space_init(as, cpu->secure_memory, "cpu-secure-memory"); cpu_address_space_init(cs, as, ARMASIdx_S); } else { cs->num_ases =3D 1; } - - cpu_address_space_init(cs, - address_space_init_shareable(cs->memory, - "cpu-memory"), - ARMASIdx_NS); + as =3D g_new0(AddressSpace, 1); + address_space_init(as, cs->memory, "cpu-memory"); + cpu_address_space_init(cs, as, ARMASIdx_NS); #endif =20 qemu_init_vcpu(cs); diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 69676e13e1..11178300ee 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -3741,10 +3741,11 @@ static void x86_cpu_realizefn(DeviceState *dev, Err= or **errp) =20 #ifndef CONFIG_USER_ONLY if (tcg_enabled()) { - AddressSpace *as_normal =3D address_space_init_shareable(cs->memor= y, - "cpu-memory= "); + AddressSpace *as_normal =3D g_new0(AddressSpace, 1); AddressSpace *as_smm =3D g_new(AddressSpace, 1); =20 + address_space_init(as_normal, cs->memory, "cpu-memory"); + cpu->cpu_as_mem =3D g_new(MemoryRegion, 1); cpu->cpu_as_root =3D g_new(MemoryRegion, 1); =20 --=20 2.11.0