mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 09:13:55 -06:00
iommu: Add IOMMU index argument to notifier APIs
Add support for multiple IOMMU indexes to the IOMMU notifier APIs. When initializing a notifier with iommu_notifier_init(), the caller must pass the IOMMU index that it is interested in. When a change happens, the IOMMU implementation must pass memory_region_notify_iommu() the IOMMU index that has changed and that notifiers must be called for. IOMMUs which support only a single index don't need to change. Callers which only really support working with IOMMUs with a single index can use the result of passing MEMTXATTRS_UNSPECIFIED to memory_region_iommu_attrs_to_index(). Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Message-id: 20180604152941.20374-3-peter.maydell@linaro.org
This commit is contained in:
parent
21f402093c
commit
cb1efcf462
7 changed files with 30 additions and 10 deletions
|
@ -662,6 +662,8 @@ static void vhost_iommu_region_add(MemoryListener *listener,
|
|||
iommu_listener);
|
||||
struct vhost_iommu *iommu;
|
||||
Int128 end;
|
||||
int iommu_idx;
|
||||
IOMMUMemoryRegion *iommu_mr = IOMMU_MEMORY_REGION(section->mr);
|
||||
|
||||
if (!memory_region_is_iommu(section->mr)) {
|
||||
return;
|
||||
|
@ -671,10 +673,13 @@ static void vhost_iommu_region_add(MemoryListener *listener,
|
|||
end = int128_add(int128_make64(section->offset_within_region),
|
||||
section->size);
|
||||
end = int128_sub(end, int128_one());
|
||||
iommu_idx = memory_region_iommu_attrs_to_index(iommu_mr,
|
||||
MEMTXATTRS_UNSPECIFIED);
|
||||
iommu_notifier_init(&iommu->n, vhost_iommu_unmap_notify,
|
||||
IOMMU_NOTIFIER_UNMAP,
|
||||
section->offset_within_region,
|
||||
int128_get64(end));
|
||||
int128_get64(end),
|
||||
iommu_idx);
|
||||
iommu->mr = section->mr;
|
||||
iommu->iommu_offset = section->offset_within_address_space -
|
||||
section->offset_within_region;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue