From patchwork Wed Jun 7 14:18:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 13270762 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D0427C7EE25 for ; Wed, 7 Jun 2023 14:20:50 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q6u0p-0002ri-3N; Wed, 07 Jun 2023 10:19:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6u0o-0002rS-4U for qemu-devel@nongnu.org; Wed, 07 Jun 2023 10:19:46 -0400 Received: from esa6.hc3370-68.iphmx.com ([216.71.155.175]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6u0l-0003PC-SY for qemu-devel@nongnu.org; Wed, 07 Jun 2023 10:19:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1686147583; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=k3ef/Yah043cuQBdWrCnL0TAtjyxnRKzu4Znq8bA1Ag=; b=V6w457R8/frNCWU02DQMigFYYLRO2orOqsFH+w5O7xTiKZnUdFIkvWy3 KXj1gc8dNdiasvjHyBm3lwuGRyCs7c9VGmHkvHYLwcDYMsIc0QZj3bNwP RPXavXa/8n+q9Wfm/CBOMTfPbE1UZLvYTJPzN+MS7M7NoO4qRz2xk1MZc U=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 4.0 X-MesageID: 111246587 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.123 X-Policy: $RELAYED IronPort-Data: A9a23:yfX2TazNClSvhGAA3qB6t+cxxirEfRIJ4+MujC+fZmUNrF6WrkUGm GNNXjqFbvqPYGP1KNknPo+29EkB7ZaAzYdqSVNvpSAxQypGp/SeCIXCJC8cHc8wwu7rFxs7s ppEOrEsCOhuExcwcz/0auCJQUFUjP3OHfykTrafYEidfCc8IA85kxVvhuUltYBhhNm9Emult Mj75sbSIzdJ4RYtWo4vw/zF8EsHUMja4mtC5QRgPa8T5jcyqlFOZH4hDfDpR5fHatE88t6SH 47r0Ly/92XFyBYhYvvNfmHTKxBirhb6ZGBiu1IOM0SQqkEqSh8ai87XAME0e0ZP4whlqvgqo Dl7WT5cfi9yVkHEsLx1vxC1iEiSN4UekFPMCSDXXcB+UyQq2pYjqhljJBheAGEWxgp4KUVq9 t8eLW9QVyqavOux246ZVrkztP12eaEHPKtH0p1h5TTQDPJgSpHfWaTao9Rf2V/chOgXQ6yYP ZBAL2MyMlKZOUYn1lQ/UfrSmM+hgGX/dDtJ7kqYv6Mt70DYzRBr0airO93QEjCPbZwMxxzE+ D+WoAwVBDk5HobOzx/V106Im/HenBqmQZ4XTOano6sCbFq7mTVIVUx+uUGAieC0j1P7V99BJ kg8/C0ooq4vskuxQbHVUwK9v1aNuxcOXNwWGOp89QLl90bPy1/HXC5eFGcHMYF48pZsHlTGy 2NlgfvNIT9MtrjKFEun74ydqiiOGzRFcl07MHpsoRQ+3/Hvp4Q6jxTqR9llEbKogtCdJQwc0 wxmvwBl2exN0JdjO7GTuAme3mny/sShohsdvF2/Y46z0u9uiGdJjaSM4EOT0/tPJZ3xorKp7 CldwJj2AAzj4PiweM2xrAclRunBCxWtame0bbtT834JqVyQF4aLJ9w43d2HDB4B3jw4UTHoe lTPngha+YVeOnCnBYcuPdLvU5t0l/S7RIi8PhwxUjaoSsIpHONg1Hs3DXN8Iki3yBR8+U3BE cnznTmQ4YYyVv08kWveqxY12r433CEurV4/triipylLJYG2PSbPIZ9caQvmUwzMxP/cyOkj2 4oFZpTiJtQ2eLGWXxQ7BqZNdQ1bcyJmX8meRg4+XrfrHzeK0VoJU5f5qY7NsaQ/90iJvo8kJ k2AZ3I= IronPort-HdrOrdr: A9a23:KBtAPayLf3mS7YbaYWGEKrPwIr1zdoMgy1knxilNoH1uHvBw8v rEoB1173DJYVoqNk3I++rhBEDwexLhHPdOiOF6UItKNzOW21dAQrsSiLfK8nnNHDD/6/4Y9Y oISdkbNDQoNykZsfrH X-Talos-CUID: 9a23:rOqFSG73SSe8CJEfJdss0GoXOcYgLSDk9m7rKkijNUR1GOKncArF X-Talos-MUID: 9a23:aCSshg/tTcmGaHECmnFIHMuQf+RCufWoLRAorbEbpdiFDHFpJzLF1yviFw== X-IronPort-AV: E=Sophos;i="6.00,224,1681185600"; d="scan'208";a="111246587" To: CC: David Woodhouse , Anthony PERARD Subject: [PULL 01/12] hw/xen: Simplify emulated Xen platform init Date: Wed, 7 Jun 2023 15:18:28 +0100 Message-ID: <20230607141839.48422-2-anthony.perard@citrix.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230607141839.48422-1-anthony.perard@citrix.com> References: <20230607141839.48422-1-anthony.perard@citrix.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.155.175; envelope-from=prvs=51561cf95=anthony.perard@citrix.com; helo=esa6.hc3370-68.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Anthony PERARD X-Patchwork-Original-From: Anthony PERARD via From: Anthony PERARD Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: David Woodhouse I initially put the basic platform init (overlay pages, grant tables, event channels) into mc->kvm_type because that was the earliest place that could sensibly test for xen_mode==XEN_EMULATE. The intent was to do this early enough that we could then initialise the XenBus and other parts which would have depended on them, from a generic location for both Xen and KVM/Xen in the PC-specific code, as seen in https://lore.kernel.org/qemu-devel/20230116221919.1124201-16-dwmw2@infradead.org/ However, then the Xen on Arm patches came along, and *they* wanted to do the XenBus init from a 'generic' Xen-specific location instead: https://lore.kernel.org/qemu-devel/20230210222729.957168-4-sstabellini@kernel.org/ Since there's no generic location that covers all three, I conceded to do it for XEN_EMULATE mode in pc_basic_devices_init(). And now there's absolutely no point in having some of the platform init done from pc_machine_kvm_type(); we can move it all up to live in a single place in pc_basic_devices_init(). This has the added benefit that we can drop the separate xen_evtchn_connect_gsis() function completely, and pass just the system GSIs in directly to xen_evtchn_create(). While I'm at it, it does no harm to explicitly pass in the *number* of said GSIs, because it does make me twitch a bit to pass an array of impicit size. During the lifetime of the KVM/Xen patchset, that had already changed (albeit just cosmetically) from GSI_NUM_PINS to IOAPIC_NUM_PINS. And document a bit better that this is for the *output* GSI for raising CPU0's events when the per-CPU vector isn't available. The fact that we create a whole set of them and then only waggle the one we're told to, instead of having a single output and only *connecting* it to the GSI that it should be connected to, is still non-intuitive for me. Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant Message-Id: <20230412185102.441523-2-dwmw2@infradead.org> Signed-off-by: Anthony PERARD --- hw/i386/kvm/xen_evtchn.c | 40 ++++++++++++++++++++-------------------- hw/i386/kvm/xen_evtchn.h | 3 +-- hw/i386/pc.c | 13 ++++--------- 3 files changed, 25 insertions(+), 31 deletions(-) diff --git a/hw/i386/kvm/xen_evtchn.c b/hw/i386/kvm/xen_evtchn.c index 3048329474..3d810dbd59 100644 --- a/hw/i386/kvm/xen_evtchn.c +++ b/hw/i386/kvm/xen_evtchn.c @@ -147,7 +147,10 @@ struct XenEvtchnState { QemuMutex port_lock; uint32_t nr_ports; XenEvtchnPort port_table[EVTCHN_2L_NR_CHANNELS]; - qemu_irq gsis[IOAPIC_NUM_PINS]; + + /* Connected to the system GSIs for raising callback as GSI / INTx */ + unsigned int nr_callback_gsis; + qemu_irq *callback_gsis; struct xenevtchn_handle *be_handles[EVTCHN_2L_NR_CHANNELS]; @@ -299,7 +302,7 @@ static void gsi_assert_bh(void *opaque) } } -void xen_evtchn_create(void) +void xen_evtchn_create(unsigned int nr_gsis, qemu_irq *system_gsis) { XenEvtchnState *s = XEN_EVTCHN(sysbus_create_simple(TYPE_XEN_EVTCHN, -1, NULL)); @@ -310,8 +313,19 @@ void xen_evtchn_create(void) qemu_mutex_init(&s->port_lock); s->gsi_bh = aio_bh_new(qemu_get_aio_context(), gsi_assert_bh, s); - for (i = 0; i < IOAPIC_NUM_PINS; i++) { - sysbus_init_irq(SYS_BUS_DEVICE(s), &s->gsis[i]); + /* + * These are the *output* GSI from event channel support, for + * signalling CPU0's events via GSI or PCI INTx instead of the + * per-CPU vector. We create a *set* of irqs and connect one to + * each of the system GSIs which were passed in from the platform + * code, and then just trigger the right one as appropriate from + * xen_evtchn_set_callback_level(). + */ + s->nr_callback_gsis = nr_gsis; + s->callback_gsis = g_new0(qemu_irq, nr_gsis); + for (i = 0; i < nr_gsis; i++) { + sysbus_init_irq(SYS_BUS_DEVICE(s), &s->callback_gsis[i]); + sysbus_connect_irq(SYS_BUS_DEVICE(s), i, system_gsis[i]); } /* @@ -336,20 +350,6 @@ void xen_evtchn_create(void) xen_evtchn_ops = &emu_evtchn_backend_ops; } -void xen_evtchn_connect_gsis(qemu_irq *system_gsis) -{ - XenEvtchnState *s = xen_evtchn_singleton; - int i; - - if (!s) { - return; - } - - for (i = 0; i < IOAPIC_NUM_PINS; i++) { - sysbus_connect_irq(SYS_BUS_DEVICE(s), i, system_gsis[i]); - } -} - static void xen_evtchn_register_types(void) { type_register_static(&xen_evtchn_info); @@ -430,8 +430,8 @@ void xen_evtchn_set_callback_level(int level) return; } - if (s->callback_gsi && s->callback_gsi < IOAPIC_NUM_PINS) { - qemu_set_irq(s->gsis[s->callback_gsi], level); + if (s->callback_gsi && s->callback_gsi < s->nr_callback_gsis) { + qemu_set_irq(s->callback_gsis[s->callback_gsi], level); if (level) { /* Ensure the vCPU polls for deassertion */ kvm_xen_set_callback_asserted(); diff --git a/hw/i386/kvm/xen_evtchn.h b/hw/i386/kvm/xen_evtchn.h index bfb67ac2bc..b740acfc0d 100644 --- a/hw/i386/kvm/xen_evtchn.h +++ b/hw/i386/kvm/xen_evtchn.h @@ -16,10 +16,9 @@ typedef uint32_t evtchn_port_t; -void xen_evtchn_create(void); +void xen_evtchn_create(unsigned int nr_gsis, qemu_irq *system_gsis); int xen_evtchn_soft_reset(void); int xen_evtchn_set_callback_param(uint64_t param); -void xen_evtchn_connect_gsis(qemu_irq *system_gsis); void xen_evtchn_set_callback_level(int level); int xen_evtchn_set_port(uint16_t port); diff --git a/hw/i386/pc.c b/hw/i386/pc.c index bb62c994fa..fc52772fdd 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1332,7 +1332,10 @@ void pc_basic_device_init(struct PCMachineState *pcms, #ifdef CONFIG_XEN_EMU if (xen_mode == XEN_EMULATE) { - xen_evtchn_connect_gsis(gsi); + xen_overlay_create(); + xen_evtchn_create(IOAPIC_NUM_PINS, gsi); + xen_gnttab_create(); + xen_xenstore_create(); if (pcms->bus) { pci_create_simple(pcms->bus, -1, "xen-platform"); } @@ -1882,14 +1885,6 @@ static void pc_machine_initfn(Object *obj) int pc_machine_kvm_type(MachineState *machine, const char *kvm_type) { -#ifdef CONFIG_XEN_EMU - if (xen_mode == XEN_EMULATE) { - xen_overlay_create(); - xen_evtchn_create(); - xen_gnttab_create(); - xen_xenstore_create(); - } -#endif return 0; } From patchwork Wed Jun 7 14:18:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 13270772 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BF0DFC7EE23 for ; Wed, 7 Jun 2023 14:21:48 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q6u0g-0002oC-Jk; Wed, 07 Jun 2023 10:19:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6u0f-0002nz-De for qemu-devel@nongnu.org; Wed, 07 Jun 2023 10:19:37 -0400 Received: from esa4.hc3370-68.iphmx.com ([216.71.155.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6u0d-0003PJ-QK for qemu-devel@nongnu.org; Wed, 07 Jun 2023 10:19:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1686147575; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hHLTPA5r0vzs3zH7Id5pGL8t1rKKqxf49ksrYuCdo6U=; b=L0OWhZcSP1CfrJNvlcbnNWKtGSxYk+TEcjLqmpAS3SQQR33xWBwLkPb1 akZ6ZN6eWbU/A9g9Ws279uerQJcxpGVs7Y37Pk8ttzMZ2ebfnEU4F1Buv WWj1Uex8DXSKYcSoS5JjnDEFhUlVMEQTbKMP+/3hKn/vl5BZ5NYtGEYX1 s=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 4.0 X-MesageID: 114430924 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.123 X-Policy: $RELAYED IronPort-Data: A9a23:SVMdHaxp2SSxlrVg8lx6t+cxxirEfRIJ4+MujC+fZmUNrF6WrkUBm mpJWG2BPKrfMzTxe9gkboqx/BsHsZ+EyYVmTgFlpSAxQypGp/SeCIXCJC8cHc8wwu7rFxs7s ppEOrEsCOhuExcwcz/0auCJQUFUjP3OHfykTrafYEidfCc8IA85kxVvhuUltYBhhNm9Emult Mj75sbSIzdJ4RYtWo4vw/zF8EsHUMja4mtC5QRgPa8T5jcyqlFOZH4hDfDpR5fHatE88t6SH 47r0Ly/92XFyBYhYvvNfmHTKxBirhb6ZGBiu1IOM0SQqkEqSh8ai87XAME0e0ZP4whlqvgqo Dl7WT5cfi9yVkHEsLx1vxC1iEiSN4UekFPMCSDXXcB+UyQq2pYjqhljJBheAGEWxgp4KUhEz cw6LW09VBeevMGT36KVGsR0lv12eaEHPKtH0p1h5TTQDPJgSpHfWaTao9Rf2V/chOgXQ6yYP ZBAL2MyMlKZOUYn1lQ/UfrSmM+hgGX/dDtJ7kqYv6Mt70DYzRBr0airO93QEjCPbZwMwhrD/ jOcowwVBDlZBs7Cxjvf1k70i/DslxnVBpkwFaORo6sCbFq7mTVIVUx+uUGAieC0j1P7V99BJ kg8/C0ooq4vskuxQbHVUwK9v1aNuxcOXNwWGOp89QLl90bPy1/HXC5eFGcHMYF48pZsHlTGy 2NlgfvADwRfkrjIeUia64y3iCyiF3g4NX87MHpsoRQ+3/Hvp4Q6jxTqR9llEbKogtCdJQwc0 wxmvwBl2exN0JdjO7GTuAme3mny/sShohsdvF2/Y46z0u9uiGdJjaSM4EOT0/tPJZ3xorKp7 CldwJj2AAzj4PiweM2xrAclRunBCxWtame0bbtT834JqVyQF4aLJ9w43d2HDB4B3jw4UTHoe lTPngha+YVeOnCnBYcuPdLvU5t0l/S7RIi8PhwxUjaoSsIpHONg1Hs3DXN8Iki3yBR8+U3BE cnznTmQ4YYyVv08kWveqxY12r433CEurV4/triipylLJYG2PSbPIZ9caQvmUwzMxP/cyOkj2 4oFZpTiJtQ2eLGWXxQ7BqZNdQ1bcyJmX8meRg4+XrfrHzeK0VoJU5f5qY7NsaQ890iJvo8kJ k2AZ3I= IronPort-HdrOrdr: A9a23:QpOZzKPukz5HWcBcTvOjsMiBIKoaSvp037BL7S9MoHluGfBw+P re+cjzuSWUtN9pYgBCpTniAse9qA3nhPxICOAqVN/JMWXbUQ2TXeVfBODZowEIdReOj9J15O NNdLV/Fc21LXUSt7eD3OBgKadG/DBQytHPudvj X-Talos-CUID: 9a23:Q0sml20b/ot9XCLQEWCt27xfM8odQl/YkUfqJFKDKkN2WJPFZEeAwfYx X-Talos-MUID: 9a23:BKViSw4hyZAZeveOqT71WJ04xowr0bbzB0FXtalettanPxZeZSy/jSqeF9o= X-IronPort-AV: E=Sophos;i="6.00,224,1681185600"; d="scan'208";a="114430924" To: CC: David Woodhouse , Anthony PERARD Subject: [PULL 02/12] hw/xen: Fix memory leak in libxenstore_open() for Xen Date: Wed, 7 Jun 2023 15:18:29 +0100 Message-ID: <20230607141839.48422-3-anthony.perard@citrix.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230607141839.48422-1-anthony.perard@citrix.com> References: <20230607141839.48422-1-anthony.perard@citrix.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.155.144; envelope-from=prvs=51561cf95=anthony.perard@citrix.com; helo=esa4.hc3370-68.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Anthony PERARD X-Patchwork-Original-From: Anthony PERARD via From: Anthony PERARD Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: David Woodhouse There was a superfluous allocation of the XS handle, leading to it being leaked on both the error path and the success path (where it gets allocated again). Spotted by Coverity (CID 1508098). Fixes: ba2a92db1ff6 ("hw/xen: Add xenstore operations to allow redirection to internal emulation") Suggested-by: Peter Maydell Signed-off-by: David Woodhouse Reviewed-by: Peter Maydell Reviewed-by: Paul Durrant Message-Id: <20230412185102.441523-3-dwmw2@infradead.org> Signed-off-by: Anthony PERARD --- hw/xen/xen-operations.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/xen/xen-operations.c b/hw/xen/xen-operations.c index 4b78fbf4bd..3d213d28df 100644 --- a/hw/xen/xen-operations.c +++ b/hw/xen/xen-operations.c @@ -287,7 +287,7 @@ static void watch_event(void *opaque) static struct qemu_xs_handle *libxenstore_open(void) { struct xs_handle *xsh = xs_open(0); - struct qemu_xs_handle *h = g_new0(struct qemu_xs_handle, 1); + struct qemu_xs_handle *h; if (!xsh) { return NULL; From patchwork Wed Jun 7 14:18:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 13270764 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9764EC7EE25 for ; Wed, 7 Jun 2023 14:20:55 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q6u0j-0002pj-7P; Wed, 07 Jun 2023 10:19:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6u0g-0002oL-Q7 for qemu-devel@nongnu.org; Wed, 07 Jun 2023 10:19:38 -0400 Received: from esa1.hc3370-68.iphmx.com ([216.71.145.142]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6u0e-0003PT-GY for qemu-devel@nongnu.org; Wed, 07 Jun 2023 10:19:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1686147576; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lZUzACCsa/eiibSQ8OwFKOw5Vxy0eEbqjsBKUOQieks=; b=HAHrBdmwJnRth12S+UkaOo+S/3UXdDv8ZQn26jn8rxAGQHPiO6MUX5xK l2MEswB1pIjSLXF2TnoDkOIS/cwcHKpNYijYaXm3hvYWQ0TTB4wXdzkSR U89fKuSMm1y+D/M+c0HVSzRWuLmBOFu4Mu42gi3QJzp+vfjmkgQD0AWKG w=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 4.0 X-MesageID: 112337997 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.123 X-Policy: $RELAYED IronPort-Data: A9a23:SCOJR6imRk4Q5b+a/AweAPJqX161ZhAKZh0ujC45NGQN5FlHY01je htvWG2HMqmCNDSmLt51bNvkoEkD6pDdyNQ2Tgtq/3w9Qiob9cadCdqndUqhZCn6wu8v7q5Ex 55HNoSfdpBcolv0/ErF3m3J9CEkvU2wbuOgTrWCYmYpHlUMpB4J0XpLg/Q+jpNjne+3CgaMv cKai8DEMRqu1iUc3lg8sspvkzsx+qyq0N8klgZmP6sT4geBzyN94K83fsldEVOpGuG4IcbiL wrz5OnR1n/U+R4rFuSknt7TGqHdauePVeQmoiM+t5mK2nCulARrukoIHKN0hXNsoyeIh7hMJ OBl7vRcf+uL0prkw4zxWzEAe8130DYvFLXveRBTuuTLp6HKnueFL1yDwyjaMKVBktubD12i+ tQEDDsXUDSurd6onru5Y7dnnJUbBsrSadZ3VnFIlVk1DN4jSJHHBa7L+cVZzHE7gcUm8fT2P pRDL2A1NVKZPkMJYw1MYH49tL7Aan3XejtEqFWTtOwv7nLa1gBZ27nxKtvFPNeNQK25m27B/ zidpDuoU05y2Nq30QSd6DWguNb1ty7cX9MCKbGp0KJUqQjGroAUIEJPDgbqyRWjsWanVtdCb kAZ5Ccqha418kOtU5/6RRLQiHKbuwE0Ut9ZAeo8rgqKjLfXizt1HUBdEGQHMoZ/8pZrG3pzj AThc87V6SJHrJmeU0y5252os227OwFLJnVTXQUHdF5QizX8m70bghXKR9dlNae6iNzpBD39q wy3QDgCa6Y71pBSifjilbzTq3f1/8WSEFZpjunCdjj9hj6VcrJJcGBBBbLzyf9bZLiUQVCa1 JTvs5jPtbteZX1hecHkfQnsIF1Lz6zdWNE/qQQ1d3XEy9hK0yDLQGyoyGsiTHqFy+5dEdMTX GfduBlK+LhYN2awYKl8buqZUpp6k/C/S465DaGIN7Kih6SdkifdpEmCgmbKhgjQfLUEy/lja f93j+7yZZrlNUiX5GXvHLpMuVPa7is/2XnSVfjGI+ePiNKjiIquYe5dajOmN7lphJ5oVS2Jq 76zwePWkUQAOAA/CwGLmbMuwacicyBmVM6s9pYOHgNBSyI/cFwc5zbq6etJU+RYc259z48kI lnVtpdk9WfC IronPort-HdrOrdr: A9a23:6n/yNqmymJokl8jO60hPr47UZtDpDfIo3DAbv31ZSRFFG/Fw9v rDoB1/73TJYVkqN03I9ervBEDjexPhHO9OgLX5VI3KNGOKhILCFvAA0WKN+UyFJwTOssJbyK d8Y+xfJbTLfD9HZB/BkWuF+gAbsby6zJw= X-Talos-CUID: 9a23:9TGoNGDW/Z2OJ536EzVD/1QqPu0PTmODxXX5fUSiWF5DS4TAHA== X-Talos-MUID: 9a23:ILSdeAow8rBtRonyAyQezylcLN0v75qXMmoAtpJXq/SIJAosBR7I2Q== X-IronPort-AV: E=Sophos;i="6.00,224,1681185600"; d="scan'208";a="112337997" To: CC: David Woodhouse , Anthony PERARD Subject: [PULL 03/12] xen: Drop support for Xen versions below 4.7.1 Date: Wed, 7 Jun 2023 15:18:30 +0100 Message-ID: <20230607141839.48422-4-anthony.perard@citrix.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230607141839.48422-1-anthony.perard@citrix.com> References: <20230607141839.48422-1-anthony.perard@citrix.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.145.142; envelope-from=prvs=51561cf95=anthony.perard@citrix.com; helo=esa1.hc3370-68.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Anthony PERARD X-Patchwork-Original-From: Anthony PERARD via From: Anthony PERARD Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: David Woodhouse In restructuring to allow for internal emulation of Xen functionality, I broke compatibility for Xen 4.6 and earlier. Fix this by explicitly removing support for anything older than 4.7.1, which is also ancient but it does still build, and the compatibility support for it is fairly unintrusive. Fixes: 15e283c5b684 ("hw/xen: Add foreignmem operations to allow redirection to internal emulation") Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant Message-Id: <20230412185102.441523-4-dwmw2@infradead.org> Signed-off-by: Anthony PERARD --- hw/xen/xen-operations.c | 57 +------------------ include/hw/xen/xen_native.h | 107 +----------------------------------- meson.build | 5 +- scripts/xen-detect.c | 60 -------------------- 4 files changed, 3 insertions(+), 226 deletions(-) diff --git a/hw/xen/xen-operations.c b/hw/xen/xen-operations.c index 3d213d28df..e00983ec44 100644 --- a/hw/xen/xen-operations.c +++ b/hw/xen/xen-operations.c @@ -28,46 +28,13 @@ #include /* - * We don't support Xen prior to 4.2.0. + * We don't support Xen prior to 4.7.1. */ -/* Xen 4.2 through 4.6 */ -#if CONFIG_XEN_CTRL_INTERFACE_VERSION < 40701 - -typedef xc_evtchn xenevtchn_handle; -typedef evtchn_port_or_error_t xenevtchn_port_or_error_t; - -#define xenevtchn_open(l, f) xc_evtchn_open(l, f); -#define xenevtchn_close(h) xc_evtchn_close(h) -#define xenevtchn_fd(h) xc_evtchn_fd(h) -#define xenevtchn_pending(h) xc_evtchn_pending(h) -#define xenevtchn_notify(h, p) xc_evtchn_notify(h, p) -#define xenevtchn_bind_interdomain(h, d, p) xc_evtchn_bind_interdomain(h, d, p) -#define xenevtchn_unmask(h, p) xc_evtchn_unmask(h, p) -#define xenevtchn_unbind(h, p) xc_evtchn_unbind(h, p) - -typedef xc_gnttab xengnttab_handle; - -#define xengnttab_open(l, f) xc_gnttab_open(l, f) -#define xengnttab_close(h) xc_gnttab_close(h) -#define xengnttab_set_max_grants(h, n) xc_gnttab_set_max_grants(h, n) -#define xengnttab_map_grant_ref(h, d, r, p) xc_gnttab_map_grant_ref(h, d, r, p) -#define xengnttab_unmap(h, a, n) xc_gnttab_munmap(h, a, n) -#define xengnttab_map_grant_refs(h, c, d, r, p) \ - xc_gnttab_map_grant_refs(h, c, d, r, p) -#define xengnttab_map_domain_grant_refs(h, c, d, r, p) \ - xc_gnttab_map_domain_grant_refs(h, c, d, r, p) - -typedef xc_interface xenforeignmemory_handle; - -#else /* CONFIG_XEN_CTRL_INTERFACE_VERSION >= 40701 */ - #include #include #include -#endif - /* Xen before 4.8 */ static int libxengnttab_fallback_grant_copy(xengnttab_handle *xgt, @@ -223,26 +190,6 @@ static struct gnttab_backend_ops libxengnttab_backend_ops = { .unmap = libxengnttab_backend_unmap, }; -#if CONFIG_XEN_CTRL_INTERFACE_VERSION < 40701 - -static void *libxenforeignmem_backend_map(uint32_t dom, void *addr, int prot, - size_t pages, xfn_pfn_t *pfns, - int *errs) -{ - if (errs) { - return xc_map_foreign_bulk(xen_xc, dom, prot, pfns, errs, pages); - } else { - return xc_map_foreign_pages(xen_xc, dom, prot, pfns, pages); - } -} - -static int libxenforeignmem_backend_unmap(void *addr, size_t pages) -{ - return munmap(addr, pages * XC_PAGE_SIZE); -} - -#else /* CONFIG_XEN_CTRL_INTERFACE_VERSION >= 40701 */ - static void *libxenforeignmem_backend_map(uint32_t dom, void *addr, int prot, size_t pages, xen_pfn_t *pfns, int *errs) @@ -256,8 +203,6 @@ static int libxenforeignmem_backend_unmap(void *addr, size_t pages) return xenforeignmemory_unmap(xen_fmem, addr, pages); } -#endif - struct foreignmem_backend_ops libxenforeignmem_backend_ops = { .map = libxenforeignmem_backend_map, .unmap = libxenforeignmem_backend_unmap, diff --git a/include/hw/xen/xen_native.h b/include/hw/xen/xen_native.h index 6bcc83baf9..f11eb423e3 100644 --- a/include/hw/xen/xen_native.h +++ b/include/hw/xen/xen_native.h @@ -24,23 +24,11 @@ extern xc_interface *xen_xc; /* - * We don't support Xen prior to 4.2.0. + * We don't support Xen prior to 4.7.1. */ -/* Xen 4.2 through 4.6 */ -#if CONFIG_XEN_CTRL_INTERFACE_VERSION < 40701 - -typedef xc_interface xenforeignmemory_handle; - -#define xenforeignmemory_open(l, f) xen_xc -#define xenforeignmemory_close(h) - -#else /* CONFIG_XEN_CTRL_INTERFACE_VERSION >= 40701 */ - #include -#endif - extern xenforeignmemory_handle *xen_fmem; #if CONFIG_XEN_CTRL_INTERFACE_VERSION < 40900 @@ -148,8 +136,6 @@ static inline xendevicemodel_handle *xendevicemodel_open( return xen_xc; } -#if CONFIG_XEN_CTRL_INTERFACE_VERSION >= 40500 - static inline int xendevicemodel_create_ioreq_server( xendevicemodel_handle *dmod, domid_t domid, int handle_bufioreq, ioservid_t *id) @@ -211,8 +197,6 @@ static inline int xendevicemodel_set_ioreq_server_state( return xc_hvm_set_ioreq_server_state(dmod, domid, id, enabled); } -#endif /* CONFIG_XEN_CTRL_INTERFACE_VERSION >= 40500 */ - static inline int xendevicemodel_set_pci_intx_level( xendevicemodel_handle *dmod, domid_t domid, uint16_t segment, uint8_t bus, uint8_t device, uint8_t intx, unsigned int level) @@ -340,15 +324,6 @@ static inline int xen_get_vmport_regs_pfn(xc_interface *xc, domid_t dom, } #endif -/* Xen before 4.6 */ -#if CONFIG_XEN_CTRL_INTERFACE_VERSION < 40600 - -#ifndef HVM_IOREQSRV_BUFIOREQ_ATOMIC -#define HVM_IOREQSRV_BUFIOREQ_ATOMIC 2 -#endif - -#endif - static inline int xen_get_default_ioreq_server_info(domid_t dom, xen_pfn_t *ioreq_pfn, xen_pfn_t *bufioreq_pfn, @@ -386,84 +361,6 @@ static inline int xen_get_default_ioreq_server_info(domid_t dom, return 0; } -/* Xen before 4.5 */ -#if CONFIG_XEN_CTRL_INTERFACE_VERSION < 40500 - -#ifndef HVM_PARAM_BUFIOREQ_EVTCHN -#define HVM_PARAM_BUFIOREQ_EVTCHN 26 -#endif - -#define IOREQ_TYPE_PCI_CONFIG 2 - -typedef uint16_t ioservid_t; - -static inline void xen_map_memory_section(domid_t dom, - ioservid_t ioservid, - MemoryRegionSection *section) -{ -} - -static inline void xen_unmap_memory_section(domid_t dom, - ioservid_t ioservid, - MemoryRegionSection *section) -{ -} - -static inline void xen_map_io_section(domid_t dom, - ioservid_t ioservid, - MemoryRegionSection *section) -{ -} - -static inline void xen_unmap_io_section(domid_t dom, - ioservid_t ioservid, - MemoryRegionSection *section) -{ -} - -static inline void xen_map_pcidev(domid_t dom, - ioservid_t ioservid, - PCIDevice *pci_dev) -{ -} - -static inline void xen_unmap_pcidev(domid_t dom, - ioservid_t ioservid, - PCIDevice *pci_dev) -{ -} - -static inline void xen_create_ioreq_server(domid_t dom, - ioservid_t *ioservid) -{ -} - -static inline void xen_destroy_ioreq_server(domid_t dom, - ioservid_t ioservid) -{ -} - -static inline int xen_get_ioreq_server_info(domid_t dom, - ioservid_t ioservid, - xen_pfn_t *ioreq_pfn, - xen_pfn_t *bufioreq_pfn, - evtchn_port_t *bufioreq_evtchn) -{ - return xen_get_default_ioreq_server_info(dom, ioreq_pfn, - bufioreq_pfn, - bufioreq_evtchn); -} - -static inline int xen_set_ioreq_server_state(domid_t dom, - ioservid_t ioservid, - bool enable) -{ - return 0; -} - -/* Xen 4.5 */ -#else - static bool use_default_ioreq_server; static inline void xen_map_memory_section(domid_t dom, @@ -624,6 +521,4 @@ static inline int xen_set_ioreq_server_state(domid_t dom, enable); } -#endif - #endif /* QEMU_HW_XEN_NATIVE_H */ diff --git a/meson.build b/meson.build index 553c8e0b9c..0984237c48 100644 --- a/meson.build +++ b/meson.build @@ -1683,16 +1683,13 @@ if get_option('xen').enabled() or (get_option('xen').auto() and have_system) endif endif if not xen.found() - xen_tests = [ '4.11.0', '4.10.0', '4.9.0', '4.8.0', '4.7.1', '4.6.0', '4.5.0', '4.2.0' ] + xen_tests = [ '4.11.0', '4.10.0', '4.9.0', '4.8.0', '4.7.1' ] xen_libs = { '4.11.0': [ 'xenstore', 'xenctrl', 'xendevicemodel', 'xenforeignmemory', 'xengnttab', 'xenevtchn', 'xentoolcore' ], '4.10.0': [ 'xenstore', 'xenctrl', 'xendevicemodel', 'xenforeignmemory', 'xengnttab', 'xenevtchn', 'xentoolcore' ], '4.9.0': [ 'xenstore', 'xenctrl', 'xendevicemodel', 'xenforeignmemory', 'xengnttab', 'xenevtchn' ], '4.8.0': [ 'xenstore', 'xenctrl', 'xenforeignmemory', 'xengnttab', 'xenevtchn' ], '4.7.1': [ 'xenstore', 'xenctrl', 'xenforeignmemory', 'xengnttab', 'xenevtchn' ], - '4.6.0': [ 'xenstore', 'xenctrl' ], - '4.5.0': [ 'xenstore', 'xenctrl' ], - '4.2.0': [ 'xenstore', 'xenctrl' ], } xen_deps = {} foreach ver: xen_tests diff --git a/scripts/xen-detect.c b/scripts/xen-detect.c index 85e8206490..db049e605c 100644 --- a/scripts/xen-detect.c +++ b/scripts/xen-detect.c @@ -138,66 +138,6 @@ return 0; } -#elif CONFIG_XEN_CTRL_INTERFACE_VERSION == 40600 - #include - #include - #include - #include - #if !defined(HVM_MAX_VCPUS) - # error HVM_MAX_VCPUS not defined - #endif - int main(void) { - xc_interface *xc; - xs_daemon_open(); - xc = xc_interface_open(0, 0, 0); - xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); - xc_gnttab_open(NULL, 0); - xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); - xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); - xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL); - xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0); - return 0; - } - -#elif CONFIG_XEN_CTRL_INTERFACE_VERSION == 40500 - #include - #include - #include - #include - #if !defined(HVM_MAX_VCPUS) - # error HVM_MAX_VCPUS not defined - #endif - int main(void) { - xc_interface *xc; - xs_daemon_open(); - xc = xc_interface_open(0, 0, 0); - xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); - xc_gnttab_open(NULL, 0); - xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); - xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); - xc_hvm_create_ioreq_server(xc, 0, 0, NULL); - return 0; - } - -#elif CONFIG_XEN_CTRL_INTERFACE_VERSION == 40200 - #include - #include - #include - #include - #if !defined(HVM_MAX_VCPUS) - # error HVM_MAX_VCPUS not defined - #endif - int main(void) { - xc_interface *xc; - xs_daemon_open(); - xc = xc_interface_open(0, 0, 0); - xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); - xc_gnttab_open(NULL, 0); - xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); - xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); - return 0; - } - #else #error invalid CONFIG_XEN_CTRL_INTERFACE_VERSION #endif From patchwork Wed Jun 7 14:18:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 13270765 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DCE17C7EE29 for ; Wed, 7 Jun 2023 14:20:57 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q6u0n-0002rA-7P; Wed, 07 Jun 2023 10:19:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6u0m-0002qm-0q for qemu-devel@nongnu.org; Wed, 07 Jun 2023 10:19:44 -0400 Received: from esa6.hc3370-68.iphmx.com ([216.71.155.175]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6u0k-0003Q0-Ec for qemu-devel@nongnu.org; Wed, 07 Jun 2023 10:19:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1686147582; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DevbehoMd5ErdPmYCLaewfSTkvvhbRICcFTF4cmkBNY=; b=RZcmB7xZn4O1Z/r3QYVs5q5QU5P37ktk36HNG0UEIcV106F3qs/NPOGm P+4yERS/h0szXEbt6S6Cc64j2sCQORfKAeLQg63aMoOSJMaAo19+Ny2kG V6DfEGdiEGMZWurUkSjFe4gOQxpLJfN6XvnkJubbU7NWTdom2CWDXIt8g Y=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 4.0 X-MesageID: 111246603 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.123 X-Policy: $RELAYED IronPort-Data: A9a23:2qr80qrYchiUX5E8RJfKEJxQ3HdeBmIeZRIvgKrLsJaIsI4StFCzt garIBmDb/ncazT0et11PITg9kpVuZXXzNdiQAJupX9hEC5A8puZCYyVIHmrMnLJJKUvbq7FA +Y2MYCccZ9uHhcwgj/3b9ANeFEljfngqoLUUbKCYWYpA1c/Ek/NsDo788YhmIlknNOlNA2Ev NL2sqX3NUSsnjV5KQr40YrawP9UlKq04GtwUmAWP6gR5weAzyZNVvrzGInqR5fGatgMdgKFb 76rIIGRpgvx4xorA9W5pbf3GmVirmn6ZFXmZtJ+AsBOszAazsAA+v9T2Mk0MC+7vw6hjdFpo OihgLTrIesf0g8gr8xGO/VQO3kW0aSrY9YrK1Dn2SCY5xWun3cBX5yCpaz5VGEV0r8fPI1Ay RAXAD4wSC7b3MS6+ZWmd/FXh+YEDuTUDrpK7xmMzRmBZRonaZXKQqGM7t5ExjYgwMtJGJ4yZ eJAN2ApNk6ZJUQSZBFOUslWcOSA3xETdxVRrk6VoqwmpXDe1gVr3JDmMcbPe8zMTsJQ9qqdj jufpj6lXE9Cb7RzzxLZ132N3MjAwxjJZ4w/EaS9qKA7q3Cqkzl75Bo+CgLg/KjRZlSFc8tSL lFR9icwoKwa8kutQd/gGRqirxassgEZRPJZFuQo7wfLwa2S/gXxO4QfZmcfMpp87pZwHGF0k AbTxLsFGACDrpWbdFSjruyyoQqVJBUNFm4gQg0pcjk8toyLTJ4IsjrDSdNqEaiQh9LzGC3tz z3ikBXSl4n/nuZQifzloAmvbyaE48GQE1Vrvlm/sneNtFsRWWKzW2C/BbE3B95kJZ3RcFSOt WNsdyO2vLFXVsHleMBgrYww8FCVCxStamW0bb1HRcNJG9GRF5mLI+htDMlWfhsBDyr9UWaBj LXvkQ1Q/oRPG3ChcLV6ZYm8Y+xzk/i+TYu7DKyPP4YXCnSUSONh1Hs2DaJ39zq0+HXAbIllY cvLGSpSJShy5VtbIMqeGL5GjO5DKtEWzmLPX5HrpylLIpLHDEN5vYwtaQPUBshgtfPsnekg2 4oHXyd840kFAbKWj+i+2dJ7EG3m2lBlXc2n9ZYKLLfrz8gPMDhJNsI9CIgJI+RN95m5XM+Sl p1hcie0EGbCuEA= IronPort-HdrOrdr: A9a23:lnR0n6jAd+DP1o2sA9e2Qh8LI3BQXugji2hC6mlwRA09TyX4ra +TdZEgviMc5wxhPU3I9ergBED4ewK+yXcX2+cs1MmZLWvbUQKTRekJgOffKlvbaknDH4VmtZ uIHZIOceHYPBxXitv7/Rn9M/tI+qj+zElwv5a48566d3ANV51d X-Talos-CUID: 9a23:TPUUvmB1X9on+Cr6Eyda0nBMQeYpS1rA8W/rIm2fK0tWeoTAHA== X-Talos-MUID: 9a23:Pv8zNwUN3+z/uTbq/GPJixA4E8g22JaRBm0IiJBY5ZivGBUlbg== X-IronPort-AV: E=Sophos;i="6.00,224,1681185600"; d="scan'208";a="111246603" To: CC: David Woodhouse , Anthony PERARD Subject: [PULL 04/12] hw/xen: Fix broken check for invalid state in xs_be_open() Date: Wed, 7 Jun 2023 15:18:31 +0100 Message-ID: <20230607141839.48422-5-anthony.perard@citrix.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230607141839.48422-1-anthony.perard@citrix.com> References: <20230607141839.48422-1-anthony.perard@citrix.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.155.175; envelope-from=prvs=51561cf95=anthony.perard@citrix.com; helo=esa6.hc3370-68.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Anthony PERARD X-Patchwork-Original-From: Anthony PERARD via From: Anthony PERARD Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: David Woodhouse Coverity points out that if (!s && !s->impl) isn't really what we intended to do here. CID 1508131. Fixes: 032475127225 ("hw/xen: Add emulated implementation of XenStore operations") Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant Reviewed-by: Peter Maydell Message-Id: <20230412185102.441523-6-dwmw2@infradead.org> Signed-off-by: Anthony PERARD --- hw/i386/kvm/xen_xenstore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/i386/kvm/xen_xenstore.c b/hw/i386/kvm/xen_xenstore.c index 0b189c6ab8..133d89e953 100644 --- a/hw/i386/kvm/xen_xenstore.c +++ b/hw/i386/kvm/xen_xenstore.c @@ -1688,7 +1688,7 @@ static struct qemu_xs_handle *xs_be_open(void) XenXenstoreState *s = xen_xenstore_singleton; struct qemu_xs_handle *h; - if (!s && !s->impl) { + if (!s || !s->impl) { errno = -ENOSYS; return NULL; } From patchwork Wed Jun 7 14:18:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 13270766 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C6012C7EE23 for ; Wed, 7 Jun 2023 14:21:05 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q6u0t-0002tl-9M; Wed, 07 Jun 2023 10:19:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6u0r-0002sm-8H for qemu-devel@nongnu.org; Wed, 07 Jun 2023 10:19:49 -0400 Received: from esa6.hc3370-68.iphmx.com ([216.71.155.175]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6u0l-0003Qf-1L for qemu-devel@nongnu.org; Wed, 07 Jun 2023 10:19:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1686147582; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Yi+pXjYLr7c/PD1ARVNoBjdszGk9MJ2cyLncx8Kx/aE=; b=QwU/wMOoCL3iIMVbZFcugMj3hbBbs2sESxkNDxPopX9BD1qHicpJJNZ1 vHg2rDz7fOENdVTk+EJtZHccITGxcP8wjeO8CqHYHG527hp7268iUhBeY ekaCllwAMuLONiP9j6mQugPv+ZPVHjDhk+m7JSC3quuXVo0w1WJ6HglIQ 4=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 4.0 X-MesageID: 111246604 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.123 X-Policy: $RELAYED IronPort-Data: A9a23:oF+lKKvH9fnUAy2sdvpfXWaCr+fnVFBeMUV32f8akzHdYApBsoF/q tZmKW+Gbq7bMWOgfdF/Poq+pEgD65SHxtVhQAc6rShkES4Q+JbJXdiXEBz9bniYRiHhoOCLz O1FM4Wdc5pkJpP4jk3wWlQ0hSAkjclkfpKlVKiffHg3HVQ+IMsYoUoLs/YjhYJ1isSODQqIu Nfjy+XSI1bg0DNvWo4uw/vrRChH4rKq4Fv0gnRkPaoQ5AGGyCFPZH4iDfrZw0XQE9E88tGSH 44v/JnhlkvF8hEkDM+Sk7qTWiXmlZaLYGBiIlIPM0STqkAqSh4ai87XB9JFAatjsB2bnsgZ9 Tl4ncfYpTHFnEH7sL91vxFwS0mSNEDdkVPNCSDXXce7lyUqf5ZwqhnH4Y5f0YAwo45K7W9yG fMwJg0rUEjYoe6P56+GUtJtpOMBAfbZBdZK0p1g5Wmx4fcORJnCR+PB5MNC3Sd2jcdLdRrcT 5NHM3w1Nk2GOkARfA5NU/rSn8/x7pX7WzRetFKSo7tx+2XJxRZ9+LPsLMDUapqBQsA9ckOw/ zufpTinXElGXDCZ4WWsqV3rmvKUpxvUe58NDKyG6KUth2TGkwT/DzVJDADm8JFVkHWWQt9aN gkY9zQjqYA080qkSMS7WAe3yFafvhMaR9dBO+I/4QCJjKHT5m6k6nMsF2AbLoZ87YlvGGJsj wXS9z/0OdBxmLOob0zFrZGYlBSvBDAuLE0lRwI7fzJQtrEPv7oPph7IS99iFou8gdv0BSz8z li2kcQuu1kApZVVjvvmpDgrlxrp/8GUFVBtum07S0r/tmtEiJiZi5tEALQxxdJJN86nQ1aIp xDocODOvblVXflheMFgKdjh/Y1FBd7faFUwYnY1RfHNEghBHFb9Fb28GBkkeC9U3j8sIFcFm nP7twJL/4N0N3C3d6JxaI/ZI510nfa4Soq/CquFMoMmjn1NmOmvpnkGiam4hTmFraTRuftnZ cfznTiEUx729piLPBLpHrxAgNfHNwg1xH/JRICT8vhU+eP2WZJhcp9caAHmRrlgvMu5TPD9r 4432z2il08OD4UTo0D/reYuELz9BSZjWMGo8ZENL4Zu4GNOQQkcNhMY+pt5E6QNokifvr2gE q2VMqOA9GfCuA== IronPort-HdrOrdr: A9a23:uhKy36HRGXrdKIyYpLqE2seALOsnbusQ8zAXPiFKJiC9F/byqy nApoV/6faZslcssQgb6LO90cq7L080i6QFg7X5VI3KNGOK1FdASrsSibcKqAeBJ8SRzJ8l6Y 5QN4R4Fd3sHRxboK/BkXGF+g8bsb66GXaT9IHj80s= X-Talos-CUID: 9a23:ZkEqf2O2+nw6Xu5DVhRByhZPPMwcVWDg1EzRAWiaJFlbcejA X-Talos-MUID: 9a23:P4M0pwT13xN0gTHNRXSzrWpNc9t1uJ6WJ2MQjo0XhdffcitJbmI= X-IronPort-AV: E=Sophos;i="6.00,224,1681185600"; d="scan'208";a="111246604" To: CC: Bernhard Beschow , Anthony PERARD Subject: [PULL 05/12] include/hw/xen/xen: Rename xen_piix3_set_irq() to xen_intx_set_irq() Date: Wed, 7 Jun 2023 15:18:32 +0100 Message-ID: <20230607141839.48422-6-anthony.perard@citrix.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230607141839.48422-1-anthony.perard@citrix.com> References: <20230607141839.48422-1-anthony.perard@citrix.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.155.175; envelope-from=prvs=51561cf95=anthony.perard@citrix.com; helo=esa6.hc3370-68.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Anthony PERARD X-Patchwork-Original-From: Anthony PERARD via From: Anthony PERARD Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Bernhard Beschow xen_piix3_set_irq() isn't PIIX specific: PIIX is a single PCI device while xen_piix3_set_irq() maps multiple PCI devices to their respective IRQs, which is board-specific. Rename xen_piix3_set_irq() to communicate this. Also rename XEN_PIIX_NUM_PIRQS to XEN_IOAPIC_NUM_PIRQS since the Xen's IOAPIC rather than PIIX has this many interrupt routes. Signed-off-by: Bernhard Beschow Reviewed-by: Michael S. Tsirkin Reviewed-by: Anthony PERARD Tested-by: Chuck Zmudzinski Message-Id: <20230312120221.99183-2-shentey@gmail.com> Message-Id: <20230403074124.3925-2-shentey@gmail.com> Signed-off-by: Anthony PERARD --- hw/i386/xen/xen-hvm.c | 2 +- hw/isa/piix3.c | 4 ++-- include/hw/xen/xen.h | 2 +- stubs/xen-hw-stub.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c index 56641a550e..ab8f1b61ee 100644 --- a/hw/i386/xen/xen-hvm.c +++ b/hw/i386/xen/xen-hvm.c @@ -143,7 +143,7 @@ int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num) return irq_num + (PCI_SLOT(pci_dev->devfn) << 2); } -void xen_piix3_set_irq(void *opaque, int irq_num, int level) +void xen_intx_set_irq(void *opaque, int irq_num, int level) { xen_set_pci_intx_level(xen_domid, 0, 0, irq_num >> 2, irq_num & 3, level); diff --git a/hw/isa/piix3.c b/hw/isa/piix3.c index f9103ea45a..6651521a46 100644 --- a/hw/isa/piix3.c +++ b/hw/isa/piix3.c @@ -35,7 +35,7 @@ #include "migration/vmstate.h" #include "hw/acpi/acpi_aml_interface.h" -#define XEN_PIIX_NUM_PIRQS 128ULL +#define XEN_IOAPIC_NUM_PIRQS 128ULL static void piix3_set_irq_pic(PIIX3State *piix3, int pic_irq) { @@ -420,7 +420,7 @@ static void piix3_xen_realize(PCIDevice *dev, Error **errp) * connected to the IOAPIC directly. * These additional routes can be discovered through ACPI. */ - pci_bus_irqs(pci_bus, xen_piix3_set_irq, piix3, XEN_PIIX_NUM_PIRQS); + pci_bus_irqs(pci_bus, xen_intx_set_irq, piix3, XEN_IOAPIC_NUM_PIRQS); } static void piix3_xen_class_init(ObjectClass *klass, void *data) diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h index 2bd8ec742d..37ecc91fc3 100644 --- a/include/hw/xen/xen.h +++ b/include/hw/xen/xen.h @@ -39,7 +39,7 @@ extern bool xen_domid_restrict; int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num); int xen_set_pci_link_route(uint8_t link, uint8_t irq); -void xen_piix3_set_irq(void *opaque, int irq_num, int level); +void xen_intx_set_irq(void *opaque, int irq_num, int level); void xen_hvm_inject_msi(uint64_t addr, uint32_t data); int xen_is_pirq_msi(uint32_t msi_data); diff --git a/stubs/xen-hw-stub.c b/stubs/xen-hw-stub.c index 34a22f2ad7..7d7ffe83a9 100644 --- a/stubs/xen-hw-stub.c +++ b/stubs/xen-hw-stub.c @@ -15,7 +15,7 @@ int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num) return -1; } -void xen_piix3_set_irq(void *opaque, int irq_num, int level) +void xen_intx_set_irq(void *opaque, int irq_num, int level) { } From patchwork Wed Jun 7 14:18:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 13270770 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0CC70C7EE23 for ; Wed, 7 Jun 2023 14:21:44 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q6u0m-0002r5-Ed; Wed, 07 Jun 2023 10:19:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6u0k-0002qB-JK for qemu-devel@nongnu.org; Wed, 07 Jun 2023 10:19:42 -0400 Received: from esa1.hc3370-68.iphmx.com ([216.71.145.142]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6u0i-0003PT-WB for qemu-devel@nongnu.org; Wed, 07 Jun 2023 10:19:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1686147580; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KHUNXK6qIii10auVdLh+VILOmUdSI2ZnD9Adc1nNpLA=; b=VlDe/eJbvSsalpP8QvalhmAlBEfRQPW7eypA79+0ove4Dp0gfegTPqFB DZjgL2b5QomcAEcUDJQgyF69Zhjmn1ZCQeA/MoorrgOT8nB4WCdj5m8UI 3IA3viDHZlDrzV+Syf3PxyXag0eTDO8iZjTijUXRMDGzDvI2uFwyx+VyD A=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 4.0 X-MesageID: 112338010 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.123 X-Policy: $RELAYED IronPort-Data: A9a23:iIUwf6zzexoGq2eN0JZ6t+cxxirEfRIJ4+MujC+fZmUNrF6WrkVRz GQfCm+BO6uDZWenfY12a42x80NTscPQzd5iGwtv+CAxQypGp/SeCIXCJC8cHc8wwu7rFxs7s ppEOrEsCOhuExcwcz/0auCJQUFUjP3OHfykTrafYEidfCc8IA85kxVvhuUltYBhhNm9Emult Mj75sbSIzdJ4RYtWo4vw/zF8EsHUMja4mtC5QRgPa8T5jcyqlFOZH4hDfDpR5fHatE88t6SH 47r0Ly/92XFyBYhYvvNfmHTKxBirhb6ZGBiu1IOM0SQqkEqSh8ai87XAME0e0ZP4whlqvgqo Dl7WT5cfi9yVkHEsLx1vxC1iEiSN4UekFPMCSDXXcB+UyQq2pYjqhljJBheAGEWxgp4KVsf9 PAncW5OVxuCh971wL/iRspOi9t2eaEHPKtH0p1h5TTQDPJgSpHfWaTao9Rf2V/chOgXQ6yYP ZBAL2MyMlKZOUYn1lQ/UfrSmM+hgGX/dDtJ7kqYv6Mt70DYzRBr0airO93QEjCPbZwMxB3D9 jqfpwwVBDkmFufCwDuEq0uin+qTmD/1UrhPCIyRo6sCbFq7mTVIVUx+uUGAieC0j1P7V99BJ kg8/C0ooq4vskuxQbHVRB21pmKJrzYTXtNRF6sx7wTl90bPy1/HXC5eFGcHMYF48pZsHlTGy 2NlgfvTVD1jj+TLCkuW97eo7jO/YCQ2D2IdMHpsoRQ+3/Hvp4Q6jxTqR9llEbKogtCdJQwc0 wxmvwBl2exN0JdjO7GTuAme3mny/sShohsdvF2/Y46z0u9uiGdJjaSM4EOT0/tPJZ3xorKp7 CldwJj2AAzj4PiweM2xrAclRunBCxWtame0bbtT834JqVyQF4aLJ9w43d2HDB4B3jw4UTHoe lTPngha+YVeOnCnBYcuPdLvU5t0l/S7RIi8PhwxUjaoSsIpHONg1Hs3DXN8Iki3yBR8+U3BE cnznTmQ4YYyVv08kWveqxY12r433CEurV4/triipylLJYG2PSbPIZ9caQvmUwzMxP/cyOkj2 4oFZpTiJtQ2eLGWXxQ7BqZNdQ1bcyJmX8meRg4+XrfrHzeK0VoJU5f5qY7NsaQ890iJvo8kJ k2AZ3I= IronPort-HdrOrdr: A9a23:p2Carap/eQIf2UycZYI9jTUaV5oleYIsimQD101hICG9E/b1qy nKpp8mPHDP5wr5NEtPpTnjAsm9qALnlKKdiLN5Vd3OYOCMghrKEGgN1/qG/xTQXwH46+5Bxe NBXsFFebnN5IFB/KTH3DU= X-Talos-CUID: 9a23:d1ftfmogWCRARUXQHw0IHYXmUfp0c3HilSmTGkS5CVoqSLDMRXyy9bwxxg== X-Talos-MUID: 9a23:C6GYRQU0WNtxSYXq/APOv2xrNcYx2qq3DRwIjZsMgZSYBAUlbg== X-IronPort-AV: E=Sophos;i="6.00,224,1681185600"; d="scan'208";a="112338010" To: CC: Bernhard Beschow , Anthony PERARD Subject: [PULL 06/12] hw/pci/pci.c: Don't leak PCIBus::irq_count[] in pci_bus_irqs() Date: Wed, 7 Jun 2023 15:18:33 +0100 Message-ID: <20230607141839.48422-7-anthony.perard@citrix.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230607141839.48422-1-anthony.perard@citrix.com> References: <20230607141839.48422-1-anthony.perard@citrix.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.145.142; envelope-from=prvs=51561cf95=anthony.perard@citrix.com; helo=esa1.hc3370-68.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Anthony PERARD X-Patchwork-Original-From: Anthony PERARD via From: Anthony PERARD Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Bernhard Beschow When calling pci_bus_irqs() multiple times on the same object without calling pci_bus_irqs_cleanup() in between PCIBus::irq_count[] is currently leaked. Let's fix this because Xen will do just that in a few commits, and because calling pci_bus_irqs_cleanup() in between seems fragile and cumbersome. Note that pci_bus_irqs_cleanup() now has to NULL irq_count such that pci_bus_irqs() doesn't do a double free. Signed-off-by: Bernhard Beschow Reviewed-by: Michael S. Tsirkin Tested-by: Chuck Zmudzinski Message-Id: <20230403074124.3925-3-shentey@gmail.com> Signed-off-by: Anthony PERARD --- hw/pci/pci.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 1cc7c89036..9b7b4d7c18 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -560,6 +560,7 @@ void pci_bus_irqs(PCIBus *bus, pci_set_irq_fn set_irq, bus->set_irq = set_irq; bus->irq_opaque = irq_opaque; bus->nirq = nirq; + g_free(bus->irq_count); bus->irq_count = g_malloc0(nirq * sizeof(bus->irq_count[0])); } @@ -575,6 +576,7 @@ void pci_bus_irqs_cleanup(PCIBus *bus) bus->irq_opaque = NULL; bus->nirq = 0; g_free(bus->irq_count); + bus->irq_count = NULL; } PCIBus *pci_register_root_bus(DeviceState *parent, const char *name, From patchwork Wed Jun 7 14:18:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 13270771 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9C7F0C7EE25 for ; Wed, 7 Jun 2023 14:21:47 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q6u0q-0002sD-Bf; Wed, 07 Jun 2023 10:19:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6u0p-0002rj-AF for qemu-devel@nongnu.org; Wed, 07 Jun 2023 10:19:47 -0400 Received: from esa2.hc3370-68.iphmx.com ([216.71.145.153]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6u0m-0003Qw-J1 for qemu-devel@nongnu.org; Wed, 07 Jun 2023 10:19:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1686147584; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5gV1SE4LsSi6EgcoPhMMnPemRAYlH4p9c99lFdvAzmc=; b=YkNRtkhSqnKdMytulGjCctvwj7OCt5/D9Wn1wwOf/3AO+wu00l4tM2ms xxKvjE2Azz0RTYQVgz27GOc+HWdwJsr7BRNL0Zk38VTKdYmT694JmbpNp oXEke6yqgp28rMgw0hmHLRq5d4HHcWUyK+A+SAMkZLBSPDbtS3prrF1QR 8=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 4.0 X-MesageID: 111808771 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.123 X-Policy: $RELAYED IronPort-Data: A9a23:Fc/cyqyzlsriS80Ub7N6t+cxxirEfRIJ4+MujC+fZmUNrF6WrkVRn 2pMWmiCa67eYWugeI8kaIy+9E5Q7cfdyoIyHVBp+SAxQypGp/SeCIXCJC8cHc8wwu7rFxs7s ppEOrEsCOhuExcwcz/0auCJQUFUjP3OHfykTrafYEidfCc8IA85kxVvhuUltYBhhNm9Emult Mj75sbSIzdJ4RYtWo4vw/zF8EsHUMja4mtC5QRgPa8T5jcyqlFOZH4hDfDpR5fHatE88t6SH 47r0Ly/92XFyBYhYvvNfmHTKxBirhb6ZGBiu1IOM0SQqkEqSh8ai87XAME0e0ZP4whlqvgqo Dl7WT5cfi9yVkHEsLx1vxC1iEiSN4UekFPMCSDXXcB+UyQq2pYjqhljJBheAGEWxgp4KUBB/ tcyNSo/VBOKu8KG67PlYdZmuO12eaEHPKtH0p1h5TTQDPJgSpHfWaTao9Rf2V/chOgXQ6yYP ZBAL2MyMlKZOUYn1lQ/UfrSmM+hgGX/dDtJ7kqYv6Mt70DYzRBr0airO93QEjCPbZwMxxbA9 j2ZpgwVBDlEKMzB+Aeo8UmWh9Xxvzj4fKEjTK+3o6sCbFq7mTVIVUx+uUGAieC0j1P7V99BJ kg8/C0ooq4vskuxQbHVRB21pmKJrzYTXtNRF6sx7wTl90bPy1/HXC5eFGcHMYF48pZsHlTGy 2NlgfvICjdEmqCPe0ie/4u0nRizZwMqJ1ErMHpsoRQ+3/Hvp4Q6jxTqR9llEbKogtCdJQwc0 wxmvwBl2exN0JdjO7GTuAme3mny/sShohsdvF2/Y46z0u9uiGdJjaSM4EOT0/tPJZ3xorKp7 CldwJj2AAzj4PiweM2xrAclRunBCxWtame0bbtT834JqVyQF4aLJ9w43d2HDB4B3jw4UTHoe lTPngha+YVeOnCnBYcuPdLvU5t0l/S7RIi8PhwxUjaoSsIpHONg1Hs3DXN8Iki3yBR8+U3BE cnznTmQ4YYyVv08kWveqxY12r433CEurV4/triipylLJYG2PSbPIZ9caQvmUwzMxP/cyOkj2 4oFZpTiJtQ2eLGWXxQ7BqZNdQ1bcyJmX8meRg4+XrfrHzeK0VoJU5f5qY7NsaQ/90iJvo8kJ k2AZ3I= IronPort-HdrOrdr: A9a23:tZVy6qOZ3UBaU8BcTz/255DYdb4zR+YMi2TDiHoedfUFSKOlfp 6V8MjzjSWE9Qr4WBkb6LW90dq7MA/hHP9OkMQs1NKZNjUO11HYVb2KgbGSoAEIXheOjNK1tp 0QP5SWaueAdWSS5PySiGLUcrYdKZu8gduVbIzlvhNQpHRRGsddBnBCe2Gm+yNNNWt7LKt8MK DZyttMpjKmd3hSRsOnBkMdV+yGi8zXmIngaRsmAQdizAWVlzun5JPzDhDdh34lIn1y6IZn1V KAvx3y562lvf3+4hjA11XL55ATtMr9xsBFDMmsjNFQDjn3kA6naKloRrXHljEop+OE7kosjb D30lgdFvU2z0mUUnC+oBPr1QWl+i0p8WXexViRhmamidDlRRohYvAxxb5xQ1/80Q4Nrdt82K VE0yayrJxMFy7Nmyz7+pzhSwxqrEypunAv+NRjzEC3ELFuKoO5n7ZvuH+9I61wWx4SL7pXVt WGOfusocq+t2nqNkwx8FMfmOBEFU5DYStuCnJyxPB9lQIm3UxR/g8g38oYkW4H9JUhD7d5x8 msCNUzqJh+CvYMa6RzHeEARtbyLFfsb1bjDEK+SG6XT53uHRr22sLKCXEOlbyXUY1Nw50olJ vbVlRE8WY0ZkL1EMWLmIZG6xbXXQyGLHzQ49Ab5YNwtaD8SLrtImmEVE0kldemrpwkc7jmsl mISeBr6tLYXB3T8LxyrkTDcogXLWNbXNweu949VV7LqsXXKpfyvuiedPrIPrLiHTstR2u6Wx I4LXLODdQF6lruVm7zgRDXVX+ockvj/YhoGKyf++QI0oACOoBFrwBQg1Wk4cOALyFEr8UNDQ BDCaKilrn+qXi9/G7O4WksMh1BDlxN6LGlSH9OrR9iCTKCTV/CgaTqRYl/5gr1GvYkdbKmLO d2nSUGxZ6K X-Talos-CUID: 9a23:TyQ6zGuE7jxlvHK3BBnMlAiL6IsEfXb25mrKEXW7AFpJeJaUF3Sv8p1Nxp8= X-Talos-MUID: 9a23:jDrUHgnsppNZSQ/Y1Xygdno8KNc20pmDC3s3kK84mdKHEQ9BYyWS2WE= X-IronPort-AV: E=Sophos;i="6.00,224,1681185600"; d="scan'208";a="111808771" To: CC: Bernhard Beschow , Anthony PERARD Subject: [PULL 07/12] hw/isa/piix3: Reuse piix3_realize() in piix3_xen_realize() Date: Wed, 7 Jun 2023 15:18:34 +0100 Message-ID: <20230607141839.48422-8-anthony.perard@citrix.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230607141839.48422-1-anthony.perard@citrix.com> References: <20230607141839.48422-1-anthony.perard@citrix.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.145.153; envelope-from=prvs=51561cf95=anthony.perard@citrix.com; helo=esa2.hc3370-68.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Anthony PERARD X-Patchwork-Original-From: Anthony PERARD via From: Anthony PERARD Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Bernhard Beschow This is a preparational patch for the next one to make the following more obvious: First, pci_bus_irqs() is now called twice in case of Xen where the second call overrides the pci_set_irq_fn with the Xen variant. Second, pci_bus_set_route_irq_fn() is now also called in Xen mode. Signed-off-by: Bernhard Beschow Reviewed-by: Michael S. Tsirkin Reviewed-by: Anthony PERARD Tested-by: Chuck Zmudzinski Message-Id: <20230312120221.99183-3-shentey@gmail.com> Message-Id: <20230403074124.3925-4-shentey@gmail.com> Signed-off-by: Anthony PERARD --- hw/isa/piix3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/isa/piix3.c b/hw/isa/piix3.c index 6651521a46..800b80f2bb 100644 --- a/hw/isa/piix3.c +++ b/hw/isa/piix3.c @@ -409,7 +409,7 @@ static void piix3_xen_realize(PCIDevice *dev, Error **errp) PIIX3State *piix3 = PIIX3_PCI_DEVICE(dev); PCIBus *pci_bus = pci_get_bus(dev); - pci_piix3_realize(dev, errp); + piix3_realize(dev, errp); if (*errp) { return; } From patchwork Wed Jun 7 14:18:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 13270769 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 844A8C7EE29 for ; Wed, 7 Jun 2023 14:21:35 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q6u1G-0003Me-8t; Wed, 07 Jun 2023 10:20:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6u1E-0003Dx-Nk for qemu-devel@nongnu.org; Wed, 07 Jun 2023 10:20:12 -0400 Received: from esa3.hc3370-68.iphmx.com ([216.71.145.155]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6u1B-0003g5-Od for qemu-devel@nongnu.org; Wed, 07 Jun 2023 10:20:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1686147609; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FL0kczg1AEWFFnOGZrrfsv4UULDPFWhofp92N3+6x0s=; b=SDVICLXHMY2/pKOTpOWr2/0FPbb48+hnG+iMTHcrSYnpVgGsHbpHCp3g c9OGgLVOaQasIvYxQsqef+yWzXu1EJOMxbJ93OHigdQOsgVFbe1GmF5qU eQ/kkK7Y37QpvelgGm/BG3Pm9iigKmgY83MTSVdGXWGAIdNG+brzvlxG7 k=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 4.0 X-MesageID: 111938275 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.123 X-Policy: $RELAYED IronPort-Data: A9a23:xv6ixqDF3YpUfhVW/yjjw5YqxClBgxIJ4kV8jS/XYbTApGl3hTUCy TMdWW2AMqyKM2DzKIh2Ydm19UIDuJbXnNFkQQY4rX1jcSlH+JHPbTi7wuUcHAvJd5GeExg3h yk6QoOdRCzhZiaE/n9BCpC48T8nk/nOHuGmYAL9EngZbRd+Tys8gg5Ulec8g4p56fC0GArIs t7pyyHlEAbNNwVcbCRMs8pvlDs15K6p4G1A4QRkDRx2lAS2e0c9Xcp3yZ6ZdxMUcqEMdsamS uDKyq2O/2+x13/B3fv8z94X2mVTKlLjFVDmZkh+AsBOsTAbzsAG6Y4pNeJ0VKtio27hc+ada jl6ncfYpQ8BZsUgkQmGOvVSO3kW0aZuoNcrLZUj2CA6IoKvn3bEmp1T4E8K0YIwws1FJH5W7 9ghNGowaUm/le2skeyJc7w57igjBJGD0II3v3hhyXfSDOo8QICFSKLPjTNa9G5u3IYUR6+YP pdHL2M1N3wsYDUWUrsTIJs4gOevgGi5azBCoUiZjaE2/3LS3Ep6172F3N/9I4XTFJ4FxBnFz o7A12LLJSkiHYGY8AKA3SiGr+vFlzngZatHQdVU8dY12QbOlwT/EiY+TFa+vLy1h1CzX/pZL Eob/DdoqrI9nGSwTtT7QxCpiHGBtx8YHdFXFoUHBBqlk/SOpVzDXy5dE2AHMYZ93CMredA0/ meirfb2HSZLiaHPdHXEyqWbt2LsCxFAeAfuehQ4ZQcC5tDipqQ6gRTOUstvHcaJszHlJd3j6 2vU9XZj3t3/meZOjvzmpg6f31pAs7CTFmYIChPrsnVJB++TTKqsfMSW5FfS9p6sx67JHwDa7 BDodyVzhd3i7K1hdgTXGI3h/5nzvZ5p1QEwZnYxd6TNDxz3pxaekXl4uVmS3ntBPMceYiPOa 0TOow5X75I7FCL0PfEvPNzrV597kfGI+THZuhb8NIImjn9ZLlbvwc2TTRTIgzCFfLYEz8nTx qt3ge7zVC1HWMyLPRK9RvsH0K9D+8zN7Tq7eHwP9Dz+ieD2TCfMGd843K6mMrhRAFWs/F+Er L6y9qKil31ibQEJSnePrN9Ndw1QdBDWx/ne8qRqSwJKGSI+cElJNhMb6e95E2C5t8y5Ttv1w 0w= IronPort-HdrOrdr: A9a23:Y6hsCqhzpCTaHPK2PCIl9BkOkHBQXtQji2hC6mlwRA09TyX4ra yTdZEgviMc5wx/ZJhNo7690cu7IU80hKQV3WB5B97LNmTbUQCTXeJfBOXZsljdMhy72ulB1b pxN4hSYeeAaWSSVPyKgjWFLw== X-Talos-CUID: 9a23:Dx0RwmF9wxrF4tQ2qmJf33wxBdg/VkTBlkrXenOqBnw4Fo+sHAo= X-Talos-MUID: 9a23:ADENMARPe3b4GfDmRXTqthZaDO415J2WDW9Xu7wCscOeLhFZbmI= X-IronPort-AV: E=Sophos;i="6.00,224,1681185600"; d="scan'208";a="111938275" To: CC: Bernhard Beschow , Anthony PERARD Subject: [PULL 08/12] hw/isa/piix3: Wire up Xen PCI IRQ handling outside of PIIX3 Date: Wed, 7 Jun 2023 15:18:35 +0100 Message-ID: <20230607141839.48422-9-anthony.perard@citrix.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230607141839.48422-1-anthony.perard@citrix.com> References: <20230607141839.48422-1-anthony.perard@citrix.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.145.155; envelope-from=prvs=51561cf95=anthony.perard@citrix.com; helo=esa3.hc3370-68.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Anthony PERARD X-Patchwork-Original-From: Anthony PERARD via From: Anthony PERARD Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Bernhard Beschow xen_intx_set_irq() doesn't depend on PIIX3State. In order to resolve TYPE_PIIX3_XEN_DEVICE and in order to make Xen agnostic about the precise south bridge being used, set up Xen's PCI IRQ handling of PIIX3 in the board. Signed-off-by: Bernhard Beschow Reviewed-by: Michael S. Tsirkin Reviewed-by: Anthony PERARD Tested-by: Chuck Zmudzinski Message-Id: <20230312120221.99183-4-shentey@gmail.com> Message-Id: <20230403074124.3925-5-shentey@gmail.com> Signed-off-by: Anthony PERARD --- hw/i386/pc_piix.c | 13 +++++++++++++ hw/isa/piix3.c | 24 +----------------------- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index d5b0dcd1fe..11af191513 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -71,6 +71,7 @@ #include "kvm/kvm-cpu.h" #define MAX_IDE_BUS 2 +#define XEN_IOAPIC_NUM_PIRQS 128ULL #ifdef CONFIG_IDE_ISA static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 }; @@ -238,6 +239,18 @@ static void pc_init1(MachineState *machine, pcms->bus = pci_bus; pci_dev = pci_create_simple_multifunction(pci_bus, -1, true, type); + + if (xen_enabled()) { + /* + * Xen supports additional interrupt routes from the PCI devices to + * the IOAPIC: the four pins of each PCI device on the bus are also + * connected to the IOAPIC directly. + * These additional routes can be discovered through ACPI. + */ + pci_bus_irqs(pci_bus, xen_intx_set_irq, pci_dev, + XEN_IOAPIC_NUM_PIRQS); + } + piix3 = PIIX3_PCI_DEVICE(pci_dev); piix3->pic = x86ms->gsi; piix3_devfn = piix3->dev.devfn; diff --git a/hw/isa/piix3.c b/hw/isa/piix3.c index 800b80f2bb..0b7e9ade0d 100644 --- a/hw/isa/piix3.c +++ b/hw/isa/piix3.c @@ -35,8 +35,6 @@ #include "migration/vmstate.h" #include "hw/acpi/acpi_aml_interface.h" -#define XEN_IOAPIC_NUM_PIRQS 128ULL - static void piix3_set_irq_pic(PIIX3State *piix3, int pic_irq) { qemu_set_irq(piix3->pic[pic_irq], @@ -403,32 +401,12 @@ static const TypeInfo piix3_info = { .class_init = piix3_class_init, }; -static void piix3_xen_realize(PCIDevice *dev, Error **errp) -{ - ERRP_GUARD(); - PIIX3State *piix3 = PIIX3_PCI_DEVICE(dev); - PCIBus *pci_bus = pci_get_bus(dev); - - piix3_realize(dev, errp); - if (*errp) { - return; - } - - /* - * Xen supports additional interrupt routes from the PCI devices to - * the IOAPIC: the four pins of each PCI device on the bus are also - * connected to the IOAPIC directly. - * These additional routes can be discovered through ACPI. - */ - pci_bus_irqs(pci_bus, xen_intx_set_irq, piix3, XEN_IOAPIC_NUM_PIRQS); -} - static void piix3_xen_class_init(ObjectClass *klass, void *data) { PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); k->config_write = piix3_write_config_xen; - k->realize = piix3_xen_realize; + k->realize = piix3_realize; } static const TypeInfo piix3_xen_info = { From patchwork Wed Jun 7 14:18:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 13270760 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CCE53C7EE23 for ; Wed, 7 Jun 2023 14:20:43 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q6u0s-0002tH-PJ; Wed, 07 Jun 2023 10:19:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6u0q-0002sF-MN for qemu-devel@nongnu.org; Wed, 07 Jun 2023 10:19:48 -0400 Received: from esa4.hc3370-68.iphmx.com ([216.71.155.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6u0o-0003SV-IB for qemu-devel@nongnu.org; Wed, 07 Jun 2023 10:19:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1686147586; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TqcufpbSnrTVN9hQiM1OlG/594iES3q/eUlxOWH9DnI=; b=FRjugmCU07DajdPSmA4/iFafkiLhfxRZBPevu+8gculxlfjUp8Xw0nTk Auy2kvcKmy5mp5VqbGiA1c5PSh8DZzyUsc7lmlRORG47vpcQMxEsOxA/F LfkIy5MI6vNe5GgN5JXGs7sZAYDpV1kZXr/CsZjSEHoGVgc/b0czRE56+ Y=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 4.0 X-MesageID: 114430941 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.123 X-Policy: $RELAYED IronPort-Data: A9a23:zpduE6LPQkQm6xO5FE+R15UlxSXFcZb7ZxGr2PjKsXjdYENS0WMFx zYaXjzVaK3ZZWWgKd0jaIjg/UsPv5WBmtNmTQBlqX01Q3x08seUXt7xwmUcnc+xBpaaEB84t ZV2hv3odp1coqr0/0/1WlTZhSAgk/rOHvykU7Ss1hlZHWdMUD0mhQ9oh9k3i4tphcnRKw6Ws Jb5rta31GWNglaYCUpKrfrbwP9TlK6q4mhA4ARhPaojUGL2zBH5MrpOfcldEFOgKmVkNrbSb /rOyri/4lTY838FYj9yuu+mGqGiaue60Tmm0hK6aYD76vRxjnVaPpIAHOgdcS9qZwChxLid/ jnvWauYEm/FNoWU8AgUvoIx/ytWZcWq85efSZSzXFD6I+QrvBIAzt03ZHzaM7H09c5OBEZeq 78kJAwSYy6hnbux4oOXbuJV05FLwMnDZOvzu1llxDDdS/0nXYrCU+PB4towMDUY354UW6yEP oxANGQpNU6bC/FMEg5/5JYWleG0hn75YntApUicv6Yf6GnP1g1hlrPqNbI5f/TTHJkJxR7J+ juuE2LRLz84HsS1yhC81neKntfftzjkaN0LLejtnhJtqALKnTFCYPEMbnOirPykz0KzRd9bA 0oT/CUosO417kPDZsL9UhukrW+ssRsVWt4WGOo/gDxh0YKNvVzfXDJdCGccNpp/7pReqSEWO kGhptbOFWIsjLGpVn+j1K3NqhGDFQweFDpXDcMbdjct797mqYA1qxvASNd/DaK45uHI9SHML yOi93Zn2ehK5SIf/+DipA2c3WrwznTcZlRtjjg7SF5J+e+QiGSNQ4WzoWbW4v9bRGpyZgnQ5 SNU8yRyAQ1nMH1sqMBvaL9VdF1Kz6zfWNE5vbKIN8dJythV0yT/Fb28GRknTKuTDu4KeCXyf GjYsh5L6ZlYMROCNPEnPdruVZ52lvm8TLwJs8w4iPIUOvCdkyfdpUlTibO4hTixwCDAb4lhU XtkTSpcJSlDUvk2pNZHb+wczaUq1kgDKZD7HPjGI+Cc+ePGPha9EO5VWGZim8hltMtoVi2Jq YcAXyZLoj0DONDDjt7/r9ZOfA5QcCJibX00wuQOHtO+zsNdMDlJI5fsLXkJIuSJQ4w9ej/0w 0yA IronPort-HdrOrdr: A9a23:e71CkqCUlCBuJXLlHeme55DYdb4zR+YMi2TDtnofdfUxSKelfq +V7ZEmPHPP6Qr5IUtQ+uxoW5PvfZqjz+8W3WB5B97LNmSLhILPFvAH0WKI+V3d8kPFh5dg/J YlX69iCMDhSXhW5PyKmDVQyuxQp+VvJprY49vj8w== X-Talos-CUID: 9a23:XrwokWpTeXjvM9ufRhh4U6jmUfkgVW2Dj0vcH1C1N0RzEbq3eHO085oxxg== X-Talos-MUID: 9a23:0A9x0QxqsZQ5Dk6ZvU/RWensTKiaqImAKmoVu5Ysgu2BEzRIKx2GkwToW7Zyfw== X-IronPort-AV: E=Sophos;i="6.00,224,1681185600"; d="scan'208";a="114430941" To: CC: Bernhard Beschow , Anthony PERARD Subject: [PULL 09/12] hw/isa/piix3: Avoid Xen-specific variant of piix3_write_config() Date: Wed, 7 Jun 2023 15:18:36 +0100 Message-ID: <20230607141839.48422-10-anthony.perard@citrix.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230607141839.48422-1-anthony.perard@citrix.com> References: <20230607141839.48422-1-anthony.perard@citrix.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.155.144; envelope-from=prvs=51561cf95=anthony.perard@citrix.com; helo=esa4.hc3370-68.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Anthony PERARD X-Patchwork-Original-From: Anthony PERARD via From: Anthony PERARD Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Bernhard Beschow Subscribe to pci_bus_fire_intx_routing_notifier() instead which allows for having a common piix3_write_config() for the PIIX3 device models. While at it, move the subscription into machine code to facilitate resolving TYPE_PIIX3_XEN_DEVICE. In a possible future followup, pci_bus_fire_intx_routing_notifier() could be adjusted in such a way that subscribing to it doesn't require knowledge of the device firing it. Signed-off-by: Bernhard Beschow Reviewed-by: Michael S. Tsirkin Reviewed-by: Anthony PERARD Tested-by: Chuck Zmudzinski Message-Id: <20230312120221.99183-5-shentey@gmail.com> Message-Id: <20230403074124.3925-6-shentey@gmail.com> Signed-off-by: Anthony PERARD --- hw/i386/pc_piix.c | 18 ++++++++++++++++++ hw/isa/piix3.c | 22 +--------------------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 11af191513..2ed2b3f3c6 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -90,6 +90,21 @@ static int pc_pci_slot_get_pirq(PCIDevice *pci_dev, int pci_intx) return (pci_intx + slot_addend) & 3; } +static void piix_intx_routing_notifier_xen(PCIDevice *dev) +{ + int i; + + /* Scan for updates to PCI link routes (0x60-0x63). */ + for (i = 0; i < PIIX_NUM_PIRQS; i++) { + uint8_t v = dev->config_read(dev, PIIX_PIRQCA + i, 1); + if (v & 0x80) { + v = 0; + } + v &= 0xf; + xen_set_pci_link_route(i, v); + } +} + /* PC hardware initialisation */ static void pc_init1(MachineState *machine, const char *host_type, const char *pci_type) @@ -241,6 +256,9 @@ static void pc_init1(MachineState *machine, pci_dev = pci_create_simple_multifunction(pci_bus, -1, true, type); if (xen_enabled()) { + pci_device_set_intx_routing_notifier( + pci_dev, piix_intx_routing_notifier_xen); + /* * Xen supports additional interrupt routes from the PCI devices to * the IOAPIC: the four pins of each PCI device on the bus are also diff --git a/hw/isa/piix3.c b/hw/isa/piix3.c index 0b7e9ade0d..5e8ac98ae0 100644 --- a/hw/isa/piix3.c +++ b/hw/isa/piix3.c @@ -122,26 +122,6 @@ static void piix3_write_config(PCIDevice *dev, } } -static void piix3_write_config_xen(PCIDevice *dev, - uint32_t address, uint32_t val, int len) -{ - int i; - - /* Scan for updates to PCI link routes (0x60-0x63). */ - for (i = 0; i < len; i++) { - uint8_t v = (val >> (8 * i)) & 0xff; - if (v & 0x80) { - v = 0; - } - v &= 0xf; - if (((address + i) >= PIIX_PIRQCA) && ((address + i) <= PIIX_PIRQCD)) { - xen_set_pci_link_route(address + i - PIIX_PIRQCA, v); - } - } - - piix3_write_config(dev, address, val, len); -} - static void piix3_reset(DeviceState *dev) { PIIX3State *d = PIIX3_PCI_DEVICE(dev); @@ -405,7 +385,7 @@ static void piix3_xen_class_init(ObjectClass *klass, void *data) { PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); - k->config_write = piix3_write_config_xen; + k->config_write = piix3_write_config; k->realize = piix3_realize; } From patchwork Wed Jun 7 14:18:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 13270768 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5EFAFC7EE23 for ; Wed, 7 Jun 2023 14:21:34 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q6u1J-0003UV-7o; Wed, 07 Jun 2023 10:20:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6u1H-0003RH-1x for qemu-devel@nongnu.org; Wed, 07 Jun 2023 10:20:15 -0400 Received: from esa3.hc3370-68.iphmx.com ([216.71.145.155]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6u1F-0003g5-6Q for qemu-devel@nongnu.org; Wed, 07 Jun 2023 10:20:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1686147612; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TMH5QUPRgSRXgIgg+Vv+HD7E9mqCFGyN0i1wUw3junY=; b=TZKIMtyczIgDCG/wsT08Iu87xgMMSiN47xXU5m+J605mOstfeV9yrW4A s1eNCmpTjstg70+Qi3ddgpQt5S/SnFyUxNbGV41L+Y8a4k4Mxe8mNLY/Z DqGDDkweAYw9ERtgKbbwMoMHkTHlQsqrhesre3CQKEotk6dpg6uVw8nQ9 E=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 4.0 X-MesageID: 111938282 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.123 X-Policy: $RELAYED IronPort-Data: A9a23:bqOxIqM9wnucMsvvrR2kl8FynXyQoLVcMsEvi/4bfWQNrUon1zEOz WUWXm6DO66OZDP1L90gPYWypBhTvJLdxtRmSgto+SlhQUwRpJueD7x1DKtS0wC6dZSfER09v 63yTvGacajYm1eF/k/F3oDJ9CU6jufQAOKnUoYoAwgpLSd8UiAtlBl/rOAwh49skLCRDhiE/ Nj/uKUzAnf8s9JPGjxSs/rrRC9H5qyo42tG5gNmP5ingXeF/5UrJMNHTU2OByOQrrl8RoaSW +vFxbelyWLVlz9F5gSNy+uTnuUiG9Y+DCDW4pZkc/HKbitq/0Te5p0TJvsEAXq7vh3S9zxHJ HehgrTrIeshFvWkdO3wyHC0GQkmVUFN0OevzXRSLaV/ZqAJGpfh66wGMa04AWEX0vhlWk9fz vpAFCEiayiYoPu627OFcfY506zPLOGzVG8eknRpzDWfBvc6W5HTBa7N4Le03h9p2JoIR6yHI ZNEN3w2Nk+ojx5nYz/7DLo3mvuogX/uNSVVsluPqYI84nTJzRw327/oWDbQUoXTHJQOzhzI/ Aoq+Uy+CSkfb92Q0AaB606Il+7WlgjLSacNQejQGvlC3wTImz175ActfUK2pOT8hkOgVtZ3L UsS9Swz668o+ySDVdnwWQG1sVaLuxcdX5xbFOhS1e2W4vOKuUDDXDFCF2MfLoV876faWADGy HeXjYjHFAdp6IGEZnel7ZCNoSizBxMKeDpqiTA/cSMJ5NzqoYcWhx3JT8p+HKPdsuAZCQ0c0 BjR8nFg2ux7YdojkvzioAuZ227ESo3hFFZd2+nBYo6yAuqVjqaBbpfg11XU5O0owG2xHgjY5 yhsdyRzAYkz4XCxeM6lGr1l8FKBvazt3NjgbblHQfEcG8yFoSLLQGypyGgWyL1VGsgFYyT1R 0TYpBlc4pReVFPzM/8pO93vUZhxnPS5fTgAahwyRoAWCnSWXFXelByCmGbKhzy9+KTSuf9X1 WinnTaEUi9BVPUPIMueTOYBy747rh3SNkuKLa0XOy+PiOLEDFbMEOdtDbd7RrxhhE9yiFmPo ok32grj40k3bdASlQGJqdNCcwpXdyFT6FKfg5U/S9Nv6zFOQAkJY8I9C5t8J+SJQ4w9ej/0w 0yA IronPort-HdrOrdr: A9a23:wquQ9aGq2J1yVWz9pLqE2seALOsnbusQ8zAXPiFKJiC9F/byqy nApoV/6faZslcssQgb6LO90cq7L080i6QFg7X5VI3KNGOK1FdASrsSibcKqAeBJ8SRzJ8l6Y 5QN4R4Fd3sHRxboK/BkXGF+g8bsb66GXaT9IHj80s= X-Talos-CUID: 9a23:mJT6wmjpd0loLPrOlwS23tdggDJubG+G4mbrJReEGElscKayUFOL+Z1fjJ87 X-Talos-MUID: 9a23:dxAnbQ1mE3tbSPcwOjr1yMWv5DUjpK+WDRsMnow6v9C4ET1xIjy2vCWSXdpy X-IronPort-AV: E=Sophos;i="6.00,224,1681185600"; d="scan'208";a="111938282" To: CC: Bernhard Beschow , Anthony PERARD Subject: [PULL 10/12] hw/isa/piix3: Resolve redundant k->config_write assignments Date: Wed, 7 Jun 2023 15:18:37 +0100 Message-ID: <20230607141839.48422-11-anthony.perard@citrix.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230607141839.48422-1-anthony.perard@citrix.com> References: <20230607141839.48422-1-anthony.perard@citrix.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.145.155; envelope-from=prvs=51561cf95=anthony.perard@citrix.com; helo=esa3.hc3370-68.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Anthony PERARD X-Patchwork-Original-From: Anthony PERARD via From: Anthony PERARD Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Bernhard Beschow The previous patch unified handling of piix3_write_config() accross the PIIX3 device models which allows for assigning k->config_write once in the base class. Signed-off-by: Bernhard Beschow Reviewed-by: Michael S. Tsirkin Reviewed-by: Anthony PERARD Tested-by: Chuck Zmudzinski Message-Id: <20230312120221.99183-6-shentey@gmail.com> Message-Id: <20230403074124.3925-7-shentey@gmail.com> Signed-off-by: Anthony PERARD --- hw/isa/piix3.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/isa/piix3.c b/hw/isa/piix3.c index 5e8ac98ae0..0549e043ca 100644 --- a/hw/isa/piix3.c +++ b/hw/isa/piix3.c @@ -322,6 +322,7 @@ static void pci_piix3_class_init(ObjectClass *klass, void *data) PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); AcpiDevAmlIfClass *adevc = ACPI_DEV_AML_IF_CLASS(klass); + k->config_write = piix3_write_config; dc->reset = piix3_reset; dc->desc = "ISA bridge"; dc->vmsd = &vmstate_piix3; @@ -371,7 +372,6 @@ static void piix3_class_init(ObjectClass *klass, void *data) { PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); - k->config_write = piix3_write_config; k->realize = piix3_realize; } @@ -385,7 +385,6 @@ static void piix3_xen_class_init(ObjectClass *klass, void *data) { PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); - k->config_write = piix3_write_config; k->realize = piix3_realize; } From patchwork Wed Jun 7 14:18:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 13270763 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E10B4C7EE29 for ; Wed, 7 Jun 2023 14:20:51 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q6u0w-0002uE-Qj; Wed, 07 Jun 2023 10:19:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6u0v-0002tw-Ce for qemu-devel@nongnu.org; Wed, 07 Jun 2023 10:19:53 -0400 Received: from esa5.hc3370-68.iphmx.com ([216.71.155.168]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6u0t-0003TL-Mi for qemu-devel@nongnu.org; Wed, 07 Jun 2023 10:19:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1686147591; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wWUJ7WtaHa9rB7fKP/foYa0k256I9Y1yoW9klntUSLk=; b=e06bdVeDDWVRrdZQpdcOS2OQhUsZYUuceSsVRPEGVYQk6v7gShbp0HlT 1K3khXWRhrshrhQD/La79sLyP0RjMcHkqgam5by6dsJpk8xzDiNyTcoeo GXnlU74H4IF3VzPOB4pZAno35RPmRuggzZlo7Qk/EBqs+jNIpDawHhuPb M=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 4.0 X-MesageID: 110672765 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.123 X-Policy: $RELAYED IronPort-Data: A9a23:c1iBcajPy6pABe7Ma6aq0Xi2X161ZhAKZh0ujC45NGQN5FlHY01je htvDTqDPq2JYWf8Ko9zbdy28kIO68DRztBmG1Y/+yo2QX4b9cadCdqndUqhZCn6wu8v7q5Ex 55HNoSfdpBcolv0/ErF3m3J9CEkvU2wbuOgTrWCYmYpHlUMpB4J0XpLg/Q+jpNjne+3CgaMv cKai8DEMRqu1iUc3lg8sspvkzsx+qyq0N8klgZmP6sT4geBzyN94K83fsldEVOpGuG4IcbiL wrz5OnR1n/U+R4rFuSknt7TGqHdauePVeQmoiM+t5mK2nCulARrukoIHKN0hXNsoyeIh7hMJ OBl7vRcf+uL0prkw4zxWzEAe8130DYvFLXveRBTuuTLp6HKnueFL1yDwyjaMKVBktubD12i+ tRfFWAhbzKdnNiq7722cPB2pMEqAJPkadZ3VnFIlVk1DN4jSJHHBa7L+cVZzHE7gcUm8fT2P pRDL2A1NVKZPkMJYw1MYH49tL7Aan3XejtEqFWTtOwv7nLa1gBZ27nxKtvFPNeNQK25m27B/ zqYoD6mXExy2Nq34BrG40+nlr/2hxzFX5xRJYea7L1DuQjGroAUIEJPDgbqyRWjsWanVtdCb kAZ5Ccqha418kOtU5/6RRLQiGWEsxgAVst4HOgz6QXLwa3Rizt1HUBdEGQHMoZ/8pZrG3pzj AThc87V6SJH94DFZXO/6KyusRy9NBIMN00HbANeQl5QizX8m70bghXKR9dlNae6iNzpBD39q wy3QDgCa6Y71pBSifjilbzTq3f1/8WSEFZpjunCdjj9hj6VcrJJcGBBBbLzyf9bZLiUQVCa1 JTvs5jPtbteZX1hecHkfQnsIF1Lz6zdWNE/qQQ1d3XEy9hK0yDLQGyoyGsiTHqFy+5dEdMTX GfduBlK+LhYN2awYKl8buqZUpp6k/C/S465DaGIN7Kih6SdkifdpEmCgmbKhgjQfLUEy/lja f93j+7yZZrlNUiX5GXvHLpMuVPa7is/2XnSVfjGI+ePiNKjiIquYe5dajOmN7lphJ5oVS2Jq 76zwePWkUQAOAA/CwGLmbMuwacicyBmVM6s9pYOHgNBSyI/cFwc5zbq6etJU+RYc259z48kI lnVtpdk9WfC IronPort-HdrOrdr: A9a23:kSKmDqsIHHAAvWEAKTjetPXj7skCiIAji2hC6mlwRA09TyXGra 6TdaUguiMc1gx8ZJh5o6H8BEGBKUmskKKdkrNhQYtKPTOW9VdASbsJ0WKM+UyYJ8STzJ8/6U 4kSdkFNDSSNyk3sS+Z2njBLz9I+rDum83I5ds2jU0dNj2CAJsQizuRfzzrdHGeMzM2YqbReq DshPZvln6FQzA6f867Dn4KU6zqoMDKrovvZVorFgMq8w6HiBKv8frfHwKD1hkTfjtTyfN6mF K13TDR1+GGibWW2xXc32jc49B/n8bg8MJKAIihm9UYMTLljyevfcBEV6eZtD44jemz4BIBkc XKoT0nI8NvgkmhMV2dkF/I4U3NwTwu43jtxRuzmn34u/H0Qzo8Fo5omZ9ZWgGx0TthgPhMlI Zwm06JvZteCh3N2A7n4cLTah1snk2o5VI/jO8oiWBFW4d2Us4TkWVfxjIWLH4zJlO/1GkVKp goMCga3ocRTbquVQGdgoCo+q30Yp18JGbffqFIgL3r79EfpgEG86Jf/r1fol4wsKsnTZ9K/u LFNbktuo1vY6YtHPhALdZEeNCwDGPVRxLKLSa1GnTIUI86G1+lke+t3F0SjNvaJKDgCKFCxa jpQRdWs3U/dFnpDtDL1JpX8grVSGH4Rjj1zNpCjqIJ8oHUVf7oKiWNVVEjk8yy5/MCH8bcR/ G/UagmdsMLglGea7qh8jeOLaW6E0NuGfE9q5I+QRaDs8jLIorluqjSd+vSPqPkFXIhVnnkCn UOUTDvLIEYh3rbEEPQkVzUQTfga0b/9ZV/HOzT+PUS0pEEMslJvhIOgVq068mXIXlJs7Awfk F5PLT7+5nL7lWe7CLN9SFkKxBdBkFa7PHpVG5LvxYDNwfufbMKq7ykCBdvNbu8V2tCpu/tYX 1iTg5MiNOKxrSrtFAfN+4= X-Talos-CUID: 9a23:pCU5YGOD4si+wO5DHxQ32E82BNsfblLSwU3JOW29AEozR+jA X-Talos-MUID: 9a23:Dk7y7wYnOYMkP+BTnh+vlQxpJJdR+ZuQD15OoK8koYqtDHkl X-IronPort-AV: E=Sophos;i="6.00,224,1681185600"; d="scan'208";a="110672765" To: CC: Bernhard Beschow , Anthony PERARD Subject: [PULL 11/12] hw/isa/piix3: Resolve redundant TYPE_PIIX3_XEN_DEVICE Date: Wed, 7 Jun 2023 15:18:38 +0100 Message-ID: <20230607141839.48422-12-anthony.perard@citrix.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230607141839.48422-1-anthony.perard@citrix.com> References: <20230607141839.48422-1-anthony.perard@citrix.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.155.168; envelope-from=prvs=51561cf95=anthony.perard@citrix.com; helo=esa5.hc3370-68.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Anthony PERARD X-Patchwork-Original-From: Anthony PERARD via From: Anthony PERARD Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Bernhard Beschow During the last patches, TYPE_PIIX3_XEN_DEVICE turned into a clone of TYPE_PIIX3_DEVICE. Remove this redundancy. Signed-off-by: Bernhard Beschow Reviewed-by: Michael S. Tsirkin Reviewed-by: Anthony PERARD Tested-by: Chuck Zmudzinski Message-Id: <20230312120221.99183-7-shentey@gmail.com> Message-Id: <20230403074124.3925-8-shentey@gmail.com> Signed-off-by: Anthony PERARD --- hw/i386/pc_piix.c | 5 ++--- hw/isa/piix3.c | 15 --------------- include/hw/southbridge/piix.h | 1 - 3 files changed, 2 insertions(+), 19 deletions(-) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 2ed2b3f3c6..42af03dbb4 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -239,8 +239,6 @@ static void pc_init1(MachineState *machine, if (pcmc->pci_enabled) { PIIX3State *piix3; PCIDevice *pci_dev; - const char *type = xen_enabled() ? TYPE_PIIX3_XEN_DEVICE - : TYPE_PIIX3_DEVICE; pci_bus = i440fx_init(pci_type, i440fx_host, @@ -253,7 +251,8 @@ static void pc_init1(MachineState *machine, : pc_pci_slot_get_pirq); pcms->bus = pci_bus; - pci_dev = pci_create_simple_multifunction(pci_bus, -1, true, type); + pci_dev = pci_create_simple_multifunction(pci_bus, -1, true, + TYPE_PIIX3_DEVICE); if (xen_enabled()) { pci_device_set_intx_routing_notifier( diff --git a/hw/isa/piix3.c b/hw/isa/piix3.c index 0549e043ca..117024e450 100644 --- a/hw/isa/piix3.c +++ b/hw/isa/piix3.c @@ -30,7 +30,6 @@ #include "hw/irq.h" #include "hw/qdev-properties.h" #include "hw/isa/isa.h" -#include "hw/xen/xen.h" #include "sysemu/runstate.h" #include "migration/vmstate.h" #include "hw/acpi/acpi_aml_interface.h" @@ -381,24 +380,10 @@ static const TypeInfo piix3_info = { .class_init = piix3_class_init, }; -static void piix3_xen_class_init(ObjectClass *klass, void *data) -{ - PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); - - k->realize = piix3_realize; -} - -static const TypeInfo piix3_xen_info = { - .name = TYPE_PIIX3_XEN_DEVICE, - .parent = TYPE_PIIX3_PCI_DEVICE, - .class_init = piix3_xen_class_init, -}; - static void piix3_register_types(void) { type_register_static(&piix3_pci_type_info); type_register_static(&piix3_info); - type_register_static(&piix3_xen_info); } type_init(piix3_register_types) diff --git a/include/hw/southbridge/piix.h b/include/hw/southbridge/piix.h index a840340308..278171752f 100644 --- a/include/hw/southbridge/piix.h +++ b/include/hw/southbridge/piix.h @@ -67,7 +67,6 @@ DECLARE_INSTANCE_CHECKER(PIIX3State, PIIX3_PCI_DEVICE, TYPE_PIIX3_PCI_DEVICE) #define TYPE_PIIX3_DEVICE "PIIX3" -#define TYPE_PIIX3_XEN_DEVICE "PIIX3-xen" #define TYPE_PIIX4_PCI_DEVICE "piix4-isa" #endif From patchwork Wed Jun 7 14:18:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 13270767 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CC965C7EE23 for ; Wed, 7 Jun 2023 14:21:29 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q6u0x-0002uF-DR; Wed, 07 Jun 2023 10:19:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6u0w-0002u5-4O for qemu-devel@nongnu.org; Wed, 07 Jun 2023 10:19:54 -0400 Received: from esa6.hc3370-68.iphmx.com ([216.71.155.175]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6u0u-0003Qf-GB for qemu-devel@nongnu.org; Wed, 07 Jun 2023 10:19:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1686147592; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=d5mAhhjITwi8S49z+YqAH0l9GdOkUuJMbFDA8evNpo8=; b=DpRDPz3OryhdUSADOomtIPA9PeVo79wab2SmTCPg24Hf5MNtLx0pzE+R eUeXIKGRypBHZgNyvFYAdWk7PfcJ1dJgME2FEqaygsE8I9UhcExgJLc9Q 1W4fRjWyGEcg3k7WDoDjUMWohd0C51TuK57NlgkasF015XzUmiof62UkU E=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 4.0 X-MesageID: 111246636 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.123 X-Policy: $RELAYED IronPort-Data: A9a23:UPvqla9ki+uhMaUZ0KuPDrUD9X6TJUtcMsCJ2f8bNWPcYEJGY0x3n DYfDz3XOK6MMGGkL49zb9uxp0kA65/RxtU1SwQ/pX08E34SpcT7XtnIdU2Y0wF+jCHgZBk+s 5hBMImowOQcFCK0SsKFa+C5xZVE/fjUAOG6UKicYXoZqTZMEE8JkQhkl/MynrlmiN24BxLlk d7pqojUNUTNNwRcawr40Ird7ks31BjOkGlA5AdmO6gU5AW2e0Q9V/rzG4ngdxMUfaEMdgKKb 76r5K20+Grf4yAsBruN+losWhRXKlJ6FVHmZkt+A8BOsDAbzsAB+v9T2M4nQVVWk120c+VZk 72hg3ASpTABZcUgkMxFO/VR/roX0aduoNcrKlDn2SCfItGvn9IBDJyCAWlvVbD09NqbDkkR+ eJHDBcsSirYiu22xbmFZelAjPYseZyD0IM34hmMzBncBPciB5vCX7/L9ZlT2zJYasJmRKiEI ZBDMHw2MUqGOkcUUrsUIMtWcOOAj3/jczpeuRSNqLA++WT7xw1tyrn9dtHSf7RmQO0Mxx/C+ jyYpDqR7hcyK/y06gSGrmiQu7XzggPKWt8dV4Ky36s/6LGU7jNKU0BHPbehmtGgh0ujHt5SN UEQ0iwpq6c06QqsVNaVYvGjiCfa5FhGAYMWSrBkrljXkcI4/jp1GEBbQiAeTPsHkPVtSDMq0 1S3sNPFDw5g5ej9pW2myp+Yqja7OC4wJGAEZDMZQQZt3+QPsL3fnTqUEI89TffdYsndXGipn mvU9HRWa6A715Zj6kmtwbzQb9tATLDtRxV92AjYV3nNAuhRNN/8PNzABbQ2AJ99wGelorup5 iBsdyu2trpm4XSxeMulHo0w8EmBvartDdElqQcH82Md3zqs4WW/Wotb/StzIkxkWu5dJ2+3O BCN418KtcMKVJdPUUORS9jpYyjN5fK5fekJq9iONoYeCnSPXFHvEN5Sib64gDm2zRlEfVAXM paHa8e8ZUv2+ow+pAdas9w1iOdxrghnnDO7eHwO50j/uVZoTCLPGOht3ZrnRrxR0Z5oVy2Lq 4sOaZHXkUw3vS+XSnC/zLP/5GsidRATba0aYeQNHgJfCmKKwF0cNsI= IronPort-HdrOrdr: A9a23:E0nf96NMbskhx8BcTvOjsMiBIKoaSvp037BL7S9MoHluGfBw+P re+cjzuSWUtN9pYgBCpTniAse9qA3nhPxICOAqVN/JMWXbUQ2TXeVfBODZowEIdReOj9J15O NNdLV/Fc21LXUSt7eD3OBgKadG/DBQytHPudvj X-Talos-CUID: 9a23:5UIcfW23ogZvx5C3jBRYd7xfRcw7LVn67VPqeEK3CWNidpKVZVWi9/Yx X-Talos-MUID: 9a23:SZScSAwfTOmq4KSBD83lVihxcOyaqLuOI2Mzkskch/TeCTNQCjXAg3eISKZyfw== X-IronPort-AV: E=Sophos;i="6.00,224,1681185600"; d="scan'208";a="111246636" To: CC: Anthony PERARD Subject: [PULL 12/12] xen-block: fix segv on unrealize Date: Wed, 7 Jun 2023 15:18:39 +0100 Message-ID: <20230607141839.48422-13-anthony.perard@citrix.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230607141839.48422-1-anthony.perard@citrix.com> References: <20230607141839.48422-1-anthony.perard@citrix.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.155.175; envelope-from=prvs=51561cf95=anthony.perard@citrix.com; helo=esa6.hc3370-68.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Anthony PERARD X-Patchwork-Original-From: Anthony PERARD via From: Anthony PERARD Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Anthony PERARD Backtrace: qemu_lockcnt_lock (lockcnt=0xb4) at ../util/lockcnt.c:238 aio_set_fd_handler (ctx=0x0, fd=51, is_external=true, io_read=0x0, io_write=0x0, io_poll=0x0, io_poll_ready=0x0, opaque=0x0) at ../util/aio-posix.c:119 xen_device_unbind_event_channel (xendev=0x55c6da5b5000, channel=0x55c6da6c4c80, errp=0x7fff641ac608) at ../hw/xen/xen-bus.c:926 xen_block_dataplane_stop (dataplane=0x55c6da6ddbe0) at ../hw/block/dataplane/xen-block.c:719 xen_block_disconnect (xendev=0x55c6da5b5000, errp=0x0) at ../hw/block/xen-block.c:48 xen_block_unrealize (xendev=0x55c6da5b5000) at ../hw/block/xen-block.c:154 xen_device_unrealize (dev=0x55c6da5b5000) at ../hw/xen/xen-bus.c:956 xen_device_exit (n=0x55c6da5b50d0, data=0x0) at ../hw/xen/xen-bus.c:985 notifier_list_notify (list=0x55c6d91f9820 , data=0x0) at ../util/notify.c:39 qemu_run_exit_notifiers () at ../softmmu/runstate.c:760 Fixes: f6eac904f682 ("xen-block: implement BlockDevOps->drained_begin()") Signed-off-by: Anthony PERARD Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Stefan Hajnoczi Message-Id: <20230606131605.55596-1-anthony.perard@citrix.com> Signed-off-by: Anthony PERARD --- hw/xen/xen-bus.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/xen/xen-bus.c b/hw/xen/xen-bus.c index 1e08cf027a..ece8ec40cd 100644 --- a/hw/xen/xen-bus.c +++ b/hw/xen/xen-bus.c @@ -923,8 +923,10 @@ void xen_device_unbind_event_channel(XenDevice *xendev, QLIST_REMOVE(channel, list); - aio_set_fd_handler(channel->ctx, qemu_xen_evtchn_fd(channel->xeh), - NULL, NULL, NULL, NULL, NULL); + if (channel->ctx) { + aio_set_fd_handler(channel->ctx, qemu_xen_evtchn_fd(channel->xeh), + NULL, NULL, NULL, NULL, NULL); + } if (qemu_xen_evtchn_unbind(channel->xeh, channel->local_port) < 0) { error_setg_errno(errp, errno, "xenevtchn_unbind failed");