Skip to content

Commit ea0b163

Browse files
bwhacksjbloomfi-intel
authored andcommitted
drm/i915/cmdparser: Fix jump whitelist clearing
When a jump_whitelist bitmap is reused, it needs to be cleared. Currently this is done with memset() and the size calculation assumes bitmaps are made of 32-bit words, not longs. So on 64-bit architectures, only the first half of the bitmap is cleared. If some whitelist bits are carried over between successive batches submitted on the same context, this will presumably allow embedding the rogue instructions that we're trying to reject. Use bitmap_zero() instead, which gets the calculation right. Fixes: f8c08d8 ("drm/i915/cmdparser: Add support for backward jumps") Signed-off-by: Ben Hutchings <[email protected]> Signed-off-by: Jon Bloomfield <[email protected]>
1 parent 7e34f4e commit ea0b163

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

drivers/gpu/drm/i915/i915_cmd_parser.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,7 +1375,7 @@ static void init_whitelist(struct i915_gem_context *ctx, u32 batch_len)
13751375
return;
13761376

13771377
if (batch_cmds <= ctx->jump_whitelist_cmds) {
1378-
memset(ctx->jump_whitelist, 0, exact_size * sizeof(u32));
1378+
bitmap_zero(ctx->jump_whitelist, batch_cmds);
13791379
return;
13801380
}
13811381

@@ -1395,8 +1395,7 @@ static void init_whitelist(struct i915_gem_context *ctx, u32 batch_len)
13951395
}
13961396

13971397
DRM_DEBUG("CMD: Failed to extend whitelist. BB_START may be disallowed\n");
1398-
memset(ctx->jump_whitelist, 0,
1399-
BITS_TO_LONGS(ctx->jump_whitelist_cmds) * sizeof(u32));
1398+
bitmap_zero(ctx->jump_whitelist, ctx->jump_whitelist_cmds);
14001399

14011400
return;
14021401
}

0 commit comments

Comments
 (0)