From nobody Mon Feb 9 01:06:45 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; 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=1606328230; cv=none; d=zohomail.com; s=zohoarc; b=bg4HBroyRQj/U+6u1PPkpXp5O5eapga6q8guE9weZ93pVSoCMGJfmtO3v7WyXgg2mGU2ceZgFjDKCvkj4jG6iIDKLT16iKQCh1niVf1aPS79WkjQSXlVd1YdLZG262IVhkKQSymp309Hi/+QKnI7Ao+PVZ7OryGdszZZkRTeK1c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606328230; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=6KQoASODljokc4o3Lq46FcWLLOYIJ7sdSG8r3tSJ5DU=; b=mas/pc4t/Nbws6CmgjWh6lyi3Bid2Xu0ivfl6Z6zaZdb9crUrwGM70R+epgJn+KphypIunMPqa0nJIPhCZVOTuk3QZWSbyXRaB6S+ctqhTyk4VEsfI7UjNNMYBfJAO/PxQhk2dFi0XXLe7w2Gn6F8FE03Xe8VUlSTnX36zXDEVY= 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 1606328230335649.540027029285; Wed, 25 Nov 2020 10:17:10 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.37952.70564 (Exim 4.92) (envelope-from ) id 1khzLb-0001U9-3k; Wed, 25 Nov 2020 18:16:55 +0000 Received: by outflank-mailman (output) from mailman id 37952.70564; Wed, 25 Nov 2020 18:16:55 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1khzLa-0001U0-Vx; Wed, 25 Nov 2020 18:16:54 +0000 Received: by outflank-mailman (input) for mailman id 37952; Wed, 25 Nov 2020 18:16:53 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1khzLZ-0001Oz-9c for xen-devel@lists.xenproject.org; Wed, 25 Nov 2020 18:16:53 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id 617e2fad-6fc2-48fd-8ed6-856b402076a1; Wed, 25 Nov 2020 18:16:47 +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 91E7E11D4; Wed, 25 Nov 2020 10:16:47 -0800 (PST) Received: from scm-wfh-server-rahsin01.stack04.eu02.mi.arm.com (unknown [10.58.246.76]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C93D93F23F; Wed, 25 Nov 2020 10:16:46 -0800 (PST) Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1khzLZ-0001Oz-9c for xen-devel@lists.xenproject.org; Wed, 25 Nov 2020 18:16:53 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id 617e2fad-6fc2-48fd-8ed6-856b402076a1; Wed, 25 Nov 2020 18:16:47 +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 91E7E11D4; Wed, 25 Nov 2020 10:16:47 -0800 (PST) Received: from scm-wfh-server-rahsin01.stack04.eu02.mi.arm.com (unknown [10.58.246.76]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C93D93F23F; Wed, 25 Nov 2020 10:16:46 -0800 (PST) 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: 617e2fad-6fc2-48fd-8ed6-856b402076a1 From: Rahul Singh To: xen-devel@lists.xenproject.org Cc: bertrand.marquis@arm.com, rahul.singh@arm.com, Jan Beulich , Paul Durrant Subject: [PATCH v4 2/3] xen/pci: solve compilation error on ARM with HAS_PCI enabled. Date: Wed, 25 Nov 2020 18:16:03 +0000 Message-Id: <2ce402cfae6d90433626bcdc6314e5ee5dda103f.1606326929.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" If mem-sharing, mem-paging, or log-dirty functionality is not enabled for architecture when HAS_PCI is enabled, the compiler will throw an error. Move code to x86 specific file to fix compilation error. Also, modify the code to use likely() in place of unlikley() for each condition to make code more optimized. No functional change intended. Signed-off-by: Rahul Singh Acked-by: Jan Beulich Reviewed-by: Bertrand Marquis --- Changes in v4: - fixed minor comments --- xen/drivers/passthrough/pci.c | 8 +------- xen/drivers/passthrough/x86/iommu.c | 13 +++++++++++++ xen/include/xen/iommu.h | 2 ++ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c index 3c6ab1bcb6..4c21655b7d 100644 --- a/xen/drivers/passthrough/pci.c +++ b/xen/drivers/passthrough/pci.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -1418,12 +1417,7 @@ static int assign_device(struct domain *d, u16 seg, = u8 bus, u8 devfn, u32 flag) if ( !is_iommu_enabled(d) ) return 0; =20 - /* Prevent device assign if mem paging or mem sharing have been=20 - * enabled for this domain */ - if ( d !=3D dom_io && - unlikely(mem_sharing_enabled(d) || - vm_event_check_ring(d->vm_event_paging) || - p2m_get_hostp2m(d)->global_logdirty) ) + if( !arch_iommu_use_permitted(d) ) return -EXDEV; =20 /* device_assigned() should already have cleared the device for assign= ment */ diff --git a/xen/drivers/passthrough/x86/iommu.c b/xen/drivers/passthrough/= x86/iommu.c index f17b1820f4..cea1032b3d 100644 --- a/xen/drivers/passthrough/x86/iommu.c +++ b/xen/drivers/passthrough/x86/iommu.c @@ -18,6 +18,7 @@ #include #include #include +#include #include =20 #include @@ -308,6 +309,18 @@ struct page_info *iommu_alloc_pgtable(struct domain *d) return pg; } =20 +bool arch_iommu_use_permitted(const struct domain *d) +{ + /* + * Prevent device assign if mem paging, mem sharing or log-dirty + * have been enabled for this domain. + */ + return d =3D=3D dom_io || + (likely(!mem_sharing_enabled(d)) && + likely(!vm_event_check_ring(d->vm_event_paging)) && + likely(!p2m_get_hostp2m(d)->global_logdirty)); +} + /* * Local variables: * mode: C diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h index 191021870f..056eaa09fc 100644 --- a/xen/include/xen/iommu.h +++ b/xen/include/xen/iommu.h @@ -381,6 +381,8 @@ DECLARE_PER_CPU(bool_t, iommu_dont_flush_iotlb); extern struct spinlock iommu_pt_cleanup_lock; extern struct page_list_head iommu_pt_cleanup_list; =20 +bool arch_iommu_use_permitted(const struct domain *d); + #endif /* _IOMMU_H_ */ =20 /* --=20 2.17.1