提交 ea0b163b 编写于 作者: B Ben Hutchings 提交者: Jon Bloomfield

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: f8c08d8f ("drm/i915/cmdparser: Add support for backward jumps")
Signed-off-by: NBen Hutchings <ben@decadent.org.uk>
Signed-off-by: NJon Bloomfield <jon.bloomfield@intel.com>
上级 7e34f4e4
...@@ -1375,7 +1375,7 @@ static void init_whitelist(struct i915_gem_context *ctx, u32 batch_len) ...@@ -1375,7 +1375,7 @@ static void init_whitelist(struct i915_gem_context *ctx, u32 batch_len)
return; return;
if (batch_cmds <= ctx->jump_whitelist_cmds) { if (batch_cmds <= ctx->jump_whitelist_cmds) {
memset(ctx->jump_whitelist, 0, exact_size * sizeof(u32)); bitmap_zero(ctx->jump_whitelist, batch_cmds);
return; return;
} }
...@@ -1395,8 +1395,7 @@ static void init_whitelist(struct i915_gem_context *ctx, u32 batch_len) ...@@ -1395,8 +1395,7 @@ static void init_whitelist(struct i915_gem_context *ctx, u32 batch_len)
} }
DRM_DEBUG("CMD: Failed to extend whitelist. BB_START may be disallowed\n"); DRM_DEBUG("CMD: Failed to extend whitelist. BB_START may be disallowed\n");
memset(ctx->jump_whitelist, 0, bitmap_zero(ctx->jump_whitelist, ctx->jump_whitelist_cmds);
BITS_TO_LONGS(ctx->jump_whitelist_cmds) * sizeof(u32));
return; return;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册