exec.c: Don't reallocate IOMMUNotifiers that are in use
commit00d0932e0bc64811c2728a2966d76a3233b4fdbc
authorPeter Maydell <peter.maydell@linaro.org>
Fri, 1 Feb 2019 14:55:45 +0000 (1 14:55 +0000)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Thu, 28 Mar 2019 01:06:46 +0000 (27 20:06 -0500)
tree66f0c0e56cef37260aaacb0bf5356855da33c645
parent2e5502300e552ab55641c1c7338531f9eac51900
exec.c: Don't reallocate IOMMUNotifiers that are in use

The tcg_register_iommu_notifier() code has a GArray of
TCGIOMMUNotifier structs which it has registered by passing
memory_region_register_iommu_notifier() a pointer to the embedded
IOMMUNotifier field. Unfortunately, if we need to enlarge the
array via g_array_set_size() this can cause a realloc(), which
invalidates the pointer that memory_region_register_iommu_notifier()
put into the MemoryRegion's iommu_notify list. This can result
in segfaults.

Switch the GArray to holding pointers to the TCGIOMMUNotifier
structs, so that we can individually allocate and free them.

Cc: qemu-stable@nongnu.org
Fixes: 1f871c5e6b0f30644a60a ("exec.c: Handle IOMMUs in address_space_translate_for_iotlb()")
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20190128174241.5860-1-peter.maydell@linaro.org
(cherry picked from commit 5601be3b01d73e21c09331599e2ce62df016ff94)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
exec.c