[PATCH v1 6/9] drivers: hv: dxgkrnl: Seal the shared resource object when dxgk_share_objects is called.

From: Iouri Tarassov
Date: Wed Jan 12 2022 - 14:57:01 EST


A dxgresource object is a collection of dxgallocation objects.
The WDDM API allows addition/removal allocations to a resource.
The WDDM API has limitations on addition/removal of allocations to
a shared resource. When a resource is "sealed", addition/removal of
allocations is not allowed.

Signed-off-by: Iouri Tarassov <iourit@xxxxxxxxxxxxxxxxxxx>
---
drivers/hv/dxgkrnl/ioctl.c | 36 ++++++++++++++++++++++++++++--------
1 file changed, 28 insertions(+), 8 deletions(-)

diff --git a/drivers/hv/dxgkrnl/ioctl.c b/drivers/hv/dxgkrnl/ioctl.c
index 2086f7347ba3..97f4d2471ca5 100644
--- a/drivers/hv/dxgkrnl/ioctl.c
+++ b/drivers/hv/dxgkrnl/ioctl.c
@@ -2767,18 +2767,38 @@ dxgk_share_objects(struct dxgprocess *process, void *__user inargs)
case HMGRENTRY_TYPE_DXGSYNCOBJECT:
ret = get_object_fd(DXG_SHARED_SYNCOBJECT, shared_syncobj,
&object_fd);
- if (ret >= 0)
- ret =
- dxgsharedsyncobj_get_host_nt_handle(shared_syncobj,
- process,
- handles[0]);
+ if (ret < 0) {
+ pr_err("%s get_object_fd failed for sync object",
+ __func__);
+ goto cleanup;
+ }
+ ret = dxgsharedsyncobj_get_host_nt_handle(shared_syncobj,
+ process,
+ handles[0]);
+ if (ret < 0) {
+ pr_err("%s get_host_nt_handle failed", __func__);
+ goto cleanup;
+ }
break;
case HMGRENTRY_TYPE_DXGRESOURCE:
ret = get_object_fd(DXG_SHARED_RESOURCE, shared_resource,
&object_fd);
- if (ret >= 0)
- ret = dxgsharedresource_get_host_nt_handle(
- shared_resource, process, handles[0]);
+ if (ret < 0) {
+ pr_err("%s get_object_fd failed for resource",
+ __func__);
+ goto cleanup;
+ }
+ ret = dxgsharedresource_get_host_nt_handle(shared_resource,
+ process, handles[0]);
+ if (ret < 0) {
+ pr_err("%s get_host_res_nt_handle failed", __func__);
+ goto cleanup;
+ }
+ ret = dxgsharedresource_seal(shared_resource);
+ if (ret < 0) {
+ pr_err("%s dxgsharedresource_seal failed", __func__);
+ goto cleanup;
+ }
break;
default:
ret = -EINVAL;
--
2.32.0