History

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.

Srinivas Kandagatla committed 4 years ago

Commit 3abe3ab1 parent fb423871 file · +46 −9Browse files

Unified · Split

drivers/misc/fastrpc.c+46−9
@@ -241,12 +241,15 @@ struct fastrpc_channel_ctx { · 240 unmodified lines
241 /* Flag if dsp attributes are cached */241 /* Flag if dsp attributes are cached */
242 bool valid_attributes;242 bool valid_attributes;
243 u32 dsp_attributes[FASTRPC_MAX_DSP_ATTRIBUTES];243 u32 dsp_attributes[FASTRPC_MAX_DSP_ATTRIBUTES];
244 struct fastrpc_device *secure_fdevice;
244 struct fastrpc_device *fdevice;245 struct fastrpc_device *fdevice;
246 bool secure;
245};247};
246 248
247struct fastrpc_device {249struct fastrpc_device {
248 struct fastrpc_channel_ctx *cctx;250 struct fastrpc_channel_ctx *cctx;
249 struct miscdevice miscdev;251 struct miscdevice miscdev;
252 bool secure;
250};253};
251 254
252struct fastrpc_user {255struct fastrpc_user {
@@ -1697,7 +1700,7 @@ static int fastrpc_req_mem_map(struct fastrpc_user *fl, char __user *argp) · 1444 unmodified lines
1697 return -EFAULT;1700 return -EFAULT;
1698 1701
1699 /* create SMMU mapping */1702 /* create SMMU mapping */
1700 err = fastrpc_map_create(fl, req.fd, req.length, &map);1703 err = fastrpc_map_create(fl, req.fd, req.length, 0, &map);
1701 if (err) {1704 if (err) {
1702 dev_err(dev, "failed to map buffer, fd = %d\n", req.fd);1705 dev_err(dev, "failed to map buffer, fd = %d\n", req.fd);
1703 return err;1706 return err;
@@ -1891,7 +1894,7 @@ static struct platform_driver fastrpc_cb_driver = { · 187 unmodified lines
1891};1894};
1892 1895
1893static int fastrpc_device_register(struct device *dev, struct fastrpc_channel_ctx *cctx,1896static int fastrpc_device_register(struct device *dev, struct fastrpc_channel_ctx *cctx,
1894 const char *domain)1897 bool is_secured, const char *domain)
1895{1898{
1896 struct fastrpc_device *fdev;1899 struct fastrpc_device *fdev;
1897 int err;1900 int err;
@@ -1900,13 +1903,19 @@ static int fastrpc_device_register(struct device *dev, struct fastrpc_channel_ct · 2 unmodified lines
1900 if (!fdev)1903 if (!fdev)
1901 return -ENOMEM;1904 return -ENOMEM;
1902 1905
1906 fdev->secure = is_secured;
1903 fdev->cctx = cctx;1907 fdev->cctx = cctx;
1904 fdev->miscdev.minor = MISC_DYNAMIC_MINOR;1908 fdev->miscdev.minor = MISC_DYNAMIC_MINOR;
1905 fdev->miscdev.fops = &fastrpc_fops;1909 fdev->miscdev.fops = &fastrpc_fops;
1906 fdev->miscdev.name = devm_kasprintf(dev, GFP_KERNEL, "fastrpc-%s", domain);1910 fdev->miscdev.name = devm_kasprintf(dev, GFP_KERNEL, "fastrpc-%s%s",
1911 domain, is_secured ? "-secure" : "");
1907 err = misc_register(&fdev->miscdev);1912 err = misc_register(&fdev->miscdev);
1908 if (!err)1913 if (!err) {
1909 cctx->fdevice = fdev;1914 if (is_secured)
1915 cctx->secure_fdevice = fdev;
1916 else
1917 cctx->fdevice = fdev;
1918 }
1910 1919
1911 return err;1920 return err;
1912}1921}
@@ -1917,6 +1926,7 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev) · 4 unmodified lines
1917 struct fastrpc_channel_ctx *data;1926 struct fastrpc_channel_ctx *data;
1918 int i, err, domain_id = -1;1927 int i, err, domain_id = -1;
1919 const char *domain;1928 const char *domain;
1929 bool secure_dsp;
1920 1930
1921 err = of_property_read_string(rdev->of_node, "label", &domain);1931 err = of_property_read_string(rdev->of_node, "label", &domain);
1922 if (err) {1932 if (err) {
@@ -1940,10 +1950,31 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev) · 17 unmodified lines
1940 if (!data)1950 if (!data)
1941 return -ENOMEM;1951 return -ENOMEM;
1942 1952
1943 err = fastrpc_device_register(rdev, data, domains[domain_id]);1953
1944 if (err) {1954 secure_dsp = !(of_property_read_bool(rdev->of_node, "qcom,non-secure-domain"));
1945 kfree(data);1955 data->secure = secure_dsp;
1946 return err;1956
1957 switch (domain_id) {
1958 case ADSP_DOMAIN_ID:
1959 case MDSP_DOMAIN_ID:
1960 case SDSP_DOMAIN_ID:
1961 err = fastrpc_device_register(rdev, data, secure_dsp, domains[domain_id]);
1962 if (err)
1963 goto fdev_error;
1964 break;
1965 case CDSP_DOMAIN_ID:
1966 /* Create both device nodes so that we can allow both Signed and Unsigned PD */
1967 err = fastrpc_device_register(rdev, data, true, domains[domain_id]);
1968 if (err)
1969 goto fdev_error;
1970
1971 err = fastrpc_device_register(rdev, data, false, domains[domain_id]);
1972 if (err)
1973 goto fdev_error;
1974 break;
1975 default:
1976 err = -EINVAL;
1977 goto fdev_error;
1947 }1978 }
1948 1979
1949 kref_init(&data->refcount);1980 kref_init(&data->refcount);
@@ -1957,6 +1988,9 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev) · 7 unmodified lines
1957 data->rpdev = rpdev;1988 data->rpdev = rpdev;
1958 1989
1959 return of_platform_populate(rdev->of_node, NULL, NULL, rdev);1990 return of_platform_populate(rdev->of_node, NULL, NULL, rdev);
1991fdev_error:
1992 kfree(data);
1993 return err;
1960}1994}
1961 1995
1962static void fastrpc_notify_users(struct fastrpc_user *user)1996static void fastrpc_notify_users(struct fastrpc_user *user)
@@ -1983,6 +2017,9 @@ static void fastrpc_rpmsg_remove(struct rpmsg_device *rpdev) · 20 unmodified lines
1983 if (cctx->fdevice)2017 if (cctx->fdevice)
1984 misc_deregister(&cctx->fdevice->miscdev);2018 misc_deregister(&cctx->fdevice->miscdev);
1985 2019
2020 if (cctx->secure_fdevice)
2021 misc_deregister(&cctx->secure_fdevice->miscdev);
2022
1986 of_platform_depopulate(&rpdev->dev);2023 of_platform_depopulate(&rpdev->dev);
1987 2024
1988 cctx->rpdev = NULL;2025 cctx->rpdev = NULL;