73,7 → 73,7 |
* those commands required by the parser. This generally works because command |
* opcode ranges have standard command length encodings. So for commands that |
* the parser does not need to check, it can easily skip them. This is |
* implementated via a per-ring length decoding vfunc. |
* implemented via a per-ring length decoding vfunc. |
* |
* Unfortunately, there are a number of commands that do not follow the standard |
* length encoding for their opcode range, primarily amongst the MI_* commands. |
138,6 → 138,11 |
.mask = MI_GLOBAL_GTT, |
.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 ), |
}; |
|
408,6 → 413,8 |
REG64(PS_INVOCATION_COUNT), |
REG64(PS_DEPTH_COUNT), |
OACONTROL, /* Only allowed for LRI and SRM. See below. */ |
REG64(MI_PREDICATE_SRC0), |
REG64(MI_PREDICATE_SRC1), |
GEN7_3DPRIM_END_OFFSET, |
GEN7_3DPRIM_START_VERTEX, |
GEN7_3DPRIM_VERTEX_COUNT, |
709,6 → 716,7 |
BUG_ON(!validate_cmds_sorted(ring, cmd_tables, cmd_table_count)); |
BUG_ON(!validate_regs_sorted(ring)); |
|
if (hash_empty(ring->cmd_hash)) { |
ret = init_hash_table(ring, cmd_tables, cmd_table_count); |
if (ret) { |
DRM_ERROR("CMD: cmd_parser_init failed!\n"); |
715,6 → 723,7 |
fini_hash_table(ring); |
return ret; |
} |
} |
|
ring->needs_cmd_parser = true; |
|
836,23 → 845,16 |
* @ring: the ring in question |
* |
* Only certain platforms require software batch buffer command parsing, and |
* only when enabled via module paramter. |
* only when enabled via module parameter. |
* |
* Return: true if the ring requires software command parsing |
*/ |
bool i915_needs_cmd_parser(struct intel_engine_cs *ring) |
{ |
struct drm_i915_private *dev_priv = ring->dev->dev_private; |
|
if (!ring->needs_cmd_parser) |
return false; |
|
/* |
* XXX: VLV is Gen7 and therefore has cmd_tables, but has PPGTT |
* disabled. That will cause all of the parser's PPGTT checks to |
* fail. For now, disable parsing when PPGTT is off. |
*/ |
if (!dev_priv->mm.aliasing_ppgtt) |
if (!USES_PPGTT(ring->dev)) |
return false; |
|
return (i915.enable_cmd_parser == 1); |
888,8 → 890,10 |
* OACONTROL writes to only MI_LOAD_REGISTER_IMM commands. |
*/ |
if (reg_addr == OACONTROL) { |
if (desc->cmd.value == MI_LOAD_REGISTER_MEM) |
if (desc->cmd.value == MI_LOAD_REGISTER_MEM) { |
DRM_DEBUG_DRIVER("CMD: Rejected LRM to OACONTROL\n"); |
return false; |
} |
|
if (desc->cmd.value == MI_LOAD_REGISTER_IMM(1)) |
*oacontrol_set = (cmd[2] != 0); |
959,7 → 963,8 |
* Parses the specified batch buffer looking for privilege violations as |
* 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, |
struct drm_i915_gem_object *batch_obj, |
1006,6 → 1011,16 |
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) |
length = desc->length.fixed; |
else |
1061,6 → 1076,8 |
* |
* 1. Initial version. Checks batches and reports violations, but leaves |
* hardware parsing enabled (so does not allow new use cases). |
* 2. Allow access to the MI_PREDICATE_SRC0 and |
* MI_PREDICATE_SRC1 registers. |
*/ |
return 1; |
return 2; |
} |