From mboxrd@z Thu Jan 1 00:00:00 1970 From: Suravee Suthikulanit Subject: Re: [PATCH 3/4] IOMMU: use is_hardware_domain instead of domid == 0 Date: Thu, 11 Jul 2013 14:57:14 -0500 Message-ID: <51DF0E1A.4000205@amd.com> References: <1373294782-20328-1-git-send-email-dgdegra@tycho.nsa.gov> <1373294782-20328-4-git-send-email-dgdegra@tycho.nsa.gov> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1373294782-20328-4-git-send-email-dgdegra@tycho.nsa.gov> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Daniel De Graaf Cc: Jacob Shin , Xiantao Zhang , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On 7/8/2013 9:46 AM, Daniel De Graaf wrote: > This makes checks for dom0 more explicit than checking the domain ID. > > Signed-off-by: Daniel De Graaf > Cc: Suravee Suthikulpanit Acked-by: Suravee Suthikulpanit > Cc: Jacob Shin > Cc: Xiantao Zhang > --- > xen/drivers/passthrough/amd/pci_amd_iommu.c | 2 +- > xen/drivers/passthrough/vtd/iommu.c | 8 ++++---- > xen/drivers/passthrough/vtd/x86/vtd.c | 2 +- > 3 files changed, 6 insertions(+), 6 deletions(-) > > diff --git a/xen/drivers/passthrough/amd/pci_amd_iommu.c b/xen/drivers/passthrough/amd/pci_amd_iommu.c > index 5ea1a1d..e8ec695 100644 > --- a/xen/drivers/passthrough/amd/pci_amd_iommu.c > +++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c > @@ -122,7 +122,7 @@ static void amd_iommu_setup_domain_device( > > BUG_ON( !hd->root_table || !hd->paging_mode || !iommu->dev_table.buffer ); > > - if ( iommu_passthrough && (domain->domain_id == 0) ) > + if ( iommu_passthrough && is_hardware_domain(domain) ) > valid = 0; > > if ( ats_enabled ) > diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c > index 0fc10de..8d5c43d 100644 > --- a/xen/drivers/passthrough/vtd/iommu.c > +++ b/xen/drivers/passthrough/vtd/iommu.c > @@ -1336,7 +1336,7 @@ int domain_context_mapping_one( > return res; > } > > - if ( iommu_passthrough && (domain->domain_id == 0) ) > + if ( iommu_passthrough && is_hardware_domain(domain) ) > { > context_set_translation_type(*context, CONTEXT_TT_PASS_THRU); > agaw = level_to_agaw(iommu->nr_pt_levels); > @@ -1710,7 +1710,7 @@ static int intel_iommu_map_page( > return 0; > > /* do nothing if dom0 and iommu supports pass thru */ > - if ( iommu_passthrough && (d->domain_id == 0) ) > + if ( iommu_passthrough && is_hardware_domain(d) ) > return 0; > > spin_lock(&hd->mapping_lock); > @@ -1754,7 +1754,7 @@ static int intel_iommu_map_page( > static int intel_iommu_unmap_page(struct domain *d, unsigned long gfn) > { > /* Do nothing if dom0 and iommu supports pass thru. */ > - if ( iommu_passthrough && (d->domain_id == 0) ) > + if ( iommu_passthrough && is_hardware_domain(d) ) > return 0; > > dma_pte_clear_one(d, (paddr_t)gfn << PAGE_SHIFT_4K); > @@ -1927,7 +1927,7 @@ static int intel_iommu_remove_device(u8 devfn, struct pci_dev *pdev) > /* If the device belongs to dom0, and it has RMRR, don't remove it > * from dom0, because BIOS may use RMRR at booting time. > */ > - if ( pdev->domain->domain_id == 0 ) > + if ( is_hardware_domain(pdev->domain) ) > { > for_each_rmrr_device ( rmrr, bdf, i ) > { > diff --git a/xen/drivers/passthrough/vtd/x86/vtd.c b/xen/drivers/passthrough/vtd/x86/vtd.c > index 875b033..eb9e52a 100644 > --- a/xen/drivers/passthrough/vtd/x86/vtd.c > +++ b/xen/drivers/passthrough/vtd/x86/vtd.c > @@ -117,7 +117,7 @@ void __init iommu_set_dom0_mapping(struct domain *d) > { > unsigned long i, j, tmp, top; > > - BUG_ON(d->domain_id != 0); > + BUG_ON(!is_hardware_domain(d)); > > top = max(max_pdx, pfn_to_pdx(0xffffffffUL >> PAGE_SHIFT) + 1); >