Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1180933rwb; Sat, 1 Oct 2022 17:38:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Pd9xAvQQUBfQ1gsO5x6oUs9YY6Ty6qzKSrr8E5ekqTRh7xqu/HWHKVr8NjTKHiHZYBCoW X-Received: by 2002:a63:451a:0:b0:439:246e:807e with SMTP id s26-20020a63451a000000b00439246e807emr12697064pga.347.1664671128474; Sat, 01 Oct 2022 17:38:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664671128; cv=none; d=google.com; s=arc-20160816; b=RGqRyuiSN3ax9p6IA2vOTR7b8oEIIiodQ4mSb7TLkry9XB8qGTYJKJdm/1uPXSbK6A +4WgzQnReRf0BRi78O6yNHZpifCBB7e/WUIiFMmzyZjiFMQjdcHq9k5GMEhyrMIcPk4c w0ExXIT90alRdAIVDuBe0DsPtZTzuyI6+E6AgBGFnzIsYhXA95c0jaSTS83dPOeCLaYh C/Q7l65ElRXPG2e/Z9Otxe36i8O4K+fPcDX8wYgecukZu1SCHF7oLvohHbvb8NrsrANB hLwoZvfdOBeG2qbYtL19hvJ40REwAH5AwjP78CeAzT47u8kekCPlCJMq55YSAhihTxiZ oKng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6M8BnQwKiAh4H7hkE7Tr1T+bve46bp7bpKlNRsJ+3VU=; b=YELePn4SVACX0ER8vPzlOc1CypZl5U+QqP6RRw6eYiELNWH+KUaj6M8GpEHZ1oEHTL klG0AQX40FuUYhz/HX5gVW6D9JDFR4xjPscm0J69eh6XHZYB8deMj3QmqWFNkNzVWHin qwgPdrcPUPO4dcSoxlqmDIinlNxvderYPdM0BO/3tZ2AGVhdvkgZ6+causC1+2neP6N9 1XHt07lkO9jXkzD4WLAwy7DDZwIBMOGFZ9QRLi9d2jf87V2K90aiQ5tiO8a4VIUqGoXT vhasjdQlMFZ6M9/0+FSbHoxdL3t/k+OpHNe5LlQnblT+JDYzmt4Y5ql9geVL/49fUTTJ 0/sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=PKkmlvFv; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id om14-20020a17090b3a8e00b00202dd7a4d3csi7265974pjb.113.2022.10.01.17.38.37; Sat, 01 Oct 2022 17:38:48 -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=@intel.com header.s=Intel header.b=PKkmlvFv; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229586AbiJBAXh (ORCPT + 99 others); Sat, 1 Oct 2022 20:23:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229470AbiJBAXd (ORCPT ); Sat, 1 Oct 2022 20:23:33 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F74853024 for ; Sat, 1 Oct 2022 17:23:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664670212; x=1696206212; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=eSTT9RCqaAKsDAKHEpxgRwFsvLUWOLIZHfpn9oZ87V8=; b=PKkmlvFvARDlMFc1wqs+EBfozyiCC3NJ746ywLwREZBjdnIn4w0xl9JB QL4GIE/nuCwMdoQaZLFl5mBmf8hqTzKcTxIAvX5NA+S6wPScD2F6gRQDC mnnHNEnPPrEBG03UzujovnPjcJeL+R+SM3RcyXld8xaTylfd2chVXjivi 9TzMBPpRCBxov/i5gZGqGseD2gzUs9/ICjOUYJY4fcrOKBSIMET0DRWnA iMa0C/xjpRYZ6GaVbbd+TM1G7WEFwYvJJBeS8wAxSbltuvRtHj93bTV8h mJmWibPiJR5fzu/0VgzZdXCOttPDD7pyrWpemHw/X2Q31mSQtfkA/H+Ac g==; X-IronPort-AV: E=McAfee;i="6500,9779,10487"; a="285564521" X-IronPort-AV: E=Sophos;i="5.93,361,1654585200"; d="scan'208";a="285564521" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Oct 2022 17:23:32 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10487"; a="656347038" X-IronPort-AV: E=Sophos;i="5.93,361,1654585200"; d="scan'208";a="656347038" Received: from iweiny-desk3.amr.corp.intel.com (HELO localhost) ([10.213.181.73]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Oct 2022 17:23:31 -0700 From: ira.weiny@intel.com To: Jens Wiklander , Sumit Garg , Andrew Morton Cc: Ira Weiny , Al Viro , "Fabio M. De Francesco" , Christoph Hellwig , Linus Torvalds , op-tee@lists.trustedfirmware.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 2/4] tee: Remove vmalloc page support Date: Sat, 1 Oct 2022 17:23:24 -0700 Message-Id: <20221002002326.946620-3-ira.weiny@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221002002326.946620-1-ira.weiny@intel.com> References: <20221002002326.946620-1-ira.weiny@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_NONE 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 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. --- 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