]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
amdkfd: process svm ioctl only on the primary kfd process
authorZhu Lingshan <lingshan.zhu@amd.com>
Fri, 14 Feb 2025 06:06:19 +0000 (14:06 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 8 Dec 2025 18:56:41 +0000 (13:56 -0500)
svm ioctl should only be processed on the primary
kfd process because only the lifecycle of the
primary kfd process is tied to the  user space
applicaiton.

Another reason is in virtualization the hypervisor owns
the primary kfd process as a privileged one.

Signed-off-by: Zhu Lingshan <lingshan.zhu@amd.com>
Reviewed-by: Felix Kuehling <felix.kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c

index 1eb826d9208e3d1d6f85f96241a4f3a948ee4b65..2226281e8146c3fca61dae5a6090538c71321ea5 100644 (file)
@@ -1718,6 +1718,12 @@ static int kfd_ioctl_svm(struct file *filep, struct kfd_process *p, void *data)
        struct kfd_ioctl_svm_args *args = data;
        int r = 0;
 
+       if (p->context_id != KFD_CONTEXT_ID_PRIMARY) {
+               pr_debug("SVM ioctl not supported on non-primary kfd process\n");
+
+               return -EOPNOTSUPP;
+       }
+
        pr_debug("start 0x%llx size 0x%llx op 0x%x nattr 0x%x\n",
                 args->start_addr, args->size, args->op, args->nattr);