ia64/xen-unstable

changeset 15951:ecbddf7b7896

vtd: Fix init/destroy domain hooks.
Signed-off-by: Keir Fraser <keir@xensource.com>
author Keir Fraser <keir@xensource.com>
date Thu Sep 20 15:59:51 2007 +0100 (2007-09-20)
parents 35893e27bdeb
children 40bf3ffff484
files xen/arch/x86/domain.c xen/arch/x86/hvm/hvm.c xen/arch/x86/hvm/vmx/vtd/intel-iommu.c xen/arch/x86/hvm/vmx/vtd/io.c xen/include/asm-x86/iommu.h
line diff
     1.1 --- a/xen/arch/x86/domain.c	Thu Sep 20 15:52:29 2007 +0100
     1.2 +++ b/xen/arch/x86/domain.c	Thu Sep 20 15:59:51 2007 +0100
     1.3 @@ -44,6 +44,7 @@
     1.4  #include <asm/hvm/support.h>
     1.5  #include <asm/msr.h>
     1.6  #include <asm/nmi.h>
     1.7 +#include <asm/iommu.h>
     1.8  #ifdef CONFIG_COMPAT
     1.9  #include <compat/vcpu.h>
    1.10  #endif
    1.11 @@ -505,10 +506,16 @@ int arch_domain_create(struct domain *d)
    1.12              virt_to_page(d->shared_info), d, XENSHARE_writable);
    1.13      }
    1.14  
    1.15 +    if ( (rc = iommu_domain_init(d)) != 0 )
    1.16 +        goto fail;
    1.17 +
    1.18      if ( is_hvm_domain(d) )
    1.19      {
    1.20          if ( (rc = hvm_domain_initialise(d)) != 0 )
    1.21 +        {
    1.22 +            iommu_domain_destroy(d);
    1.23              goto fail;
    1.24 +        }
    1.25      }
    1.26      else
    1.27      {
    1.28 @@ -538,6 +545,8 @@ void arch_domain_destroy(struct domain *
    1.29      if ( is_hvm_domain(d) )
    1.30          hvm_domain_destroy(d);
    1.31  
    1.32 +    iommu_domain_destroy(d);
    1.33 +
    1.34      paging_final_teardown(d);
    1.35  
    1.36      free_xenheap_pages(
     2.1 --- a/xen/arch/x86/hvm/hvm.c	Thu Sep 20 15:52:29 2007 +0100
     2.2 +++ b/xen/arch/x86/hvm/hvm.c	Thu Sep 20 15:59:51 2007 +0100
     2.3 @@ -48,7 +48,6 @@
     2.4  #include <public/hvm/ioreq.h>
     2.5  #include <public/version.h>
     2.6  #include <public/memory.h>
     2.7 -#include <asm/iommu.h>
     2.8  
     2.9  int hvm_enabled __read_mostly;
    2.10  
    2.11 @@ -220,21 +219,13 @@ int hvm_domain_initialise(struct domain 
    2.12      if ( rc != 0 )
    2.13          return rc;
    2.14  
    2.15 -    rc = iommu_domain_init(d);
    2.16 -    if ( rc != 0 )
    2.17 -        return rc;
    2.18 -
    2.19      vpic_init(d);
    2.20      vioapic_init(d);
    2.21  
    2.22      hvm_init_ioreq_page(d, &d->arch.hvm_domain.ioreq);
    2.23      hvm_init_ioreq_page(d, &d->arch.hvm_domain.buf_ioreq);
    2.24  
    2.25 -    rc = hvm_funcs.domain_initialise(d);
    2.26 -    if ( rc != 0 )
    2.27 -        release_devices(d);
    2.28 -
    2.29 -    return rc;
    2.30 +    return hvm_funcs.domain_initialise(d);
    2.31  }
    2.32  
    2.33  void hvm_domain_relinquish_resources(struct domain *d)
    2.34 @@ -250,7 +241,6 @@ void hvm_domain_relinquish_resources(str
    2.35  
    2.36  void hvm_domain_destroy(struct domain *d)
    2.37  {
    2.38 -    release_devices(d);
    2.39      hvm_funcs.domain_destroy(d);
    2.40  }
    2.41  
     3.1 --- a/xen/arch/x86/hvm/vmx/vtd/intel-iommu.c	Thu Sep 20 15:52:29 2007 +0100
     3.2 +++ b/xen/arch/x86/hvm/vmx/vtd/intel-iommu.c	Thu Sep 20 15:59:51 2007 +0100
     3.3 @@ -972,7 +972,7 @@ int iommu_domain_init(struct domain *dom
     3.4          gdprintk(XENLOG_ERR VTDPREFIX,
     3.5                   "IOMMU: hardware doesn't support the agaw\n");
     3.6          agaw = find_next_bit(&sagaw, 5, agaw);
     3.7 -        if (agaw >= 5)
     3.8 +        if ( agaw >= 5 )
     3.9              return -ENODEV;
    3.10      }
    3.11      hd->agaw = agaw;
     4.1 --- a/xen/arch/x86/hvm/vmx/vtd/io.c	Thu Sep 20 15:52:29 2007 +0100
     4.2 +++ b/xen/arch/x86/hvm/vmx/vtd/io.c	Thu Sep 20 15:59:51 2007 +0100
     4.3 @@ -134,19 +134,17 @@ void hvm_dpci_eoi(unsigned int guest_gsi
     4.4      }
     4.5  }
     4.6  
     4.7 -int release_devices(struct domain *d)
     4.8 +void iommu_domain_destroy(struct domain *d)
     4.9  {
    4.10      struct hvm_domain *hd = &d->arch.hvm_domain;
    4.11      uint32_t i;
    4.12 -    int ret = 0;
    4.13  
    4.14      if ( !vtd_enabled )
    4.15 -        return ret;
    4.16 +        return;
    4.17  
    4.18      for ( i = 0; i < NR_IRQS; i++ )
    4.19          if ( hd->irq.mirq[i].valid )
    4.20 -            ret = pirq_guest_unbind(d, i);
    4.21 +            pirq_guest_unbind(d, i);
    4.22  
    4.23      iommu_domain_teardown(d);
    4.24 -    return ret;
    4.25  }
     5.1 --- a/xen/include/asm-x86/iommu.h	Thu Sep 20 15:52:29 2007 +0100
     5.2 +++ b/xen/include/asm-x86/iommu.h	Thu Sep 20 15:59:51 2007 +0100
     5.3 @@ -68,8 +68,8 @@ struct iommu {
     5.4  
     5.5  int iommu_setup(void);
     5.6  int iommu_domain_init(struct domain *d);
     5.7 +void iommu_domain_destroy(struct domain *d);
     5.8  int assign_device(struct domain *d, u8 bus, u8 devfn);
     5.9 -int release_devices(struct domain *d);
    5.10  int iommu_map_page(struct domain *d, dma_addr_t gfn, dma_addr_t mfn);
    5.11  int iommu_unmap_page(struct domain *d, dma_addr_t gfn);
    5.12  void iommu_flush(struct domain *d, dma_addr_t gfn, u64 *p2m_entry);