From nobody Thu May 2 10:44:32 2024 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1511429146586427.5596886992124; Thu, 23 Nov 2017 01:25:46 -0800 (PST) Received: from localhost ([::1]:43123 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eHnl6-0002zJ-Nv for importer@patchew.org; Thu, 23 Nov 2017 04:25:24 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38615) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eHnjX-0002CB-CN for qemu-devel@nongnu.org; Thu, 23 Nov 2017 04:23:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eHnjW-0005yl-4Z for qemu-devel@nongnu.org; Thu, 23 Nov 2017 04:23:47 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59380) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eHnjV-0005y8-U9 for qemu-devel@nongnu.org; Thu, 23 Nov 2017 04:23:46 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E39347F41E; Thu, 23 Nov 2017 09:23:44 +0000 (UTC) Received: from xz-mi.nay.redhat.com (dhcp-14-111.nay.redhat.com [10.66.14.111]) by smtp.corp.redhat.com (Postfix) with ESMTP id A47F95D9C7; Thu, 23 Nov 2017 09:23:42 +0000 (UTC) From: Peter Xu To: qemu-devel@nongnu.org Date: Thu, 23 Nov 2017 17:23:31 +0800 Message-Id: <20171123092333.16085-2-peterx@redhat.com> In-Reply-To: <20171123092333.16085-1-peterx@redhat.com> References: <20171123092333.16085-1-peterx@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 23 Nov 2017 09:23:45 +0000 (UTC) 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: 209.132.183.28 Subject: [Qemu-devel] [PATCH 1/3] pci: Initialize pci_dev->name before use 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: Peter Maydell , Eduardo Habkost , Alexey Kardashevskiy , peterx@redhat.com, Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Alexey Kardashevskiy This moves pci_dev->name initialization earlier so pci_dev->bus_master_as could get a name instead of an empty string. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Peter Xu Signed-off-by: Alexey Kardashevskiy Signed-off-by: Peter Xu --- hw/pci/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 5ed3c8dca4..b2d139bd9a 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1030,6 +1030,7 @@ static PCIDevice *do_pci_register_device(PCIDevice *p= ci_dev, PCIBus *bus, =20 pci_dev->devfn =3D devfn; pci_dev->requester_id_cache =3D pci_req_id_cache_get(pci_dev); + pstrcpy(pci_dev->name, sizeof(pci_dev->name), name); =20 memory_region_init(&pci_dev->bus_master_container_region, OBJECT(pci_d= ev), "bus master container", UINT64_MAX); @@ -1039,7 +1040,6 @@ static PCIDevice *do_pci_register_device(PCIDevice *p= ci_dev, PCIBus *bus, if (qdev_hotplug) { pci_init_bus_master(pci_dev); } - pstrcpy(pci_dev->name, sizeof(pci_dev->name), name); pci_dev->irq_state =3D 0; pci_config_alloc(pci_dev); =20 --=20 2.14.3 From nobody Thu May 2 10:44:32 2024 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1511429151081704.8103059103719; Thu, 23 Nov 2017 01:25:51 -0800 (PST) Received: from localhost ([::1]:43127 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eHnlJ-0003A4-37 for importer@patchew.org; Thu, 23 Nov 2017 04:25:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38708) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eHnjd-0002FI-7l for qemu-devel@nongnu.org; Thu, 23 Nov 2017 04:23:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eHnjY-00061U-VJ for qemu-devel@nongnu.org; Thu, 23 Nov 2017 04:23:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58990) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eHnjY-0005zy-Lp for qemu-devel@nongnu.org; Thu, 23 Nov 2017 04:23:48 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B31A9267D5; Thu, 23 Nov 2017 09:23:47 +0000 (UTC) Received: from xz-mi.nay.redhat.com (dhcp-14-111.nay.redhat.com [10.66.14.111]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5BBBC5D9C7; Thu, 23 Nov 2017 09:23:45 +0000 (UTC) From: Peter Xu To: qemu-devel@nongnu.org Date: Thu, 23 Nov 2017 17:23:32 +0800 Message-Id: <20171123092333.16085-3-peterx@redhat.com> In-Reply-To: <20171123092333.16085-1-peterx@redhat.com> References: <20171123092333.16085-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 23 Nov 2017 09:23:47 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/3] cpu: refactor cpu_address_space_init() 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: Peter Maydell , Eduardo Habkost , Alexey Kardashevskiy , peterx@redhat.com, Paolo Bonzini , Richard Henderson 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" Normally we create an address space for that CPU and pass that address space into the function. Let's just do it inside to unify address space creations. It'll simplify my next patch to rename those address spaces. Signed-off-by: Peter Xu --- cpus.c | 5 +---- exec.c | 7 ++++++- include/exec/exec-all.h | 6 ++++-- target/arm/cpu.c | 13 +++---------- target/i386/cpu.c | 10 ++-------- 5 files changed, 16 insertions(+), 25 deletions(-) diff --git a/cpus.c b/cpus.c index 114c29b6a0..ae9dbf9510 100644 --- a/cpus.c +++ b/cpus.c @@ -1778,11 +1778,8 @@ 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 g_new0(AddressSpace, 1); - - address_space_init(as, cpu->memory, "cpu-memory"); cpu->num_ases =3D 1; - cpu_address_space_init(cpu, as, 0); + cpu_address_space_init(cpu, 0, "cpu-memory", cpu->memory); } =20 if (kvm_enabled()) { diff --git a/exec.c b/exec.c index 8b579c0cd9..b4abe75931 100644 --- a/exec.c +++ b/exec.c @@ -714,9 +714,14 @@ CPUState *qemu_get_cpu(int index) } =20 #if !defined(CONFIG_USER_ONLY) -void cpu_address_space_init(CPUState *cpu, AddressSpace *as, int asidx) +void cpu_address_space_init(CPUState *cpu, int asidx, + const char *prefix, MemoryRegion *mr) { CPUAddressSpace *newas; + AddressSpace *as =3D g_new0(AddressSpace, 1); + + assert(mr); + address_space_init(as, mr, prefix); =20 /* Target code should have set num_ases before calling us */ assert(asidx < cpu->num_ases); diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 0f51c92adb..b37f7d8d92 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -74,8 +74,9 @@ void cpu_reloading_memory_map(void); /** * cpu_address_space_init: * @cpu: CPU to add this address space to - * @as: address space to add * @asidx: integer index of this address space + * @prefix: prefix to be used as name of address space + * @mr: the root memory region of address space * * Add the specified address space to the CPU's cpu_ases list. * The address space added with @asidx 0 is the one used for the @@ -89,7 +90,8 @@ void cpu_reloading_memory_map(void); * * Note that with KVM only one address space is supported. */ -void cpu_address_space_init(CPUState *cpu, AddressSpace *as, int asidx); +void cpu_address_space_init(CPUState *cpu, int asidx, + const char *prefix, MemoryRegion *mr); #endif =20 #if !defined(CONFIG_USER_ONLY) && defined(CONFIG_TCG) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 7f7a3d1e32..cc1856c32b 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -705,9 +705,6 @@ 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) { @@ -912,21 +909,17 @@ 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)) { - as =3D g_new0(AddressSpace, 1); - cs->num_ases =3D 2; =20 if (!cpu->secure_memory) { cpu->secure_memory =3D cs->memory; } - address_space_init(as, cpu->secure_memory, "cpu-secure-memory"); - cpu_address_space_init(cs, as, ARMASIdx_S); + cpu_address_space_init(cs, ARMASIdx_S, "cpu-secure-memory", + cpu->secure_memory); } else { cs->num_ases =3D 1; } - as =3D g_new0(AddressSpace, 1); - address_space_init(as, cs->memory, "cpu-memory"); - cpu_address_space_init(cs, as, ARMASIdx_NS); + cpu_address_space_init(cs, ARMASIdx_NS, "cpu-memory", cs->memory); #endif =20 qemu_init_vcpu(cs); diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 1edcf29e27..7dd408cba8 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -3736,11 +3736,6 @@ static void x86_cpu_realizefn(DeviceState *dev, Erro= r **errp) =20 #ifndef CONFIG_USER_ONLY if (tcg_enabled()) { - AddressSpace *as_normal =3D g_new0(AddressSpace, 1); - AddressSpace *as_smm =3D g_new(AddressSpace, 1); - - 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 @@ -3755,11 +3750,10 @@ static void x86_cpu_realizefn(DeviceState *dev, Err= or **errp) get_system_memory(), 0, ~0ull); memory_region_add_subregion_overlap(cpu->cpu_as_root, 0, cpu->cpu_= as_mem, 0); memory_region_set_enabled(cpu->cpu_as_mem, true); - address_space_init(as_smm, cpu->cpu_as_root, "CPU"); =20 cs->num_ases =3D 2; - cpu_address_space_init(cs, as_normal, 0); - cpu_address_space_init(cs, as_smm, 1); + cpu_address_space_init(cs, 0, "cpu-memory", cs->memory); + cpu_address_space_init(cs, 1, "cpu-smm", cpu->cpu_as_root); =20 /* ... SMRAM with higher priority, linked from /machine/smram. */ cpu->machine_done.notify =3D x86_cpu_machine_done; --=20 2.14.3 From nobody Thu May 2 10:44:32 2024 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 1511429253592851.7554014081691; Thu, 23 Nov 2017 01:27:33 -0800 (PST) Received: from localhost ([::1]:43137 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eHnn5-0004iP-SC for importer@patchew.org; Thu, 23 Nov 2017 04:27:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38695) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eHnjc-0002Ed-AA for qemu-devel@nongnu.org; Thu, 23 Nov 2017 04:23:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eHnjb-00066A-E6 for qemu-devel@nongnu.org; Thu, 23 Nov 2017 04:23:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:4812) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eHnjb-000650-8I for qemu-devel@nongnu.org; Thu, 23 Nov 2017 04:23:51 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6E7CC356F0; Thu, 23 Nov 2017 09:23:50 +0000 (UTC) Received: from xz-mi.nay.redhat.com (dhcp-14-111.nay.redhat.com [10.66.14.111]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2859F5D9C7; Thu, 23 Nov 2017 09:23:47 +0000 (UTC) From: Peter Xu To: qemu-devel@nongnu.org Date: Thu, 23 Nov 2017 17:23:33 +0800 Message-Id: <20171123092333.16085-4-peterx@redhat.com> In-Reply-To: <20171123092333.16085-1-peterx@redhat.com> References: <20171123092333.16085-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 23 Nov 2017 09:23:50 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 3/3] cpu: suffix cpu address spaces with cpu index 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: Peter Maydell , Eduardo Habkost , Alexey Kardashevskiy , peterx@redhat.com, Paolo Bonzini , Richard Henderson 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" Renaming cpu address space names so that they won't be the same when there are more than one. Signed-off-by: Peter Xu --- exec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/exec.c b/exec.c index b4abe75931..c6e4c20c8f 100644 --- a/exec.c +++ b/exec.c @@ -719,9 +719,12 @@ void cpu_address_space_init(CPUState *cpu, int asidx, { CPUAddressSpace *newas; AddressSpace *as =3D g_new0(AddressSpace, 1); + char *as_name; =20 assert(mr); - address_space_init(as, mr, prefix); + as_name =3D g_strdup_printf("%s-%d", prefix, cpu->cpu_index); + address_space_init(as, mr, as_name); + g_free(as_name); =20 /* Target code should have set num_ases before calling us */ assert(asidx < cpu->num_ases); --=20 2.14.3