ia64/xen-unstable

changeset 17725:36bbcc6baadf

VT-d: Improve page table debug output

Ignore 'current' domain when dumping VT-d page tables. Also add page
type summary for domain pages output.

Signed-off-by: Espen Skoglund <espen.skoglund@netronome.com>
author Keir Fraser <keir.fraser@citrix.com>
date Sat May 24 09:35:05 2008 +0100 (2008-05-24)
parents 5590509941b1
children 62f1c837057f
files xen/drivers/passthrough/vtd/extern.h xen/drivers/passthrough/vtd/iommu.c xen/drivers/passthrough/vtd/utils.c
line diff
     1.1 --- a/xen/drivers/passthrough/vtd/extern.h	Sat May 24 09:27:48 2008 +0100
     1.2 +++ b/xen/drivers/passthrough/vtd/extern.h	Sat May 24 09:35:05 2008 +0100
     1.3 @@ -27,8 +27,7 @@ extern struct qi_ctrl *qi_ctrl;
     1.4  extern struct ir_ctrl *ir_ctrl;
     1.5  
     1.6  void print_iommu_regs(struct acpi_drhd_unit *drhd);
     1.7 -void print_vtd_entries(struct domain *d, struct iommu *iommu,
     1.8 -                       int bus, int devfn, unsigned long gmfn);
     1.9 +void print_vtd_entries(struct iommu *iommu, int bus, int devfn, u64 gmfn);
    1.10  void pdev_flr(u8 bus, u8 devfn);
    1.11  
    1.12  int qinval_setup(struct iommu *iommu);
     2.1 --- a/xen/drivers/passthrough/vtd/iommu.c	Sat May 24 09:27:48 2008 +0100
     2.2 +++ b/xen/drivers/passthrough/vtd/iommu.c	Sat May 24 09:35:05 2008 +0100
     2.3 @@ -777,16 +777,17 @@ int iommu_disable_translation(struct iom
     2.4  
     2.5  static struct iommu *vector_to_iommu[NR_VECTORS];
     2.6  static int iommu_page_fault_do_one(struct iommu *iommu, int type,
     2.7 -                                   u8 fault_reason, u16 source_id, u32 addr)
     2.8 +                                   u8 fault_reason, u16 source_id, u64 addr)
     2.9  {
    2.10      dprintk(XENLOG_WARNING VTDPREFIX,
    2.11 -            "iommu_fault:%s: %x:%x.%x addr %x REASON %x iommu->reg = %p\n",
    2.12 +            "iommu_fault:%s: %x:%x.%x addr %"PRIx64" REASON %x "
    2.13 +            "iommu->reg = %p\n",
    2.14              (type ? "DMA Read" : "DMA Write"), (source_id >> 8),
    2.15              PCI_SLOT(source_id & 0xFF), PCI_FUNC(source_id & 0xFF), addr,
    2.16              fault_reason, iommu->reg);
    2.17  
    2.18      if ( fault_reason < 0x20 )
    2.19 -        print_vtd_entries(current->domain, iommu, (source_id >> 8),
    2.20 +        print_vtd_entries(iommu, (source_id >> 8),
    2.21                            (source_id & 0xff), (addr >> PAGE_SHIFT));
    2.22  
    2.23      return 0;
    2.24 @@ -844,7 +845,8 @@ static void iommu_page_fault(int vector,
    2.25      {
    2.26          u8 fault_reason;
    2.27          u16 source_id;
    2.28 -        u32 guest_addr, data;
    2.29 +        u32 data;
    2.30 +        u64 guest_addr;
    2.31          int type;
    2.32  
    2.33          /* highest 32 bits */
     3.1 --- a/xen/drivers/passthrough/vtd/utils.c	Sat May 24 09:27:48 2008 +0100
     3.2 +++ b/xen/drivers/passthrough/vtd/utils.c	Sat May 24 09:35:05 2008 +0100
     3.3 @@ -213,109 +213,97 @@ u32 get_level_index(unsigned long gmfn, 
     3.4      return gmfn & LEVEL_MASK;
     3.5  }
     3.6  
     3.7 -void print_vtd_entries(
     3.8 -    struct domain *d,
     3.9 -    struct iommu *iommu,
    3.10 -    int bus, int devfn,
    3.11 -    unsigned long gmfn)
    3.12 +void print_vtd_entries(struct iommu *iommu, int bus, int devfn, u64 gmfn)
    3.13  {
    3.14 -    struct hvm_iommu *hd = domain_hvm_iommu(d);
    3.15 -    struct acpi_drhd_unit *drhd;
    3.16      struct context_entry *ctxt_entry;
    3.17      struct root_entry *root_entry;
    3.18      struct dma_pte pte;
    3.19      u64 *l;
    3.20 -    u32 l_index;
    3.21 -    u32 i = 0;
    3.22 -    int level = agaw_to_level(hd->agaw);
    3.23 +    u32 l_index, level;
    3.24  
    3.25 -    printk("print_vtd_entries: domain_id = %x bdf = %x:%x:%x gmfn = %lx\n",
    3.26 -           d->domain_id, bus, PCI_SLOT(devfn), PCI_FUNC(devfn), gmfn);
    3.27 +    printk("print_vtd_entries: iommu = %p bdf = %x:%x:%x gmfn = %"PRIx64"\n",
    3.28 +           iommu, bus, PCI_SLOT(devfn), PCI_FUNC(devfn), gmfn);
    3.29  
    3.30 -    if ( hd->pgd_maddr == 0 )
    3.31 +    if ( iommu->root_maddr == 0 )
    3.32      {
    3.33 -        printk("    hd->pgd_maddr == 0\n");
    3.34 +        printk("    iommu->root_maddr = 0\n");
    3.35          return;
    3.36      }
    3.37 -    printk("    hd->pgd_maddr = %"PRIx64"\n", hd->pgd_maddr);
    3.38 -
    3.39 -    for_each_drhd_unit ( drhd )
    3.40 -    {
    3.41 -        printk("---- print_vtd_entries %d ----\n", i++);
    3.42  
    3.43 -        if ( iommu->root_maddr == 0 )
    3.44 -        {
    3.45 -            printk("    iommu->root_maddr = 0\n");
    3.46 -            continue;
    3.47 -        }
    3.48 -
    3.49 -        root_entry =
    3.50 -            (struct root_entry *)map_vtd_domain_page(iommu->root_maddr);
    3.51 +    root_entry = (struct root_entry *)map_vtd_domain_page(iommu->root_maddr);
    3.52   
    3.53 -        printk("    root_entry = %p\n", root_entry);
    3.54 -        printk("    root_entry[%x] = %"PRIx64"\n", bus, root_entry[bus].val);
    3.55 -        if ( !root_present(root_entry[bus]) )
    3.56 -        {
    3.57 -            unmap_vtd_domain_page(root_entry);
    3.58 -            printk("    root_entry[%x] not present\n", bus);
    3.59 -            continue;
    3.60 -        }
    3.61 +    printk("    root_entry = %p\n", root_entry);
    3.62 +    printk("    root_entry[%x] = %"PRIx64"\n", bus, root_entry[bus].val);
    3.63 +    if ( !root_present(root_entry[bus]) )
    3.64 +    {
    3.65 +        unmap_vtd_domain_page(root_entry);
    3.66 +        printk("    root_entry[%x] not present\n", bus);
    3.67 +        return;
    3.68 +    }
    3.69  
    3.70 -        ctxt_entry =
    3.71 -            (struct context_entry *)map_vtd_domain_page(root_entry[bus].val);
    3.72 -        if ( ctxt_entry == NULL )
    3.73 -        {
    3.74 -            unmap_vtd_domain_page(root_entry);
    3.75 -            printk("    ctxt_entry == NULL\n");
    3.76 -            continue;
    3.77 -        }
    3.78 +    ctxt_entry =
    3.79 +        (struct context_entry *)map_vtd_domain_page(root_entry[bus].val);
    3.80 +    if ( ctxt_entry == NULL )
    3.81 +    {
    3.82 +        unmap_vtd_domain_page(root_entry);
    3.83 +        printk("    ctxt_entry == NULL\n");
    3.84 +        return;
    3.85 +    }
    3.86  
    3.87 -        printk("    context = %p\n", ctxt_entry);
    3.88 -        printk("    context[%x] = %"PRIx64" %"PRIx64"\n",
    3.89 -               devfn, ctxt_entry[devfn].hi, ctxt_entry[devfn].lo);
    3.90 -        if ( !context_present(ctxt_entry[devfn]) )
    3.91 +    printk("    context = %p\n", ctxt_entry);
    3.92 +    printk("    context[%x] = %"PRIx64"_%"PRIx64"\n",
    3.93 +           devfn, ctxt_entry[devfn].hi, ctxt_entry[devfn].lo);
    3.94 +    if ( !context_present(ctxt_entry[devfn]) )
    3.95 +    {
    3.96 +        unmap_vtd_domain_page(ctxt_entry);
    3.97 +        unmap_vtd_domain_page(root_entry);
    3.98 +        printk("    ctxt_entry[%x] not present\n", devfn);
    3.99 +        return;
   3.100 +    }
   3.101 +
   3.102 +    level = agaw_to_level(context_address_width(ctxt_entry[devfn]));
   3.103 +    if ( level != VTD_PAGE_TABLE_LEVEL_3 &&
   3.104 +         level != VTD_PAGE_TABLE_LEVEL_4)
   3.105 +    {
   3.106 +        unmap_vtd_domain_page(ctxt_entry);
   3.107 +        unmap_vtd_domain_page(root_entry);
   3.108 +        printk("Unsupported VTD page table level (%d)!\n", level);
   3.109 +    }
   3.110 +
   3.111 +    l = maddr_to_virt(ctxt_entry[devfn].lo);
   3.112 +    do
   3.113 +    {
   3.114 +        l = (u64*)(((unsigned long)l >> PAGE_SHIFT_4K) << PAGE_SHIFT_4K);
   3.115 +        printk("    l%d = %p\n", level, l);
   3.116 +        if ( l == NULL )
   3.117          {
   3.118              unmap_vtd_domain_page(ctxt_entry);
   3.119              unmap_vtd_domain_page(root_entry);
   3.120 -            printk("    ctxt_entry[%x] not present\n", devfn);
   3.121 -            continue;
   3.122 +            printk("    l%d == NULL\n", level);
   3.123 +            break;
   3.124          }
   3.125 +        l_index = get_level_index(gmfn, level);
   3.126 +        printk("    l%d_index = %x\n", level, l_index);
   3.127 +        printk("    l%d[%x] = %"PRIx64"\n", level, l_index, l[l_index]);
   3.128  
   3.129 -        if ( level != VTD_PAGE_TABLE_LEVEL_3 &&
   3.130 -             level != VTD_PAGE_TABLE_LEVEL_4)
   3.131 +        pte.val = l[l_index];
   3.132 +        if ( !dma_pte_present(pte) )
   3.133          {
   3.134              unmap_vtd_domain_page(ctxt_entry);
   3.135              unmap_vtd_domain_page(root_entry);
   3.136 -            printk("Unsupported VTD page table level (%d)!\n", level);
   3.137 -            continue;
   3.138 +            printk("    l%d[%x] not present\n", level, l_index);
   3.139 +            break;
   3.140          }
   3.141  
   3.142 -        l = maddr_to_virt(ctxt_entry[devfn].lo);
   3.143 -        do
   3.144 -        {
   3.145 -            l = (u64*)(((unsigned long)l >> PAGE_SHIFT_4K) << PAGE_SHIFT_4K);
   3.146 -            printk("    l%d = %p\n", level, l);
   3.147 -            if ( l == NULL )
   3.148 -            {
   3.149 -                unmap_vtd_domain_page(ctxt_entry);
   3.150 -                unmap_vtd_domain_page(root_entry);
   3.151 -                printk("    l%d == NULL\n", level);
   3.152 -                break;
   3.153 -            }
   3.154 -            l_index = get_level_index(gmfn, level);
   3.155 -            printk("    l%d_index = %x\n", level, l_index);
   3.156 -            printk("    l%d[%x] = %"PRIx64"\n", level, l_index, l[l_index]);
   3.157 +        l = maddr_to_virt(l[l_index]);
   3.158 +    } while ( --level );
   3.159 +}
   3.160  
   3.161 -            pte.val = l[l_index];
   3.162 -            if ( !dma_pte_present(pte) )
   3.163 -            {
   3.164 -                unmap_vtd_domain_page(ctxt_entry);
   3.165 -                unmap_vtd_domain_page(root_entry);
   3.166 -                printk("    l%d[%x] not present\n", level, l_index);
   3.167 -                break;
   3.168 -            }
   3.169 -
   3.170 -            l = maddr_to_virt(l[l_index]);
   3.171 -        } while ( --level );
   3.172 -    }
   3.173 -}
   3.174 +/*
   3.175 + * Local variables:
   3.176 + * mode: C
   3.177 + * c-set-style: "BSD"
   3.178 + * c-basic-offset: 4
   3.179 + * indent-tabs-mode: nil
   3.180 + * End:
   3.181 + */