aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/fastrpc.c
diff options
context:
space:
mode:
authorSrinivas Kandagatla <srinivas.kandagatla@linaro.org>2022-02-14 16:09:55 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-03-18 14:11:00 +0100
commit3abe3ab3cdab71b2073ba6331edc0b2994643133 (patch)
treeab4f1069aeea742f7fd6a36277ee7464b89fb081 /drivers/misc/fastrpc.c
parentdt-bindings: misc: add property to support non-secure DSP (diff)
downloadlinux-dev-3abe3ab3cdab71b2073ba6331edc0b2994643133.tar.xz
linux-dev-3abe3ab3cdab71b2073ba6331edc0b2994643133.zip
misc: fastrpc: add secure domain support
ADSP/MDSP/SDSP are by default secured, which means it can only be loaded with a Signed process. Where as CDSP can be either be secured/unsecured. non-secured Compute DSP would allow users to load unsigned process and run hexagon instructions, but blocking access to secured hardware within the DSP. Where as signed process with secure CDSP would be allowed to access all the dsp resources. This patch adds basic code to create device nodes as per device tree property. Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Link: https://lore.kernel.org/r/20220214161002.6831-6-srinivas.kandagatla@linaro.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc/fastrpc.c')
-rw-r--r--drivers/misc/fastrpc.c55
1 files changed, 46 insertions, 9 deletions
diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 4b1a4c1c5535..3b7731f158eb 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -241,12 +241,15 @@ struct fastrpc_channel_ctx {
/* Flag if dsp attributes are cached */
bool valid_attributes;
u32 dsp_attributes[FASTRPC_MAX_DSP_ATTRIBUTES];
+ struct fastrpc_device *secure_fdevice;
struct fastrpc_device *fdevice;
+ bool secure;
};
struct fastrpc_device {
struct fastrpc_channel_ctx *cctx;
struct miscdevice miscdev;
+ bool secure;
};
struct fastrpc_user {
@@ -1697,7 +1700,7 @@ static int fastrpc_req_mem_map(struct fastrpc_user *fl, char __user *argp)
return -EFAULT;
/* create SMMU mapping */
- err = fastrpc_map_create(fl, req.fd, req.length, &map);
+ err = fastrpc_map_create(fl, req.fd, req.length, 0, &map);
if (err) {
dev_err(dev, "failed to map buffer, fd = %d\n", req.fd);
return err;
@@ -1891,7 +1894,7 @@ static struct platform_driver fastrpc_cb_driver = {
};
static int fastrpc_device_register(struct device *dev, struct fastrpc_channel_ctx *cctx,
- const char *domain)
+ bool is_secured, const char *domain)
{
struct fastrpc_device *fdev;
int err;
@@ -1900,13 +1903,19 @@ static int fastrpc_device_register(struct device *dev, struct fastrpc_channel_ct
if (!fdev)
return -ENOMEM;
+ fdev->secure = is_secured;
fdev->cctx = cctx;
fdev->miscdev.minor = MISC_DYNAMIC_MINOR;
fdev->miscdev.fops = &fastrpc_fops;
- fdev->miscdev.name = devm_kasprintf(dev, GFP_KERNEL, "fastrpc-%s", domain);
+ fdev->miscdev.name = devm_kasprintf(dev, GFP_KERNEL, "fastrpc-%s%s",
+ domain, is_secured ? "-secure" : "");
err = misc_register(&fdev->miscdev);
- if (!err)
- cctx->fdevice = fdev;
+ if (!err) {
+ if (is_secured)
+ cctx->secure_fdevice = fdev;
+ else
+ cctx->fdevice = fdev;
+ }
return err;
}
@@ -1917,6 +1926,7 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
struct fastrpc_channel_ctx *data;
int i, err, domain_id = -1;
const char *domain;
+ bool secure_dsp;
err = of_property_read_string(rdev->of_node, "label", &domain);
if (err) {
@@ -1940,10 +1950,31 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
if (!data)
return -ENOMEM;
- err = fastrpc_device_register(rdev, data, domains[domain_id]);
- if (err) {
- kfree(data);
- return err;
+
+ secure_dsp = !(of_property_read_bool(rdev->of_node, "qcom,non-secure-domain"));
+ data->secure = secure_dsp;
+
+ switch (domain_id) {
+ case ADSP_DOMAIN_ID:
+ case MDSP_DOMAIN_ID:
+ case SDSP_DOMAIN_ID:
+ err = fastrpc_device_register(rdev, data, secure_dsp, domains[domain_id]);
+ if (err)
+ goto fdev_error;
+ break;
+ case CDSP_DOMAIN_ID:
+ /* Create both device nodes so that we can allow both Signed and Unsigned PD */
+ err = fastrpc_device_register(rdev, data, true, domains[domain_id]);
+ if (err)
+ goto fdev_error;
+
+ err = fastrpc_device_register(rdev, data, false, domains[domain_id]);
+ if (err)
+ goto fdev_error;
+ break;
+ default:
+ err = -EINVAL;
+ goto fdev_error;
}
kref_init(&data->refcount);
@@ -1957,6 +1988,9 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
data->rpdev = rpdev;
return of_platform_populate(rdev->of_node, NULL, NULL, rdev);
+fdev_error:
+ kfree(data);
+ return err;
}
static void fastrpc_notify_users(struct fastrpc_user *user)
@@ -1983,6 +2017,9 @@ static void fastrpc_rpmsg_remove(struct rpmsg_device *rpdev)
if (cctx->fdevice)
misc_deregister(&cctx->fdevice->miscdev);
+ if (cctx->secure_fdevice)
+ misc_deregister(&cctx->secure_fdevice->miscdev);
+
of_platform_depopulate(&rpdev->dev);
cctx->rpdev = NULL;