Commit 1d0e2c93 authored by Chris Wilson's avatar Chris Wilson

drm/i915/gt: Always poison the kernel_context image before unparking

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: default avatarImre Deak <imre.deak@intel.com>
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Cc: Imre Deak <imre.deak@intel.com>
Reviewed-by: default avatarMika Kuoppala <mika.kuoppala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200102131707.1463945-5-chris@chris-wilson.co.uk
parent fb218f20
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
#include "intel_engine_types.h" #include "intel_engine_types.h"
#include "intel_sseu.h" #include "intel_sseu.h"
#define CONTEXT_REDZONE POISON_INUSE
struct i915_gem_context; struct i915_gem_context;
struct i915_vma; struct i915_vma;
struct intel_context; struct intel_context;
......
...@@ -37,8 +37,24 @@ static int __engine_unpark(struct intel_wakeref *wf) ...@@ -37,8 +37,24 @@ static int __engine_unpark(struct intel_wakeref *wf)
/* Discard stale context state from across idling */ /* Discard stale context state from across idling */
ce = engine->kernel_context; ce = engine->kernel_context;
if (ce) if (ce) {
GEM_BUG_ON(test_bit(CONTEXT_VALID_BIT, &ce->flags));
/* First poison the image to verify we never fully trust it */
if (IS_ENABLED(CONFIG_DRM_I915_DEBUG_GEM) && ce->state) {
struct drm_i915_gem_object *obj = ce->state->obj;
int type = i915_coherent_map_type(engine->i915);
map = i915_gem_object_pin_map(obj, type);
if (!IS_ERR(map)) {
memset(map, CONTEXT_REDZONE, obj->base.size);
i915_gem_object_flush_map(obj);
i915_gem_object_unpin_map(obj);
}
}
ce->ops->reset(ce); ce->ops->reset(ce);
}
if (engine->unpark) if (engine->unpark)
engine->unpark(engine); engine->unpark(engine);
......
...@@ -2507,7 +2507,7 @@ set_redzone(void *vaddr, const struct intel_engine_cs *engine) ...@@ -2507,7 +2507,7 @@ set_redzone(void *vaddr, const struct intel_engine_cs *engine)
vaddr += engine->context_size; vaddr += engine->context_size;
memset(vaddr, POISON_INUSE, I915_GTT_PAGE_SIZE); memset(vaddr, CONTEXT_REDZONE, I915_GTT_PAGE_SIZE);
} }
static void static void
...@@ -2518,7 +2518,7 @@ check_redzone(const void *vaddr, const struct intel_engine_cs *engine) ...@@ -2518,7 +2518,7 @@ check_redzone(const void *vaddr, const struct intel_engine_cs *engine)
vaddr += engine->context_size; vaddr += engine->context_size;
if (memchr_inv(vaddr, POISON_INUSE, I915_GTT_PAGE_SIZE)) if (memchr_inv(vaddr, CONTEXT_REDZONE, I915_GTT_PAGE_SIZE))
dev_err_once(engine->i915->drm.dev, dev_err_once(engine->i915->drm.dev,
"%s context redzone overwritten!\n", "%s context redzone overwritten!\n",
engine->name); engine->name);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment