From: Harsh Prateek Bora Date: Mon, 25 Nov 2024 06:43:34 +0000 (+1000) Subject: ppc/spapr: fix drc index mismatch for partially enabled vcpus X-Git-Tag: v9.1.3~55 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d6f305515ac55eb8dc585283665e46d431e4b667;p=thirdparty%2Fqemu.git ppc/spapr: fix drc index mismatch for partially enabled vcpus In case when vcpus are explicitly enabled/disabled in a non-consecutive order within a libvirt xml, it results in a drc index mismatch during vcpu hotplug later because the existing logic uses vcpu id to derive the corresponding drc index which is not correct. Use env->core_index to derive a vcpu's drc index as appropriate to fix this issue. For ex, for the given libvirt xml config: We see below error on guest console with "virsh setvcpus 5" : pseries-hotplug-cpu: CPU with drc index 10000002 already exists This patch fixes the issue by using correct drc index for explicitly enabled vcpus during init. Reported-by: Anushree Mathur Tested-by: Anushree Mathur Signed-off-by: Harsh Prateek Bora Reviewed-by: Nicholas Piggin Signed-off-by: Nicholas Piggin (cherry picked from commit e8185fdc63e1db1efba695aae568fae8a075a815) Signed-off-by: Michael Tokarev --- diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 370d7c35d3a..0307953fe57 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -758,7 +758,7 @@ static void spapr_dt_cpu(CPUState *cs, void *fdt, int offset, uint32_t radix_AP_encodings[PPC_PAGE_SIZES_MAX_SZ]; int i; - drc = spapr_drc_by_id(TYPE_SPAPR_DRC_CPU, index); + drc = spapr_drc_by_id(TYPE_SPAPR_DRC_CPU, env->core_index); if (drc) { drc_index = spapr_drc_index(drc); _FDT((fdt_setprop_cell(fdt, offset, "ibm,my-drc-index", drc_index)));