drm/amdkfd: Check against device cgroup
authorHarish Kasiviswanathan <Harish.Kasiviswanathan@amd.com>
Mon, 20 Aug 2018 16:14:50 +0000 (12:14 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 7 Oct 2019 20:11:38 +0000 (15:11 -0500)
commit6b855f7b83d2fb0237263f143437aedf8caed152
treee0fc3a1ac296691c9743d63fe6acd4879c3cb05d
parent4b7d4d453fc46769394e31d1cb19088f49897b59
drm/amdkfd: Check against device cgroup

Participate in device cgroup. All kfd devices are exposed via /dev/kfd.
So use /dev/dri/renderN node.

Before exposing the device to a task check if it has permission to
access it. If the task (based on its cgroup) can access /dev/dri/renderN
then expose the device via kfd node.

If the task cannot access /dev/dri/renderN then process device data
(pdd) is not created. This will ensure that task cannot use the device.

In sysfs topology, all device nodes are visible irrespective of the task
cgroup. The sysfs node directories are created at driver load time and
cannot be changed dynamically. However, access to information inside
nodes is controlled based on the task's cgroup permissions.

Signed-off-by: Harish Kasiviswanathan <Harish.Kasiviswanathan@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_flat_memory.c
drivers/gpu/drm/amd/amdkfd/kfd_priv.h
drivers/gpu/drm/amd/amdkfd/kfd_topology.c