From nobody Mon Feb 9 23:01:03 2026 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; dkim=fail; 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 1529373706613719.42716746927; Mon, 18 Jun 2018 19:01:46 -0700 (PDT) Received: from localhost ([::1]:38458 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5xp-00059T-Sr for importer@patchew.org; Mon, 18 Jun 2018 22:01:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45077) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5hE-0000kK-1t for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5hD-0007yU-0R for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:36 -0400 Received: from mail-ot0-x232.google.com ([2607:f8b0:4003:c0f::232]:36649) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5hC-0007yB-RI; Mon, 18 Jun 2018 21:44:34 -0400 Received: by mail-ot0-x232.google.com with SMTP id c15-v6so20775961otl.3; Mon, 18 Jun 2018 18:44:34 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id c2-v6sm7230601oia.53.2018.06.18.18.44.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:44:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=VezRNQfXglW/W0BokEbZqT2nWAl5NAFctJeiToebtKA=; b=UIqPXgw6DxfSiL4w/z6hcqyQLeVG6Nms1dJFsLKYxJKz05PuoL76PLPoj03FHWhLQ6 RBK/N+ZxcRQtxTSfLgFco7/ZbV2IXQVCTdq+1BEeJgYeByBktudLhcOx4dx2peXKa81+ 6gq/5b9Lq0iuvvR2Y3gRUZIkDNDpbuhIHsaH4e284XByHepJmBUSPpURP7VwOSbVMAUk rSu+xjwLI639GfmeWCiKjG6tww0k0ZMB89iPhyGF9aiaoevoiYk5mrWe5fr2pqcNy7VB Pa45KlnWF5Q+uPQjzEC2Z7Jh47XZce8/QvQUGrISGNnD77Vi4hmsiWeugjYG3eP6BX49 gqKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=VezRNQfXglW/W0BokEbZqT2nWAl5NAFctJeiToebtKA=; b=SIrqpZnrE84V2Tf57JO9nVHYoiwmeP3wgq9qlswYvHpMTzpHPZp0XccFTg3EoiYcpH 2M049FzaRvVJlg0L1COtJ0KvcXeW9Ix67mpQ1VOfO0528dqmujTe6FO+jkAUgkC8Nluj vp3FIgTpe1W9tWaHIlD2ukPOsJIKNANZiijd4Vzb0EEH13lY1kQDj2Nwqi9wDzW+5cso fPv9qWsMIG8JU6v/EAX00eF22T00xxjkreP0//K2qfPk9H7yDn1kbRwHXideCg59U7Zh Ubuq44vXhMnx8RiobOI6gSeFq8nQrJtOzRE5cexiiFpzWrIxEDJaQVgd+sahOqO9fZk3 cXXw== X-Gm-Message-State: APt69E3W6axp545Gxwg2xDNrHq7s38OEt3IK65PSA88iOoZoaJebhShF 5r76h/kwgMynhJU27mRn1iza1JUd X-Google-Smtp-Source: ADUXVKIjg3VAvg0/na96kZ/j1eMBd/R3dXiY5WIRcn1AGwkLFvoR7yYkLSqKA50qzP1HTHJ5ZSOO2Q== X-Received: by 2002:a9d:70d6:: with SMTP id w22-v6mr9686724otj.375.1529372673630; Mon, 18 Jun 2018 18:44:33 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:41:41 -0500 Message-Id: <20180619014319.28272-16-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c0f::232 Subject: [Qemu-devel] [PATCH 015/113] spapr: register dummy ICPs later 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: David Gibson , qemu-stable@nongnu.org, Greg Kurz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Greg Kurz Some older machine types create more ICPs than needed. We hence need to register up to xics_max_server_number() dummy ICPs to accomodate the migration of these machine types. Recent VSMT rework changed xics_max_server_number() to return DIV_ROUND_UP(max_cpus * spapr->vsmt, smp_threads) instead of DIV_ROUND_UP(max_cpus * kvmppc_smt_threads(), smp_threads); The change is okay but it requires spapr->vsmt to be set, which isn't the case with the current code. This causes the formula to return zero and we don't create dummy ICPs. This breaks migration of older guests as reported here: https://bugzilla.redhat.com/show_bug.cgi?id=3D1549087 The dummy ICP workaround doesn't really have a dependency on XICS itself. But it does depend on proper VCPU id numbering and it must be applied before creating vCPUs (ie, creating real ICPs). So this patch moves the workaround to spapr_init_cpus(), which already assumes VSMT to be set. Fixes: 72194664c8a1 ("spapr: use spapr->vsmt to compute VCPU ids") Reported-by: Lukas Doktor Signed-off-by: Greg Kurz Signed-off-by: David Gibson (cherry picked from commit 72fdd4de8e5fdc1a6078e000835fb54592a3fe97) Signed-off-by: Greg Kurz --- hw/ppc/spapr.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index d53123c127..1a2dd1f597 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -184,7 +184,6 @@ static int xics_max_server_number(sPAPRMachineState *sp= apr) 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) && @@ -206,17 +205,6 @@ 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(spapr); 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, @@ -2210,6 +2198,7 @@ static void spapr_init_cpus(sPAPRMachineState *spapr) { MachineState *machine =3D MACHINE(spapr); MachineClass *mc =3D MACHINE_GET_CLASS(machine); + sPAPRMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(machine); const char *type =3D spapr_get_cpu_core_type(machine->cpu_type); const CPUArchIdList *possible_cpus; int boot_cores_nr =3D smp_cpus / smp_threads; @@ -2240,6 +2229,17 @@ static void spapr_init_cpus(sPAPRMachineState *spapr) boot_cores_nr =3D possible_cpus->len; } =20 + if (smc->pre_2_10_has_unused_icps) { + int i; + + for (i =3D 0; i < xics_max_server_number(spapr); i++) { + /* Dummy entries get deregistered when real ICPState objects + * are registered during CPU core hotplug. + */ + pre_2_10_vmstate_register_dummy_icp(i); + } + } + for (i =3D 0; i < possible_cpus->len; i++) { int core_id =3D i * smp_threads; =20 --=20 2.11.0