iommu/vt-d: Duplicate iommu_resv_region objects per device list
authorEric Auger <eric.auger@redhat.com>
Mon, 3 Jun 2019 06:53:31 +0000 (08:53 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 27 Jan 2020 13:50:54 +0000 (14:50 +0100)
commit2ca113011d9c28c0f7b55b0dd408eaab04d6d49c
tree3dd6e7c4b3927e2425922979887f40eb291896e4
parent3add501c19e8545875fc4a0bf5f201670aded04d
iommu/vt-d: Duplicate iommu_resv_region objects per device list

[ Upstream commit 5f64ce5411b467f1cfea6c63e2494c22b773582b ]

intel_iommu_get_resv_regions() aims to return the list of
reserved regions accessible by a given @device. However several
devices can access the same reserved memory region and when
building the list it is not safe to use a single iommu_resv_region
object, whose container is the RMRR. This iommu_resv_region must
be duplicated per device reserved region list.

Let's remove the struct iommu_resv_region from the RMRR unit
and allocate the iommu_resv_region directly in
intel_iommu_get_resv_regions(). We hold the dmar_global_lock instead
of the rcu-lock to allow sleeping.

Fixes: 0659b8dc45a6 ("iommu/vt-d: Implement reserved region get/put callbacks")
Signed-off-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/iommu/intel-iommu.c