From nobody Tue Sep 9 21:42:13 2025 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; 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 ARC-Seal: i=1; a=rsa-sha256; t=1757114870; cv=none; d=zohomail.com; s=zohoarc; b=lXVuNSj1yAz4MVbAQ47yDSwVBUZLIICp5uHe7H0hL/UOrEs+d0982PS+263qWJYUREND8whtOAwZ3Jx501e5y/oiXxNMN2UGib5AS8Z3IQhukE85iAPn8nA/TNDPe5OCJ3R4Cg8a4WbrAt2OwWqrPuQd/uw4z8kyWNft7BLBUhI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757114870; h=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=kdR4+D2HTw7sqqj0HNahqkkhzpwH2jMWlfFIDzxZevA=; b=eYsXzzgoMm0MXMF5p088Y8hHP2SqXnrLU1Kv168iCiDlMhedBDy31nMHj0CCjahnpYwCrWVRgRBiCyrtDbffvdpnL97hzcUYWYEaPEkrhi9GuP+9BHRPWk9UZ0+7HW+KOkQgNKwD+S9YAQpxbKfcQogcH9SLzDqOb2PLj8Xf/Aw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1757114870249838.0299457165974; Fri, 5 Sep 2025 16:27:50 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1112647.1460954 (Exim 4.92) (envelope-from ) id 1uufqD-0004kK-T1; Fri, 05 Sep 2025 23:27:37 +0000 Received: by outflank-mailman (output) from mailman id 1112647.1460954; Fri, 05 Sep 2025 23:27:37 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uufqC-0004j6-Uv; Fri, 05 Sep 2025 23:27:36 +0000 Received: by outflank-mailman (input) for mailman id 1112647; Fri, 05 Sep 2025 23:27:34 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uufqA-0004HV-De for xen-devel@lists.xenproject.org; Fri, 05 Sep 2025 23:27:34 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.96) (envelope-from ) id 1uufqA-008ACs-05; Fri, 05 Sep 2025 23:27:34 +0000 Received: from [19.12.91.86] (helo=localhost) by xenbits.xenproject.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uufqA-0005Dg-04; Fri, 05 Sep 2025 23:27:34 +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" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From; bh=kdR4+D2HTw7sqqj0HNahqkkhzpwH2jMWlfFIDzxZevA=; b=VME4w8rPFIRkvrv6atSbQYGNhs 0kMQUp/RAjELNTLais/tj1W5WJZWZQnzQSq+78Yaje5xgmSr7H7U4fPs04obNgvxgO1RS+tMTb0Oa dn+3nmvjMo883tmFIFqSjO5ZRFCNEkB879c9VE9P9Alv+T81gwynHnnLkol1N+L+UCBM=; From: dmukhin@xen.org To: xen-devel@lists.xenproject.org Cc: andrew.cooper3@citrix.com, anthony.perard@vates.tech, jbeulich@suse.com, julien@xen.org, michal.orzel@amd.com, roger.pau@citrix.com, sstabellini@kernel.org, dmukhin@ford.com Subject: [PATCH v6 14/15] xen/domain: allocate d->irq_caps before arch-specific initialization Date: Fri, 5 Sep 2025 16:27:13 -0700 Message-ID: <20250905232715.440758-15-dmukhin@ford.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250905232715.440758-1-dmukhin@ford.com> References: <20250905232715.440758-1-dmukhin@ford.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xen.org) X-ZM-MESSAGEID: 1757114872852124100 Content-Type: text/plain; charset="utf-8" From: Denis Mukhin =20 Make sure that NS16550 emulator does not share virtual device IRQ with the physical one. This is needed for enabling NS16550 emulator for PVH hwdom (dom0). To do that, move per-domain interrupt rangeset allocation before arch-speci= fic code. Add irqs_setup_access() to setup the initial rangeset. Signed-off-by: Denis Mukhin --- Changes since v5: - n/a - Link to v5: https://lore.kernel.org/xen-devel/20250828235409.2835815-15-d= mukhin@ford.com/ --- xen/arch/x86/dom0_build.c | 1 - xen/arch/x86/hvm/dom0_build.c | 7 +++++++ xen/arch/x86/include/asm/irq.h | 2 ++ xen/arch/x86/irq.c | 8 ++++++++ xen/arch/x86/pv/dom0_build.c | 3 +++ xen/common/domain.c | 8 ++++++-- xen/common/emul/vuart/ns16x50.c | 9 +++++++++ 7 files changed, 35 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index 26202b33345c..9dc87efbf3e8 100644 --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -442,7 +442,6 @@ int __init dom0_setup_permissions(struct domain *d) =20 rc |=3D iomem_permit_access(d, 0UL, PFN_DOWN(1UL << domain_max_paddr_bits(d)) - = 1); - rc |=3D irqs_permit_access(d, 1, nr_irqs_gsi - 1); =20 /* Local APIC. */ if ( mp_lapic_addr !=3D 0 ) diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c index 5551f9044836..245a42dec9aa 100644 --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -1348,6 +1348,13 @@ int __init dom0_construct_pvh(const struct boot_doma= in *bd) */ pvh_setup_mmcfg(d); =20 + rc =3D irqs_setup_access(d); + if ( rc ) + { + printk("%pd unable to setup IRQ rangeset: %d\n", d, rc); + return rc; + } + /* * Setup permissions early so that calls to add MMIO regions to the * p2m as part of vPCI setup don't fail due to permission checks. diff --git a/xen/arch/x86/include/asm/irq.h b/xen/arch/x86/include/asm/irq.h index 8c81f66434a8..8bffec3bbfee 100644 --- a/xen/arch/x86/include/asm/irq.h +++ b/xen/arch/x86/include/asm/irq.h @@ -231,4 +231,6 @@ int allocate_and_map_gsi_pirq(struct domain *d, int ind= ex, int *pirq_p); int allocate_and_map_msi_pirq(struct domain *d, int index, int *pirq_p, int type, struct msi_info *msi); =20 +int irqs_setup_access(struct domain *d); + #endif /* _ASM_HW_IRQ_H */ diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c index 556134f85aa0..079277be719d 100644 --- a/xen/arch/x86/irq.c +++ b/xen/arch/x86/irq.c @@ -3046,3 +3046,11 @@ int allocate_and_map_msi_pirq(struct domain *d, int = index, int *pirq_p, =20 return ret; } + +int irqs_setup_access(struct domain *d) +{ + if ( is_hardware_domain(d) ) + return irqs_permit_access(d, 1, nr_irqs_gsi - 1); + + return 0; +} diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index 2b8b4d869ee7..1a092b802833 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -1037,6 +1037,9 @@ static int __init dom0_construct(const struct boot_do= main *bd) rc =3D ioports_setup_access(d); BUG_ON(rc !=3D 0); =20 + rc =3D irqs_setup_access(d); + BUG_ON(rc !=3D 0); + rc =3D dom0_setup_permissions(d); BUG_ON(rc !=3D 0); =20 diff --git a/xen/common/domain.c b/xen/common/domain.c index 775c33928585..edf76b02e1a1 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -952,6 +952,11 @@ struct domain *domain_create(domid_t domid, radix_tree_init(&d->pirq_tree); #endif =20 + err =3D -ENOMEM; + d->irq_caps =3D rangeset_new(d, "Interrupts", 0); + if ( !d->irq_caps ) + goto fail; + if ( (err =3D arch_domain_create(d, config, flags)) !=3D 0 ) goto fail; init_status |=3D INIT_arch; @@ -961,8 +966,7 @@ struct domain *domain_create(domid_t domid, =20 err =3D -ENOMEM; d->iomem_caps =3D rangeset_new(d, "I/O Memory", RANGESETF_prettyprint_= hex); - d->irq_caps =3D rangeset_new(d, "Interrupts", 0); - if ( !d->iomem_caps || !d->irq_caps ) + if ( !d->iomem_caps ) goto fail; =20 if ( (err =3D xsm_domain_create(XSM_HOOK, d, config->ssidref)) !=3D 0 ) diff --git a/xen/common/emul/vuart/ns16x50.c b/xen/common/emul/vuart/ns16x5= 0.c index 7c4affe98533..bcbd765b815d 100644 --- a/xen/common/emul/vuart/ns16x50.c +++ b/xen/common/emul/vuart/ns16x50.c @@ -806,6 +806,15 @@ static int ns16x50_init(void *arg) return rc; } =20 + /* Disallow sharing physical IRQ */ + rc =3D irq_deny_access(d, info->irq); + if ( rc ) + { + ns16x50_err(info, "virtual IRQ#%d: conflict w/ physical IRQ: %d\n", + info->irq, rc); + return rc; + } + /* NB: report 115200 baud rate. */ vdev->regs[NS16X50_REGS_NUM + UART_DLL] =3D divisor & 0xff; vdev->regs[NS16X50_REGS_NUM + UART_DLM] =3D (divisor >> 8) & 0xff; --=20 2.51.0