ia64/xen-unstable

changeset 18469:6a37b3d966f9

vtd: Add a command line param to enable/disable pass-through feature

Taking security into accout, it's not suitable to bypass VT-d
translation for Dom0 by default when the pass-through field in
extended capability register is set. This feature is for people/usages
who are not overly worried about security/isolation, but want better
performance.

This patch adds a command line param that controls if it's enabled or
disabled.

Signed-off-by: Weidong Han <weidong.han@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Sep 10 10:53:09 2008 +0100 (2008-09-10)
parents b5912430e66c
children 9ee24da5a488
files xen/drivers/passthrough/iommu.c xen/drivers/passthrough/vtd/iommu.c xen/include/xen/iommu.h
line diff
     1.1 --- a/xen/drivers/passthrough/iommu.c	Wed Sep 10 10:51:48 2008 +0100
     1.2 +++ b/xen/drivers/passthrough/iommu.c	Wed Sep 10 10:53:09 2008 +0100
     1.3 @@ -33,11 +33,13 @@ int amd_iov_detect(void);
     1.4   *   pv                         Enable IOMMU for PV domains
     1.5   *   no-pv                      Disable IOMMU for PV domains (default)
     1.6   *   force|required             Don't boot unless IOMMU is enabled
     1.7 + *   passthrough                Bypass VT-d translation for Dom0
     1.8   */
     1.9  custom_param("iommu", parse_iommu_param);
    1.10  int iommu_enabled = 0;
    1.11  int iommu_pv_enabled = 0;
    1.12  int force_iommu = 0;
    1.13 +int iommu_passthrough = 0;
    1.14  
    1.15  static void __init parse_iommu_param(char *s)
    1.16  {
    1.17 @@ -58,6 +60,8 @@ static void __init parse_iommu_param(cha
    1.18              iommu_pv_enabled = 0;
    1.19          else if ( !strcmp(s, "force") || !strcmp(s, "required") )
    1.20              force_iommu = 1;
    1.21 +        else if ( !strcmp(s, "passthrough") )
    1.22 +            iommu_passthrough = 1;
    1.23  
    1.24          s = ss + 1;
    1.25      } while ( ss );
     2.1 --- a/xen/drivers/passthrough/vtd/iommu.c	Wed Sep 10 10:51:48 2008 +0100
     2.2 +++ b/xen/drivers/passthrough/vtd/iommu.c	Wed Sep 10 10:53:09 2008 +0100
     2.3 @@ -1090,7 +1090,8 @@ static int domain_context_mapping_one(
     2.4      }
     2.5  
     2.6      spin_lock_irqsave(&iommu->lock, flags);
     2.7 -    if ( ecap_pass_thru(iommu->ecap) && (domain->domain_id == 0) )
     2.8 +    if ( iommu_passthrough &&
     2.9 +         ecap_pass_thru(iommu->ecap) && (domain->domain_id == 0) )
    2.10      {
    2.11          context_set_translation_type(*context, CONTEXT_TT_PASS_THRU);
    2.12          agaw = level_to_agaw(iommu->nr_pt_levels);
    2.13 @@ -1463,7 +1464,8 @@ int intel_iommu_map_page(
    2.14      iommu = drhd->iommu;
    2.15  
    2.16      /* do nothing if dom0 and iommu supports pass thru */
    2.17 -    if ( ecap_pass_thru(iommu->ecap) && (d->domain_id == 0) )
    2.18 +    if ( iommu_passthrough &&
    2.19 +         ecap_pass_thru(iommu->ecap) && (d->domain_id == 0) )
    2.20          return 0;
    2.21  
    2.22      pg_maddr = addr_to_dma_page_maddr(d, (paddr_t)gfn << PAGE_SHIFT_4K, 1);
    2.23 @@ -1502,7 +1504,8 @@ int intel_iommu_unmap_page(struct domain
    2.24      iommu = drhd->iommu;
    2.25  
    2.26      /* do nothing if dom0 and iommu supports pass thru */
    2.27 -    if ( ecap_pass_thru(iommu->ecap) && (d->domain_id == 0) )
    2.28 +    if ( iommu_passthrough &&
    2.29 +         ecap_pass_thru(iommu->ecap) && (d->domain_id == 0) )
    2.30          return 0;
    2.31  
    2.32      dma_pte_clear_one(d, (paddr_t)gfn << PAGE_SHIFT_4K);
     3.1 --- a/xen/include/xen/iommu.h	Wed Sep 10 10:51:48 2008 +0100
     3.2 +++ b/xen/include/xen/iommu.h	Wed Sep 10 10:53:09 2008 +0100
     3.3 @@ -31,6 +31,7 @@ extern int vtd_enabled;
     3.4  extern int iommu_enabled;
     3.5  extern int iommu_pv_enabled;
     3.6  extern int force_iommu;
     3.7 +extern int iommu_passthrough;
     3.8  
     3.9  #define domain_hvm_iommu(d)     (&d->arch.hvm_domain.hvm_iommu)
    3.10