From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F2ADC433F5 for ; Mon, 3 Oct 2022 06:41:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E7EDA6B0072; Mon, 3 Oct 2022 02:41:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E2E7E6B0073; Mon, 3 Oct 2022 02:41:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CCEEC8E0001; Mon, 3 Oct 2022 02:41:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id B545E6B0072 for ; Mon, 3 Oct 2022 02:41:46 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 8D48FA0A81 for ; Mon, 3 Oct 2022 06:41:46 +0000 (UTC) X-FDA: 79978692612.12.DF51C94 Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by imf30.hostedemail.com (Postfix) with ESMTP id 2EDDC80007 for ; Mon, 3 Oct 2022 06:41:44 +0000 (UTC) Received: by mail-pj1-f50.google.com with SMTP id v10-20020a17090a634a00b00205e48cf845so14387549pjs.4 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=0Dp0Ux0hSwtNE28evckAKX6LSDZuM4MqLC1Ze9c+rFzHNJGC/C/WXIkEKC+l4r2Ceh dnUpVg9fiky+qnJxuqSioGQtsEBepQbKrlgIUoips/wOXrQMRtt3HnJ/JSqrYXUiabhl gf3FL1ZAkEJ3EVAxsVtVU1FocPZcptJfjsq81rboV4cchCjnnvo4QkMn0J0M0xJcCezQ Xdue0/Aje7B6eEvKRNnBLJ+gmPCSr0ZdYClCXWUS+F9HopoTg1ArSv6SOpyRswAxwENj xVr/+DPJ00XqZdQNdLwUmLOT3oU08dW7yihAN9Aqjq6/oGzZQCypXvgx8765I5KWiDxm DXpg== X-Gm-Message-State: ACrzQf1+URSd+gLVclIKwUUyWIox4iC69Syytj764GkZcjfAJzjEZMg4 28f6D/M4Rh42ft8tF5M5N2gCvJyARg2Zj1nZYb9BUQ== X-Google-Smtp-Source: AMsMyM4mfa3XZLqdg492URjcVsH7rT6K1G8Xq4IJJbfmqDqVxmbS7hvkxYwDKhQ104Av+emUnEnfR1thSbTlYv2mNLM= 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" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664779305; a=rsa-sha256; cv=none; b=kmjy/atHR/3TnP680hpC8kHwLVSXGz990m2aDWY62fa2+ePeuEfKxKo5DvrkvXxgfhyz3E Hs7HGtP+OhBzJi3qmQ/HDk8v1h4kq0hgxbiJAdGMaXSAZ8QgyFczNzITCa82/fiZ2CJ1+Y E8cU7Nty+IJsFdUD8R1bOlCmt6IhhXE= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=linaro.org header.s=google header.b=DlFF2Ar2; spf=pass (imf30.hostedemail.com: domain of jens.wiklander@linaro.org designates 209.85.216.50 as permitted sender) smtp.mailfrom=jens.wiklander@linaro.org; dmarc=pass (policy=none) header.from=linaro.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664779305; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ScdaBgFXaRs1eyoBsVV/91rx258ROb5jgVthd9W2/J8=; b=mWDo6a6rfAV1SMqjGzjHeal/qwxyIaABQmFGZ9GWQ3rArwOD1JHXG2f0D6gvXuoZBFS7FJ IfusOb3ZDCBPQ/HQbkurleK9EajvFwGLQhYZ+sqNhSEVGMAdYrJZb4peKfIvOCW7dy/jcJ TZTSKRBgll2rPzH5jANHVR0c2MGGQbo= X-Stat-Signature: 8fsyiwt81eq7oa4a9e6r5e7f6z6u65m7 X-Rspamd-Queue-Id: 2EDDC80007 Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=linaro.org header.s=google header.b=DlFF2Ar2; spf=pass (imf30.hostedemail.com: domain of jens.wiklander@linaro.org designates 209.85.216.50 as permitted sender) smtp.mailfrom=jens.wiklander@linaro.org; dmarc=pass (policy=none) header.from=linaro.org X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1664779304-599754 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 >