Skip to content

Commit 66d8aba

Browse files
drm/i915: Remove Master tables from cmdparser
The previous patch has killed support for secure batches on gen6+, and hence the cmdparsers master tables are now dead code. Remove them. 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]> Reviewed-by: Chris Wilson <[email protected]>
1 parent 4415764 commit 66d8aba

File tree

3 files changed

+26
-68
lines changed

3 files changed

+26
-68
lines changed

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1955,7 +1955,7 @@ static int i915_reset_gen7_sol_offsets(struct i915_request *rq)
19551955
return 0;
19561956
}
19571957

1958-
static struct i915_vma *eb_parse(struct i915_execbuffer *eb, bool is_master)
1958+
static struct i915_vma *eb_parse(struct i915_execbuffer *eb)
19591959
{
19601960
struct intel_engine_pool_node *pool;
19611961
struct i915_vma *vma;
@@ -1969,8 +1969,7 @@ static struct i915_vma *eb_parse(struct i915_execbuffer *eb, bool is_master)
19691969
eb->batch->obj,
19701970
pool->obj,
19711971
eb->batch_start_offset,
1972-
eb->batch_len,
1973-
is_master);
1972+
eb->batch_len);
19741973
if (err) {
19751974
if (err == -EACCES) /* unhandled chained batch */
19761975
vma = NULL;
@@ -2541,7 +2540,7 @@ i915_gem_do_execbuffer(struct drm_device *dev,
25412540
if (eb_use_cmdparser(&eb)) {
25422541
struct i915_vma *vma;
25432542

2544-
vma = eb_parse(&eb, drm_is_current_master(file));
2543+
vma = eb_parse(&eb);
25452544
if (IS_ERR(vma)) {
25462545
err = PTR_ERR(vma);
25472546
goto err_vma;

drivers/gpu/drm/i915/i915_cmd_parser.c

Lines changed: 22 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,11 @@
5353
* granting userspace undue privileges. There are three categories of privilege.
5454
*
5555
* First, commands which are explicitly defined as privileged or which should
56-
* only be used by the kernel driver. The parser generally rejects such
57-
* commands, though it may allow some from the drm master process.
56+
* only be used by the kernel driver. The parser rejects such commands
5857
*
5958
* Second, commands which access registers. To support correct/enhanced
6059
* userspace functionality, particularly certain OpenGL extensions, the parser
61-
* provides a whitelist of registers which userspace may safely access (for both
62-
* normal and drm master processes).
60+
* provides a whitelist of registers which userspace may safely access
6361
*
6462
* Third, commands which access privileged memory (i.e. GGTT, HWS page, etc).
6563
* The parser always rejects such commands.
@@ -84,9 +82,9 @@
8482
* in the per-engine command tables.
8583
*
8684
* Other command table entries map fairly directly to high level categories
87-
* mentioned above: rejected, master-only, register whitelist. The parser
88-
* implements a number of checks, including the privileged memory checks, via a
89-
* general bitmasking mechanism.
85+
* mentioned above: rejected, register whitelist. The parser implements a number
86+
* of checks, including the privileged memory checks, via a general bitmasking
87+
* mechanism.
9088
*/
9189

9290
/*
@@ -104,16 +102,13 @@ struct drm_i915_cmd_descriptor {
104102
* CMD_DESC_REJECT: The command is never allowed
105103
* CMD_DESC_REGISTER: The command should be checked against the
106104
* register whitelist for the appropriate ring
107-
* CMD_DESC_MASTER: The command is allowed if the submitting process
108-
* is the DRM master
109105
*/
110106
u32 flags;
111107
#define CMD_DESC_FIXED (1<<0)
112108
#define CMD_DESC_SKIP (1<<1)
113109
#define CMD_DESC_REJECT (1<<2)
114110
#define CMD_DESC_REGISTER (1<<3)
115111
#define CMD_DESC_BITMASK (1<<4)
116-
#define CMD_DESC_MASTER (1<<5)
117112

118113
/*
119114
* The command's unique identification bits and the bitmask to get them.
@@ -209,14 +204,13 @@ struct drm_i915_cmd_table {
209204
#define R CMD_DESC_REJECT
210205
#define W CMD_DESC_REGISTER
211206
#define B CMD_DESC_BITMASK
212-
#define M CMD_DESC_MASTER
213207

214208
/* Command Mask Fixed Len Action
215209
---------------------------------------------------------- */
216210
static const struct drm_i915_cmd_descriptor gen7_common_cmds[] = {
217211
CMD( MI_NOOP, SMI, F, 1, S ),
218212
CMD( MI_USER_INTERRUPT, SMI, F, 1, R ),
219-
CMD( MI_WAIT_FOR_EVENT, SMI, F, 1, M ),
213+
CMD( MI_WAIT_FOR_EVENT, SMI, F, 1, R ),
220214
CMD( MI_ARB_CHECK, SMI, F, 1, S ),
221215
CMD( MI_REPORT_HEAD, SMI, F, 1, S ),
222216
CMD( MI_SUSPEND_FLUSH, SMI, F, 1, S ),
@@ -313,7 +307,7 @@ static const struct drm_i915_cmd_descriptor hsw_render_cmds[] = {
313307
CMD( MI_URB_ATOMIC_ALLOC, SMI, F, 1, S ),
314308
CMD( MI_SET_APPID, SMI, F, 1, S ),
315309
CMD( MI_RS_CONTEXT, SMI, F, 1, S ),
316-
CMD( MI_LOAD_SCAN_LINES_INCL, SMI, !F, 0x3F, M ),
310+
CMD( MI_LOAD_SCAN_LINES_INCL, SMI, !F, 0x3F, R ),
317311
CMD( MI_LOAD_SCAN_LINES_EXCL, SMI, !F, 0x3F, R ),
318312
CMD( MI_LOAD_REGISTER_REG, SMI, !F, 0xFF, W,
319313
.reg = { .offset = 1, .mask = 0x007FFFFC, .step = 1 } ),
@@ -446,7 +440,7 @@ static const struct drm_i915_cmd_descriptor gen7_blt_cmds[] = {
446440
};
447441

448442
static const struct drm_i915_cmd_descriptor hsw_blt_cmds[] = {
449-
CMD( MI_LOAD_SCAN_LINES_INCL, SMI, !F, 0x3F, M ),
443+
CMD( MI_LOAD_SCAN_LINES_INCL, SMI, !F, 0x3F, R ),
450444
CMD( MI_LOAD_SCAN_LINES_EXCL, SMI, !F, 0x3F, R ),
451445
};
452446

@@ -463,7 +457,6 @@ static const struct drm_i915_cmd_descriptor noop_desc =
463457
#undef R
464458
#undef W
465459
#undef B
466-
#undef M
467460

468461
static const struct drm_i915_cmd_table gen7_render_cmd_table[] = {
469462
{ gen7_common_cmds, ARRAY_SIZE(gen7_common_cmds) },
@@ -612,47 +605,29 @@ static const struct drm_i915_reg_descriptor gen7_blt_regs[] = {
612605
REG64_IDX(RING_TIMESTAMP, BLT_RING_BASE),
613606
};
614607

615-
static const struct drm_i915_reg_descriptor ivb_master_regs[] = {
616-
REG32(FORCEWAKE_MT),
617-
REG32(DERRMR),
618-
REG32(GEN7_PIPE_DE_LOAD_SL(PIPE_A)),
619-
REG32(GEN7_PIPE_DE_LOAD_SL(PIPE_B)),
620-
REG32(GEN7_PIPE_DE_LOAD_SL(PIPE_C)),
621-
};
622-
623-
static const struct drm_i915_reg_descriptor hsw_master_regs[] = {
624-
REG32(FORCEWAKE_MT),
625-
REG32(DERRMR),
626-
};
627-
628608
#undef REG64
629609
#undef REG32
630610

631611
struct drm_i915_reg_table {
632612
const struct drm_i915_reg_descriptor *regs;
633613
int num_regs;
634-
bool master;
635614
};
636615

637616
static const struct drm_i915_reg_table ivb_render_reg_tables[] = {
638-
{ gen7_render_regs, ARRAY_SIZE(gen7_render_regs), false },
639-
{ ivb_master_regs, ARRAY_SIZE(ivb_master_regs), true },
617+
{ gen7_render_regs, ARRAY_SIZE(gen7_render_regs) },
640618
};
641619

642620
static const struct drm_i915_reg_table ivb_blt_reg_tables[] = {
643-
{ gen7_blt_regs, ARRAY_SIZE(gen7_blt_regs), false },
644-
{ ivb_master_regs, ARRAY_SIZE(ivb_master_regs), true },
621+
{ gen7_blt_regs, ARRAY_SIZE(gen7_blt_regs) },
645622
};
646623

647624
static const struct drm_i915_reg_table hsw_render_reg_tables[] = {
648-
{ gen7_render_regs, ARRAY_SIZE(gen7_render_regs), false },
649-
{ hsw_render_regs, ARRAY_SIZE(hsw_render_regs), false },
650-
{ hsw_master_regs, ARRAY_SIZE(hsw_master_regs), true },
625+
{ gen7_render_regs, ARRAY_SIZE(gen7_render_regs) },
626+
{ hsw_render_regs, ARRAY_SIZE(hsw_render_regs) },
651627
};
652628

653629
static const struct drm_i915_reg_table hsw_blt_reg_tables[] = {
654-
{ gen7_blt_regs, ARRAY_SIZE(gen7_blt_regs), false },
655-
{ hsw_master_regs, ARRAY_SIZE(hsw_master_regs), true },
630+
{ gen7_blt_regs, ARRAY_SIZE(gen7_blt_regs) },
656631
};
657632

658633
static u32 gen7_render_get_cmd_length_mask(u32 cmd_header)
@@ -1029,22 +1004,16 @@ __find_reg(const struct drm_i915_reg_descriptor *table, int count, u32 addr)
10291004
}
10301005

10311006
static const struct drm_i915_reg_descriptor *
1032-
find_reg(const struct intel_engine_cs *engine, bool is_master, u32 addr)
1007+
find_reg(const struct intel_engine_cs *engine, u32 addr)
10331008
{
10341009
const struct drm_i915_reg_table *table = engine->reg_tables;
1010+
const struct drm_i915_reg_descriptor *reg = NULL;
10351011
int count = engine->reg_table_count;
10361012

1037-
for (; count > 0; ++table, --count) {
1038-
if (!table->master || is_master) {
1039-
const struct drm_i915_reg_descriptor *reg;
1013+
for (; !reg && (count > 0); ++table, --count)
1014+
reg = __find_reg(table->regs, table->num_regs, addr);
10401015

1041-
reg = __find_reg(table->regs, table->num_regs, addr);
1042-
if (reg != NULL)
1043-
return reg;
1044-
}
1045-
}
1046-
1047-
return NULL;
1016+
return reg;
10481017
}
10491018

10501019
/* Returns a vmap'd pointer to dst_obj, which the caller must unmap */
@@ -1128,8 +1097,7 @@ static u32 *copy_batch(struct drm_i915_gem_object *dst_obj,
11281097

11291098
static bool check_cmd(const struct intel_engine_cs *engine,
11301099
const struct drm_i915_cmd_descriptor *desc,
1131-
const u32 *cmd, u32 length,
1132-
const bool is_master)
1100+
const u32 *cmd, u32 length)
11331101
{
11341102
if (desc->flags & CMD_DESC_SKIP)
11351103
return true;
@@ -1139,12 +1107,6 @@ static bool check_cmd(const struct intel_engine_cs *engine,
11391107
return false;
11401108
}
11411109

1142-
if ((desc->flags & CMD_DESC_MASTER) && !is_master) {
1143-
DRM_DEBUG_DRIVER("CMD: Rejected master-only command: 0x%08X\n",
1144-
*cmd);
1145-
return false;
1146-
}
1147-
11481110
if (desc->flags & CMD_DESC_REGISTER) {
11491111
/*
11501112
* Get the distance between individual register offset
@@ -1158,7 +1120,7 @@ static bool check_cmd(const struct intel_engine_cs *engine,
11581120
offset += step) {
11591121
const u32 reg_addr = cmd[offset] & desc->reg.mask;
11601122
const struct drm_i915_reg_descriptor *reg =
1161-
find_reg(engine, is_master, reg_addr);
1123+
find_reg(engine, reg_addr);
11621124

11631125
if (!reg) {
11641126
DRM_DEBUG_DRIVER("CMD: Rejected register 0x%08X in command: 0x%08X (%s)\n",
@@ -1245,7 +1207,6 @@ static bool check_cmd(const struct intel_engine_cs *engine,
12451207
* @shadow_batch_obj: copy of the batch buffer in question
12461208
* @batch_start_offset: byte offset in the batch at which execution starts
12471209
* @batch_len: length of the commands in batch_obj
1248-
* @is_master: is the submitting process the drm master?
12491210
*
12501211
* Parses the specified batch buffer looking for privilege violations as
12511212
* described in the overview.
@@ -1257,8 +1218,7 @@ int intel_engine_cmd_parser(struct intel_engine_cs *engine,
12571218
struct drm_i915_gem_object *batch_obj,
12581219
struct drm_i915_gem_object *shadow_batch_obj,
12591220
u32 batch_start_offset,
1260-
u32 batch_len,
1261-
bool is_master)
1221+
u32 batch_len)
12621222
{
12631223
u32 *cmd, *batch_end;
12641224
struct drm_i915_cmd_descriptor default_desc = noop_desc;
@@ -1324,7 +1284,7 @@ int intel_engine_cmd_parser(struct intel_engine_cs *engine,
13241284
break;
13251285
}
13261286

1327-
if (!check_cmd(engine, desc, cmd, length, is_master)) {
1287+
if (!check_cmd(engine, desc, cmd, length)) {
13281288
ret = -EACCES;
13291289
break;
13301290
}

drivers/gpu/drm/i915/i915_drv.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2398,8 +2398,7 @@ int intel_engine_cmd_parser(struct intel_engine_cs *engine,
23982398
struct drm_i915_gem_object *batch_obj,
23992399
struct drm_i915_gem_object *shadow_batch_obj,
24002400
u32 batch_start_offset,
2401-
u32 batch_len,
2402-
bool is_master);
2401+
u32 batch_len);
24032402

24042403
/* intel_device_info.c */
24052404
static inline struct intel_device_info *

0 commit comments

Comments
 (0)