Skip to content

Commit 311a50e

Browse files
drm/i915: Add support for mandatory cmdparsing
The existing cmdparser for gen7 can be bypassed by specifying batch_len=0 in the execbuf call. This is safe because bypassing simply reduces the cmd-set available. In a later patch we will introduce cmdparsing for gen9, as a security measure, which must be strictly enforced since without it we are vulnerable to DoS attacks. Introduce the concept of 'required' cmd parsing that cannot be bypassed by submitting zero-length bb's. v2: rebase (Mika) v2: rebase (Mika) v3: fix conflict on engine flags (Mika) Signed-off-by: Jon Bloomfield <[email protected]> Cc: Tony Luck <[email protected]> Cc: Dave Airlie <[email protected]> Cc: Takashi Iwai <[email protected]> Cc: Tyler Hicks <[email protected]> Signed-off-by: Mika Kuoppala <[email protected]> Reviewed-by: Chris Wilson <[email protected]>
1 parent 66d8aba commit 311a50e

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,8 @@ static inline u64 gen8_noncanonical_addr(u64 address)
296296

297297
static inline bool eb_use_cmdparser(const struct i915_execbuffer *eb)
298298
{
299-
return intel_engine_needs_cmd_parser(eb->engine) && eb->batch_len;
299+
return intel_engine_requires_cmd_parser(eb->engine) ||
300+
(intel_engine_using_cmd_parser(eb->engine) && eb->batch_len);
300301
}
301302

302303
static int eb_create(struct i915_execbuffer *eb)

drivers/gpu/drm/i915/gt/intel_engine_types.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,12 +475,13 @@ struct intel_engine_cs {
475475

476476
struct intel_engine_hangcheck hangcheck;
477477

478-
#define I915_ENGINE_NEEDS_CMD_PARSER BIT(0)
478+
#define I915_ENGINE_USING_CMD_PARSER BIT(0)
479479
#define I915_ENGINE_SUPPORTS_STATS BIT(1)
480480
#define I915_ENGINE_HAS_PREEMPTION BIT(2)
481481
#define I915_ENGINE_HAS_SEMAPHORES BIT(3)
482482
#define I915_ENGINE_NEEDS_BREADCRUMB_TASKLET BIT(4)
483483
#define I915_ENGINE_IS_VIRTUAL BIT(5)
484+
#define I915_ENGINE_REQUIRES_CMD_PARSER BIT(7)
484485
unsigned int flags;
485486

486487
/*
@@ -541,9 +542,15 @@ struct intel_engine_cs {
541542
};
542543

543544
static inline bool
544-
intel_engine_needs_cmd_parser(const struct intel_engine_cs *engine)
545+
intel_engine_using_cmd_parser(const struct intel_engine_cs *engine)
545546
{
546-
return engine->flags & I915_ENGINE_NEEDS_CMD_PARSER;
547+
return engine->flags & I915_ENGINE_USING_CMD_PARSER;
548+
}
549+
550+
static inline bool
551+
intel_engine_requires_cmd_parser(const struct intel_engine_cs *engine)
552+
{
553+
return engine->flags & I915_ENGINE_REQUIRES_CMD_PARSER;
547554
}
548555

549556
static inline bool

drivers/gpu/drm/i915/i915_cmd_parser.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ void intel_engine_init_cmd_parser(struct intel_engine_cs *engine)
918918
return;
919919
}
920920

921-
engine->flags |= I915_ENGINE_NEEDS_CMD_PARSER;
921+
engine->flags |= I915_ENGINE_USING_CMD_PARSER;
922922
}
923923

924924
/**
@@ -930,7 +930,7 @@ void intel_engine_init_cmd_parser(struct intel_engine_cs *engine)
930930
*/
931931
void intel_engine_cleanup_cmd_parser(struct intel_engine_cs *engine)
932932
{
933-
if (!intel_engine_needs_cmd_parser(engine))
933+
if (!intel_engine_using_cmd_parser(engine))
934934
return;
935935

936936
fini_hash_table(engine);
@@ -1317,7 +1317,7 @@ int i915_cmd_parser_get_version(struct drm_i915_private *dev_priv)
13171317

13181318
/* If the command parser is not enabled, report 0 - unsupported */
13191319
for_each_uabi_engine(engine, dev_priv) {
1320-
if (intel_engine_needs_cmd_parser(engine)) {
1320+
if (intel_engine_using_cmd_parser(engine)) {
13211321
active = true;
13221322
break;
13231323
}

0 commit comments

Comments
 (0)