Commit b3512414 authored by Keir Fraser's avatar Keir Fraser

vtd: Fix init/destroy domain hooks.

Signed-off-by: default avatarKeir Fraser <keir@xensource.com>
parent 5b9d7e48
......@@ -44,6 +44,7 @@
#include <asm/hvm/support.h>
#include <asm/msr.h>
#include <asm/nmi.h>
#include <asm/iommu.h>
#ifdef CONFIG_COMPAT
#include <compat/vcpu.h>
#endif
......@@ -505,10 +506,16 @@ int arch_domain_create(struct domain *d)
virt_to_page(d->shared_info), d, XENSHARE_writable);
}
if ( (rc = iommu_domain_init(d)) != 0 )
goto fail;
if ( is_hvm_domain(d) )
{
if ( (rc = hvm_domain_initialise(d)) != 0 )
{
iommu_domain_destroy(d);
goto fail;
}
}
else
{
......@@ -538,6 +545,8 @@ void arch_domain_destroy(struct domain *d)
if ( is_hvm_domain(d) )
hvm_domain_destroy(d);
iommu_domain_destroy(d);
paging_final_teardown(d);
free_xenheap_pages(
......
......@@ -48,7 +48,6 @@
#include <public/hvm/ioreq.h>
#include <public/version.h>
#include <public/memory.h>
#include <asm/iommu.h>
int hvm_enabled __read_mostly;
......@@ -220,21 +219,13 @@ int hvm_domain_initialise(struct domain *d)
if ( rc != 0 )
return rc;
rc = iommu_domain_init(d);
if ( rc != 0 )
return rc;
vpic_init(d);
vioapic_init(d);
hvm_init_ioreq_page(d, &d->arch.hvm_domain.ioreq);
hvm_init_ioreq_page(d, &d->arch.hvm_domain.buf_ioreq);
rc = hvm_funcs.domain_initialise(d);
if ( rc != 0 )
release_devices(d);
return rc;
return hvm_funcs.domain_initialise(d);
}
void hvm_domain_relinquish_resources(struct domain *d)
......@@ -250,7 +241,6 @@ void hvm_domain_relinquish_resources(struct domain *d)
void hvm_domain_destroy(struct domain *d)
{
release_devices(d);
hvm_funcs.domain_destroy(d);
}
......
......@@ -972,7 +972,7 @@ int iommu_domain_init(struct domain *domain)
gdprintk(XENLOG_ERR VTDPREFIX,
"IOMMU: hardware doesn't support the agaw\n");
agaw = find_next_bit(&sagaw, 5, agaw);
if (agaw >= 5)
if ( agaw >= 5 )
return -ENODEV;
}
hd->agaw = agaw;
......
......@@ -134,19 +134,17 @@ void hvm_dpci_eoi(unsigned int guest_gsi, union vioapic_redir_entry *ent)
}
}
int release_devices(struct domain *d)
void iommu_domain_destroy(struct domain *d)
{
struct hvm_domain *hd = &d->arch.hvm_domain;
uint32_t i;
int ret = 0;
if ( !vtd_enabled )
return ret;
return;
for ( i = 0; i < NR_IRQS; i++ )
if ( hd->irq.mirq[i].valid )
ret = pirq_guest_unbind(d, i);
pirq_guest_unbind(d, i);
iommu_domain_teardown(d);
return ret;
}
......@@ -68,8 +68,8 @@ struct iommu {
int iommu_setup(void);
int iommu_domain_init(struct domain *d);
void iommu_domain_destroy(struct domain *d);
int assign_device(struct domain *d, u8 bus, u8 devfn);
int release_devices(struct domain *d);
int iommu_map_page(struct domain *d, dma_addr_t gfn, dma_addr_t mfn);
int iommu_unmap_page(struct domain *d, dma_addr_t gfn);
void iommu_flush(struct domain *d, dma_addr_t gfn, u64 *p2m_entry);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment