From patchwork Thu Oct 26 08:17:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ekansh Gupta X-Patchwork-Id: 158443 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp509201vqb; Thu, 26 Oct 2023 01:18:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHZGOvd+PiZTe+vn82Jcdu1GuyD2HULsJLlMdtYih6/BMd/nTPeSjbghAQ7u9uZ+FWOTRcC X-Received: by 2002:a25:694f:0:b0:da0:515d:ade3 with SMTP id e76-20020a25694f000000b00da0515dade3mr5965171ybc.59.1698308334190; Thu, 26 Oct 2023 01:18:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698308334; cv=none; d=google.com; s=arc-20160816; b=LfB6l9f/tBzuRXKgNd85ObnRkWlgQDOjrMaxQBaJLnFjzbGjkibQRnXu0WZIUUubjV jZ1ocX7DVktInaN0KWZbCsoaw4L0xtXwFI13tcO0rGvvOmwsoJWVMf5X4RxoAfPWMxdL iQISC6GGpBr8g1tj29DOd8cehkv5HPbmuluI44BQ8JMsf8qs/MvRq6jJ8DjrL6Y7oni7 24FmBBAoEfnSGQ1g4UoZL0Bqao30Ih2aUMNODrC29BNMgGaF73EKkFyp+nzg3W+VAcMe mWKD6satCzqqY6j3Dr7HnMQD6xFc9NbT7xKvv5QlYH4QvcLqSXEkhIewOUNGI1MRZf1K 0skA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=hsibUURuaOSyADWg6+k+o19Ya1zYqRn0cGAJHu9TGow=; fh=qZfm2gxVFKi5OFpGqqouvPKfcV9/1EOj1DTqrfs2EPk=; b=yXHbzFZszHIpEW4GVtwRsN3BbLgBcIPtdpYOledbZbTj6rcntrqB7upg5CwSKm1jIx Tkxc+PuePz1zopqAb0H1DlhOVx+2FixBpJgv3MMBIzsjx7X5vV5RwrqGTS1KgNf3ieqW UIwXLVQR68JTth3bvF0jhW0JkMdHn98jNL6PJpN4SKk7k1U2k1QT1bTxQ4Op5XspRg31 6AMcWVROcrP5jK6rsSOk0hwTyx1EE0gGIWvsKse+1IiXfdXOpGb+9JGgFHHUS+kXD7Ul rblaWhjZVqC92UGvM2eBIF3+emo/PycilaaWaTmmzQVpUZHUabIFfxIuuW2Et+h/rly5 G9Lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=bOlQ0wH8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id k63-20020a252442000000b00d8666657762si13081668ybk.165.2023.10.26.01.18.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 01:18:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=bOlQ0wH8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 49F648271DF7; Thu, 26 Oct 2023 01:18:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344579AbjJZISV (ORCPT + 26 others); Thu, 26 Oct 2023 04:18:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230283AbjJZISR (ORCPT ); Thu, 26 Oct 2023 04:18:17 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4A26DE; Thu, 26 Oct 2023 01:18:15 -0700 (PDT) Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39Q84QkD005464; Thu, 26 Oct 2023 08:18:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=hsibUURuaOSyADWg6+k+o19Ya1zYqRn0cGAJHu9TGow=; b=bOlQ0wH8sduyri08tHaW3tjayKiPU4p7/byZYApA8L0En5eReb31Eil3CVDXDS8T5Spp p/n/yuapNsYHgFJf87TivWd4LJrhgHSSLxcj+wSagdAdwTCRKrAA0IIzeDhEQIz9jW0d nCQw+iau/GMK30P8rkF66Esgqyt9DGmkTx7fk3H7ktnaasRQadOU7WOAhDyOzVRQoSBK fADOedQSgkzWNApoiwsX3zKPo5VX8ZjNOYpp3hzK+VPyUnS1xh4/qeXJqEjuEvVGV/vY TRJpUfe8jFVSZtSqGwMSrRkWNagh5aVlxc1gphGWbAtOnKG2MyICKQB55fsaqNMncy/q 7g== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3txtw1k4rj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Oct 2023 08:18:13 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 39Q8ICIs017837 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Oct 2023 08:18:12 GMT Received: from ekangupt-linux.qualcomm.com (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.39; Thu, 26 Oct 2023 01:18:10 -0700 From: Ekansh Gupta To: , CC: , Subject: [PATCH v6 2/5] misc: fastrpc: Add CRC support for remote buffers Date: Thu, 26 Oct 2023 13:47:59 +0530 Message-ID: <1698308282-8648-3-git-send-email-quic_ekangupt@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1698308282-8648-1-git-send-email-quic_ekangupt@quicinc.com> References: <1698308282-8648-1-git-send-email-quic_ekangupt@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: XRz_8GQ4-u_bW3nMSRy8ihqkK7RgC1WQ X-Proofpoint-GUID: XRz_8GQ4-u_bW3nMSRy8ihqkK7RgC1WQ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-26_05,2023-10-25_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 malwarescore=0 priorityscore=1501 adultscore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 lowpriorityscore=0 clxscore=1015 impostorscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310170001 definitions=main-2310260068 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 26 Oct 2023 01:18:46 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780805360104708672 X-GMAIL-MSGID: 1780805360104708672 CRC check for input and output argument helps in ensuring data consistency over a remote call. If user intends to enable CRC check, first local user CRC is calculated at user end and a CRC buffer is passed to DSP to capture remote CRC values. DSP is expected to write to the remote CRC buffer which is then compared at user level with the local CRC values. Signed-off-by: Ekansh Gupta --- drivers/misc/fastrpc.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index e392e2a..825ff91 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -611,6 +611,7 @@ static struct fastrpc_invoke_ctx *fastrpc_context_alloc( /* Released in fastrpc_context_put() */ fastrpc_channel_ctx_get(cctx); + ctx->crc = (u32 *)(uintptr_t)invoke->crc; ctx->sc = sc; ctx->retval = -1; ctx->pid = current->pid; @@ -1066,6 +1067,7 @@ static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx, struct fastrpc_invoke_buf *list; struct fastrpc_phy_page *pages; u64 *fdlist; + u32 *crclist; int i, inbufs, outbufs, handles; inbufs = REMOTE_SCALARS_INBUFS(ctx->sc); @@ -1073,7 +1075,8 @@ static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx, handles = REMOTE_SCALARS_INHANDLES(ctx->sc) + REMOTE_SCALARS_OUTHANDLES(ctx->sc); list = fastrpc_invoke_buf_start(rpra, ctx->nscalars); pages = fastrpc_phy_page_start(list, ctx->nscalars); - fdlist = (uint64_t *)(pages + inbufs + outbufs + handles); + fdlist = (u64 *)(pages + inbufs + outbufs + handles); + crclist = (u32 *)(fdlist + FASTRPC_MAX_FDLIST); for (i = inbufs; i < ctx->nbufs; ++i) { if (!ctx->maps[i]) { @@ -1097,6 +1100,10 @@ static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx, fastrpc_map_put(mmap); } + if (ctx->crc && crclist && rpra) { + if (copy_to_user((void __user *)ctx->crc, crclist, FASTRPC_MAX_CRCLIST * sizeof(u32))) + return -EFAULT; + } return 0; } @@ -1721,6 +1728,7 @@ static int fastrpc_multimode_invoke(struct fastrpc_user *fl, char __user *argp) switch (invoke.req) { case FASTRPC_INVOKE: + case FASTRPC_INVOKE_ENHANCED: /* nscalars is truncated here to max supported value */ if (copy_from_user(&einv, (void __user *)(uintptr_t)invoke.invparam, invoke.size))