Skip to content

Commit a923b18

Browse files
author
Iouri Tarassov
committed
drivers: hv: dxgkrnl: Implement D3DKMTEnumProcesses to match the Windows implementation
The behavior of D3DKMTEnumProcesses on Windows is that when buffer_count is 0 or input buffer is NULL, the number of active processes is returned. The Linux implemenation is updated to match this. Signed-off-by: Iouri Tarassov <[email protected]>
1 parent e2e5f60 commit a923b18

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

drivers/hv/dxgkrnl/dxgmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -965,4 +965,4 @@ module_exit(dxg_drv_exit);
965965

966966
MODULE_LICENSE("GPL");
967967
MODULE_DESCRIPTION("Microsoft Dxgkrnl virtual compute device Driver");
968-
MODULE_VERSION("2.0.2");
968+
MODULE_VERSION("2.0.3");

drivers/hv/dxgkrnl/ioctl.c

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5373,7 +5373,7 @@ dxgkio_enum_processes(struct dxgprocess *process, void *__user inargs)
53735373
struct dxgprocess_adapter *pentry;
53745374
int nump = 0; /* Current number of processes*/
53755375
struct ntstatus status;
5376-
int ret;
5376+
int ret, ret1;
53775377

53785378
ret = copy_from_user(&args, inargs, sizeof(args));
53795379
if (ret) {
@@ -5382,12 +5382,6 @@ dxgkio_enum_processes(struct dxgprocess *process, void *__user inargs)
53825382
goto cleanup;
53835383
}
53845384

5385-
if (args.buffer_count == 0) {
5386-
DXG_ERR("Invalid buffer count");
5387-
ret = -EINVAL;
5388-
goto cleanup;
5389-
}
5390-
53915385
dxgglobal_acquire_adapter_list_lock(DXGLOCK_SHARED);
53925386
dxgglobal_acquire_process_adapter_lock();
53935387

@@ -5405,6 +5399,19 @@ dxgkio_enum_processes(struct dxgprocess *process, void *__user inargs)
54055399
goto cleanup_locks;
54065400
}
54075401

5402+
list_for_each_entry(pentry, &adapter->adapter_process_list_head,
5403+
adapter_process_list_entry) {
5404+
if (pentry->process->nspid == task_active_pid_ns(current))
5405+
nump++;
5406+
}
5407+
5408+
if (nump > args.buffer_count || args.buffer == NULL) {
5409+
status.v = STATUS_BUFFER_TOO_SMALL;
5410+
ret = ntstatus2int(status);
5411+
goto cleanup_locks;
5412+
}
5413+
5414+
nump = 0;
54085415
list_for_each_entry(pentry, &adapter->adapter_process_list_head,
54095416
adapter_process_list_entry) {
54105417
if (pentry->process->nspid != task_active_pid_ns(current))
@@ -5429,10 +5436,10 @@ dxgkio_enum_processes(struct dxgprocess *process, void *__user inargs)
54295436
dxgglobal_release_process_adapter_lock();
54305437
dxgglobal_release_adapter_list_lock(DXGLOCK_SHARED);
54315438

5432-
if (ret == 0) {
5433-
ret = copy_to_user(&input->buffer_count, &nump, sizeof(u32));
5434-
if (ret)
5435-
DXG_ERR("failed to copy buffer count to user");
5439+
ret1 = copy_to_user(&input->buffer_count, &nump, sizeof(u32));
5440+
if (ret1) {
5441+
DXG_ERR("failed to copy buffer count to user");
5442+
ret = -EFAULT;
54365443
}
54375444

54385445
cleanup:

0 commit comments

Comments
 (0)