From nobody Fri May 10 13:29:17 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.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 149744704534869.53577533814303; Wed, 14 Jun 2017 06:30:45 -0700 (PDT) Received: from localhost ([::1]:48922 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dL8Nb-0006xg-UH for importer@patchew.org; Wed, 14 Jun 2017 09:30:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56092) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dL8MA-0005so-QH for qemu-devel@nongnu.org; Wed, 14 Jun 2017 09:29:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dL8M6-00044b-PU for qemu-devel@nongnu.org; Wed, 14 Jun 2017 09:29:10 -0400 Received: from 10.mo5.mail-out.ovh.net ([46.105.52.148]:45549) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dL8M6-00044L-Io for qemu-devel@nongnu.org; Wed, 14 Jun 2017 09:29:06 -0400 Received: from player799.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo5.mail-out.ovh.net (Postfix) with ESMTP id 3DC74106209 for ; Wed, 14 Jun 2017 15:29:05 +0200 (CEST) Received: from bahia.lan (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player799.ha.ovh.net (Postfix) with ESMTPA id E4514520093; Wed, 14 Jun 2017 15:29:00 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Wed, 14 Jun 2017 15:29:00 +0200 Message-ID: <149744694069.5507.18392116536249515873.stgit@bahia.lan> In-Reply-To: <149744692318.5507.14451686460325895979.stgit@bahia.lan> References: <149744692318.5507.14451686460325895979.stgit@bahia.lan> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 4188629129684162854 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeeljedrjeehgdeikecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.52.148 Subject: [Qemu-devel] [PATCH v5 1/3] spapr: manage hotplugged devices while the VM is not started 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: Laurent Vivier , qemu-ppc@nongnu.org, Cedric Le Goater , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 From: Laurent Vivier For QEMU, a hotlugged device is a device added using the HMP/QMP interface. For SPAPR, a hotplugged device is a device added while the machine is running. In this case QEMU doesn't update internal state but relies on the OS for this part In the case of migration, when we (libvirt) hotplug a device on the source guest, we (libvirt) generally hotplug the same device on the destination guest. But in this case, the machine is stopped (RUN_STATE_INMIGRATE) and QEMU must not expect the OS will manage it as an hotplugged device as it will be "imported" by the migration. This patch changes the meaning of "hotplugged" in spapr.c to manage a QEMU hotplugged device like a "coldplugged" one when the machine is awaiting an incoming migration. Signed-off-by: Laurent Vivier Reviewed-by: Greg Kurz Reviewed-by: Daniel Barboza Tested-by: Daniel Barboza [groug: rebased to latest ppc-for-2.10] Signed-off-by: Greg Kurz --- hw/ppc/spapr.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 1df642f4f5cf..1e13880ecb7c 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2566,6 +2566,12 @@ static void spapr_nmi(NMIState *n, int cpu_index, Er= ror **errp) } } =20 +static bool spapr_coldplugged(DeviceState *dev) +{ + return runstate_check(RUN_STATE_INMIGRATE) || + !dev->hotplugged; +} + static void spapr_add_lmbs(DeviceState *dev, uint64_t addr_start, uint64_t= size, uint32_t node, bool dedicated_hp_event_source, Error **errp) @@ -2575,6 +2581,7 @@ static void spapr_add_lmbs(DeviceState *dev, uint64_t= addr_start, uint64_t size, int i, fdt_offset, fdt_size; void *fdt; uint64_t addr =3D addr_start; + bool coldplugged =3D spapr_coldplugged(dev); =20 for (i =3D 0; i < nr_lmbs; i++) { drc =3D spapr_drc_by_id(TYPE_SPAPR_DRC_LMB, @@ -2585,9 +2592,9 @@ static void spapr_add_lmbs(DeviceState *dev, uint64_t= addr_start, uint64_t size, fdt_offset =3D spapr_populate_memory_node(fdt, node, addr, SPAPR_MEMORY_BLOCK_SIZE); =20 - spapr_drc_attach(drc, dev, fdt, fdt_offset, !dev->hotplugged, errp= ); + spapr_drc_attach(drc, dev, fdt, fdt_offset, coldplugged, errp); addr +=3D SPAPR_MEMORY_BLOCK_SIZE; - if (!dev->hotplugged) { + if (coldplugged) { sPAPRDRConnectorClass *drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(d= rc); /* guests expect coldplugged LMBs to be pre-allocated */ drck->set_allocation_state(drc, SPAPR_DR_ALLOCATION_STATE_USAB= LE); @@ -2597,7 +2604,7 @@ static void spapr_add_lmbs(DeviceState *dev, uint64_t= addr_start, uint64_t size, /* send hotplug notification to the * guest only in case of hotplugged memory */ - if (dev->hotplugged) { + if (!coldplugged) { if (dedicated_hp_event_source) { drc =3D spapr_drc_by_id(TYPE_SPAPR_DRC_LMB, addr_start / SPAPR_MEMORY_BLOCK_SIZE); @@ -2908,6 +2915,7 @@ static void spapr_core_plug(HotplugHandler *hotplug_d= ev, DeviceState *dev, int smt =3D kvmppc_smt_threads(); CPUArchId *core_slot; int index; + bool coldplugged =3D spapr_coldplugged(dev); =20 core_slot =3D spapr_find_cpu_slot(MACHINE(hotplug_dev), cc->core_id, &= index); if (!core_slot) { @@ -2928,8 +2936,7 @@ static void spapr_core_plug(HotplugHandler *hotplug_d= ev, DeviceState *dev, } =20 if (drc) { - spapr_drc_attach(drc, dev, fdt, fdt_offset, !dev->hotplugged, - &local_err); + spapr_drc_attach(drc, dev, fdt, fdt_offset, coldplugged, &local_er= r); if (local_err) { g_free(fdt); error_propagate(errp, local_err); @@ -2937,7 +2944,7 @@ static void spapr_core_plug(HotplugHandler *hotplug_d= ev, DeviceState *dev, } } =20 - if (dev->hotplugged) { + if (!coldplugged) { /* * Send hotplug notification interrupt to the guest only in case * of hotplugged CPUs. From nobody Fri May 10 13:29:17 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.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 1497447142766446.93777612294525; Wed, 14 Jun 2017 06:32:22 -0700 (PDT) Received: from localhost ([::1]:48927 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dL8PA-00084X-He for importer@patchew.org; Wed, 14 Jun 2017 09:32:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56180) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dL8MK-00063M-OT for qemu-devel@nongnu.org; Wed, 14 Jun 2017 09:29:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dL8MG-00049L-AI for qemu-devel@nongnu.org; Wed, 14 Jun 2017 09:29:20 -0400 Received: from 7.mo5.mail-out.ovh.net ([178.32.124.100]:33159) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dL8MG-00048Y-45 for qemu-devel@nongnu.org; Wed, 14 Jun 2017 09:29:16 -0400 Received: from player799.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo5.mail-out.ovh.net (Postfix) with ESMTP id C8B141065E0 for ; Wed, 14 Jun 2017 15:29:14 +0200 (CEST) Received: from bahia.lan (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player799.ha.ovh.net (Postfix) with ESMTPA id 7D45652006D; Wed, 14 Jun 2017 15:29:10 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Wed, 14 Jun 2017 15:29:10 +0200 Message-ID: <149744695027.5507.7049830187351447969.stgit@bahia.lan> In-Reply-To: <149744692318.5507.14451686460325895979.stgit@bahia.lan> References: <149744692318.5507.14451686460325895979.stgit@bahia.lan> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 4191162404791425318 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeeljedrjeehgdeikecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 178.32.124.100 Subject: [Qemu-devel] [PATCH v5 2/3] xics: directly register ICPState objects to vmstate 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: Laurent Vivier , qemu-ppc@nongnu.org, Cedric Le Goater , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 The ICPState objects are currently registered to vmstate as qdev objects. Their instance ids are hence computed automatically in the migration code, and thus depends on the order the CPU cores were plugged. If the destination had its CPU cores plugged in a different order than the source, then ICPState objects will have different instance_ids and load the wrong state. Since CPU objects have a reliable cpu_index which is already used as instance_id in vmstate, let's use it for ICPState as well. Please note that this doesn't break migration. Older machine types used to allocate and realize all ICPState objects at machine init time, for the who= le lifetime of the machine. The qdev instance ids are thus 0,1,2... nr_servers and happen to map to the vCPU indexes. Signed-off-by: Greg Kurz Reviewed-by: Laurent Vivier --- v5: - explain why it doesn't break migration in the changelog --- hw/intc/xics.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/intc/xics.c b/hw/intc/xics.c index 7ccfb53c55a0..faa5c631f655 100644 --- a/hw/intc/xics.c +++ b/hw/intc/xics.c @@ -344,10 +344,14 @@ static void icp_realize(DeviceState *dev, Error **err= p) } =20 qemu_register_reset(icp_reset, dev); + vmstate_register(NULL, icp->cs->cpu_index, &vmstate_icp_server, icp); } =20 static void icp_unrealize(DeviceState *dev, Error **errp) { + ICPState *icp =3D ICP(dev); + + vmstate_unregister(NULL, &vmstate_icp_server, icp); qemu_unregister_reset(icp_reset, dev); } =20 @@ -355,7 +359,6 @@ static void icp_class_init(ObjectClass *klass, void *da= ta) { DeviceClass *dc =3D DEVICE_CLASS(klass); =20 - dc->vmsd =3D &vmstate_icp_server; dc->realize =3D icp_realize; dc->unrealize =3D icp_unrealize; } From nobody Fri May 10 13:29:17 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.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 1497447074244781.0092518311208; Wed, 14 Jun 2017 06:31:14 -0700 (PDT) Received: from localhost ([::1]:48923 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dL8O7-0007KW-VL for importer@patchew.org; Wed, 14 Jun 2017 09:31:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56250) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dL8MT-0006B6-Ug for qemu-devel@nongnu.org; Wed, 14 Jun 2017 09:29:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dL8MQ-0004C0-NV for qemu-devel@nongnu.org; Wed, 14 Jun 2017 09:29:29 -0400 Received: from 2.mo5.mail-out.ovh.net ([178.33.109.111]:53632) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dL8MQ-0004BQ-E5 for qemu-devel@nongnu.org; Wed, 14 Jun 2017 09:29:26 -0400 Received: from player799.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo5.mail-out.ovh.net (Postfix) with ESMTP id 829A7106598 for ; Wed, 14 Jun 2017 15:29:24 +0200 (CEST) Received: from bahia.lan (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player799.ha.ovh.net (Postfix) with ESMTPA id 1580F52008E; Wed, 14 Jun 2017 15:29:20 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Wed, 14 Jun 2017 15:29:19 +0200 Message-ID: <149744695984.5507.11604157257247801492.stgit@bahia.lan> In-Reply-To: <149744692318.5507.14451686460325895979.stgit@bahia.lan> References: <149744692318.5507.14451686460325895979.stgit@bahia.lan> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 4193977154000558374 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeeljedrjeehgdeikecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 178.33.109.111 Subject: [Qemu-devel] [PATCH v5 3/3] spapr: fix migration of ICPState objects from/to older QEMU 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: Laurent Vivier , qemu-ppc@nongnu.org, Cedric Le Goater , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Commit 5bc8d26de20c ("spapr: allocate the ICPState object from under sPAPRCPUCore") moved ICPState objects from the machine to CPU cores. This is an improvement since we no longer allocate ICPState objects that will never be used. But it has the side-effect of breaking migration of older machine types from older QEMU versions. This patch allows spapr to register dummy "icp/server" entries to vmstate. These entries use a dedicated VMStateDescription that can swallow and discard state of an incoming migration stream, and that don't send anything on outgoing migration. As for real ICPState objects, the instance_id is the cpu_index of the corresponding vCPU, which happens to be equal to the generated instance_id of older machine types. The machine can unregister/register these entries when CPUs are dynamically plugged/unplugged. This is only available for pseries-2.9 and older machines, thanks to a compat property. Signed-off-by: Greg Kurz --- v5: - pass the CPU index as opaque argument to vmstate_(un)register() - renamed xics_nr_server() to xics_max_server_number() - added comment to explain why pre_2_10_vmstate_dummy_icp_needed() always return false - added comment in xics_system_init() to indicate that dummy entries get deregistered when real ICPs are registered --- hw/ppc/spapr.c | 88 ++++++++++++++++++++++++++++++++++++++++++++= +++- include/hw/ppc/spapr.h | 1 + 2 files changed, 87 insertions(+), 2 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 1e13880ecb7c..b939cc72731f 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -127,9 +127,49 @@ error: return NULL; } =20 +static bool pre_2_10_vmstate_dummy_icp_needed(void *opaque) +{ + /* Dummy entries correspond to unused ICPState objects in older QEMUs, + * and newer QEMUs don't even have them. In both cases, we don't want + * to send anything on the wire. + */ + return false; +} + +static const VMStateDescription pre_2_10_vmstate_dummy_icp =3D { + .name =3D "icp/server", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D pre_2_10_vmstate_dummy_icp_needed, + .fields =3D (VMStateField[]) { + VMSTATE_UNUSED(4), /* uint32_t xirr */ + VMSTATE_UNUSED(1), /* uint8_t pending_priority */ + VMSTATE_UNUSED(1), /* uint8_t mfrr */ + VMSTATE_END_OF_LIST() + }, +}; + +static void pre_2_10_vmstate_register_dummy_icp(int i) +{ + vmstate_register(NULL, i, &pre_2_10_vmstate_dummy_icp, + (void *)(uintptr_t) i); +} + +static void pre_2_10_vmstate_unregister_dummy_icp(int i) +{ + vmstate_unregister(NULL, &pre_2_10_vmstate_dummy_icp, + (void *)(uintptr_t) i); +} + +static inline int xics_max_server_number(void) +{ + return DIV_ROUND_UP(max_cpus * kvmppc_smt_threads(), smp_threads); +} + static void xics_system_init(MachineState *machine, int nr_irqs, Error **e= rrp) { sPAPRMachineState *spapr =3D SPAPR_MACHINE(machine); + sPAPRMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(machine); =20 if (kvm_enabled()) { if (machine_kernel_irqchip_allowed(machine) && @@ -151,6 +191,17 @@ static void xics_system_init(MachineState *machine, in= t nr_irqs, Error **errp) return; } } + + if (smc->pre_2_10_has_unused_icps) { + int i; + + for (i =3D 0; i < xics_max_server_number(); i++) { + /* Dummy entries get deregistered when real ICPState objects + * are registered during CPU core hotplug. + */ + pre_2_10_vmstate_register_dummy_icp(i); + } + } } =20 static int spapr_fixup_cpu_smt_dt(void *fdt, int offset, PowerPCCPU *cpu, @@ -979,7 +1030,6 @@ static void *spapr_build_fdt(sPAPRMachineState *spapr, void *fdt; sPAPRPHBState *phb; char *buf; - int smt =3D kvmppc_smt_threads(); =20 fdt =3D g_malloc0(FDT_MAX_SIZE); _FDT((fdt_create_empty_tree(fdt, FDT_MAX_SIZE))); @@ -1019,7 +1069,7 @@ static void *spapr_build_fdt(sPAPRMachineState *spapr, _FDT(fdt_setprop_cell(fdt, 0, "#size-cells", 2)); =20 /* /interrupt controller */ - spapr_dt_xics(DIV_ROUND_UP(max_cpus * smt, smp_threads), fdt, PHANDLE_= XICP); + spapr_dt_xics(xics_max_server_number(), fdt, PHANDLE_XICP); =20 ret =3D spapr_populate_memory(spapr, fdt); if (ret < 0) { @@ -2851,9 +2901,24 @@ static void spapr_core_unplug(HotplugHandler *hotplu= g_dev, DeviceState *dev, Error **errp) { MachineState *ms =3D MACHINE(qdev_get_machine()); + sPAPRMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(ms); CPUCore *cc =3D CPU_CORE(dev); CPUArchId *core_slot =3D spapr_find_cpu_slot(ms, cc->core_id, NULL); =20 + if (smc->pre_2_10_has_unused_icps) { + sPAPRCPUCore *sc =3D SPAPR_CPU_CORE(OBJECT(dev)); + sPAPRCPUCoreClass *scc =3D SPAPR_CPU_CORE_GET_CLASS(OBJECT(cc)); + const char *typename =3D object_class_get_name(scc->cpu_class); + size_t size =3D object_type_get_instance_size(typename); + int i; + + for (i =3D 0; i < cc->nr_threads; i++) { + CPUState *cs =3D CPU(sc->threads + i * size); + + pre_2_10_vmstate_register_dummy_icp(cs->cpu_index); + } + } + assert(core_slot); core_slot->cpu =3D NULL; object_unparent(OBJECT(dev)); @@ -2905,6 +2970,7 @@ static void spapr_core_plug(HotplugHandler *hotplug_d= ev, DeviceState *dev, { sPAPRMachineState *spapr =3D SPAPR_MACHINE(OBJECT(hotplug_dev)); MachineClass *mc =3D MACHINE_GET_CLASS(spapr); + sPAPRMachineClass *smc =3D SPAPR_MACHINE_CLASS(mc); sPAPRCPUCore *core =3D SPAPR_CPU_CORE(OBJECT(dev)); CPUCore *cc =3D CPU_CORE(dev); CPUState *cs =3D CPU(core->threads); @@ -2961,6 +3027,21 @@ static void spapr_core_plug(HotplugHandler *hotplug_= dev, DeviceState *dev, } } core_slot->cpu =3D OBJECT(dev); + + if (smc->pre_2_10_has_unused_icps) { + sPAPRCPUCoreClass *scc =3D SPAPR_CPU_CORE_GET_CLASS(OBJECT(cc)); + const char *typename =3D object_class_get_name(scc->cpu_class); + size_t size =3D object_type_get_instance_size(typename); + int i; + + for (i =3D 0; i < cc->nr_threads; i++) { + sPAPRCPUCore *sc =3D SPAPR_CPU_CORE(dev); + void *obj =3D sc->threads + i * size; + + cs =3D CPU(obj); + pre_2_10_vmstate_unregister_dummy_icp(cs->cpu_index); + } + } } =20 static void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *= dev, @@ -3410,9 +3491,12 @@ static void spapr_machine_2_9_instance_options(Machi= neState *machine) =20 static void spapr_machine_2_9_class_options(MachineClass *mc) { + sPAPRMachineClass *smc =3D SPAPR_MACHINE_CLASS(mc); + spapr_machine_2_10_class_options(mc); SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_9); mc->numa_auto_assign_ram =3D numa_legacy_auto_assign_ram; + smc->pre_2_10_has_unused_icps =3D true; } =20 DEFINE_SPAPR_MACHINE(2_9, "2.9", false); diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 2ddb052c24b9..a66bbac35242 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -53,6 +53,7 @@ struct sPAPRMachineClass { bool dr_lmb_enabled; /* enable dynamic-reconfig/hotplug of LMBs = */ bool use_ohci_by_default; /* use USB-OHCI instead of XHCI */ const char *tcg_default_cpu; /* which (TCG) CPU to simulate by default= */ + bool pre_2_10_has_unused_icps; void (*phb_placement)(sPAPRMachineState *spapr, uint32_t index, uint64_t *buid, hwaddr *pio,=20 hwaddr *mmio32, hwaddr *mmio64,