From patchwork Thu Mar 7 10:12:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 159827 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp7251244jad; Thu, 7 Mar 2019 02:13:41 -0800 (PST) X-Google-Smtp-Source: APXvYqznc1iYSMI/O0EKiy01XjJuVMfNdgZFHHiY2WZf9ZpQUhjBO+qlc+W9R0lZk0zL7T/PWvMX X-Received: by 2002:a65:6283:: with SMTP id f3mr10751114pgv.125.1551953621387; Thu, 07 Mar 2019 02:13:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551953621; cv=none; d=google.com; s=arc-20160816; b=G/ZpDsw7rhOxnbSins7Yh94m6WAG96YgPb1kp+QarSmVcdRG0ssaqY4HRrngemhTo0 mamdRGd0PigDwdl48FXLJuZ3aHe/iK7v/em7qIb4/9pns1VzWWUa7HyOyV95tYYOk/5+ xVV5HgCheURIySd27eBTp44pyeOdNVlfrTl3CwF+Lbi2HzwP46z62xdt0IXFgiJA9FBV egtf0lsH3yXT7bSBrV0kiBul+gq3pGQKd/0kr74YlmTw2XrisYS6gjNk8VD6GRxcPgCy PKAB6XkmipJMnA9X2dAStVQXhJzkg/lKRfZ1W+vTx/mOZg2gMNR1VPqUedVcz2RlIRD3 3Reg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=FPxNdvt+kGcCG8uzNQ9lroy0iRhdBt0KuB6zFefUSXk=; b=VKmf3kMNhYUT2abctQ6wl7XJ26m5OCiN7/TACdP5BFOTLJMLJOXl6kZnyVnIfn9e82 /qMO4TUnDPwjGzXUIgzmZkspRFlbba+uKP9cRKvTjdAmxoah3DReOZueYqKhGR4O0yj2 r+N3pUp2s2fPbl5SEyl0Y29KCiSEcuegBnQgMAjbWyTc/ZFjJwsufhTPiUKn5vR9NrKH Ekv2E6Qk0L75OXzQlBTFEhKObyqrjVifvMpZ1mUdaVeqGmC4N9ikt79Ay82auNprGtSL kVwZK6Cl8cyXQvjK3a22aIDc4+y2cDZNRc0syuAcQ+y5LpqVX5JONr6G0HZa4yofUFJ9 HyoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="MyY/T+4h"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a8si3922753ple.346.2019.03.07.02.13.40; Thu, 07 Mar 2019 02:13:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="MyY/T+4h"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726556AbfCGKNj (ORCPT + 31 others); Thu, 7 Mar 2019 05:13:39 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:34631 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726483AbfCGKNY (ORCPT ); Thu, 7 Mar 2019 05:13:24 -0500 Received: by mail-wm1-f68.google.com with SMTP id o10so6364248wmc.1 for ; Thu, 07 Mar 2019 02:13:23 -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=FPxNdvt+kGcCG8uzNQ9lroy0iRhdBt0KuB6zFefUSXk=; b=MyY/T+4heOH9NyLJAPUtf+h+tOOTQ8w5lyCiHswAOkciuxnZZ6cy4xY5fRJAIrbjih Xp54rf/2Zv++De+fDp4m9fGyqICPYROXsUdk/YZoseajrB1xo4P2YMJtPYvsdF4F2Ui2 39pm5ovfhNJokRMnByEP0I1o5wWOt8a2SRShhX7x29DT9G/5FZucynJqqJA+IbbMSxmJ HWljc38inYK6/Bm0k1Ig0UIBE0G48KLlHPWINZJS0p5Dbl59bHDsCQHfQblTwclFU6tJ Gjq6MplvHraf/q+8pEIAE4kMDPXOENrR85NTf7T7mAu8I/z9Dr8WcKSr1b8liB6QzeZR Twxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FPxNdvt+kGcCG8uzNQ9lroy0iRhdBt0KuB6zFefUSXk=; b=ZmEH10zK9bk36vaRrsHXvcKkgKgE/IwtXIsq0eb/PDYo/xdD9wgP+58OKZItJmG2ez aM7XMWYPB0EN5kVnQ7f9RH4suGnsx25b2898HXApNMDzA4IIkEx+++AJipJOAjZlNCyY b7XZPmbylC9Jc3XUhD/mDhfqgwHVit8LcaV0Y8zFN0ZzcRXgaV1KUORULnqdcK/bLNCM NGVc7rZtQ35wmx7bveVGoNM1hrlCE0ku46DrL3hwtmMcol5ZVXhnKJUVf7zxb0FoSglx ss8qd3wH4tbQhwXJ4GW7FwOHPpbLJNcteJ/nL4L9habVl7p+X91QVQkUkon6CZ3NATMD FySA== X-Gm-Message-State: APjAAAUuAugCHdWjc9n1Ybb1dEE0lgr0iFAWiagGCG1G2VC1mglWhBJa 3xdEvxtRZfJ9oodyfW3Ahak1YA== X-Received: by 2002:a1c:a885:: with SMTP id r127mr5582093wme.74.1551953602372; Thu, 07 Mar 2019 02:13:22 -0800 (PST) Received: from srini-hackbox.lan (cpc89974-aztw32-2-0-cust43.18-1.cable.virginm.net. [86.30.250.44]) by smtp.gmail.com with ESMTPSA id n9sm3529767wmi.33.2019.03.07.02.13.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 Mar 2019 02:13:21 -0800 (PST) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org, arnd@arndb.de Cc: linux-kernel@vger.kernel.org, bjorn.andersson@linaro.org, bkumar@qti.qualcomm.com, linux-arm-msm@vger.kernel.org, ktadakam@qti.qualcomm.com, Srinivas Kandagatla Subject: [PATCH 7/8] misc: fastrpc: fix remote page size calculation Date: Thu, 7 Mar 2019 10:12:28 +0000 Message-Id: <20190307101229.7856-8-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190307101229.7856-1-srinivas.kandagatla@linaro.org> References: <20190307101229.7856-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Remote page size should be calculated based on address and size, fix this! Without this we will endup with one page less in cases where the buffer is across 3 pages. Fixes: c68cfb718c8f ("misc: fastrpc: Add support for context Invoke method") Reported-by: Krishnaiah Tadakamalla Signed-off-by: Srinivas Kandagatla --- drivers/misc/fastrpc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) -- 2.21.0 diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 17bbb017bb08..d0e2e2620087 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -712,6 +712,7 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx) struct fastrpc_phy_page *pages; int inbufs, i, oix, err = 0; u64 len, rlen, pkt_size; + u64 pg_start, pg_end; uintptr_t args; int metalen; @@ -751,8 +752,6 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx) if (!len) continue; - pages[i].size = roundup(len, PAGE_SIZE); - if (ctx->maps[i]) { struct vm_area_struct *vma = NULL; @@ -764,6 +763,11 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx) pages[i].addr += ctx->args[i].ptr - vma->vm_start; + pg_start = (ctx->args[i].ptr & PAGE_MASK) >> PAGE_SHIFT; + pg_end = ((ctx->args[i].ptr + len - 1) & PAGE_MASK) >> + PAGE_SHIFT; + pages[i].size = (pg_end - pg_start + 1) * PAGE_SIZE; + } else { if (ctx->olaps[oix].offset == 0) { @@ -782,6 +786,9 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx) (pkt_size - rlen); pages[i].addr = pages[i].addr & PAGE_MASK; + pg_start = (args & PAGE_MASK) >> PAGE_SHIFT; + pg_end = ((args + len - 1) & PAGE_MASK) >> PAGE_SHIFT; + pages[i].size = (pg_end - pg_start + 1) * PAGE_SIZE; args = args + mlen; rlen -= mlen; }