From nobody Thu Nov 6 20:34:47 2025 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.zoho.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 1487747951445586.2729043232447; Tue, 21 Feb 2017 23:19:11 -0800 (PST) Received: from localhost ([::1]:50371 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgRCf-0006Ct-0N for importer@patchew.org; Wed, 22 Feb 2017 02:19:10 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37963) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgQVA-00037Q-JE for qemu-devel@nongnu.org; Wed, 22 Feb 2017 01:34:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgQV7-000872-Cf for qemu-devel@nongnu.org; Wed, 22 Feb 2017 01:34:12 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:42217) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cgQV6-00080k-Et; Wed, 22 Feb 2017 01:34:09 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3vSndL11yyz9sDB; Wed, 22 Feb 2017 17:33:55 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1487745238; bh=C7Jv7H9e+em0EKxNkb1fScMdiG09Tm1nrC2aFKUQ/mU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QLR+z8v/N/rXAKx2UOrR7BPrSy+ghv6BvifMlDY/VQ0FJeeIppBSRodv/ejx3j1ws bBauzBfgeVUWUZVbLp+XK0Xpk1v3bo/E6QWPkPcwDwjcQqJM8FbgwBDiNSumsJqsPp +++vmzaaExQPcqTmXbiv8ZhmXwDpl5dyUDo+sZFE= From: David Gibson To: peter.maydell@linaro.org Date: Wed, 22 Feb 2017 17:33:37 +1100 Message-Id: <20170222063348.32176-33-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170222063348.32176-1-david@gibson.dropbear.id.au> References: <20170222063348.32176-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 32/43] machine: move possible_cpus to MachineState 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: lvivier@redhat.com, thuth@redhat.com, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, agraf@suse.de, qemu-ppc@nongnu.org, imammedo@redhat.com, David Gibson 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" From: Igor Mammedov so that it would be possible to reuse it with spapr/virt-aarch64 targets. Signed-off-by: Igor Mammedov Signed-off-by: David Gibson --- hw/i386/pc.c | 57 ++++++++++++++++++++++++++----------------------= ---- include/hw/boards.h | 1 + include/hw/i386/pc.h | 1 - 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 60b0946..04c6e59 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -707,7 +707,8 @@ static void pc_build_smbios(PCMachineState *pcms) size_t smbios_tables_len, smbios_anchor_len; struct smbios_phys_mem_area *mem_array; unsigned i, array_count; - X86CPU *cpu =3D X86_CPU(pcms->possible_cpus->cpus[0].cpu); + MachineState *ms =3D MACHINE(pcms); + X86CPU *cpu =3D X86_CPU(ms->possible_cpus->cpus[0].cpu); =20 /* tell smbios about cpuid version and features */ smbios_set_cpuid(cpu->env.cpuid_version, cpu->env.features[FEAT_1_EDX]= ); @@ -1111,7 +1112,7 @@ static void pc_new_cpu(const char *typename, int64_t = apic_id, Error **errp) void pc_hot_add_cpu(const int64_t id, Error **errp) { ObjectClass *oc; - PCMachineState *pcms =3D PC_MACHINE(qdev_get_machine()); + MachineState *ms =3D MACHINE(qdev_get_machine()); int64_t apic_id =3D x86_cpu_apic_id_from_index(id); Error *local_err =3D NULL; =20 @@ -1127,8 +1128,8 @@ void pc_hot_add_cpu(const int64_t id, Error **errp) return; } =20 - assert(pcms->possible_cpus->cpus[0].cpu); /* BSP is always present */ - oc =3D OBJECT_CLASS(CPU_GET_CLASS(pcms->possible_cpus->cpus[0].cpu)); + assert(ms->possible_cpus->cpus[0].cpu); /* BSP is always present */ + oc =3D OBJECT_CLASS(CPU_GET_CLASS(ms->possible_cpus->cpus[0].cpu)); pc_new_cpu(object_class_get_name(oc), apic_id, &local_err); if (local_err) { error_propagate(errp, local_err); @@ -1178,11 +1179,11 @@ void pc_cpus_init(PCMachineState *pcms) * This is used for FW_CFG_MAX_CPUS. See comments on bochs_bios_init(). */ pcms->apic_id_limit =3D x86_cpu_apic_id_from_index(max_cpus - 1) + 1; - pcms->possible_cpus =3D g_malloc0(sizeof(CPUArchIdList) + - sizeof(CPUArchId) * max_cpus); + machine->possible_cpus =3D g_malloc0(sizeof(CPUArchIdList) + + sizeof(CPUArchId) * max_cpus); for (i =3D 0; i < max_cpus; i++) { - pcms->possible_cpus->cpus[i].arch_id =3D x86_cpu_apic_id_from_inde= x(i); - pcms->possible_cpus->len++; + machine->possible_cpus->cpus[i].arch_id =3D x86_cpu_apic_id_from_i= ndex(i); + machine->possible_cpus->len++; if (i < smp_cpus) { pc_new_cpu(typename, x86_cpu_apic_id_from_index(i), &error_fat= al); } @@ -1191,7 +1192,8 @@ void pc_cpus_init(PCMachineState *pcms) =20 static void pc_build_feature_control_file(PCMachineState *pcms) { - X86CPU *cpu =3D X86_CPU(pcms->possible_cpus->cpus[0].cpu); + MachineState *ms =3D MACHINE(pcms); + X86CPU *cpu =3D X86_CPU(ms->possible_cpus->cpus[0].cpu); CPUX86State *env =3D &cpu->env; uint32_t unused, ecx, edx; uint64_t feature_control_bits =3D 0; @@ -1787,21 +1789,20 @@ static int pc_apic_cmp(const void *a, const void *b) } =20 /* returns pointer to CPUArchId descriptor that matches CPU's apic_id - * in pcms->possible_cpus->cpus, if pcms->possible_cpus->cpus has no + * in ms->possible_cpus->cpus, if ms->possible_cpus->cpus has no * entry corresponding to CPU's apic_id returns NULL. */ -static CPUArchId *pc_find_cpu_slot(PCMachineState *pcms, CPUState *cpu, - int *idx) +static CPUArchId *pc_find_cpu_slot(MachineState *ms, CPUState *cpu, int *i= dx) { CPUClass *cc =3D CPU_GET_CLASS(cpu); CPUArchId apic_id, *found_cpu; =20 apic_id.arch_id =3D cc->get_arch_id(CPU(cpu)); - found_cpu =3D bsearch(&apic_id, pcms->possible_cpus->cpus, - pcms->possible_cpus->len, sizeof(*pcms->possible_cpus->cpus), + found_cpu =3D bsearch(&apic_id, ms->possible_cpus->cpus, + ms->possible_cpus->len, sizeof(*ms->possible_cpus->cpus), pc_apic_cmp); if (found_cpu && idx) { - *idx =3D found_cpu - pcms->possible_cpus->cpus; + *idx =3D found_cpu - ms->possible_cpus->cpus; } return found_cpu; } @@ -1831,7 +1832,7 @@ static void pc_cpu_plug(HotplugHandler *hotplug_dev, fw_cfg_modify_i16(pcms->fw_cfg, FW_CFG_NB_CPUS, pcms->boot_cpus); } =20 - found_cpu =3D pc_find_cpu_slot(pcms, CPU(dev), NULL); + found_cpu =3D pc_find_cpu_slot(MACHINE(pcms), CPU(dev), NULL); found_cpu->cpu =3D CPU(dev); out: error_propagate(errp, local_err); @@ -1844,7 +1845,7 @@ static void pc_cpu_unplug_request_cb(HotplugHandler *= hotplug_dev, Error *local_err =3D NULL; PCMachineState *pcms =3D PC_MACHINE(hotplug_dev); =20 - pc_find_cpu_slot(pcms, CPU(dev), &idx); + pc_find_cpu_slot(MACHINE(pcms), CPU(dev), &idx); assert(idx !=3D -1); if (idx =3D=3D 0) { error_setg(&local_err, "Boot CPU is unpluggable"); @@ -1878,7 +1879,7 @@ static void pc_cpu_unplug_cb(HotplugHandler *hotplug_= dev, goto out; } =20 - found_cpu =3D pc_find_cpu_slot(pcms, CPU(dev), NULL); + found_cpu =3D pc_find_cpu_slot(MACHINE(pcms), CPU(dev), NULL); found_cpu->cpu =3D NULL; object_unparent(OBJECT(dev)); =20 @@ -1936,13 +1937,15 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug= _dev, cpu->apic_id =3D apicid_from_topo_ids(smp_cores, smp_threads, &top= o); } =20 - cpu_slot =3D pc_find_cpu_slot(pcms, CPU(dev), &idx); + cpu_slot =3D pc_find_cpu_slot(MACHINE(pcms), CPU(dev), &idx); if (!cpu_slot) { + MachineState *ms =3D MACHINE(pcms); + x86_topo_ids_from_apicid(cpu->apic_id, smp_cores, smp_threads, &to= po); error_setg(errp, "Invalid CPU [socket: %u, core: %u, thread: %u] w= ith" " APIC ID %" PRIu32 ", valid index range 0:%d", topo.pkg_id, topo.core_id, topo.smt_id, cpu->apic_id, - pcms->possible_cpus->len - 1); + ms->possible_cpus->len - 1); return; } =20 @@ -2253,9 +2256,8 @@ static unsigned pc_cpu_index_to_socket_id(unsigned cp= u_index) =20 static const CPUArchIdList *pc_possible_cpu_arch_ids(MachineState *machine) { - PCMachineState *pcms =3D PC_MACHINE(machine); - assert(pcms->possible_cpus); - return pcms->possible_cpus; + assert(machine->possible_cpus); + return machine->possible_cpus; } =20 static HotpluggableCPUList *pc_query_hotpluggable_cpus(MachineState *machi= ne) @@ -2263,19 +2265,18 @@ static HotpluggableCPUList *pc_query_hotpluggable_c= pus(MachineState *machine) int i; CPUState *cpu; HotpluggableCPUList *head =3D NULL; - PCMachineState *pcms =3D PC_MACHINE(machine); const char *cpu_type; =20 - cpu =3D pcms->possible_cpus->cpus[0].cpu; + cpu =3D machine->possible_cpus->cpus[0].cpu; assert(cpu); /* BSP is always present */ cpu_type =3D object_class_get_name(OBJECT_CLASS(CPU_GET_CLASS(cpu))); =20 - for (i =3D 0; i < pcms->possible_cpus->len; i++) { + for (i =3D 0; i < machine->possible_cpus->len; i++) { X86CPUTopoInfo topo; HotpluggableCPUList *list_item =3D g_new0(typeof(*list_item), 1); HotpluggableCPU *cpu_item =3D g_new0(typeof(*cpu_item), 1); CpuInstanceProperties *cpu_props =3D g_new0(typeof(*cpu_props), 1); - const uint32_t apic_id =3D pcms->possible_cpus->cpus[i].arch_id; + const uint32_t apic_id =3D machine->possible_cpus->cpus[i].arch_id; =20 x86_topo_ids_from_apicid(apic_id, smp_cores, smp_threads, &topo); =20 @@ -2289,7 +2290,7 @@ static HotpluggableCPUList *pc_query_hotpluggable_cpu= s(MachineState *machine) cpu_props->thread_id =3D topo.smt_id; cpu_item->props =3D cpu_props; =20 - cpu =3D pcms->possible_cpus->cpus[i].cpu; + cpu =3D machine->possible_cpus->cpus[i].cpu; if (cpu) { cpu_item->has_qom_path =3D true; cpu_item->qom_path =3D object_get_canonical_path(OBJECT(cpu)); diff --git a/include/hw/boards.h b/include/hw/boards.h index ac891a8..64e8c07 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -178,6 +178,7 @@ struct MachineState { char *initrd_filename; const char *cpu_model; AccelState *accelerator; + CPUArchIdList *possible_cpus; }; =20 #define DEFINE_MACHINE(namestr, machine_initfn) \ diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 079e8d9..d1f4554 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -73,7 +73,6 @@ struct PCMachineState { /* CPU and apic information: */ bool apic_xrupt_override; unsigned apic_id_limit; - CPUArchIdList *possible_cpus; uint16_t boot_cpus; =20 /* NUMA information: */ --=20 2.9.3