drm/vmwgfx: Make the object handles idr-generated
Instead of generating user-space object handles based on a, possibly processed, hash of the kernel address of the object, use idr to generate and lookup those handles. This might improve somewhat on security since we loose all connections to the object's kernel address. Also idr is designed to do just this. As a todo-item, since user-space handles are now generated in sequence, we can probably use a much simpler hash function to hash them. Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com> Reviewed-by: Sinclair Yeh <syeh@vmware.com> Reviewed-by: Deepak Rawat <drawat@vmware.com>
This commit is contained in:
@@ -755,14 +755,10 @@ static int vmw_context_define(struct drm_device *dev, void *data,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Approximate idr memory usage with 128 bytes. It will be limited
|
||||
* by maximum number_of contexts anyway.
|
||||
*/
|
||||
|
||||
if (unlikely(vmw_user_context_size == 0))
|
||||
vmw_user_context_size = ttm_round_pot(sizeof(*ctx)) + 128 +
|
||||
((dev_priv->has_mob) ? vmw_cmdbuf_res_man_size() : 0);
|
||||
vmw_user_context_size = ttm_round_pot(sizeof(*ctx)) +
|
||||
((dev_priv->has_mob) ? vmw_cmdbuf_res_man_size() : 0) +
|
||||
+ VMW_IDA_ACC_SIZE + TTM_OBJ_EXTRA_SIZE;
|
||||
|
||||
ret = ttm_read_lock(&dev_priv->reservation_sem, true);
|
||||
if (unlikely(ret != 0))
|
||||
@@ -807,7 +803,7 @@ static int vmw_context_define(struct drm_device *dev, void *data,
|
||||
goto out_err;
|
||||
}
|
||||
|
||||
arg->cid = ctx->base.hash.key;
|
||||
arg->cid = ctx->base.handle;
|
||||
out_err:
|
||||
vmw_resource_unreference(&res);
|
||||
out_unlock:
|
||||
|
Reference in New Issue
Block a user