ia64/xen-unstable

changeset 17800:5009f5d093ce

AMD IOMMU: add support for PV guest

Assuming iommu_populate_page_table() is only used for PV guest, a new
check is added into assign_device() to avoid duplicating the work done
by amd_iommu_sync_p2m() for hvm guest.

Signed-off-by: Wei Wang <wei.wang2@amd.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Jun 09 09:44:21 2008 +0100 (2008-06-09)
parents 041f67ddcd7b
children 268a9f8286f3
files xen/drivers/passthrough/iommu.c
line diff
     1.1 --- a/xen/drivers/passthrough/iommu.c	Mon Jun 09 09:42:51 2008 +0100
     1.2 +++ b/xen/drivers/passthrough/iommu.c	Mon Jun 09 09:44:21 2008 +0100
     1.3 @@ -68,7 +68,7 @@ int assign_device(struct domain *d, u8 b
     1.4      if ( (rc = hd->platform_ops->assign_device(d, bus, devfn)) )
     1.5          return rc;
     1.6  
     1.7 -    if ( has_iommu_pdevs(d) && !need_iommu(d) )
     1.8 +    if ( has_iommu_pdevs(d) && !is_hvm_domain(d) && !need_iommu(d) )
     1.9      {
    1.10          d->need_iommu = 1;
    1.11          return iommu_populate_page_table(d);
    1.12 @@ -114,6 +114,16 @@ void iommu_domain_destroy(struct domain 
    1.13      if ( !iommu_enabled || !hd->platform_ops )
    1.14          return;
    1.15  
    1.16 +    if ( !is_hvm_domain(d) && !need_iommu(d)  )
    1.17 +        return;
    1.18 +
    1.19 +    if ( need_iommu(d) )
    1.20 +    {
    1.21 +        d->need_iommu = 0;
    1.22 +        hd->platform_ops->teardown(d);
    1.23 +        return;
    1.24 +    }
    1.25 +
    1.26      if ( hvm_irq_dpci != NULL )
    1.27      {
    1.28          for ( i = 0; i < NR_IRQS; i++ )
    1.29 @@ -207,10 +217,10 @@ static int iommu_setup(void)
    1.30      iommu_enabled = (rc == 0);
    1.31  
    1.32   out:
    1.33 -    if ( !iommu_enabled || !vtd_enabled )
    1.34 +    if ( !iommu_enabled )
    1.35          iommu_pv_enabled = 0;
    1.36      printk("I/O virtualisation %sabled\n", iommu_enabled ? "en" : "dis");
    1.37 -    if (iommu_enabled)
    1.38 +    if ( iommu_enabled )
    1.39          printk("I/O virtualisation for PV guests %sabled\n",
    1.40                 iommu_pv_enabled ? "en" : "dis");
    1.41      return rc;