Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 148708
b: refs/heads/master
c: 83d6079
h: refs/heads/master
v: v3
  • Loading branch information
Chris Wilson authored and Eric Anholt committed Jun 9, 2009
1 parent 9921562 commit 716f8db
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: fa0864b26b4bfa1dd4bb78eeffbc1f398cb56425
refs/heads/master: 83d60795157c83389e6aaa0532d5e19afa976a24
38 changes: 27 additions & 11 deletions trunk/drivers/gpu/drm/i915/i915_gem.c
Original file line number Diff line number Diff line change
Expand Up @@ -3050,20 +3050,12 @@ i915_dispatch_gem_execbuffer(struct drm_device *dev,
drm_i915_private_t *dev_priv = dev->dev_private;
int nbox = exec->num_cliprects;
int i = 0, count;
uint32_t exec_start, exec_len;
uint32_t exec_start, exec_len;
RING_LOCALS;

exec_start = (uint32_t) exec_offset + exec->batch_start_offset;
exec_len = (uint32_t) exec->batch_len;

if ((exec_start | exec_len) & 0x7) {
DRM_ERROR("alignment\n");
return -EINVAL;
}

if (!exec_start)
return -EINVAL;

count = nbox ? nbox : 1;

for (i = 0; i < count; i++) {
Expand Down Expand Up @@ -3211,6 +3203,24 @@ i915_gem_put_relocs_to_user(struct drm_i915_gem_exec_object *exec_list,
return ret;
}

static int
i915_gem_check_execbuffer (struct drm_i915_gem_execbuffer *exec,
uint64_t exec_offset)
{
uint32_t exec_start, exec_len;

exec_start = (uint32_t) exec_offset + exec->batch_start_offset;
exec_len = (uint32_t) exec->batch_len;

if ((exec_start | exec_len) & 0x7)
return -EINVAL;

if (!exec_start)
return -EINVAL;

return 0;
}

int
i915_gem_execbuffer(struct drm_device *dev, void *data,
struct drm_file *file_priv)
Expand Down Expand Up @@ -3362,6 +3372,14 @@ i915_gem_execbuffer(struct drm_device *dev, void *data,
batch_obj->pending_read_domains = I915_GEM_DOMAIN_COMMAND;
batch_obj->pending_write_domain = 0;

/* Sanity check the batch buffer, prior to moving objects */
exec_offset = exec_list[args->buffer_count - 1].offset;
ret = i915_gem_check_execbuffer (args, exec_offset);
if (ret != 0) {
DRM_ERROR("execbuf with invalid offset/length\n");
goto err;
}

i915_verify_inactive(dev, __FILE__, __LINE__);

/* Zero the global flush/invalidate flags. These
Expand Down Expand Up @@ -3410,8 +3428,6 @@ i915_gem_execbuffer(struct drm_device *dev, void *data,
}
#endif

exec_offset = exec_list[args->buffer_count - 1].offset;

#if WATCH_EXEC
i915_gem_dump_object(batch_obj,
args->batch_len,
Expand Down

0 comments on commit 716f8db

Please sign in to comment.