Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5977336pxb; Mon, 14 Feb 2022 12:09:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJwZi2ocZmmCjbfzRgP8OJLzlc2ktKTOLMdMSixm/G1RA362Fldmw0BbLWE70SFl89TfXeBU X-Received: by 2002:a17:90b:1e4b:b0:1b9:c387:d107 with SMTP id pi11-20020a17090b1e4b00b001b9c387d107mr254049pjb.239.1644869386006; Mon, 14 Feb 2022 12:09:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644869386; cv=none; d=google.com; s=arc-20160816; b=ioJEJO4ypT04Ptuug9hI7QPg2vIGMIywBo5PQcnfMDIYKLTWQ6EM2nv/2h+xVkGZWn zH6MTeh5iBUFtHXzDVSUjC4x4cCwLr6EfWJWP07hRyUWv4m+zi1Uy2qEBBYwmk29PhFK WFRsrotFzEImBtifuWP0vMSfOyxE+UCvuufS8TgS5tZW5TTtIF95PwbqerzARbCJgFk2 jK17RQz3aXvzOz+Ln8NVRBtAT/5zg8k5NgvvsQXPokbt1olWRscohv6Wf83PQGixw8YJ 6Ssmp73xBGtSgKQ32gDK4IYeDIsN1BfCtpi+FpdVTeUuJOA0FyXVLvSSSaox0X779tZ+ +F9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=b/uKzniHb9UB6MYZAJLuo4z7YZEOuojp10KqgKZuEAA=; b=YODHIFFjG8ZstdT/rp98EJcgZggi4jSJPTbqGeHMOYXe/Xyu1MnuBjMQSv7HRFnTC0 GUy4wzLZOGF2DCtarrB15mzV6koJrc+5P0ImswZVpaHzNratA87kqyDt2z8G/kRJa92j McJb8EG10o/C/BLsTBB+QHdqKSwi+HAasswUZh1hKLlAUSBbqytJt11NmQp6GAzXp+iB +psXG0cXsk+WOjNH+J0WBPx3aBFq0Z/Yg9/6RcoKzWNUy+rekAxWokUX7OM406oL/t3R E7YP/Ae8HEkTFoRDs35bK3PHjrimKPPgtpmfpxgYjQuCZINLo+6jg0CtnwLfR2Eh/zc8 fHaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qdt0JjkI; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id in20si12333757pjb.91.2022.02.14.12.09.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 12:09:45 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qdt0JjkI; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 999BC1592A9; Mon, 14 Feb 2022 11:46:57 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356219AbiBNQKh (ORCPT + 99 others); Mon, 14 Feb 2022 11:10:37 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:53740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356169AbiBNQKX (ORCPT ); Mon, 14 Feb 2022 11:10:23 -0500 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C03CC60ABE for ; Mon, 14 Feb 2022 08:10:14 -0800 (PST) Received: by mail-wr1-x434.google.com with SMTP id u1so13931949wrg.11 for ; Mon, 14 Feb 2022 08:10:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=b/uKzniHb9UB6MYZAJLuo4z7YZEOuojp10KqgKZuEAA=; b=qdt0JjkIS5Au+XCm2PNkkj4pu2ouPIrhx3OvBdF9QpFcoEr0MoQ6rN5+iZarwCB2k0 bBXXvgh2RuQ+9eM2aRWhX4C4ylqiaQYrP5DsP8HjKKD4KicSZSWnOo4lqntP6+C25ZtI FdbDbNfZ1t+Z/Kj7QNoBxvdbAQoU3dukDdBbnV51ap+V+VAeRWy7aMloAkIGj8r1OqkH s89B4FJUOR8BLqH0B0BsVgmKg2oKBeuMlEBYlbVdj9XlrynDcT1x6wOdCkkQbIu/FkhO R1Zl8t69i3eLMCM1+FNWvO9owdDRSchX/I/x886RgOC8xlYZyH8TohUqaNIlWm7m2DK7 NKnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=b/uKzniHb9UB6MYZAJLuo4z7YZEOuojp10KqgKZuEAA=; b=LB7uYRVigg0AtD/N8IO93G2mEb7kItRRh0SI+Xdp5SW5EuULOou4qLF/6Cv3+1Cuid YjXblt2UNY4SIKVpRRWkC9KErxJ++eUIy6aJp4+jOEmkZ4beh4uaLXLgWjFWn3JjCYr8 v+ll04QtLry2PG6XhwfbTxvmAJsLS3wuHHRnkihzXVjyiYnRPwnRYegS2AMZO2k+92pq t3AhsenvxTChsy4Sph81OkN8rGQVdfYJNMK5eBMKQ4TWgDb5N0/QZ45uotZ6TLfZKII2 Tr2zszZ69oHWVldI7Aquy3s3zbR+7n28mhZicsrrfOLJo6gP7x4N+V0J9j3y/SGsT+hv /srA== X-Gm-Message-State: AOAM533JR8Ndw6Fdr4AAzdMegPXbulokitBDzA/IglW/nFDylrX6tdlV p1e+KIoeznXSS3clC85M0KkjGw== X-Received: by 2002:a5d:64ec:: with SMTP id g12mr272829wri.143.1644855013363; Mon, 14 Feb 2022 08:10:13 -0800 (PST) Received: from srini-hackbox.lan (cpc90716-aztw32-2-0-cust825.18-1.cable.virginm.net. [86.26.103.58]) by smtp.gmail.com with ESMTPSA id k28sm13677022wms.23.2022.02.14.08.10.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 08:10:12 -0800 (PST) From: Srinivas Kandagatla To: robh+dt@kernel.org, gregkh@linuxfoundation.org Cc: devicetree@vger.kernel.org, ekangupt@qti.qualcomm.com, bkumar@qti.qualcomm.com, linux-kernel@vger.kernel.org, srini@kernel.org, bjorn.andersson@linaro.org, linux-arm-msm@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH v4 05/12] misc: fastrpc: add secure domain support Date: Mon, 14 Feb 2022 16:09:55 +0000 Message-Id: <20220214161002.6831-6-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20220214161002.6831-1-srinivas.kandagatla@linaro.org> References: <20220214161002.6831-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/misc/fastrpc.c | 55 +++++++++++++++++++++++++++++++++++------- 1 file changed, 46 insertions(+), 9 deletions(-) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 528ae5777586..af8bb4bd0cb3 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 { @@ -1690,7 +1693,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; @@ -1884,7 +1887,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; @@ -1893,13 +1896,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; } @@ -1910,6 +1919,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) { @@ -1933,10 +1943,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); @@ -1950,6 +1981,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) @@ -1976,6 +2010,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; -- 2.21.0