ia64/xen-unstable

changeset 19272:5dee49f3a86e

vtd: Fix iommu_inclusive_mapping to map all under 4GB.

Signed-off-by: Ross Philipson <ross.philipson@citrix.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Mar 05 14:55:24 2009 +0000 (2009-03-05)
parents 3673926b2375
children 2a52806199fc
files xen/drivers/passthrough/vtd/x86/vtd.c
line diff
     1.1 --- a/xen/drivers/passthrough/vtd/x86/vtd.c	Thu Mar 05 09:32:37 2009 +0000
     1.2 +++ b/xen/drivers/passthrough/vtd/x86/vtd.c	Thu Mar 05 14:55:24 2009 +0000
     1.3 @@ -27,8 +27,11 @@
     1.4  #include "../dmar.h"
     1.5  #include "../vtd.h"
     1.6  
     1.7 -/* iommu_inclusive_mapping: when set, all memory below 4GB is included in dom0 1-1 iommu mappings except xen and unusable regions */
     1.8 -static int iommu_inclusive_mapping = 0;
     1.9 +/*
    1.10 + * iommu_inclusive_mapping: when set, all memory below 4GB is included in dom0
    1.11 + * 1:1 iommu mappings except xen and unusable regions.
    1.12 + */
    1.13 +static int iommu_inclusive_mapping;
    1.14  boolean_param("iommu_inclusive_mapping", iommu_inclusive_mapping);
    1.15  
    1.16  void *map_vtd_domain_page(u64 maddr)
    1.17 @@ -151,25 +154,23 @@ void hvm_dpci_isairq_eoi(struct domain *
    1.18  void iommu_set_dom0_mapping(struct domain *d)
    1.19  {
    1.20      u64 i, j, tmp;
    1.21 +    unsigned long max_pfn = max(max_page, 0x100000000ul >> PAGE_SHIFT);
    1.22      extern int xen_in_range(paddr_t start, paddr_t end);
    1.23  
    1.24      BUG_ON(d->domain_id != 0);
    1.25  
    1.26 -    for ( i = 0; i < max_page; i++ )
    1.27 +    for ( i = 0; i < max_pfn; i++ )
    1.28      {
    1.29 -        /* Set up 1:1 mapping for dom0 */
    1.30 -        if ( !page_is_ram_type(i, RAM_TYPE_CONVENTIONAL) )
    1.31 -        {
    1.32 -            /* Default it to use only conventional RAM areas and let RMRRs include needed reserved regions */
    1.33 -            if (iommu_inclusive_mapping)
    1.34 -            {
    1.35 -                /* When set, the inclusive mapping maps in everything below 4GB except unusable ranges */
    1.36 -                if ( (i >= 0x100000) || page_is_ram_type(i, RAM_TYPE_UNUSABLE) )
    1.37 -                    continue;
    1.38 -            }
    1.39 -            else
    1.40 -                continue;
    1.41 -        }
    1.42 +        /*
    1.43 +         * Set up 1:1 mapping for dom0. Default to use only conventional RAM 
    1.44 +         * areas and let RMRRs include needed reserved regions. When set, the 
    1.45 +         * inclusive mapping maps in everything below 4GB except unusable
    1.46 +         * ranges. 
    1.47 +         */
    1.48 +        if ( !page_is_ram_type(i, RAM_TYPE_CONVENTIONAL) &&
    1.49 +             (!iommu_inclusive_mapping ||
    1.50 +              page_is_ram_type(i, RAM_TYPE_UNUSABLE)) )
    1.51 +            continue;
    1.52  
    1.53          /* Exclude Xen bits */
    1.54          if ( xen_in_range(i << PAGE_SHIFT, (i + 1) << PAGE_SHIFT) )