From nobody Thu Nov 6 20:34:48 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 1487747283412585.9462831681466; Tue, 21 Feb 2017 23:08:03 -0800 (PST) Received: from localhost ([::1]:50311 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgR1u-0001vZ-1Y for importer@patchew.org; Wed, 22 Feb 2017 02:08:02 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38252) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgQVG-0003Ex-NZ for qemu-devel@nongnu.org; Wed, 22 Feb 2017 01:34:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgQVD-0008Fm-5V for qemu-devel@nongnu.org; Wed, 22 Feb 2017 01:34:18 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:41909) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cgQVC-0008Cm-Lr; Wed, 22 Feb 2017 01:34:15 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3vSndM5Ck1z9sNG; Wed, 22 Feb 2017 17:33:57 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1487745239; bh=7qFzPEvrBsf5In97ArLE3/n/h9KHuoVTmNJKF6n4lQs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JPW5y+WFfsDI4nhisw7bZKAAYAajDTwA77Jp2j224ruaeYFz530TLdheVignaakxp 3WKQEN6jXAcIYlvIVrNPkVPAtBwDy2nXWeDbtgU9V4D65wgVzbtTggS/yG3ZdPZWIK sVTfz9/T33KFyw0aJ+qCezAI6N+lWMdA5o8a/BOI= From: David Gibson To: peter.maydell@linaro.org Date: Wed, 22 Feb 2017 17:33:40 +1100 Message-Id: <20170222063348.32176-36-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 35/43] pc: pass apic_id to pc_find_cpu_slot() directly so lookup could be done without CPU object 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 Signed-off-by: Igor Mammedov Signed-off-by: David Gibson --- hw/i386/pc.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 50ba977..3475174 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1789,12 +1789,11 @@ static int pc_apic_cmp(const void *a, const void *b) * 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(MachineState *ms, CPUState *cpu, int *i= dx) +static CPUArchId *pc_find_cpu_slot(MachineState *ms, uint32_t id, int *idx) { - CPUClass *cc =3D CPU_GET_CLASS(cpu); CPUArchId apic_id, *found_cpu; =20 - apic_id.arch_id =3D cc->get_arch_id(CPU(cpu)); + apic_id.arch_id =3D id; found_cpu =3D bsearch(&apic_id, ms->possible_cpus->cpus, ms->possible_cpus->len, sizeof(*ms->possible_cpus->cpus), pc_apic_cmp); @@ -1810,6 +1809,7 @@ static void pc_cpu_plug(HotplugHandler *hotplug_dev, CPUArchId *found_cpu; HotplugHandlerClass *hhc; Error *local_err =3D NULL; + X86CPU *cpu =3D X86_CPU(dev); PCMachineState *pcms =3D PC_MACHINE(hotplug_dev); =20 if (pcms->acpi_dev) { @@ -1829,7 +1829,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(MACHINE(pcms), CPU(dev), NULL); + found_cpu =3D pc_find_cpu_slot(MACHINE(pcms), cpu->apic_id, NULL); found_cpu->cpu =3D CPU(dev); out: error_propagate(errp, local_err); @@ -1840,9 +1840,10 @@ static void pc_cpu_unplug_request_cb(HotplugHandler = *hotplug_dev, int idx =3D -1; HotplugHandlerClass *hhc; Error *local_err =3D NULL; + X86CPU *cpu =3D X86_CPU(dev); PCMachineState *pcms =3D PC_MACHINE(hotplug_dev); =20 - pc_find_cpu_slot(MACHINE(pcms), CPU(dev), &idx); + pc_find_cpu_slot(MACHINE(pcms), cpu->apic_id, &idx); assert(idx !=3D -1); if (idx =3D=3D 0) { error_setg(&local_err, "Boot CPU is unpluggable"); @@ -1867,6 +1868,7 @@ static void pc_cpu_unplug_cb(HotplugHandler *hotplug_= dev, CPUArchId *found_cpu; HotplugHandlerClass *hhc; Error *local_err =3D NULL; + X86CPU *cpu =3D X86_CPU(dev); PCMachineState *pcms =3D PC_MACHINE(hotplug_dev); =20 hhc =3D HOTPLUG_HANDLER_GET_CLASS(pcms->acpi_dev); @@ -1876,7 +1878,7 @@ static void pc_cpu_unplug_cb(HotplugHandler *hotplug_= dev, goto out; } =20 - found_cpu =3D pc_find_cpu_slot(MACHINE(pcms), CPU(dev), NULL); + found_cpu =3D pc_find_cpu_slot(MACHINE(pcms), cpu->apic_id, NULL); found_cpu->cpu =3D NULL; object_unparent(OBJECT(dev)); =20 @@ -1934,7 +1936,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_d= ev, cpu->apic_id =3D apicid_from_topo_ids(smp_cores, smp_threads, &top= o); } =20 - cpu_slot =3D pc_find_cpu_slot(MACHINE(pcms), CPU(dev), &idx); + cpu_slot =3D pc_find_cpu_slot(MACHINE(pcms), cpu->apic_id, &idx); if (!cpu_slot) { MachineState *ms =3D MACHINE(pcms); =20 --=20 2.9.3