Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2443287rwb; Mon, 3 Oct 2022 00:09:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5mv3KGewOy9ojdrRdDq4PAE/iSgLhDlJBCB3xqKNgZxUCr+rnS+cAm0f7x0N5X0ocqYi1T X-Received: by 2002:a17:906:cc59:b0:779:f094:af3d with SMTP id mm25-20020a170906cc5900b00779f094af3dmr13857216ejb.239.1664780984545; Mon, 03 Oct 2022 00:09:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664780984; cv=none; d=google.com; s=arc-20160816; b=sCN971zUcSJDd92ccSkV3uOZlbDhHhIHWcJV9xA7FWzdfC0W8HRkcqur5W6KTfN7ca xt1hkQxhgdtbBD34Cu/sNs5ZB72NvBZdBaGnGgbaoUUWAwF0p6qeIIdR638guTRHBdJA f5Ol8aubWeccDwBH3J0JpDisMZUU69qgSMl4B503EGU9rCW4GRqiC3ehtcP47T82F4Xr cFBlSK/40q1tEbRo1L6ne0ZjI2R/ZnjpjJQvE5bco9lcvVDqtDTvtlky7v1Cly2oJVoL PAl/X57TBuY7oKgAwwQvRMw+RmwE80dc87wwYFsDlQzPIYG1a7CGyO4V9nKcRSf1OvGT /QrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=/1Kjm+tlGvTFEl2ExNhozH8lcuXI6M+d4lR60oFBYPY=; b=WMnqapqnNKGZ5R3MaxZDsshQHJgvelv3zv0wjXZx7SCQ7ymUMe4Tn4MvwJHrQ4rktz XostFxNvt3B9R83QDZbqpnkYCvM1jivsukte/R2tu3e41IPP+wIo4qFyz3MObqhfLNft Cv9Kik4SMjcm6ydVl2fdTNlYaPUBZVmltuMJTx1wXYQ44hishdkbdobqBQ71jfsFjK+2 qxezpYZmFQ7Z+XeGIjfdzCZ/EC5sVhkk9+raH4x8FwX2jrGwVHcU+lRMuHFBZYOOpZME Psh9kUY5Zfg1OsJ2mXborGfslWwySC0q/LBrM/+F2B2wbla3pTJI3LJsX1Fng/Qg4v/4 yE0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AwzKwhX9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kl12-20020a170907994c00b00781d6cda765si6550509ejc.913.2022.10.03.00.09.17; Mon, 03 Oct 2022 00:09:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AwzKwhX9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S229653AbiJCG5W (ORCPT + 99 others); Mon, 3 Oct 2022 02:57:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229470AbiJCG5V (ORCPT ); Mon, 3 Oct 2022 02:57:21 -0400 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3F483B3 for ; Sun, 2 Oct 2022 23:57:19 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id nb11so20109642ejc.5 for ; Sun, 02 Oct 2022 23:57:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=/1Kjm+tlGvTFEl2ExNhozH8lcuXI6M+d4lR60oFBYPY=; b=AwzKwhX9x4Yjc9haniR/rahUAxhObz4WWpbKmDsQJFtYTWYjud6EIXN0a16X/ZAYyF 7qotqFzbCOP3Xvcc2ToRTpraOm1QEXGrpuw5hT0ffe9kK1T7eDAD9+1RmXFuytVmcfPK dprc9JqQL8M2obHbszNmRyoHq+7QBUUth9lVR/015GUp1OTjbQOfQaDYIK2uJKXnckU8 lzIWFvCKgXYp+pgmCGHAPfaLY2LQK2XJZyBjWcr+qWVvwksOnAtAwehpwiO7yHQrKKWN PtDzhSk/8v/0Y6Xbrrtd9FDPVPnL75559cLY7hefuYX3rpVpyWO3BO9tvBvuqWOAKhah OJMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=/1Kjm+tlGvTFEl2ExNhozH8lcuXI6M+d4lR60oFBYPY=; b=T2qSfjB8x3wz3gyoMgOpk60ALaNETItI2xRnj9dFMgdvZXR8FWgHnB5kDLwHgF3ZVA RYmfqmNKklSn4LRho9UfmtXLvnA92CYOjre5ajjakxogzauDqtPRRg+OXe7cEq/l3cmp 4YFixxJXYepR8B5YohQ3z+vn/M8tVrxK3zlsHcPNZsN3A9ed1T1OThqPDOR52d+B0osa 2jOeZYIcAISECxp9nrVJEGkNoy6YZ+aXYJAnQujtR0RcSxAeIilg0T589z3gbJ2vl6DH vzMWuPWlCrLd52V/ysaPepOjIcqtSPYoAlNtLeeldgx3T2Qz0l22EnKv//omxBj8qtup PDDg== X-Gm-Message-State: ACrzQf1BW56KvdM558df68F0JRRJeeGQare93Snyt4sSo+Nd+qVVFf0U YUEdMGU2WE1sl3ufsTsLVpLvp4fmH2AacE9WCLVe0g== X-Received: by 2002:a17:907:8a17:b0:782:6e72:7aba with SMTP id sc23-20020a1709078a1700b007826e727abamr14424481ejc.474.1664780238397; Sun, 02 Oct 2022 23:57:18 -0700 (PDT) MIME-Version: 1.0 References: <20221002002326.946620-1-ira.weiny@intel.com> <20221002002326.946620-3-ira.weiny@intel.com> In-Reply-To: <20221002002326.946620-3-ira.weiny@intel.com> From: Sumit Garg Date: Mon, 3 Oct 2022 12:27:07 +0530 Message-ID: Subject: Re: [PATCH 2/4] tee: Remove vmalloc page support To: ira.weiny@intel.com Cc: Jens Wiklander , Andrew Morton , Al Viro , "Fabio M. De Francesco" , Christoph Hellwig , Linus Torvalds , op-tee@lists.trustedfirmware.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Phil Chang Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 + Phil Hi Ira, On Sun, 2 Oct 2022 at 05:53, wrote: > > From: Ira Weiny > > The kernel pages used by shm_get_kernel_pages() are allocated using > GFP_KERNEL through the following call stack: > > trusted_instantiate() > trusted_payload_alloc() -> GFP_KERNEL > > tee_shm_register_kernel_buf() > register_shm_helper() > shm_get_kernel_pages() > > Where is one of: > > trusted_key_unseal() > trusted_key_get_random() > trusted_key_seal() > > Remove the vmalloc page support from shm_get_kernel_pages(). Replace > with a warn on once. > > Cc: Jens Wiklander > Cc: Al Viro > Cc: "Fabio M. De Francesco" > Cc: Christoph Hellwig > Cc: Linus Torvalds > Signed-off-by: Ira Weiny > > --- > Jens I went with the suggestion from Linus and Christoph and rejected > vmalloc addresses. I did not hear back from you regarding Linus' > question if the vmalloc page support was required by an up coming patch > set or not. So I assumed it was something out of tree. It looks like I wasn't CC'd to that conversation. IIRC, support for vmalloc addresses was added recently by Phil here [1]. So I would like to give him a chance if he is planning to post a corresponding kernel driver upstream. [1] https://lists.trustedfirmware.org/archives/list/op-tee@lists.trustedfirmware.org/thread/M7HI3P2M66V27SK35CGQRICZ7DJZ5J2W/ -Sumit > --- > drivers/tee/tee_shm.c | 36 ++++++++++++------------------------ > 1 file changed, 12 insertions(+), 24 deletions(-) > > diff --git a/drivers/tee/tee_shm.c b/drivers/tee/tee_shm.c > index 27295bda3e0b..527a6eabc03e 100644 > --- a/drivers/tee/tee_shm.c > +++ b/drivers/tee/tee_shm.c > @@ -24,37 +24,25 @@ static void shm_put_kernel_pages(struct page **pages, size_t page_count) > static int shm_get_kernel_pages(unsigned long start, size_t page_count, > struct page **pages) > { > + struct kvec *kiov; > size_t n; > int rc; > > - if (is_vmalloc_addr((void *)start)) { > - struct page *page; > - > - for (n = 0; n < page_count; n++) { > - page = vmalloc_to_page((void *)(start + PAGE_SIZE * n)); > - if (!page) > - return -ENOMEM; > - > - get_page(page); > - pages[n] = page; > - } > - rc = page_count; > - } else { > - struct kvec *kiov; > - > - kiov = kcalloc(page_count, sizeof(*kiov), GFP_KERNEL); > - if (!kiov) > - return -ENOMEM; > + if (WARN_ON_ONCE(is_vmalloc_addr((void *)start))) > + return -EINVAL; > > - for (n = 0; n < page_count; n++) { > - kiov[n].iov_base = (void *)(start + n * PAGE_SIZE); > - kiov[n].iov_len = PAGE_SIZE; > - } > + kiov = kcalloc(page_count, sizeof(*kiov), GFP_KERNEL); > + if (!kiov) > + return -ENOMEM; > > - rc = get_kernel_pages(kiov, page_count, 0, pages); > - kfree(kiov); > + for (n = 0; n < page_count; n++) { > + kiov[n].iov_base = (void *)(start + n * PAGE_SIZE); > + kiov[n].iov_len = PAGE_SIZE; > } > > + rc = get_kernel_pages(kiov, page_count, 0, pages); > + kfree(kiov); > + > return rc; > } > > -- > 2.37.2 >