From nobody Sun Nov 2 11:47:14 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.zohomail.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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1509300912419969.5678646701349; Sun, 29 Oct 2017 11:15:12 -0700 (PDT) Received: from localhost ([::1]:37294 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e8s6l-0005qg-Tm for importer@patchew.org; Sun, 29 Oct 2017 14:14:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35532) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e8s4m-0004dr-6n for qemu-devel@nongnu.org; Sun, 29 Oct 2017 14:12:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e8s4j-0005ob-15 for qemu-devel@nongnu.org; Sun, 29 Oct 2017 14:12:48 -0400 Received: from 6.mo178.mail-out.ovh.net ([46.105.53.132]:59051) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e8s4i-0005oD-RC for qemu-devel@nongnu.org; Sun, 29 Oct 2017 14:12:44 -0400 Received: from player793.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo178.mail-out.ovh.net (Postfix) with ESMTP id 6F4BA63798 for ; Sun, 29 Oct 2017 19:12:43 +0100 (CET) Received: from zorba.kaod.org (ken64-2-78-199-76-109.fbx.proxad.net [78.199.76.109]) (Authenticated sender: clg@kaod.org) by player793.ha.ovh.net (Postfix) with ESMTPSA id 445A74007B; Sun, 29 Oct 2017 19:12:36 +0100 (CET) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, David Gibson , Greg Kurz , Benjamin Herrenschmidt Date: Sun, 29 Oct 2017 19:12:11 +0100 Message-Id: <20171029181217.9927-3-clg@kaod.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171029181217.9927-1-clg@kaod.org> References: <20171029181217.9927-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1881097271350889299 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedttddrfeekgddutdelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.53.132 Subject: [Qemu-devel] [PATCH 2/8] spapr: introduce a machine class flag to handle migration compatibility 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: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Older pseries machines, before 2.11, do not have a bitmap acting as a IRQ number allocator but use the ICSIRQState array for this purpose. This difference between machine versions needs to be taken into account when loading the state. To keep in sync the bitmap with the ICSIRQState array flags, we introduce a machine class flag 'pre_2_11_has_no_bitmap' identifying an older version. Signed-off-by: C=C3=A9dric Le Goater --- hw/ppc/spapr.c | 19 +++++++++++++++++++ include/hw/ppc/spapr.h | 1 + 2 files changed, 20 insertions(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 88da4bad2328..b33eebe44906 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1532,6 +1532,7 @@ static bool spapr_vga_init(PCIBus *pci_bus, Error **e= rrp) static int spapr_post_load(void *opaque, int version_id) { sPAPRMachineState *spapr =3D (sPAPRMachineState *)opaque; + sPAPRMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(spapr); int err =3D 0; =20 if (!object_dynamic_cast(OBJECT(spapr->ics), TYPE_ICS_KVM)) { @@ -1562,6 +1563,20 @@ static int spapr_post_load(void *opaque, int version= _id) } } =20 + /* + * synchronize the IRQ number bitmap with the ICSIRQState array + * coming from an pre-2.11 pseries machine + */ + if (smc->pre_2_11_has_no_bitmap) { + int srcno; + + for (srcno =3D 0; srcno < spapr->ics->nr_irqs; srcno++) { + if (spapr->ics->irqs[srcno].flags & XICS_FLAGS_IRQ_MASK && + !test_bit(srcno, spapr->irq_map)) { + bitmap_set(spapr->irq_map, srcno, 1); + } + } + } return err; } =20 @@ -3772,8 +3787,12 @@ static void spapr_machine_2_10_instance_options(Mach= ineState *machine) =20 static void spapr_machine_2_10_class_options(MachineClass *mc) { + sPAPRMachineClass *smc =3D SPAPR_MACHINE_CLASS(mc); + spapr_machine_2_11_class_options(mc); SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_10); + + smc->pre_2_11_has_no_bitmap =3D true; } =20 DEFINE_SPAPR_MACHINE(2_10, "2.10", false); diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index b962bfe09bb5..1525d1518c47 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -62,6 +62,7 @@ struct sPAPRMachineClass { bool dr_lmb_enabled; /* enable dynamic-reconfig/hotplug of LMBs = */ bool use_ohci_by_default; /* use USB-OHCI instead of XHCI */ bool pre_2_10_has_unused_icps; + bool pre_2_11_has_no_bitmap; void (*phb_placement)(sPAPRMachineState *spapr, uint32_t index, uint64_t *buid, hwaddr *pio,=20 hwaddr *mmio32, hwaddr *mmio64, --=20 2.13.6