From patchwork Tue Jul 30 13:44:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 11065837 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 61CA7174A for ; Tue, 30 Jul 2019 13:45:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 507B02223E for ; Tue, 30 Jul 2019 13:45:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4449527BA5; Tue, 30 Jul 2019 13:45:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EC33B22BF1 for ; Tue, 30 Jul 2019 13:45:57 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hsSQW-00057X-Q7; Tue, 30 Jul 2019 13:44:28 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hsSQU-00056Z-Jl for xen-devel@lists.xenproject.org; Tue, 30 Jul 2019 13:44:26 +0000 X-Inumbo-ID: 2456fc8b-b2d0-11e9-8980-bc764e045a96 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 2456fc8b-b2d0-11e9-8980-bc764e045a96; Tue, 30 Jul 2019 13:44:24 +0000 (UTC) Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=paul.durrant@citrix.com; spf=Pass smtp.mailfrom=Paul.Durrant@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of paul.durrant@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="Paul.Durrant@citrix.com"; x-sender="paul.durrant@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.hc3370-68.iphmx.com: domain of Paul.Durrant@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="Paul.Durrant@citrix.com"; x-sender="Paul.Durrant@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ~all" Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="Paul.Durrant@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: /BC2c72ZHmeNmZZkvgU7aysbEuQtF1YQzlOaTrtpL10cJlCsU7ktJDE1nN8BBuxltWExckZRF+ PW00YvnOtMiGNJIarnQkvnfsEE590UyoEOptGAmQsXsm1hBtOmxZmLzzud5smFgf/WIGW5DBaJ SnWrSXQnRiLb8OSni0ifoUJEExLmWpT0as/eQDOSPzRYVgh4baGZtayC3Vi029JsesGTM6PvGF QugX76dkli7TAWslkkbDVKJLEJ4m1hucWRnizHiusQNZxP0F5Q/OzSsuFhpcfCYbrgZDHuIr+f mBM= X-SBRS: 2.7 X-MesageID: 3760801 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,326,1559534400"; d="scan'208";a="3760801" From: Paul Durrant To: Date: Tue, 30 Jul 2019 14:44:15 +0100 Message-ID: <20190730134419.2739-3-paul.durrant@citrix.com> X-Mailer: git-send-email 2.20.1.2.gb21ebb671 In-Reply-To: <20190730134419.2739-1-paul.durrant@citrix.com> References: <20190730134419.2739-1-paul.durrant@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 2/6] use is_iommu_enabled() where appropriate... X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Kevin Tian , Stefano Stabellini , Jun Nakajima , Wei Liu , George Dunlap , Andrew Cooper , Brian Woods , Julien Grall , Paul Durrant , Jan Beulich , Volodymyr Babchuk , Suravee Suthikulpanit , =?utf-8?q?Roger_Pau_?= =?utf-8?q?Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP ...rather than testing the global iommu_enabled flag and ops pointer. Now that there is a per-domain flag indicating whether the domain is permitted to use the IOMMU (which determines whether the ops pointer will be set), many tests of the global iommu_enabled flag and ops pointer can be translated into tests of the per-domain flag. Some of the other tests of purely the global iommu_enabled flag can also be translated into tests of the per-domain flag. NOTE: The comment in iommu_share_p2m_table() is also fixed; need_iommu() disappeared some time ago. Signed-off-by: Paul Durrant --- Cc: Stefano Stabellini Cc: Julien Grall Cc: Volodymyr Babchuk Cc: Jan Beulich Cc: Andrew Cooper Cc: Wei Liu Cc: "Roger Pau Monné" Cc: Jun Nakajima Cc: Kevin Tian Cc: George Dunlap Cc: Suravee Suthikulpanit Cc: Brian Woods --- xen/arch/arm/p2m.c | 3 +-- xen/arch/x86/dom0_build.c | 2 +- xen/arch/x86/domctl.c | 4 ++-- xen/arch/x86/hvm/hvm.c | 6 ++--- xen/arch/x86/hvm/vioapic.c | 2 +- xen/arch/x86/hvm/vmx/vmcs.c | 2 +- xen/arch/x86/hvm/vmx/vmx.c | 2 +- xen/arch/x86/mm/p2m-ept.c | 4 ++-- xen/drivers/passthrough/amd/iommu_guest.c | 2 +- xen/drivers/passthrough/device_tree.c | 4 ++-- xen/drivers/passthrough/io.c | 8 +++---- xen/drivers/passthrough/iommu.c | 29 ++++++++++------------- xen/drivers/passthrough/pci.c | 14 +++++------ xen/drivers/passthrough/vtd/iommu.c | 2 +- xen/drivers/passthrough/vtd/x86/hvm.c | 2 +- xen/drivers/passthrough/x86/iommu.c | 2 +- 16 files changed, 42 insertions(+), 46 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index e28ea1c85a..c5cea25caa 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -1531,8 +1531,7 @@ int p2m_init(struct domain *d) * shared with the CPU, Xen has to make sure that the PT changes have * reached the memory */ - p2m->clean_pte = iommu_enabled && - !iommu_has_feature(d, IOMMU_FEAT_COHERENT_WALK); + p2m->clean_pte = !iommu_has_feature(d, IOMMU_FEAT_COHERENT_WALK); rc = p2m_alloc_table(d); diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index c69570920c..d381784edd 100644 --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -356,7 +356,7 @@ unsigned long __init dom0_compute_nr_pages( avail -= d->max_vcpus - 1; /* Reserve memory for iommu_dom0_init() (rough estimate). */ - if ( iommu_enabled ) + if ( is_iommu_enabled(d) ) { unsigned int s; diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c index 2d45e5b8a8..be4b206068 100644 --- a/xen/arch/x86/domctl.c +++ b/xen/arch/x86/domctl.c @@ -715,7 +715,7 @@ long arch_do_domctl( break; ret = -ESRCH; - if ( iommu_enabled ) + if ( is_iommu_enabled(d) ) { pcidevs_lock(); ret = pt_irq_create_bind(d, bind); @@ -744,7 +744,7 @@ long arch_do_domctl( if ( ret ) break; - if ( iommu_enabled ) + if ( is_iommu_enabled(d) ) { pcidevs_lock(); ret = pt_irq_destroy_bind(d, bind); diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 029eea3b85..172c860acc 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -465,7 +465,7 @@ void hvm_migrate_timers(struct vcpu *v) void hvm_migrate_pirq(struct hvm_pirq_dpci *pirq_dpci, const struct vcpu *v) { - ASSERT(iommu_enabled && + ASSERT(is_iommu_enabled(v->domain) && (is_hardware_domain(v->domain) || hvm_domain_irq(v->domain)->dpci)); if ( (pirq_dpci->flags & HVM_IRQ_DPCI_MACH_MSI) && @@ -496,7 +496,7 @@ void hvm_migrate_pirqs(struct vcpu *v) { struct domain *d = v->domain; - if ( !iommu_enabled || !hvm_domain_irq(d)->dpci ) + if ( !is_iommu_enabled(d) || !hvm_domain_irq(d)->dpci ) return; spin_lock(&d->event_lock); @@ -2264,7 +2264,7 @@ int hvm_set_cr0(unsigned long value, bool may_defer) } if ( ((value ^ old_value) & X86_CR0_CD) && - iommu_enabled && hvm_funcs.handle_cd && + is_iommu_enabled(d) && hvm_funcs.handle_cd && (!rangeset_is_empty(d->iomem_caps) || !rangeset_is_empty(d->arch.ioport_caps) || has_arch_pdevs(d)) ) diff --git a/xen/arch/x86/hvm/vioapic.c b/xen/arch/x86/hvm/vioapic.c index 9c25f72b4d..9aeef32a14 100644 --- a/xen/arch/x86/hvm/vioapic.c +++ b/xen/arch/x86/hvm/vioapic.c @@ -536,7 +536,7 @@ void vioapic_update_EOI(struct domain *d, u8 vector) ent->fields.remote_irr = 0; - if ( iommu_enabled ) + if ( is_iommu_enabled(d) ) { spin_unlock(&d->arch.hvm.irq_lock); hvm_dpci_eoi(d, vioapic->base_gsi + pin, ent); diff --git a/xen/arch/x86/hvm/vmx/vmcs.c b/xen/arch/x86/hvm/vmx/vmcs.c index 45d18493df..9850da460a 100644 --- a/xen/arch/x86/hvm/vmx/vmcs.c +++ b/xen/arch/x86/hvm/vmx/vmcs.c @@ -1087,7 +1087,7 @@ static int construct_vmcs(struct vcpu *v) vmx_clear_msr_intercept(v, MSR_IA32_SYSENTER_CS, VMX_MSR_RW); vmx_clear_msr_intercept(v, MSR_IA32_SYSENTER_ESP, VMX_MSR_RW); vmx_clear_msr_intercept(v, MSR_IA32_SYSENTER_EIP, VMX_MSR_RW); - if ( paging_mode_hap(d) && (!iommu_enabled || iommu_snoop) ) + if ( paging_mode_hap(d) && (!is_iommu_enabled(d) || iommu_snoop) ) vmx_clear_msr_intercept(v, MSR_IA32_CR_PAT, VMX_MSR_RW); if ( (vmexit_ctl & VM_EXIT_CLEAR_BNDCFGS) && (vmentry_ctl & VM_ENTRY_LOAD_BNDCFGS) ) diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 0060310d74..3b3d5b6250 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -1210,7 +1210,7 @@ static void vmx_handle_cd(struct vcpu *v, unsigned long value) { v->arch.hvm.cache_mode = NORMAL_CACHE_MODE; vmx_set_guest_pat(v, *pat); - if ( !iommu_enabled || iommu_snoop ) + if ( !is_iommu_enabled(v->domain) || iommu_snoop ) vmx_clear_msr_intercept(v, MSR_IA32_CR_PAT, VMX_MSR_RW); hvm_asid_flush_vcpu(v); /* no need to flush cache */ } diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c index 6b8468c793..ef1423fe2d 100644 --- a/xen/arch/x86/mm/p2m-ept.c +++ b/xen/arch/x86/mm/p2m-ept.c @@ -260,7 +260,7 @@ static bool_t ept_split_super_page(struct p2m_domain *p2m, *epte = *ept_entry; epte->sp = (level > 1); epte->mfn += i * trunk; - epte->snp = (iommu_enabled && iommu_snoop); + epte->snp = is_iommu_enabled(p2m->domain) && iommu_snoop; epte->suppress_ve = 1; ept_p2m_type_to_flags(p2m, epte, epte->sa_p2mt, epte->access); @@ -766,7 +766,7 @@ ept_set_entry(struct p2m_domain *p2m, gfn_t gfn_, mfn_t mfn, new_entry.sp = !!i; new_entry.sa_p2mt = p2mt; new_entry.access = p2ma; - new_entry.snp = (iommu_enabled && iommu_snoop); + new_entry.snp = is_iommu_enabled(p2m->domain) && iommu_snoop; /* the caller should take care of the previous page */ new_entry.mfn = mfn_x(mfn); diff --git a/xen/drivers/passthrough/amd/iommu_guest.c b/xen/drivers/passthrough/amd/iommu_guest.c index 328e7509d5..5fc3b1a56c 100644 --- a/xen/drivers/passthrough/amd/iommu_guest.c +++ b/xen/drivers/passthrough/amd/iommu_guest.c @@ -857,7 +857,7 @@ int guest_iommu_init(struct domain* d) struct guest_iommu *iommu; struct domain_iommu *hd = dom_iommu(d); - if ( !is_hvm_domain(d) || !iommu_enabled || !iommuv2_enabled || + if ( !is_hvm_domain(d) || !is_iommu_enabled(d) || !iommuv2_enabled || !has_viommu(d) ) return 0; diff --git a/xen/drivers/passthrough/device_tree.c b/xen/drivers/passthrough/device_tree.c index d32b172664..12f2c4c3f2 100644 --- a/xen/drivers/passthrough/device_tree.c +++ b/xen/drivers/passthrough/device_tree.c @@ -29,7 +29,7 @@ int iommu_assign_dt_device(struct domain *d, struct dt_device_node *dev) int rc = -EBUSY; struct domain_iommu *hd = dom_iommu(d); - if ( !iommu_enabled || !hd->platform_ops ) + if ( !is_iommu_enabled(d) ) return -EINVAL; if ( !dt_device_is_protected(dev) ) @@ -71,7 +71,7 @@ int iommu_deassign_dt_device(struct domain *d, struct dt_device_node *dev) const struct domain_iommu *hd = dom_iommu(d); int rc; - if ( !iommu_enabled || !hd->platform_ops ) + if ( !is_iommu_enabled(d) ) return -EINVAL; if ( !dt_device_is_protected(dev) ) diff --git a/xen/drivers/passthrough/io.c b/xen/drivers/passthrough/io.c index 4290c7c710..b292e79382 100644 --- a/xen/drivers/passthrough/io.c +++ b/xen/drivers/passthrough/io.c @@ -434,7 +434,7 @@ int pt_irq_create_bind( if ( vcpu ) pirq_dpci->gmsi.posted = true; } - if ( vcpu && iommu_enabled ) + if ( vcpu && is_iommu_enabled(d) ) hvm_migrate_pirq(pirq_dpci, vcpu); /* Use interrupt posting if it is supported. */ @@ -817,7 +817,7 @@ int hvm_do_IRQ_dpci(struct domain *d, struct pirq *pirq) ASSERT(is_hvm_domain(d)); - if ( !iommu_enabled || (!is_hardware_domain(d) && !dpci) || + if ( !is_iommu_enabled(d) || (!is_hardware_domain(d) && !dpci) || !pirq_dpci || !(pirq_dpci->flags & HVM_IRQ_DPCI_MAPPED) ) return 0; @@ -869,7 +869,7 @@ static int _hvm_dpci_msi_eoi(struct domain *d, void hvm_dpci_msi_eoi(struct domain *d, int vector) { - if ( !iommu_enabled || + if ( !is_iommu_enabled(d) || (!hvm_domain_irq(d)->dpci && !is_hardware_domain(d)) ) return; @@ -1001,7 +1001,7 @@ void hvm_dpci_eoi(struct domain *d, unsigned int guest_gsi, const struct hvm_irq_dpci *hvm_irq_dpci; const struct hvm_girq_dpci_mapping *girq; - if ( !iommu_enabled ) + if ( !is_iommu_enabled(d) ) return; if ( is_hardware_domain(d) ) diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c index 0a00279067..d0200d82f0 100644 --- a/xen/drivers/passthrough/iommu.c +++ b/xen/drivers/passthrough/iommu.c @@ -179,7 +179,7 @@ void __hwdom_init iommu_hwdom_init(struct domain *d) check_hwdom_reqs(d); - if ( !iommu_enabled ) + if ( !is_iommu_enabled(d) ) return; register_keyhandler('o', &iommu_dump_p2m_table, "dump iommu p2m table", 0); @@ -284,7 +284,7 @@ int iommu_construct(struct domain *d) void iommu_domain_destroy(struct domain *d) { - if ( !iommu_enabled || !dom_iommu(d)->platform_ops ) + if ( !is_iommu_enabled(d) ) return; iommu_teardown(d); @@ -300,7 +300,7 @@ int iommu_map(struct domain *d, dfn_t dfn, mfn_t mfn, unsigned long i; int rc = 0; - if ( !iommu_enabled || !hd->platform_ops ) + if ( !is_iommu_enabled(d) ) return 0; ASSERT(IS_ALIGNED(dfn_x(dfn), (1ul << page_order))); @@ -360,7 +360,7 @@ int iommu_unmap(struct domain *d, dfn_t dfn, unsigned int page_order, unsigned long i; int rc = 0; - if ( !iommu_enabled || !hd->platform_ops ) + if ( !is_iommu_enabled(d) ) return 0; ASSERT(IS_ALIGNED(dfn_x(dfn), (1ul << page_order))); @@ -413,7 +413,7 @@ int iommu_lookup_page(struct domain *d, dfn_t dfn, mfn_t *mfn, { const struct domain_iommu *hd = dom_iommu(d); - if ( !iommu_enabled || !hd->platform_ops || !hd->platform_ops->lookup_page ) + if ( !is_iommu_enabled(d) || !hd->platform_ops->lookup_page ) return -EOPNOTSUPP; return iommu_call(hd->platform_ops, lookup_page, d, dfn, mfn, flags); @@ -442,8 +442,8 @@ int iommu_iotlb_flush(struct domain *d, dfn_t dfn, unsigned int page_count, const struct domain_iommu *hd = dom_iommu(d); int rc; - if ( !iommu_enabled || !hd->platform_ops || - !hd->platform_ops->iotlb_flush || !page_count || !flush_flags ) + if ( !is_iommu_enabled(d) || !hd->platform_ops->iotlb_flush || + !page_count || !flush_flags ) return 0; if ( dfn_eq(dfn, INVALID_DFN) ) @@ -470,8 +470,8 @@ int iommu_iotlb_flush_all(struct domain *d, unsigned int flush_flags) const struct domain_iommu *hd = dom_iommu(d); int rc; - if ( !iommu_enabled || !hd->platform_ops || - !hd->platform_ops->iotlb_flush_all || !flush_flags ) + if ( !is_iommu_enabled(d) || !hd->platform_ops->iotlb_flush_all || + !flush_flags ) return 0; /* @@ -556,7 +556,7 @@ int iommu_do_domctl( { int ret = -ENODEV; - if ( !iommu_enabled ) + if ( !is_iommu_enabled(d) ) return -ENOSYS; #ifdef CONFIG_HAS_PCI @@ -576,9 +576,9 @@ void iommu_share_p2m_table(struct domain* d) ASSERT(hap_enabled(d)); /* * iommu_use_hap_pt(d) cannot be used here because during domain - * construction need_iommu(d) will always return false here. + * construction has_iommu_pt(d) will always return false here. */ - if ( iommu_enabled && iommu_hap_pt_share ) + if ( is_iommu_enabled(d) && iommu_hap_pt_share ) iommu_get_ops()->share_p2m(d); } @@ -608,10 +608,7 @@ int iommu_get_reserved_device_memory(iommu_grdm_t *func, void *ctxt) bool_t iommu_has_feature(struct domain *d, enum iommu_feature feature) { - if ( !iommu_enabled ) - return 0; - - return test_bit(feature, dom_iommu(d)->features); + return is_iommu_enabled(d) && test_bit(feature, dom_iommu(d)->features); } static void iommu_dump_p2m_table(unsigned char key) diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c index 7c196ba58b..61b5b330ca 100644 --- a/xen/drivers/passthrough/pci.c +++ b/xen/drivers/passthrough/pci.c @@ -864,7 +864,7 @@ static int pci_clean_dpci_irqs(struct domain *d) { struct hvm_irq_dpci *hvm_irq_dpci = NULL; - if ( !iommu_enabled ) + if ( !is_iommu_enabled(d) ) return 0; if ( !is_hvm_domain(d) ) @@ -1333,7 +1333,7 @@ static int iommu_add_device(struct pci_dev *pdev) ASSERT(pcidevs_locked()); hd = dom_iommu(pdev->domain); - if ( !iommu_enabled || !hd->platform_ops ) + if ( !is_iommu_enabled(pdev->domain) ) return 0; rc = hd->platform_ops->add_device(pdev->devfn, pci_to_dev(pdev)); @@ -1362,7 +1362,7 @@ static int iommu_enable_device(struct pci_dev *pdev) ASSERT(pcidevs_locked()); hd = dom_iommu(pdev->domain); - if ( !iommu_enabled || !hd->platform_ops || + if ( !is_iommu_enabled(pdev->domain) || !hd->platform_ops->enable_device ) return 0; @@ -1378,7 +1378,7 @@ static int iommu_remove_device(struct pci_dev *pdev) return -EINVAL; hd = dom_iommu(pdev->domain); - if ( !iommu_enabled || !hd->platform_ops ) + if ( !is_iommu_enabled(pdev->domain) ) return 0; for ( devfn = pdev->devfn ; pdev->phantom_stride; ) @@ -1421,7 +1421,7 @@ static int assign_device(struct domain *d, u16 seg, u8 bus, u8 devfn, u32 flag) struct pci_dev *pdev; int rc = 0; - if ( !iommu_enabled || !hd->platform_ops ) + if ( !is_iommu_enabled(d) ) return 0; /* Prevent device assign if mem paging or mem sharing have been @@ -1483,7 +1483,7 @@ int deassign_device(struct domain *d, u16 seg, u8 bus, u8 devfn) struct pci_dev *pdev = NULL; int ret = 0; - if ( !iommu_enabled || !hd->platform_ops ) + if ( !is_iommu_enabled(d) ) return -EINVAL; ASSERT(pcidevs_locked()); @@ -1536,7 +1536,7 @@ static int iommu_get_device_group( int i = 0; const struct iommu_ops *ops = hd->platform_ops; - if ( !iommu_enabled || !ops || !ops->get_device_group_id ) + if ( !is_iommu_enabled(d) || !ops->get_device_group_id ) return 0; group_id = ops->get_device_group_id(seg, bus, devfn); diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c index 5d72270c5b..01f0bc4689 100644 --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -1757,7 +1757,7 @@ static void iommu_domain_teardown(struct domain *d) xfree(mrmrr); } - ASSERT(iommu_enabled); + ASSERT(is_iommu_enabled(d)); /* * We can't use iommu_use_hap_pt here because either IOMMU state diff --git a/xen/drivers/passthrough/vtd/x86/hvm.c b/xen/drivers/passthrough/vtd/x86/hvm.c index 6675dca027..f77b35815c 100644 --- a/xen/drivers/passthrough/vtd/x86/hvm.c +++ b/xen/drivers/passthrough/vtd/x86/hvm.c @@ -51,7 +51,7 @@ void hvm_dpci_isairq_eoi(struct domain *d, unsigned int isairq) struct hvm_irq_dpci *dpci = NULL; ASSERT(isairq < NR_ISAIRQS); - if ( !iommu_enabled ) + if ( !is_iommu_enabled(d) ) return; spin_lock(&d->event_lock); diff --git a/xen/drivers/passthrough/x86/iommu.c b/xen/drivers/passthrough/x86/iommu.c index fd05075bb5..9879558c17 100644 --- a/xen/drivers/passthrough/x86/iommu.c +++ b/xen/drivers/passthrough/x86/iommu.c @@ -178,7 +178,7 @@ int arch_iommu_populate_page_table(struct domain *d) void __hwdom_init arch_iommu_check_autotranslated_hwdom(struct domain *d) { - if ( !iommu_enabled ) + if ( !is_iommu_enabled(d) ) panic("Presently, iommu must be enabled for PVH hardware domain\n"); }