53
53
* granting userspace undue privileges. There are three categories of privilege.
54
54
*
55
55
* 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
58
57
*
59
58
* Second, commands which access registers. To support correct/enhanced
60
59
* 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
63
61
*
64
62
* Third, commands which access privileged memory (i.e. GGTT, HWS page, etc).
65
63
* The parser always rejects such commands.
84
82
* in the per-engine command tables.
85
83
*
86
84
* 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.
90
88
*/
91
89
92
90
/*
@@ -104,16 +102,13 @@ struct drm_i915_cmd_descriptor {
104
102
* CMD_DESC_REJECT: The command is never allowed
105
103
* CMD_DESC_REGISTER: The command should be checked against the
106
104
* register whitelist for the appropriate ring
107
- * CMD_DESC_MASTER: The command is allowed if the submitting process
108
- * is the DRM master
109
105
*/
110
106
u32 flags ;
111
107
#define CMD_DESC_FIXED (1<<0)
112
108
#define CMD_DESC_SKIP (1<<1)
113
109
#define CMD_DESC_REJECT (1<<2)
114
110
#define CMD_DESC_REGISTER (1<<3)
115
111
#define CMD_DESC_BITMASK (1<<4)
116
- #define CMD_DESC_MASTER (1<<5)
117
112
118
113
/*
119
114
* The command's unique identification bits and the bitmask to get them.
@@ -209,14 +204,13 @@ struct drm_i915_cmd_table {
209
204
#define R CMD_DESC_REJECT
210
205
#define W CMD_DESC_REGISTER
211
206
#define B CMD_DESC_BITMASK
212
- #define M CMD_DESC_MASTER
213
207
214
208
/* Command Mask Fixed Len Action
215
209
---------------------------------------------------------- */
216
210
static const struct drm_i915_cmd_descriptor gen7_common_cmds [] = {
217
211
CMD ( MI_NOOP , SMI , F , 1 , S ),
218
212
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 ),
220
214
CMD ( MI_ARB_CHECK , SMI , F , 1 , S ),
221
215
CMD ( MI_REPORT_HEAD , SMI , F , 1 , S ),
222
216
CMD ( MI_SUSPEND_FLUSH , SMI , F , 1 , S ),
@@ -313,7 +307,7 @@ static const struct drm_i915_cmd_descriptor hsw_render_cmds[] = {
313
307
CMD ( MI_URB_ATOMIC_ALLOC , SMI , F , 1 , S ),
314
308
CMD ( MI_SET_APPID , SMI , F , 1 , S ),
315
309
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 ),
317
311
CMD ( MI_LOAD_SCAN_LINES_EXCL , SMI , !F , 0x3F , R ),
318
312
CMD ( MI_LOAD_REGISTER_REG , SMI , !F , 0xFF , W ,
319
313
.reg = { .offset = 1 , .mask = 0x007FFFFC , .step = 1 } ),
@@ -446,7 +440,7 @@ static const struct drm_i915_cmd_descriptor gen7_blt_cmds[] = {
446
440
};
447
441
448
442
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 ),
450
444
CMD ( MI_LOAD_SCAN_LINES_EXCL , SMI , !F , 0x3F , R ),
451
445
};
452
446
@@ -463,7 +457,6 @@ static const struct drm_i915_cmd_descriptor noop_desc =
463
457
#undef R
464
458
#undef W
465
459
#undef B
466
- #undef M
467
460
468
461
static const struct drm_i915_cmd_table gen7_render_cmd_table [] = {
469
462
{ gen7_common_cmds , ARRAY_SIZE (gen7_common_cmds ) },
@@ -612,47 +605,29 @@ static const struct drm_i915_reg_descriptor gen7_blt_regs[] = {
612
605
REG64_IDX (RING_TIMESTAMP , BLT_RING_BASE ),
613
606
};
614
607
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
-
628
608
#undef REG64
629
609
#undef REG32
630
610
631
611
struct drm_i915_reg_table {
632
612
const struct drm_i915_reg_descriptor * regs ;
633
613
int num_regs ;
634
- bool master ;
635
614
};
636
615
637
616
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 ) },
640
618
};
641
619
642
620
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 ) },
645
622
};
646
623
647
624
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 ) },
651
627
};
652
628
653
629
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 ) },
656
631
};
657
632
658
633
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)
1029
1004
}
1030
1005
1031
1006
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 )
1033
1008
{
1034
1009
const struct drm_i915_reg_table * table = engine -> reg_tables ;
1010
+ const struct drm_i915_reg_descriptor * reg = NULL ;
1035
1011
int count = engine -> reg_table_count ;
1036
1012
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 );
1040
1015
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 ;
1048
1017
}
1049
1018
1050
1019
/* 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,
1128
1097
1129
1098
static bool check_cmd (const struct intel_engine_cs * engine ,
1130
1099
const struct drm_i915_cmd_descriptor * desc ,
1131
- const u32 * cmd , u32 length ,
1132
- const bool is_master )
1100
+ const u32 * cmd , u32 length )
1133
1101
{
1134
1102
if (desc -> flags & CMD_DESC_SKIP )
1135
1103
return true;
@@ -1139,12 +1107,6 @@ static bool check_cmd(const struct intel_engine_cs *engine,
1139
1107
return false;
1140
1108
}
1141
1109
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
-
1148
1110
if (desc -> flags & CMD_DESC_REGISTER ) {
1149
1111
/*
1150
1112
* Get the distance between individual register offset
@@ -1158,7 +1120,7 @@ static bool check_cmd(const struct intel_engine_cs *engine,
1158
1120
offset += step ) {
1159
1121
const u32 reg_addr = cmd [offset ] & desc -> reg .mask ;
1160
1122
const struct drm_i915_reg_descriptor * reg =
1161
- find_reg (engine , is_master , reg_addr );
1123
+ find_reg (engine , reg_addr );
1162
1124
1163
1125
if (!reg ) {
1164
1126
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,
1245
1207
* @shadow_batch_obj: copy of the batch buffer in question
1246
1208
* @batch_start_offset: byte offset in the batch at which execution starts
1247
1209
* @batch_len: length of the commands in batch_obj
1248
- * @is_master: is the submitting process the drm master?
1249
1210
*
1250
1211
* Parses the specified batch buffer looking for privilege violations as
1251
1212
* described in the overview.
@@ -1257,8 +1218,7 @@ int intel_engine_cmd_parser(struct intel_engine_cs *engine,
1257
1218
struct drm_i915_gem_object * batch_obj ,
1258
1219
struct drm_i915_gem_object * shadow_batch_obj ,
1259
1220
u32 batch_start_offset ,
1260
- u32 batch_len ,
1261
- bool is_master )
1221
+ u32 batch_len )
1262
1222
{
1263
1223
u32 * cmd , * batch_end ;
1264
1224
struct drm_i915_cmd_descriptor default_desc = noop_desc ;
@@ -1324,7 +1284,7 @@ int intel_engine_cmd_parser(struct intel_engine_cs *engine,
1324
1284
break ;
1325
1285
}
1326
1286
1327
- if (!check_cmd (engine , desc , cmd , length , is_master )) {
1287
+ if (!check_cmd (engine , desc , cmd , length )) {
1328
1288
ret = - EACCES ;
1329
1289
break ;
1330
1290
}
0 commit comments