amdkfd: Disable support for 32-bit user processes
authorOded Gabbay <oded.gabbay@amd.com>
Fri, 5 Dec 2014 08:40:34 +0000 (10:40 +0200)
committerOded Gabbay <oded.gabbay@amd.com>
Fri, 5 Dec 2014 20:01:35 +0000 (22:01 +0200)
This patch checks if the process that opens the /dev/kfd device is 32-bit
process. If so, it returns -EPERM and prints a warning message in dmesg.

This is done to prevent 32-bit user processes from using amdkfd, and hence, HSA
features.

AMD's HSA userspace stack will also support only 64-bit processes on Linux.

Reviewed-by: Alexey Skidanov <alexey.skidanov@amd.com>
Signed-off-by: Oded Gabbay <oded.gabbay@amd.com>
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c

index 102cd36799b129d4680567bb3de912a73b3070a9..4f7b275f2f7b0fdbb488055057c3291a1aab3a70 100644 (file)
@@ -102,15 +102,26 @@ struct device *kfd_chardev(void)
 static int kfd_open(struct inode *inode, struct file *filep)
 {
        struct kfd_process *process;
+       bool is_32bit_user_mode;
 
        if (iminor(inode) != 0)
                return -ENODEV;
 
+       is_32bit_user_mode = is_compat_task();
+
+       if (is_32bit_user_mode == true) {
+               dev_warn(kfd_device,
+                       "Process %d (32-bit) failed to open /dev/kfd\n"
+                       "32-bit processes are not supported by amdkfd\n",
+                       current->pid);
+               return -EPERM;
+       }
+
        process = kfd_create_process(current);
        if (IS_ERR(process))
                return PTR_ERR(process);
 
-       process->is_32bit_user_mode = is_compat_task();
+       process->is_32bit_user_mode = is_32bit_user_mode;
 
        dev_dbg(kfd_device, "process %d opened, compat mode (32 bit) - %d\n",
                process->pasid, process->is_32bit_user_mode);