gpu: nvgpu: bind sched domains as fds

Replace id-based lookup with fd-based lookup when binding a TSG to a
domain. The device node based domain interface naturally provides access
control; this way userspace tools can limit which uid/gid can access
each domain.

Also, explicitly disallow binding channels to a TSG that has no runlist
domain yet. Normally a TSG is in the default domain if nothing else has
been specified, but the default domain can be deleted.

Jira NVGPU-6788

Change-Id: I2af96dfc002367d894eaf0c175006332f790c27f
Signed-off-by: Konsta Hölttä <kholtta@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2651165
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Alex Waterman <alexw@nvidia.com>
GVS: Gerrit_Virtual_Submit
This commit is contained in:
Konsta Hölttä
2022-02-23 12:10:50 +02:00
committed by mobile promotions
parent 3a64fdefc4
commit 2a8914619d
4 changed files with 42 additions and 18 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2021, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2014-2022, NVIDIA CORPORATION. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -36,10 +36,12 @@
#include <nvgpu/nvgpu_init.h>
#include <nvgpu/grmgr.h>
#include <nvgpu/ltc.h>
#include <nvgpu/nvs.h>
#include "platform_gk20a.h"
#include "ioctl_tsg.h"
#include "ioctl_channel.h"
#include "ioctl_nvs.h"
#include "ioctl.h"
#include "os_linux.h"
@@ -180,6 +182,12 @@ out:
static int nvgpu_tsg_bind_scheduling_domain(struct nvgpu_tsg *tsg,
struct nvgpu_tsg_bind_scheduling_domain_args *args)
{
struct nvgpu_nvs_domain *domain;
int err;
if (args->reserved0 != 0) {
return -EINVAL;
}
if (args->reserved[0] != 0) {
return -EINVAL;
@@ -197,7 +205,16 @@ static int nvgpu_tsg_bind_scheduling_domain(struct nvgpu_tsg *tsg,
return -ENOSYS;
}
return nvgpu_tsg_bind_domain(tsg, args->domain_id);
domain = nvgpu_nvs_domain_get_from_file(args->domain_fd);
if (domain == NULL) {
return -ENOENT;
}
err = nvgpu_tsg_bind_domain(tsg, domain);
nvgpu_nvs_domain_put(tsg->g, domain);
return err;
}
#endif