Skip to content

Commit 51eed9d

Browse files
committed
Merge tag 'drm-intel-next-fixes-2023-08-31' of git://anongit.freedesktop.org/drm/drm-intel into drm-next
- Mark requests for GuC virtual engines to avoid use-after-free (Andrzej). Signed-off-by: Dave Airlie <airlied@redhat.com> From: Rodrigo Vivi <rodrigo.vivi@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/ZPEGEeP2EwCtx9hM@intel.com
2 parents d9809d2 + 5eefc53 commit 51eed9d

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

drivers/gpu/drm/i915/gt/intel_engine_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ struct i915_perf_group;
5858

5959
typedef u32 intel_engine_mask_t;
6060
#define ALL_ENGINES ((intel_engine_mask_t)~0ul)
61+
#define VIRTUAL_ENGINES BIT(BITS_PER_TYPE(intel_engine_mask_t) - 1)
6162

6263
struct intel_hw_status_page {
6364
struct list_head timelines;

drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5470,6 +5470,9 @@ guc_create_virtual(struct intel_engine_cs **siblings, unsigned int count,
54705470

54715471
ve->base.flags = I915_ENGINE_IS_VIRTUAL;
54725472

5473+
BUILD_BUG_ON(ilog2(VIRTUAL_ENGINES) < I915_NUM_ENGINES);
5474+
ve->base.mask = VIRTUAL_ENGINES;
5475+
54735476
intel_context_init(&ve->context, &ve->base);
54745477

54755478
for (n = 0; n < count; n++) {

drivers/gpu/drm/i915/i915_request.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,7 @@ static void i915_fence_release(struct dma_fence *fence)
134134
i915_sw_fence_fini(&rq->semaphore);
135135

136136
/*
137-
* Keep one request on each engine for reserved use under mempressure
138-
* do not use with virtual engines as this really is only needed for
139-
* kernel contexts.
137+
* Keep one request on each engine for reserved use under mempressure.
140138
*
141139
* We do not hold a reference to the engine here and so have to be
142140
* very careful in what rq->engine we poke. The virtual engine is
@@ -166,8 +164,7 @@ static void i915_fence_release(struct dma_fence *fence)
166164
* know that if the rq->execution_mask is a single bit, rq->engine
167165
* can be a physical engine with the exact corresponding mask.
168166
*/
169-
if (!intel_engine_is_virtual(rq->engine) &&
170-
is_power_of_2(rq->execution_mask) &&
167+
if (is_power_of_2(rq->execution_mask) &&
171168
!cmpxchg(&rq->engine->request_pool, NULL, rq))
172169
return;
173170

0 commit comments

Comments
 (0)