intel/ds: Fix crash when allocating more intel_ds_queues than u_vector was initialized
authorJosé Roberto de Souza <jose.souza@intel.com>
Mon, 23 Jan 2023 20:09:56 +0000 (12:09 -0800)
committerEric Engestrom <eric@engestrom.ch>
Wed, 8 Feb 2023 20:34:42 +0000 (20:34 +0000)
commit58a320186d1ee1a9a3e03b4ae57da10d88361d00
tree4def4093643fbc6585f2be3bdcb1b3d4b982f2d0
parent52b984e55575472c9e70e82aada029209fe97a10
intel/ds: Fix crash when allocating more intel_ds_queues than u_vector was initialized

u_vector_add() don't keep the returned pointers valid.
After the initial size allocated in u_vector_init() is reached it will
allocate a bigger buffer and copy data from older buffer to the new
one and free the old buffer, making all the previous pointers returned
by u_vector_add() invalid and crashing the application when trying to
access it.

This is reproduced when running
dEQP-VK.synchronization.signal_order.timeline_semaphore.* in DG2 SKUs
that has 4 CCS engines, INTEL_COMPUTE_CLASS=1 is set and of course
perfetto build is enabled.

To fix this issue here I'm moving the storage/allocation of
struct intel_ds_queue to struct anv_queue/iris_batch and using
struct list_head to maintain a chain of intel_ds_queue of the
intel_ds_device.
This allows us to append or remove queues dynamically in future if
necessary.

Fixes: e760c5b37be9 ("anv: add perfetto source")
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20977>
(cherry picked from commit 8092bc2158ebb8a5f85e0ec569387c5dcd0d1627)
12 files changed:
.pick_status.json
src/gallium/drivers/iris/iris_batch.c
src/gallium/drivers/iris/iris_batch.h
src/gallium/drivers/iris/iris_utrace.c
src/intel/ds/intel_driver_ds.cc
src/intel/ds/intel_driver_ds.h
src/intel/vulkan/anv_batch_chain.c
src/intel/vulkan/anv_private.h
src/intel/vulkan/anv_utrace.c
src/intel/vulkan_hasvk/anv_batch_chain.c
src/intel/vulkan_hasvk/anv_private.h
src/intel/vulkan_hasvk/anv_utrace.c