debuggers.hg

changeset 19967:f17c897546bf

VT-d: fix assertion fault in pci passthrough code

Remove ASSERT(spin_is_locked(&pcidevs_lock)) in
pci_get_pdev_by_domain() to allow caller the flexibility to not hold
the lock if it does not care if the device is hot removed between the
time it got the pdev and the time it is used to get the corresponding
vt-d engine. In the new RHSA use case, we just wanted to get the vt-d
engine of any device passthrough in the domain. Also, rename RHSA
field "domain" to "proximity domain" to avoid overloading the term
"domain" in virtualization context.

Signed-off-by: Allen Kay <allen.m.kay@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Jul 13 11:52:49 2009 +0100 (2009-07-13)
parents 3f12d48f2880
children 0d4406bc5cb7
files xen/drivers/passthrough/pci.c xen/drivers/passthrough/vtd/dmar.c xen/drivers/passthrough/vtd/dmar.h xen/drivers/passthrough/vtd/iommu.c xen/include/xen/acpi.h
line diff
     1.1 --- a/xen/drivers/passthrough/pci.c	Mon Jul 13 11:51:07 2009 +0100
     1.2 +++ b/xen/drivers/passthrough/pci.c	Mon Jul 13 11:52:49 2009 +0100
     1.3 @@ -89,8 +89,6 @@ struct pci_dev *pci_get_pdev_by_domain(s
     1.4  {
     1.5      struct pci_dev *pdev = NULL;
     1.6  
     1.7 -    ASSERT(spin_is_locked(&pcidevs_lock));
     1.8 -
     1.9      list_for_each_entry ( pdev, &alldevs_list, alldevs_list )
    1.10           if ( (pdev->bus == bus || bus == -1) &&
    1.11                (pdev->devfn == devfn || devfn == -1) &&
     2.1 --- a/xen/drivers/passthrough/vtd/dmar.c	Mon Jul 13 11:51:07 2009 +0100
     2.2 +++ b/xen/drivers/passthrough/vtd/dmar.c	Mon Jul 13 11:52:49 2009 +0100
     2.3 @@ -499,7 +499,7 @@ acpi_parse_one_rhsa(struct acpi_dmar_ent
     2.4      memset(rhsau, 0, sizeof(struct acpi_rhsa_unit));
     2.5  
     2.6      rhsau->address = rhsa->address;
     2.7 -    rhsau->domain = rhsa->domain;
     2.8 +    rhsau->proximity_domain = rhsa->proximity_domain;
     2.9      list_add_tail(&rhsau->list, &acpi_rhsa_units);
    2.10  
    2.11      return ret;
     3.1 --- a/xen/drivers/passthrough/vtd/dmar.h	Mon Jul 13 11:51:07 2009 +0100
     3.2 +++ b/xen/drivers/passthrough/vtd/dmar.h	Mon Jul 13 11:52:49 2009 +0100
     3.3 @@ -72,7 +72,7 @@ struct acpi_atsr_unit {
     3.4  struct acpi_rhsa_unit {
     3.5      struct list_head list;
     3.6      u64    address;
     3.7 -    u32    domain;
     3.8 +    u32    proximity_domain;
     3.9  };
    3.10  
    3.11  #define for_each_drhd_unit(drhd) \
     4.1 --- a/xen/drivers/passthrough/vtd/iommu.c	Mon Jul 13 11:51:07 2009 +0100
     4.2 +++ b/xen/drivers/passthrough/vtd/iommu.c	Mon Jul 13 11:52:49 2009 +0100
     4.3 @@ -143,10 +143,14 @@ u64 alloc_pgtable_maddr(struct acpi_drhd
     4.4      struct acpi_rhsa_unit *rhsa;
     4.5      struct page_info *pg;
     4.6      u64 *vaddr;
     4.7 +    int node = -1;
     4.8  
     4.9      rhsa = drhd_to_rhsa(drhd);
    4.10 +    if ( rhsa )
    4.11 +        node =  pxm_to_node(rhsa->proximity_domain);
    4.12 +
    4.13      pg = alloc_domheap_pages(NULL, get_order_from_pages(npages),
    4.14 -                             rhsa ? rhsa->domain : 0);
    4.15 +                             (node == -1 ) ? 0 : MEMF_node(node));
    4.16      if ( !pg )
    4.17          return 0;
    4.18      vaddr = map_domain_page(page_to_mfn(pg));
    4.19 @@ -204,6 +208,10 @@ static u64 addr_to_dma_page_maddr(struct
    4.20      ASSERT(spin_is_locked(&hd->mapping_lock));
    4.21      if ( hd->pgd_maddr == 0 )
    4.22      {
    4.23 +        /*
    4.24 +         * just get any passthrough device in the domainr - assume user
    4.25 +         * assigns only devices from same node to a given guest.
    4.26 +         */
    4.27          pdev = pci_get_pdev_by_domain(domain, -1, -1);
    4.28          drhd = acpi_find_matched_drhd_unit(pdev);
    4.29          if ( !alloc || ((hd->pgd_maddr = alloc_pgtable_maddr(drhd, 1)) == 0) )
     5.1 --- a/xen/include/xen/acpi.h	Mon Jul 13 11:51:07 2009 +0100
     5.2 +++ b/xen/include/xen/acpi.h	Mon Jul 13 11:52:49 2009 +0100
     5.3 @@ -227,7 +227,7 @@ struct acpi_table_atsr {
     5.4  
     5.5  struct acpi_table_rhsa {
     5.6          struct  acpi_dmar_entry_header header;
     5.7 -        u32     domain;
     5.8 +        u32     proximity_domain;
     5.9          u64     address; /* register base address for this drhd */
    5.10  } __attribute__ ((packed));
    5.11