[PATCH 3/5] drm/i915/gt: Always poison the kernel_context image before unparking

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Keep scrubbing the kernel_context image with poison before we reset it
in order to demonstrate that we will be resilient in the case where it
is accidentally overwritten on idle.

Suggested-by: Imre Deak <imre.deak@xxxxxxxxx>
Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
Cc: Imre Deak <imre.deak@xxxxxxxxx>
---
 drivers/gpu/drm/i915/gt/intel_engine_pm.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/gpu/drm/i915/gt/intel_engine_pm.c b/drivers/gpu/drm/i915/gt/intel_engine_pm.c
index b9444ce29a3a..86970bbff8bb 100644
--- a/drivers/gpu/drm/i915/gt/intel_engine_pm.c
+++ b/drivers/gpu/drm/i915/gt/intel_engine_pm.c
@@ -35,6 +35,20 @@ static int __engine_unpark(struct intel_wakeref *wf)
 	if (!IS_ERR_OR_NULL(map))
 		engine->pinned_default_state = map;
 
+	/* Poison the kernel_context image to verify we never fully trust it */
+	if (IS_ENABLED(CONFIG_DRM_I915_DEBUG_GEM) &&
+	    engine->kernel_context->state) {
+		struct drm_i915_gem_object *obj =
+			engine->kernel_context->state->obj;
+
+		map = i915_gem_object_pin_map(obj, i915_coherent_map_type(engine->i915));
+		if (!IS_ERR(map)) {
+			memset(map, POISON_INUSE, obj->base.size);
+			i915_gem_object_flush_map(obj);
+			i915_gem_object_unpin_map(obj);
+		}
+	}
+
 	/* Discard stale context state from across idling */
 	ce = engine->kernel_context;
 	if (ce)
-- 
2.24.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx



[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux