From nobody Mon Mar 23 21:23:14 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=thierry.escande@vates.tech; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=vates.tech ARC-Seal: i=1; a=rsa-sha256; t=1773420445; cv=none; d=zohomail.com; s=zohoarc; b=Jz9J5eragWMA6TKRa03sRjJ2PtM86hccZN94O3XzjELSRte7M0k0jwiXsHsoMVrYcXHRo8BalwHCe+6UlyWfYtQhJ0EjSdRqpnYpEZnOuXisN1AXcBJvuSdPSYu3tyizmqx7kkhB2fiU9RUMRdLzp46zVCuK2o6wsPFpGLtifWk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773420445; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=B1fZqJL36gLjyygjzjPY/WHbUmBzonK71fAY1TCjXcI=; b=dd3M7XWggjx/S3I8cS+PY5CA8pYHkhV+caGgpakKQruySFqb0zweu1wSwe5uFEmW4vKQMI5CVqft+9QyIhqCf0QOCYhJ1/783pwNkELr7wH/PtPy49i+AqxxYYAUN2TMGDd1MC5nUeX/GKgSSpqGG9+qOWHNXq8bEa+5lIQRSgs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=thierry.escande@vates.tech; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1773420445690720.6457155448902; Fri, 13 Mar 2026 09:47:25 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1254161.1550144 (Exim 4.92) (envelope-from ) id 1w15fK-0006wg-V4; Fri, 13 Mar 2026 16:47:10 +0000 Received: by outflank-mailman (output) from mailman id 1254161.1550144; Fri, 13 Mar 2026 16:47:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w15fK-0006wX-Rs; Fri, 13 Mar 2026 16:47:10 +0000 Received: by outflank-mailman (input) for mailman id 1254161; Fri, 13 Mar 2026 16:47:10 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w15fK-0006dJ-CA for xen-devel@lists.xenproject.org; Fri, 13 Mar 2026 16:47:10 +0000 Received: from mail134-15.atl141.mandrillapp.com (mail134-15.atl141.mandrillapp.com [198.2.134.15]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 45afdb7e-1efc-11f1-9ccf-f158ae23cfc8; Fri, 13 Mar 2026 17:47:08 +0100 (CET) Received: from pmta10.mandrill.prod.atl01.rsglab.com (localhost [127.0.0.1]) by mail134-15.atl141.mandrillapp.com (Mailchimp) with ESMTP id 4fXVkz1vGhzPm0Pr5 for ; Fri, 13 Mar 2026 16:47:07 +0000 (GMT) Received: from [37.26.189.201] by mandrillapp.com id 0118508a42d54da1a844b7f27097d1e0; Fri, 13 Mar 2026 16:47:07 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 45afdb7e-1efc-11f1-9ccf-f158ae23cfc8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com; s=mte1; t=1773420427; x=1773690427; bh=B1fZqJL36gLjyygjzjPY/WHbUmBzonK71fAY1TCjXcI=; h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID: Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date: Subject:From; b=Nzp0JDE45Zx44s8jrK143spt1uvUCtMqqhBlIK+aG/9duFiB23hhggAZ4W+uCWKo9 QfP7uzBQo0PiQAcW+7dkILIaaRHj1y/1esxc7t2EgnPWSh1c7OpYBygvWL9vzIPVAw imY+B6mecylxmM1UMutwFHYwK7pTwtEhPdz3QCH9QjUfH4w5P6CTCn5ZN7BXD36bni 1TTayukUzKA3fjIaa3pDsmpvBgi0rTMrWv4bvZnpisWWPTJBVEBqCFivyfI+UdXYkp hz8Ga8kFrL1ftzV9iewE51HA3YxVRG2DorZYhJwH2IOG7HbN5gl06lQq00884mbe+h NGMrDS+jfpz7Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1; t=1773420427; x=1773680927; i=thierry.escande@vates.tech; bh=B1fZqJL36gLjyygjzjPY/WHbUmBzonK71fAY1TCjXcI=; h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID: Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date: Subject:From; b=zDYb8qxoF4KjqvLStQ+Or7YsG/BV3GDd/z35iPo/DBevuXqsYBg2Wle4sU+mmxgAb WB0IrzGAEwtboUxZi4wXzLgqnWel1bYYr8i5IWqREwDmzQBeZxTyN/3ZgLjw/09W5T tat8cjKPdk3QS00WAS8GS9sbItFhb9Jq3dh3/w9Tvi2FdPg+ydtFPNgJQ8ubkMmCmO vgUQ6OKJMGZ4BgRtJR2iK/4RbHOp10m/fUjZzWc2svLr/AM98mmsttPxzqf3Mdo1my OLc6x1DbIt3ku9SepM872qup7kJePcEHxC/tJj7cojMs+CAjYTVQY8fbLyQlAFOSUP wsGIRfvlP0tKQ== From: "Thierry Escande" Subject: =?utf-8?Q?[PATCH=201/4]=20pc/xen:=20Xen=20Q35=20support:=20provide=20IRQ=20handling=20for=20PCI=20devices?= X-Mailer: git-send-email 2.51.0 X-Bm-Disclaimer: Yes X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2 X-Bm-Transport-Timestamp: 1773420425990 To: qemu-devel@nongnu.org Cc: "Alexey Gerasimenko" , "Paolo Bonzini" , "Richard Henderson" , "Michael S. Tsirkin" , "Eduardo Habkost" , "Anthony PERARD" , xen-devel@lists.xenproject.org, "Thierry Escande" Message-Id: <20260313164649.794591-2-thierry.escande@vates.tech> In-Reply-To: <20260313164649.794591-1-thierry.escande@vates.tech> References: <20260313164649.794591-1-thierry.escande@vates.tech> X-Native-Encoded: 1 X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.0118508a42d54da1a844b7f27097d1e0?= X-Mandrill-User: md_30504962 Feedback-ID: 30504962:30504962.20260313:md Date: Fri, 13 Mar 2026 16:47:07 +0000 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @mandrillapp.com) (identity thierry.escande@vates.tech) X-ZM-MESSAGEID: 1773420446149158500 Content-Type: text/plain; charset="utf-8" From: Alexey Gerasimenko This patch introduces support for ICH9 LPC PCI interrupt routing when running under Xen. This intercepts writes to the PIRQA-D routing registers and propagates routing changes to the Xen device model via xen_set_pci_link_route(). A major difference between i440 and Q35 is the number of PIRQ inputs and PIRQ routers (PCI IRQ links in terms of ACPI) available. i440 has 4 PCI interrupt links, while Q35 has 8 (PIRQA...PIRQH). Currently Xen has support for only 4 PCI links, so we describe only 4 of 8 PCI links in ACPI tables. Also, hvmloader disables PIRQ routing for PIRQE..PIRQH by writing 80h into corresponding PIRQ[n]_ROUT registers. All this PCI interrupt routing stuff largely concerns legacy mechanism from PIC era. It's hardly worth to extend number of PCI links supported as we normally deal with APIC mode and/or MSI interrupts. The only useful thing to do with PIRQE..PIRQH routing currently is to check if guest actually attempts to use it for some reason (despite ACPI PCI routing information provided). In this case, a warning is reported. This has been tested on Linux guests with noapic and pci=3Dnomsi kernel parameters set. Signed-off-by: Alexey Gerasimenko Signed-off-by: Thierry Escande --- hw/i386/pc_piix.c | 2 -- hw/i386/xen/xen-hvm.c | 38 ++++++++++++++++++++++++++++++++++++++ hw/isa/lpc_ich9.c | 16 +++++++++++++--- include/hw/xen/xen.h | 5 +++++ stubs/xen-hw-stub.c | 4 ++++ 5 files changed, 60 insertions(+), 5 deletions(-) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 4d71e0d51a..a65e09e46c 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -66,8 +66,6 @@ #include "hw/i386/acpi-build.h" #include "target/i386/cpu.h" =20 -#define XEN_IOAPIC_NUM_PIRQS 128ULL - static GlobalProperty pc_piix_compat_defaults[] =3D { { TYPE_RAMFB_DEVICE, "use-legacy-x86-rom", "true" }, { TYPE_VFIO_PCI_NOHOTPLUG, "use-legacy-x86-rom", "true" }, diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c index 67d3e836eb..2dba289e09 100644 --- a/hw/i386/xen/xen-hvm.c +++ b/hw/i386/xen/xen-hvm.c @@ -18,6 +18,7 @@ #include "hw/core/hw-error.h" #include "hw/i386/pc.h" #include "hw/core/irq.h" +#include "hw/southbridge/ich9.h" #include "hw/i386/apic-msidef.h" #include "hw/xen/xen-x86.h" #include "qemu/range.h" @@ -87,6 +88,43 @@ int xen_set_pci_link_route(uint8_t link, uint8_t irq) return xendevicemodel_set_pci_link_route(xen_dmod, xen_domid, link, ir= q); } =20 +void xen_ich9_pci_write_config_client(PCIDevice *pci_dev, uint32_t address= , uint32_t val, int len) +{ + static bool pirqe_f_warned =3D false; + int i; + + if (ranges_overlap(address, len, ICH9_LPC_PIRQA_ROUT, 4)) { + /* handle PIRQA..PIRQD routing */ + /* Scan for updates to PCI link routes (0x60-0x63). */ + for (i =3D 0; i < len; i++) { + uint8_t v =3D (val >> (8 * i)) & 0xff; + if (v & 0x80) { + v =3D 0; + } + v &=3D 0xf; + if (((address + i) >=3D ICH9_LPC_PIRQA_ROUT) && + ((address + i) <=3D ICH9_LPC_PIRQD_ROUT)) { + xen_set_pci_link_route(address + i - ICH9_LPC_PIRQA_ROUT, = v); + } + } + } else if (ranges_overlap(address, len, ICH9_LPC_PIRQE_ROUT, 4)) { + while (len--) { + if (range_covers_byte(ICH9_LPC_PIRQE_ROUT, 4, address) && + (val & 0x80) =3D=3D 0) { + /* print warning only once */ + if (!pirqe_f_warned) { + pirqe_f_warned =3D true; + warn_report("WARNING: guest domain attempted to use PI= RQ%c " + "routing which is not supported for Xen/Q3= 5 currently\n", + (char)(address - ICH9_LPC_PIRQE_ROUT + 'E'= )); + break; + } + } + address++, val >>=3D 8; + } + } +} + int xen_is_pirq_msi(uint32_t msi_data) { /* If vector is 0, the msi is remapped into a pirq, passed as diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c index 51dc680029..8c627f0734 100644 --- a/hw/isa/lpc_ich9.c +++ b/hw/isa/lpc_ich9.c @@ -46,8 +46,10 @@ #include "hw/acpi/ich9_timer.h" #include "hw/pci/pci_bus.h" #include "hw/core/qdev-properties.h" +#include "hw/xen/xen.h" #include "system/runstate.h" #include "system/system.h" +#include "system/xen.h" #include "hw/core/cpu.h" #include "hw/nvram/fw_cfg.h" #include "qemu/cutils.h" @@ -569,6 +571,9 @@ static void ich9_lpc_config_write(PCIDevice *d, ICH9LPCState *lpc =3D ICH9_LPC_DEVICE(d); uint32_t rcba_old =3D pci_get_long(d->config + ICH9_LPC_RCBA); =20 + if (xen_enabled()){ + xen_ich9_pci_write_config_client(d, addr, val, len); + } pci_default_write_config(d, addr, val, len); if (ranges_overlap(addr, len, ICH9_LPC_PMBASE, 4) || ranges_overlap(addr, len, ICH9_LPC_ACPI_CTRL, 1)) { @@ -762,9 +767,14 @@ static void ich9_lpc_realize(PCIDevice *d, Error **err= p) irq =3D object_property_get_uint(OBJECT(&lpc->rtc), "irq", &error_fata= l); isa_connect_gpio_out(ISA_DEVICE(&lpc->rtc), 0, irq); =20 - pci_bus_irqs(pci_bus, ich9_lpc_set_irq, d, ICH9_LPC_NB_PIRQS); - pci_bus_map_irqs(pci_bus, ich9_lpc_map_irq); - pci_bus_set_route_irq_fn(pci_bus, ich9_route_intx_pin_to_irq); + if (xen_enabled()) { + pci_bus_irqs(pci_bus, xen_intx_set_irq, d, XEN_IOAPIC_NUM_PIRQS); + pci_bus_map_irqs(pci_bus, xen_pci_slot_get_pirq); + } else { + pci_bus_irqs(pci_bus, ich9_lpc_set_irq, d, ICH9_LPC_NB_PIRQS); + pci_bus_map_irqs(pci_bus, ich9_lpc_map_irq); + pci_bus_set_route_irq_fn(pci_bus, ich9_route_intx_pin_to_irq); + } =20 ich9_lpc_pm_init(lpc); } diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h index e94c6e5a31..910289b54d 100644 --- a/include/hw/xen/xen.h +++ b/include/hw/xen/xen.h @@ -24,6 +24,8 @@ #define __XEN_INTERFACE_VERSION__ 0x00040e00 #endif =20 +#define XEN_IOAPIC_NUM_PIRQS 128ULL + /* xen-machine.c */ enum xen_mode { XEN_DISABLED =3D 0, /* xen support disabled (default) */ @@ -39,6 +41,9 @@ extern bool xen_is_stubdomain; 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_intx_set_irq(void *opaque, int irq_num, int level); +void xen_ich9_pci_write_config_client(PCIDevice *pci_dev, + uint32_t address, uint32_t val, + int len); void xen_hvm_inject_msi(uint64_t addr, uint32_t data); int xen_is_pirq_msi(uint32_t msi_data); =20 diff --git a/stubs/xen-hw-stub.c b/stubs/xen-hw-stub.c index 6cf0e9a4c1..a74209d01e 100644 --- a/stubs/xen-hw-stub.c +++ b/stubs/xen-hw-stub.c @@ -24,6 +24,10 @@ int xen_set_pci_link_route(uint8_t link, uint8_t irq) return -1; } =20 +void xen_ich9_pci_write_config_client(PCIDevice *pci_dev, uint32_t address= , uint32_t val, int len) +{ +} + int xen_is_pirq_msi(uint32_t msi_data) { return 0; --=20 2.51.0 -- Thierry Escande | Vates XCP-ng Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech