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

Chris Wilson chris at chris-wilson.co.uk
Thu Dec 26 10:14:02 UTC 2019


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 at intel.com>
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Imre Deak <imre.deak at intel.com>
---
 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..eb5a58290d2f 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_END, 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



More information about the Intel-gfx-trybot mailing list