From nobody Sat Apr 20 07:46:02 2024 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; 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=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1617709274; cv=none; d=zohomail.com; s=zohoarc; b=X7UApXTtZRh7/lZbQx5PkUmyHtmKgF2wZAKnBDWaoqMtMPgl1sILauP69wAHRumvJpDd6Hrp11Nqf6UdlqkfQjIYbWk0LlI42FD/LSbQX47cXhxN8nmZbE8iEwbeUbjQVebcfi28P1JsmXUY5cZZGTDDQBy4bIeK1rAMgFSIrVQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617709274; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=NzVgU/OZQUEFVPltu0GeLBYQWCaIovnQPNcbohgTPS0=; b=iFHdlucQ440GoMBt13sgQt8jFbTbMo0TamGYRJnh4Sl0W9Js7iWBOpML+Y3L8iRSWwQbeJVbb39u6cYJqadY85DVP5YGtygseUaj8oWCGbwAJI6BsfBXNF9Av+SO4HOHGg5+du1mzFGPiITK/+4tZ/JM8kc52+0iTfTsfo4EHFY= ARC-Authentication-Results: i=1; mx.zohomail.com; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1617709274102126.75274878031041; Tue, 6 Apr 2021 04:41:14 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.105906.202536 (Exim 4.92) (envelope-from ) id 1lTk4q-0000p1-Ka; Tue, 06 Apr 2021 11:41:00 +0000 Received: by outflank-mailman (output) from mailman id 105906.202536; Tue, 06 Apr 2021 11:41:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lTk4q-0000ou-HK; Tue, 06 Apr 2021 11:41:00 +0000 Received: by outflank-mailman (input) for mailman id 105906; Tue, 06 Apr 2021 11:41:00 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lTk4q-0000op-2U for xen-devel@lists.xenproject.org; Tue, 06 Apr 2021 11:41:00 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id a8a90018-4185-4ad6-b665-11352dfccd80; Tue, 06 Apr 2021 11:40:59 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E9CDF1042; Tue, 6 Apr 2021 04:40:58 -0700 (PDT) Received: from e109506.cambridge.arm.com (e109506.cambridge.arm.com [10.1.199.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2A8BA3F73D; Tue, 6 Apr 2021 04:40:58 -0700 (PDT) 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: a8a90018-4185-4ad6-b665-11352dfccd80 From: Rahul Singh To: xen-devel@lists.xenproject.org Cc: bertrand.marquis@arm.com, rahul.singh@arm.com, Jan Beulich , Paul Durrant Subject: [PATCH 1/2] xen/pci: Move PCI ATS code to common directory Date: Tue, 6 Apr 2021 12:39:10 +0100 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" PCI ATS code is common for all architecture, move code to common directory to be usable for other architectures. No functional change intended. Signed-off-by: Rahul Singh Acked-by: Jan Beulich --- xen/drivers/passthrough/Makefile | 1 + xen/drivers/passthrough/{x86 =3D> }/ats.c | 2 +- xen/drivers/passthrough/x86/Makefile | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) rename xen/drivers/passthrough/{x86 =3D> }/ats.c (99%) diff --git a/xen/drivers/passthrough/Makefile b/xen/drivers/passthrough/Mak= efile index cc646612c7..445690e3e5 100644 --- a/xen/drivers/passthrough/Makefile +++ b/xen/drivers/passthrough/Makefile @@ -6,3 +6,4 @@ obj-$(CONFIG_ARM) +=3D arm/ obj-y +=3D iommu.o obj-$(CONFIG_HAS_PCI) +=3D pci.o obj-$(CONFIG_HAS_DEVICE_TREE) +=3D device_tree.o +obj-$(CONFIG_HAS_PCI) +=3D ats.o diff --git a/xen/drivers/passthrough/x86/ats.c b/xen/drivers/passthrough/at= s.c similarity index 99% rename from xen/drivers/passthrough/x86/ats.c rename to xen/drivers/passthrough/ats.c index 4628ffde45..7f7b16dc49 100644 --- a/xen/drivers/passthrough/x86/ats.c +++ b/xen/drivers/passthrough/ats.c @@ -16,7 +16,7 @@ #include #include #include -#include "../ats.h" +#include "ats.h" =20 bool_t __read_mostly ats_enabled =3D 0; boolean_param("ats", ats_enabled); diff --git a/xen/drivers/passthrough/x86/Makefile b/xen/drivers/passthrough= /x86/Makefile index 69284a5d19..75b2885336 100644 --- a/xen/drivers/passthrough/x86/Makefile +++ b/xen/drivers/passthrough/x86/Makefile @@ -1,3 +1,2 @@ -obj-y +=3D ats.o obj-y +=3D iommu.o obj-$(CONFIG_HVM) +=3D hvm.o --=20 2.17.1 From nobody Sat Apr 20 07:46:02 2024 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; 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=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1617709301; cv=none; d=zohomail.com; s=zohoarc; b=TkM8LUAItxQfR6jJl+WyW7jB2TGhRGXHLO9zKZ9bR2bkCMmMIRSSCWqwYxRrgNCUUo7vkbedlLtq7HhWBFJt9SVDo5942sIo1MzmVds8E5VZ+KThwecBO5sFuAfqNYdZT8eVb1M9zRDnvxBF/XZ9Hin6W29nPiVoypZPg0qMilU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617709301; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=6Sa+skSCWksQsZ9YTwgSQCaRAnRx3zaRUjvAfDDgdyA=; b=KZhEMntMkGcl7lctUjQEm1flDQChit06Vdy7ePJbpts9//sSHPFJ/apGhSc8XAZdTm5NUtqRDdCEsR+gwrn5xG9evv3wYD19cGUpFkO8TdCJ4zsuYHUKIlX0ET/vsLXhXGmeJeexb+bXrKmfZF7Nq2o6OYZrO3b3LawtLiCuS4s= ARC-Authentication-Results: i=1; mx.zohomail.com; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 161770930175842.91326036133751; Tue, 6 Apr 2021 04:41:41 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.105909.202548 (Exim 4.92) (envelope-from ) id 1lTk5I-0000vP-UH; Tue, 06 Apr 2021 11:41:28 +0000 Received: by outflank-mailman (output) from mailman id 105909.202548; Tue, 06 Apr 2021 11:41:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lTk5I-0000vI-QX; Tue, 06 Apr 2021 11:41:28 +0000 Received: by outflank-mailman (input) for mailman id 105909; Tue, 06 Apr 2021 11:41:28 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lTk5I-0000v9-0N for xen-devel@lists.xenproject.org; Tue, 06 Apr 2021 11:41:28 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 88f0cd12-37fa-45cd-9643-7b06aea7f225; Tue, 06 Apr 2021 11:41:26 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 056AA113E; Tue, 6 Apr 2021 04:41:26 -0700 (PDT) Received: from e109506.cambridge.arm.com (e109506.cambridge.arm.com [10.1.199.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 343D93F73D; Tue, 6 Apr 2021 04:41:24 -0700 (PDT) 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: 88f0cd12-37fa-45cd-9643-7b06aea7f225 From: Rahul Singh To: xen-devel@lists.xenproject.org Cc: bertrand.marquis@arm.com, rahul.singh@arm.com, Jan Beulich , Paul Durrant , Andrew Cooper , George Dunlap , Ian Jackson , Julien Grall , Stefano Stabellini , Wei Liu , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Daniel De Graaf Subject: [PATCH 2/2] xen/pci: Gate all MSI code in common code with CONFIG_HAS_PCI_MSI Date: Tue, 6 Apr 2021 12:39:11 +0100 Message-Id: <4471ba4fffc8a0cef24cc11314fc788334f85ccc.1617702520.git.rahul.singh@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" MSI support is not implemented for ARM architecture but it is enabled for x86 architecture and referenced in common passthrough/pci.c code. Therefore introducing the new flag to gate the MSI code for ARM in common code to avoid compilation error when HAS_PCI is enabled for ARM. Signed-off-by: Rahul Singh --- xen/drivers/passthrough/pci.c | 17 +++++++++++++++++ xen/drivers/pci/Kconfig | 4 ++++ xen/drivers/vpci/Makefile | 3 ++- xen/drivers/vpci/header.c | 6 ++++++ xen/drivers/vpci/vpci.c | 2 ++ xen/include/xen/vpci.h | 4 ++++ xen/xsm/flask/hooks.c | 6 +++--- 7 files changed, 38 insertions(+), 4 deletions(-) diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c index 705137f8be..390b960d83 100644 --- a/xen/drivers/passthrough/pci.c +++ b/xen/drivers/passthrough/pci.c @@ -33,7 +33,9 @@ #include #include #include +#ifdef CONFIG_HAS_PCI_MSI #include +#endif #include "ats.h" =20 struct pci_seg { @@ -327,6 +329,8 @@ static struct pci_dev *alloc_pdev(struct pci_seg *pseg,= u8 bus, u8 devfn) *((u8*) &pdev->bus) =3D bus; *((u8*) &pdev->devfn) =3D devfn; pdev->domain =3D NULL; + +#ifdef CONFIG_HAS_PCI_MSI INIT_LIST_HEAD(&pdev->msi_list); =20 pos =3D pci_find_cap_offset(pseg->nr, bus, PCI_SLOT(devfn), PCI_FUNC(d= evfn), @@ -357,6 +361,7 @@ static struct pci_dev *alloc_pdev(struct pci_seg *pseg,= u8 bus, u8 devfn) =20 pdev->msix =3D msix; } +#endif =20 list_add(&pdev->alldevs_list, &pseg->alldevs_list); =20 @@ -449,7 +454,9 @@ static void free_pdev(struct pci_seg *pseg, struct pci_= dev *pdev) } =20 list_del(&pdev->alldevs_list); +#ifdef CONFIG_HAS_PCI_MSI xfree(pdev->msix); +#endif xfree(pdev); } =20 @@ -827,7 +834,9 @@ int pci_remove_device(u16 seg, u8 bus, u8 devfn) list_for_each_entry ( pdev, &pseg->alldevs_list, alldevs_list ) if ( pdev->bus =3D=3D bus && pdev->devfn =3D=3D devfn ) { +#ifdef CONFIG_HAS_PCI_MSI pci_cleanup_msi(pdev); +#endif ret =3D iommu_remove_device(pdev); if ( pdev->domain ) list_del(&pdev->domain_list); @@ -1271,7 +1280,9 @@ bool_t pcie_aer_get_firmware_first(const struct pci_d= ev *pdev) static int _dump_pci_devices(struct pci_seg *pseg, void *arg) { struct pci_dev *pdev; +#ifdef CONFIG_HAS_PCI_MSI struct msi_desc *msi; +#endif =20 printk("=3D=3D=3D=3D segment %04x =3D=3D=3D=3D\n", pseg->nr); =20 @@ -1280,8 +1291,10 @@ static int _dump_pci_devices(struct pci_seg *pseg, v= oid *arg) printk("%pp - %pd - node %-3d - MSIs < ", &pdev->sbdf, pdev->domain, (pdev->node !=3D NUMA_NO_NODE) ? pdev->node : -1); +#ifdef CONFIG_HAS_PCI_MSI list_for_each_entry ( msi, &pdev->msi_list, list ) printk("%d ", msi->irq); +#endif printk(">\n"); } =20 @@ -1303,12 +1316,14 @@ static int __init setup_dump_pcidevs(void) } __initcall(setup_dump_pcidevs); =20 +#ifdef CONFIG_HAS_PCI_MSI int iommu_update_ire_from_msi( struct msi_desc *msi_desc, struct msi_msg *msg) { return iommu_intremap ? iommu_call(&iommu_ops, update_ire_from_msi, msi_desc, msg) : = 0; } +#endif =20 static int iommu_add_device(struct pci_dev *pdev) { @@ -1429,6 +1444,7 @@ static int assign_device(struct domain *d, u16 seg, u= 8 bus, u8 devfn, u32 flag) ASSERT(pdev && (pdev->domain =3D=3D hardware_domain || pdev->domain =3D=3D dom_io)); =20 +#ifdef CONFIG_HAS_PCI_MSI if ( pdev->msix ) { rc =3D pci_reset_msix_state(pdev); @@ -1436,6 +1452,7 @@ static int assign_device(struct domain *d, u16 seg, u= 8 bus, u8 devfn, u32 flag) goto done; msixtbl_init(d); } +#endif =20 pdev->fault.count =3D 0; =20 diff --git a/xen/drivers/pci/Kconfig b/xen/drivers/pci/Kconfig index 7da03fa13b..695781ce3a 100644 --- a/xen/drivers/pci/Kconfig +++ b/xen/drivers/pci/Kconfig @@ -1,3 +1,7 @@ =20 config HAS_PCI bool + +config HAS_PCI_MSI + def_bool y + depends on X86 && HAS_PCI diff --git a/xen/drivers/vpci/Makefile b/xen/drivers/vpci/Makefile index 55d1bdfda0..1a1413b93e 100644 --- a/xen/drivers/vpci/Makefile +++ b/xen/drivers/vpci/Makefile @@ -1 +1,2 @@ -obj-y +=3D vpci.o header.o msi.o msix.o +obj-y +=3D vpci.o header.o +obj-$(CONFIG_HAS_PCI_MSI) +=3D msi.o msix.o diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c index ba9a036202..b90c345612 100644 --- a/xen/drivers/vpci/header.c +++ b/xen/drivers/vpci/header.c @@ -96,8 +96,10 @@ static void modify_decoding(const struct pci_dev *pdev, = uint16_t cmd, * FIXME: punching holes after the p2m has been set up might be racy f= or * DomU usage, needs to be revisited. */ +#ifdef CONFIG_HAS_PCI_MSI if ( map && !rom_only && vpci_make_msix_hole(pdev) ) return; +#endif =20 for ( i =3D 0; i < ARRAY_SIZE(header->bars); i++ ) { @@ -206,7 +208,9 @@ static int modify_bars(const struct pci_dev *pdev, uint= 16_t cmd, bool rom_only) struct vpci_header *header =3D &pdev->vpci->header; struct rangeset *mem =3D rangeset_new(NULL, NULL, 0); struct pci_dev *tmp, *dev =3D NULL; +#ifdef CONFIG_HAS_PCI_MSI const struct vpci_msix *msix =3D pdev->vpci->msix; +#endif unsigned int i; int rc; =20 @@ -243,6 +247,7 @@ static int modify_bars(const struct pci_dev *pdev, uint= 16_t cmd, bool rom_only) } } =20 +#ifdef CONFIG_HAS_PCI_MSI /* Remove any MSIX regions if present. */ for ( i =3D 0; msix && i < ARRAY_SIZE(msix->tables); i++ ) { @@ -260,6 +265,7 @@ static int modify_bars(const struct pci_dev *pdev, uint= 16_t cmd, bool rom_only) return rc; } } +#endif /* CONFIG_HAS_PCI_MSI */ =20 /* * Check for overlaps with other BARs. Note that only BARs that are diff --git a/xen/drivers/vpci/vpci.c b/xen/drivers/vpci/vpci.c index cbd1bac7fc..474eb2f0ac 100644 --- a/xen/drivers/vpci/vpci.c +++ b/xen/drivers/vpci/vpci.c @@ -48,8 +48,10 @@ void vpci_remove_device(struct pci_dev *pdev) xfree(r); } spin_unlock(&pdev->vpci->lock); +#ifdef CONFIG_HAS_PCI_MSI xfree(pdev->vpci->msix); xfree(pdev->vpci->msi); +#endif xfree(pdev->vpci); pdev->vpci =3D NULL; } diff --git a/xen/include/xen/vpci.h b/xen/include/xen/vpci.h index 9f5b5d52e1..d81588ba64 100644 --- a/xen/include/xen/vpci.h +++ b/xen/include/xen/vpci.h @@ -91,6 +91,7 @@ struct vpci { /* FIXME: currently there's no support for SR-IOV. */ } header; =20 +#ifdef CONFIG_HAS_PCI_MSI /* MSI data. */ struct vpci_msi { /* Address. */ @@ -136,6 +137,7 @@ struct vpci { struct vpci_arch_msix_entry arch; } entries[]; } *msix; +#endif /* CONFIG_HAS_PCI_MSI */ #endif }; =20 @@ -148,6 +150,7 @@ struct vpci_vcpu { }; =20 #ifdef __XEN__ +#ifdef CONFIG_HAS_PCI_MSI void vpci_dump_msi(void); =20 /* Make sure there's a hole in the p2m for the MSIX mmio areas. */ @@ -208,6 +211,7 @@ static inline unsigned int vmsix_entry_nr(const struct = vpci_msix *msix, { return entry - msix->entries; } +#endif /* CONFIG_HAS_PCI_MSI */ #endif /* __XEN__ */ =20 #else /* !CONFIG_HAS_VPCI */ diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c index 3b7313b949..df594c80a9 100644 --- a/xen/xsm/flask/hooks.c +++ b/xen/xsm/flask/hooks.c @@ -21,7 +21,7 @@ #include #include #include -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_PCI_MSI #include #endif #include @@ -114,7 +114,7 @@ static int get_irq_sid(int irq, u32 *sid, struct avc_au= dit_data *ad) } return security_irq_sid(irq, sid); } -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_PCI_MSI { struct irq_desc *desc =3D irq_to_desc(irq); if ( desc->msi_desc && desc->msi_desc->dev ) { @@ -868,7 +868,7 @@ static int flask_map_domain_pirq (struct domain *d) static int flask_map_domain_msi (struct domain *d, int irq, const void *da= ta, u32 *sid, struct avc_audit_data *ad) { -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_PCI_MSI const struct msi_info *msi =3D data; u32 machine_bdf =3D (msi->seg << 16) | (msi->bus << 8) | msi->devfn; =20 --=20 2.17.1