Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2445912rwb; Mon, 3 Oct 2022 00:12:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM66O+lhfUH5WE7GOXtyI7QC911rCTW1mujzWOnOe8yNpjtGuEWRTKKOXs2ylq7jJQMD9FvZ X-Received: by 2002:a17:907:969e:b0:782:6b92:6b1f with SMTP id hd30-20020a170907969e00b007826b926b1fmr13697027ejc.140.1664781172271; Mon, 03 Oct 2022 00:12:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664781172; cv=none; d=google.com; s=arc-20160816; b=M0bVk+n+WuduOc0B63Gytsk+wzChw2lsDjlWuRUe0ZjcBBMldcACcMwSIBxAR60g+B KG7o4VmkiddK+kAr5Z8PEg/+fzHlqBQep5tLNlObjtL8BtyL48f5WCX1r1Rt3cWHaiix b2z0ZOR8wal8Ft1nDxi0b/sxW4VBCNtN+CGx5O2C/N9XetTWkgereLCkFFzgwBa8fvpL pLyRolVMd6oaPp36Af80U0IdENF6d0jRQ0ShpcA1l7xoYUKMyKxjM2XVXN3rdk2LPeMo kSkvfT15Q3N3jrMdh4MVst8drNFcJP8BAsnrAtLJedHcFjimjj+gNlTWpyjHTSnMLjby HA2Q== 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=ScdaBgFXaRs1eyoBsVV/91rx258ROb5jgVthd9W2/J8=; b=EcKANBHYoS347BgzC7Zg2o+tsrCpfYCzENukRtZTXPAuiTUZ07KbbavFXMgczZ+VAk 7V86FhND0XAGtAUkjQSubbUvH+tSgU15xPtdO5ZEmuoIxESmuJm43ofGtrKAz6dXqwNL fqhi+p1eUsPTpzuEFgFpUUg7gkHg3K/6WENvjQe8L7B6VKqDXe6OG1hOTz8giiPVMFol 2aoRADhJBt1nCtb7szesJ/7SBabG2OVbPaassS1T2SsG+nSyJI+c9nvOsqSQPOBDD/ZD o/ObFjeAzFyDUIldbb1IM4YLizoSC/lTmplyF5wDz6WwmBhGtsU6kXE2k3qKukKXUV01 m5PA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DlFF2Ar2; 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 u5-20020a509505000000b0045744c3c3d8si7025946eda.515.2022.10.03.00.12.26; Mon, 03 Oct 2022 00:12:52 -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=DlFF2Ar2; 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 S229495AbiJCGlu (ORCPT + 99 others); Mon, 3 Oct 2022 02:41:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229506AbiJCGlq (ORCPT ); Mon, 3 Oct 2022 02:41:46 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 700CD3AE72 for ; Sun, 2 Oct 2022 23:41:44 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id l12so8916204pjh.2 for ; Sun, 02 Oct 2022 23:41:44 -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=ScdaBgFXaRs1eyoBsVV/91rx258ROb5jgVthd9W2/J8=; b=DlFF2Ar21f3FNeiCL9SCozGNsnkd9hYvXZfj+9n44a6RCBUTzL602lvQsvDplZvHHX ybk9hLAenBFNHiOymfzg+5VtD7XaklM5U9TaBzOzzELVHFfY2wgjEigUltyQZvqXws1l xK5CZHKnEkLT5zowBm732obuo7DVbUf6qgQA5089cHMV+5gZpO0aziXW74H60Jth06Qb TNt0mz/pGr+VcGpIWRG+BYL2Gb4uR7NwiFicQFVVP2FeQfFSM8mOGH8YuEu9NTnPjkfS jbMfazfBF/imqPMpxrCKBBOsK8QxnOFj6siWQS1EIQwuEFaUmyXpgPE3vECeJf3prxXX hExQ== 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=ScdaBgFXaRs1eyoBsVV/91rx258ROb5jgVthd9W2/J8=; b=Fa58AM4uxzGtEYF3KTDjsTpuvVtAwQrzmWKXNVq+KleKphos7uAmAR/PI4RwnESGrj 17r16rl2eK2pEQEMY+QTqhxTwctqi27ZgtehdkEsR5+wdZBQ0NtqS/VHpCiAGsSB43OY Ea35G88+01MDYLQh9WTWkZA7uHp3bEtKSMPIyd1E/ChSeetLSfYfW6iaC8Fzr0sR27e2 +z/oUSgH0GFzi+N1iaNMKbYnUHtNor1yBZwAXNv8++svrvh3N+RiYpcCxZLKS+OL0xkA R4CYKLsomUK5/Gf+e1n1dZO5uOB23bJudiJx2+OGNzz5riwP10Z426XX85TTq3Ig/b6P 9GvA== X-Gm-Message-State: ACrzQf0RiSRt0Q+CkvJTDZQyBuU/i4TnUR17VB1LvXbYsPNLfDPQ0usX sfM+XcnKvd9XJJcgWm3wL7WtDjj2VQe7gk/qUpYkVA== X-Received: by 2002:a17:90b:4b88:b0:202:e381:e643 with SMTP id lr8-20020a17090b4b8800b00202e381e643mr10508198pjb.148.1664779303942; Sun, 02 Oct 2022 23:41:43 -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: Jens Wiklander Date: Mon, 3 Oct 2022 08:41:33 +0200 Message-ID: Subject: Re: [PATCH 2/4] tee: Remove vmalloc page support To: ira.weiny@intel.com Cc: Sumit Garg , 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 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 Hi Ira, On Sun, Oct 2, 2022 at 2:23 AM 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. Yes, that's correctly assumed, sorry for not confirming that earlier. Reviewed-by: Jens Wiklander Thanks, Jens > --- > 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 >