summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/tegra/submit.c
diff options
context:
space:
mode:
authorMikko Perttunen <mperttunen@nvidia.com>2021-06-10 14:04:55 +0300
committerThierry Reding <treding@nvidia.com>2021-08-10 17:04:05 +0200
commit8cc95f3fd35e1de3495d9e2acb051162c739cd25 (patch)
treeeeabb697cdf949b5460fdefaf851dea5e9a0d338 /drivers/gpu/drm/tegra/submit.c
parent13abe0bb15ceac2fb8e8853bd30c278426d95ad0 (diff)
downloadlinux-8cc95f3fd35e1de3495d9e2acb051162c739cd25.tar.gz
linux-8cc95f3fd35e1de3495d9e2acb051162c739cd25.tar.bz2
linux-8cc95f3fd35e1de3495d9e2acb051162c739cd25.zip
drm/tegra: Add job firewall
Add a firewall that validates jobs before submission to ensure they don't do anything they aren't allowed to do, like accessing memory they should not access. The firewall is functionality-wise a copy of the firewall already implemented in gpu/host1x. It is copied here as it makes more sense for it to live on the DRM side, as it is only needed for userspace job submissions, and generally the data it needs to do its job is easier to access here. In the future, the other implementation will be removed. Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com> Signed-off-by: Thierry Reding <treding@nvidia.com>
Diffstat (limited to 'drivers/gpu/drm/tegra/submit.c')
-rw-r--r--drivers/gpu/drm/tegra/submit.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/gpu/drm/tegra/submit.c b/drivers/gpu/drm/tegra/submit.c
index e253b0d0151e..776f825df52f 100644
--- a/drivers/gpu/drm/tegra/submit.c
+++ b/drivers/gpu/drm/tegra/submit.c
@@ -326,7 +326,8 @@ static int submit_get_syncpt(struct tegra_drm_context *context, struct host1x_jo
static int submit_job_add_gather(struct host1x_job *job, struct tegra_drm_context *context,
struct drm_tegra_submit_cmd_gather_uptr *cmd,
struct gather_bo *bo, u32 *offset,
- struct tegra_drm_submit_data *job_data)
+ struct tegra_drm_submit_data *job_data,
+ u32 *class)
{
u32 next_offset;
@@ -351,6 +352,12 @@ static int submit_job_add_gather(struct host1x_job *job, struct tegra_drm_contex
return -EINVAL;
}
+ if (tegra_drm_fw_validate(context->client, bo->gather_data, *offset,
+ cmd->words, job_data, class)) {
+ SUBMIT_ERR(context, "job was rejected by firewall");
+ return -EINVAL;
+ }
+
host1x_job_add_gather(job, &bo->base, cmd->words, *offset * 4);
*offset = next_offset;
@@ -404,7 +411,7 @@ submit_create_job(struct tegra_drm_context *context, struct gather_bo *bo,
if (cmd->type == DRM_TEGRA_SUBMIT_CMD_GATHER_UPTR) {
err = submit_job_add_gather(job, context, &cmd->gather_uptr, bo,
- &gather_offset, job_data);
+ &gather_offset, job_data, &class);
if (err)
goto free_job;
} else if (cmd->type == DRM_TEGRA_SUBMIT_CMD_WAIT_SYNCPT) {