Commit 42c7156a authored by Brad Volkin's avatar Brad Volkin Committed by Daniel Vetter

drm/i915: Abort command parsing for chained batches

libva uses chained batch buffers in a way that the command parser
can't generally handle. Fortunately, libva doesn't need to write
registers from batch buffers in the way that mesa does, so this
patch causes the driver to fall back to non-secure dispatch if
the parser detects a chained batch buffer.

Note: The 2nd hunk to munge the error code of the parser looks a bit
superflous. At least until we have the batch copy code ready and can
run the cmd parser in granting mode. But it isn't since we still need
to let existing libva buffers pass (though not with elevated privs
ofc!).

Testcase: igt/gem_exec_parse/chained-batch
Signed-off-by: default avatarBrad Volkin <bradley.d.volkin@intel.com>
[danvet: Add note - this confused me in review and Brad clarified
things (after a few mails ...).]
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent a919db90
...@@ -138,6 +138,11 @@ static const struct drm_i915_cmd_descriptor common_cmds[] = { ...@@ -138,6 +138,11 @@ static const struct drm_i915_cmd_descriptor common_cmds[] = {
.mask = MI_GLOBAL_GTT, .mask = MI_GLOBAL_GTT,
.expected = 0, .expected = 0,
}}, ), }}, ),
/*
* MI_BATCH_BUFFER_START requires some special handling. It's not
* really a 'skip' action but it doesn't seem like it's worth adding
* a new action. See i915_parse_cmds().
*/
CMD( MI_BATCH_BUFFER_START, SMI, !F, 0xFF, S ), CMD( MI_BATCH_BUFFER_START, SMI, !F, 0xFF, S ),
}; };
...@@ -955,7 +960,8 @@ static bool check_cmd(const struct intel_engine_cs *ring, ...@@ -955,7 +960,8 @@ static bool check_cmd(const struct intel_engine_cs *ring,
* Parses the specified batch buffer looking for privilege violations as * Parses the specified batch buffer looking for privilege violations as
* described in the overview. * described in the overview.
* *
* Return: non-zero if the parser finds violations or otherwise fails * Return: non-zero if the parser finds violations or otherwise fails; -EACCES
* if the batch appears legal but should use hardware parsing
*/ */
int i915_parse_cmds(struct intel_engine_cs *ring, int i915_parse_cmds(struct intel_engine_cs *ring,
struct drm_i915_gem_object *batch_obj, struct drm_i915_gem_object *batch_obj,
...@@ -1002,6 +1008,16 @@ int i915_parse_cmds(struct intel_engine_cs *ring, ...@@ -1002,6 +1008,16 @@ int i915_parse_cmds(struct intel_engine_cs *ring,
break; break;
} }
/*
* If the batch buffer contains a chained batch, return an
* error that tells the caller to abort and dispatch the
* workload as a non-secure batch.
*/
if (desc->cmd.value == MI_BATCH_BUFFER_START) {
ret = -EACCES;
break;
}
if (desc->flags & CMD_DESC_FIXED) if (desc->flags & CMD_DESC_FIXED)
length = desc->length.fixed; length = desc->length.fixed;
else else
......
...@@ -1365,9 +1365,10 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, ...@@ -1365,9 +1365,10 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
batch_obj, batch_obj,
args->batch_start_offset, args->batch_start_offset,
file->is_master); file->is_master);
if (ret) if (ret) {
if (ret != -EACCES)
goto err; goto err;
} else {
/* /*
* XXX: Actually do this when enabling batch copy... * XXX: Actually do this when enabling batch copy...
* *
...@@ -1377,6 +1378,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, ...@@ -1377,6 +1378,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
* want that set when the command parser is enabled. * want that set when the command parser is enabled.
*/ */
} }
}
/* snb/ivb/vlv conflate the "batch in ppgtt" bit with the "non-secure /* snb/ivb/vlv conflate the "batch in ppgtt" bit with the "non-secure
* batch" bit. Hence we need to pin secure batches into the global gtt. * batch" bit. Hence we need to pin secure batches into the global gtt.
......
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