diff options
author | Jiang Liu <jiang.liu@linux.intel.com> | 2014-01-06 01:18:10 -0500 |
---|---|---|
committer | Joerg Roedel <joro@8bytes.org> | 2014-01-09 06:43:24 -0500 |
commit | 18d99165d3ebe5e365de57bcc673901d754c7142 (patch) | |
tree | 9729b26cae46a1ebf2c66cdd8de7418beb4948c3 /drivers/iommu | |
parent | ada4d4b2a32e9f63d4dcb9f69578473408f4622c (diff) |
iommu/vt-d: fix a race window in allocating domain ID for virtual machines
Function intel_iommu_domain_init() may be concurrently called by upper
layer without serialization, so use atomic_t to protect domain id
allocation.
Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
Cc: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Joerg Roedel <joro@8bytes.org>
Diffstat (limited to 'drivers/iommu')
-rw-r--r-- | drivers/iommu/intel-iommu.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index 64d8942d6d14..e2d2cb3119b3 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c | |||
@@ -3877,7 +3877,7 @@ static void vm_domain_remove_all_dev_info(struct dmar_domain *domain) | |||
3877 | } | 3877 | } |
3878 | 3878 | ||
3879 | /* domain id for virtual machine, it won't be set in context */ | 3879 | /* domain id for virtual machine, it won't be set in context */ |
3880 | static unsigned long vm_domid; | 3880 | static atomic_t vm_domid = ATOMIC_INIT(0); |
3881 | 3881 | ||
3882 | static struct dmar_domain *iommu_alloc_vm_domain(void) | 3882 | static struct dmar_domain *iommu_alloc_vm_domain(void) |
3883 | { | 3883 | { |
@@ -3887,7 +3887,7 @@ static struct dmar_domain *iommu_alloc_vm_domain(void) | |||
3887 | if (!domain) | 3887 | if (!domain) |
3888 | return NULL; | 3888 | return NULL; |
3889 | 3889 | ||
3890 | domain->id = vm_domid++; | 3890 | domain->id = atomic_inc_return(&vm_domid); |
3891 | domain->nid = -1; | 3891 | domain->nid = -1; |
3892 | memset(domain->iommu_bmp, 0, sizeof(domain->iommu_bmp)); | 3892 | memset(domain->iommu_bmp, 0, sizeof(domain->iommu_bmp)); |
3893 | domain->flags = DOMAIN_FLAG_VIRTUAL_MACHINE; | 3893 | domain->flags = DOMAIN_FLAG_VIRTUAL_MACHINE; |