diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2015-03-18 14:21:43 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2015-04-30 16:55:32 +0200 |
commit | 41063e1e7afcb2f13e103720fe96221657f5dbbc (patch) | |
tree | ce78dca7d90917ffc9bfe45fcec5dfba0f8a9320 /hw/vfio | |
parent | 4c6637525290dc863a00be7f58fc11d07b780bd4 (diff) | |
download | qemu-41063e1e7afcb2f13e103720fe96221657f5dbbc.tar.gz qemu-41063e1e7afcb2f13e103720fe96221657f5dbbc.tar.bz2 qemu-41063e1e7afcb2f13e103720fe96221657f5dbbc.zip |
exec: move rcu_read_lock/unlock to address_space_translate callers
Once address_space_translate will be called outside the BQL, the returned
MemoryRegion might disappear as soon as the RCU read-side critical section
ends. Avoid this by moving the critical section to the callers.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <1426684909-95030-3-git-send-email-pbonzini@redhat.com>
Diffstat (limited to 'hw/vfio')
-rw-r--r-- | hw/vfio/common.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/hw/vfio/common.c b/hw/vfio/common.c index b01262063d..b1045da857 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -270,13 +270,14 @@ static void vfio_iommu_map_notify(Notifier *n, void *data) * this IOMMU to its immediate target. We need to translate * it the rest of the way through to memory. */ + rcu_read_lock(); mr = address_space_translate(&address_space_memory, iotlb->translated_addr, &xlat, &len, iotlb->perm & IOMMU_WO); if (!memory_region_is_ram(mr)) { error_report("iommu map to non memory area %"HWADDR_PRIx"", xlat); - return; + goto out; } /* * Translation truncates length to the IOMMU page size, @@ -284,7 +285,7 @@ static void vfio_iommu_map_notify(Notifier *n, void *data) */ if (len & iotlb->addr_mask) { error_report("iommu has granularity incompatible with target AS"); - return; + goto out; } if ((iotlb->perm & IOMMU_RW) != IOMMU_NONE) { @@ -307,6 +308,8 @@ static void vfio_iommu_map_notify(Notifier *n, void *data) iotlb->addr_mask + 1, ret); } } +out: + rcu_read_unlock(); } static void vfio_listener_region_add(MemoryListener *listener, |