From patchwork Tue Nov 19 07:14:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 179730 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp245661ilf; Mon, 18 Nov 2019 23:15:19 -0800 (PST) X-Google-Smtp-Source: APXvYqytM7Zb+fB5eIZW4wb0/xRDrzb+wrh0pHJvzJesAO7OE/FaB+RygrmYlc9CJpsMsm0RH0BN X-Received: by 2002:a17:906:7251:: with SMTP id n17mr33224203ejk.329.1574147718969; Mon, 18 Nov 2019 23:15:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574147718; cv=none; d=google.com; s=arc-20160816; b=Nf1HrD2vCQH5swr1LHWEwKlaVOOnebp0hvexQAsVmFcd37lXR2Bu8xuzxNVV+KNGcS Qz79OAliCwoaBHWUi7RmNGm5na6CtP377HAXLGs0gg9J1fxrvXBX4PksoB3v98I7sPMb xCmBwst3xlEkke2pgU68fOR+FDIMQZWFI2LsdQ0wCCkawxGcrYP6fGnFmk3viZB5YKcU He3GqzZo1RrhwbZ4TogkJ2b2TomdpGMyeZivaefPF+bZMmym1ZvJCsFdbqgiV+U8o7th TOz+SHl9Lqnae9V+lc8WcWZXM/PM8CMfzBDJ/Nk5SdPPhQQJr4ISoK0FN3bttVudh4Bq uj/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=F/DaNK9LjWuKTu4vv+ENnwTZZ+61EjuSFDTlcOkYW/Q=; b=XuYKLS5yBbktQOiqKiAJRJmKVAiOXlA+bmz0i66dLXRwXqvJReTAfIW5YOMVWFO2W/ X1c6quDcfPzs8DI23VkFDaFrFbZVKv/Dtx87rohbX1aZUMMUWZbWfPNcPQsKT1ftK+7N Mc1qDhntLe6sAikNKAW09IBe599C3jq2il1yGH7ZDfshXgr2yWcCTDFGrFHl9leUh3QH sNZg2iKoR6a7m66AuofgQh39lqIoklQduipggTeg8hcjXV/JjHxgfqZXDRGL7Qk90sJS HIqi/lbqMDCyiwga7e1YlIPq6h4QoZebJfk5Y2oCPKbMFVvqe239w9XVrYbaGJZqox9x zSQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZPqjeJEP; 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 j18si15579799eda.278.2019.11.18.23.15.18; Mon, 18 Nov 2019 23:15:18 -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=ZPqjeJEP; 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 S1727922AbfKSHPR (ORCPT + 26 others); Tue, 19 Nov 2019 02:15:17 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:39629 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726860AbfKSHPR (ORCPT ); Tue, 19 Nov 2019 02:15:17 -0500 Received: by mail-pf1-f196.google.com with SMTP id x28so11706554pfo.6 for ; Mon, 18 Nov 2019 23:15:16 -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; bh=F/DaNK9LjWuKTu4vv+ENnwTZZ+61EjuSFDTlcOkYW/Q=; b=ZPqjeJEPInN19j4uu3yHXqRyHKAgF1+j1ngbJGzgSsrdm0L9h8c2/WzSSMA71i8IBF iim2951LdF/+s4s++/zHM7ewtwSJrsPH8CfxRXWy81B9K8aC2zCHkzWbmbBYhK/Ght2j 44KZZaf0ePg8ngJQJ7dI6nlvK4A3i9QDxceT+1NQZ4qI1TVstGkuJfcHM/XM8oZYj+dZ TdPUnEKa2SSs5xbIT7T+fCu/hPlxP2AQbjZtiXjAHPxaU6yW9+D49QRuRr4/HeUoP/zc PgBNWZO6BhR6kUp447oOhq0hHLg1fnAHrJ/GD8rfVdTjl+83aGpva445tYga3ZjK+PwF Sb0A== 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; bh=F/DaNK9LjWuKTu4vv+ENnwTZZ+61EjuSFDTlcOkYW/Q=; b=NFLbdDRbM15ZG84P7vRZispmIRbDu7vRD+iU5De3QpdktySRN4pIrmG5+cLmxjVF3T Bopqcr0qZlLVdQ/iXZetMPYUsyUyE53yQxcm2DQzETMCuK/mnMfF8iytEjUzSiEgaeza kZ4h15n7072CeXXKV7m0POowYOsQkE5K5nLVf6xT293iiK4Bg/mPGKCvkvtyupXWSsfw DuwWRmfWcWOJx8YE/Y5mXwvov5XBflgi0ADUfdYdPKjsEf3ErhTK95ky39oC2RAMcRB1 3/ycVxIo3eDqF6htpm3JNBIc1fSaA4LGOfgRvZSC+YqRVimt4FTDFqTlxojVxajtQEx+ PHiA== X-Gm-Message-State: APjAAAW6Dn0+8xmXFysgVYh+5BtAGyzQEHyASFmjTlQl4Rau9nschnLf 2OblOdG3/R+P9S+I74BT6iQ2ow== X-Received: by 2002:a63:553:: with SMTP id 80mr3829352pgf.366.1574147714640; Mon, 18 Nov 2019 23:15:14 -0800 (PST) Received: from localhost.localdomain ([117.252.69.77]) by smtp.gmail.com with ESMTPSA id u18sm1141839pfn.183.2019.11.18.23.15.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 18 Nov 2019 23:15:13 -0800 (PST) From: Sumit Garg To: jens.wiklander@linaro.org Cc: tee-dev@lists.linaro.org, Volodymyr_Babchuk@epam.com, jerome@forissier.org, etienne.carriere@linaro.org, vincent.t.cao@intel.com, linux-kernel@vger.kernel.org, Sumit Garg Subject: [PATCH] optee: Fix multi page dynamic shm pool alloc Date: Tue, 19 Nov 2019 12:44:26 +0530 Message-Id: <1574147666-19356-1-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org optee_shm_register() expected pages to be passed as an array of page pointers rather than as an array of contiguous pages. So fix that via correctly passing pages as per expectation. Fixes: a249dd200d03 ("tee: optee: Fix dynamic shm pool allocations") Reported-by: Vincent Cao Signed-off-by: Sumit Garg Tested-by: Vincent Cao --- drivers/tee/optee/shm_pool.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/tee/optee/shm_pool.c b/drivers/tee/optee/shm_pool.c index 0332a53..85aa5bb 100644 --- a/drivers/tee/optee/shm_pool.c +++ b/drivers/tee/optee/shm_pool.c @@ -28,8 +28,20 @@ static int pool_op_alloc(struct tee_shm_pool_mgr *poolm, shm->size = PAGE_SIZE << order; if (shm->flags & TEE_SHM_DMA_BUF) { + unsigned int nr_pages = 1 << order, i; + struct page **pages; + + pages = kcalloc(nr_pages, sizeof(pages), GFP_KERNEL); + if (!pages) + return -ENOMEM; + + for (i = 0; i < nr_pages; i++) { + pages[i] = page; + page++; + } + shm->flags |= TEE_SHM_REGISTER; - rc = optee_shm_register(shm->ctx, shm, &page, 1 << order, + rc = optee_shm_register(shm->ctx, shm, pages, nr_pages, (unsigned long)shm->kaddr); }