From nobody Sat Sep 13 07:15:24 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23554C636CD for ; Sat, 4 Feb 2023 04:07:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232637AbjBDEGy (ORCPT ); Fri, 3 Feb 2023 23:06:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231375AbjBDEGs (ORCPT ); Fri, 3 Feb 2023 23:06:48 -0500 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50EAB93E3F for ; Fri, 3 Feb 2023 20:06:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675483607; x=1707019607; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=T75P/a7C6FXtvE4L4LzphFH5nPphv2diXLDPq5xM7Wg=; b=YiTweZh0+aAllsHYnxB5tuEiSQNHdILndxAPsmHkbAV50pdeP4/Gv5j9 h8OwNVnX9q57Z5upohu4oRxYZDG6m/Y1yFyBPA1GAHjR4cCnWsiZS0seg APZ3pQ4u5dpNMbbrKDkjGQq4I52WCvAfnJzqtci6fgkDWUWgikkTzj9DD Wf9cSSDd90LzJykVTMc5CsKECzKD+B2/bP4WCDSeIb0EYdclMSqOMX5Z2 53MeqiEjU2YI6IgJyEtJMtyGydMXtrOmMyXhf8Ktq9gwTKuISGYfJPE/2 mDUPWObWv/N9NLtxYYByZTJszQ2B55qjhxSCZu2GCfJgvANnbj0lPj/RN A==; X-IronPort-AV: E=McAfee;i="6500,9779,10610"; a="391309354" X-IronPort-AV: E=Sophos;i="5.97,272,1669104000"; d="scan'208";a="391309354" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Feb 2023 20:06:46 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10610"; a="734573722" X-IronPort-AV: E=Sophos;i="5.97,272,1669104000"; d="scan'208";a="734573722" Received: from iweiny-mobl.amr.corp.intel.com (HELO localhost) ([10.209.125.166]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Feb 2023 20:06:45 -0800 From: Ira Weiny Date: Fri, 03 Feb 2023 20:06:32 -0800 Subject: [PATCH v2 1/4] highmem: Enhance is_kmap_addr() to check kmap_local_page() mappings MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230203-get_kernel_pages-v2-1-f1dc4af273f1@intel.com> References: <20230203-get_kernel_pages-v2-0-f1dc4af273f1@intel.com> In-Reply-To: <20230203-get_kernel_pages-v2-0-f1dc4af273f1@intel.com> To: Sumit Garg , Andrew Morton Cc: Al Viro , Christoph Hellwig , linux-kernel@vger.kernel.org, op-tee@lists.trustedfirmware.org, linux-mm@kvack.org, Jens Wiklander , "Fabio M. De Francesco" , Ira Weiny , John Hubbard , Matthew Wilcox , Thomas Gleixner X-Mailer: b4 0.12-dev-cc11a X-Developer-Signature: v=1; a=ed25519-sha256; t=1675483603; l=1291; i=ira.weiny@intel.com; s=20221211; h=from:subject:message-id; bh=T75P/a7C6FXtvE4L4LzphFH5nPphv2diXLDPq5xM7Wg=; b=0B27CfriIJ0dEfMl8Am+J8B+vWOf/F2xdBWsw+oYNclAM5NadCqEGNnPN+iFuLdkXLXByDbAxosU okv9YtfrCVqkAntku9KClpR74B47/CFM0FjeMzURUnTIqo2RDh/w X-Developer-Key: i=ira.weiny@intel.com; a=ed25519; pk=noldbkG+Wp1qXRrrkfY1QJpDf7QsOEthbOT7vm0PqsE= Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org is_kmap_addr() is only looking at the kmap() address range which may cause check_heap_object() to miss checking an overflow on a kmap_local_page() page. Add a check for the kmap_local_page() address range to is_kmap_addr(). Cc: Matthew Wilcox Cc: Al Viro Cc: "Fabio M. De Francesco" Cc: Thomas Gleixner Cc: Christoph Hellwig Cc: Andrew Morton Signed-off-by: Ira Weiny Acked-by: Andrew Morton --- include/linux/highmem-internal.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/linux/highmem-internal.h b/include/linux/highmem-inter= nal.h index e098f38422af..a3028e400a9c 100644 --- a/include/linux/highmem-internal.h +++ b/include/linux/highmem-internal.h @@ -152,7 +152,10 @@ static inline void totalhigh_pages_add(long count) static inline bool is_kmap_addr(const void *x) { unsigned long addr =3D (unsigned long)x; - return addr >=3D PKMAP_ADDR(0) && addr < PKMAP_ADDR(LAST_PKMAP); + + return (addr >=3D PKMAP_ADDR(0) && addr < PKMAP_ADDR(LAST_PKMAP)) || + (addr >=3D __fix_to_virt(FIX_KMAP_END) && + addr < __fix_to_virt(FIX_KMAP_BEGIN)); } #else /* CONFIG_HIGHMEM */ =20 --=20 2.39.1 From nobody Sat Sep 13 07:15:24 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F38BC636D3 for ; Sat, 4 Feb 2023 04:07:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233086AbjBDEG5 (ORCPT ); Fri, 3 Feb 2023 23:06:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233004AbjBDEGu (ORCPT ); Fri, 3 Feb 2023 23:06:50 -0500 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8781193E3C for ; Fri, 3 Feb 2023 20:06:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675483609; x=1707019609; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=xPznNTTYEOG4Wgd/WE5V34/CM30jMXDiAV2/7i6RFQ0=; b=LHOFfvzIUQXyO3LMDkcSrL3Wk6fhPcpe7VMa5L0t3PWPcO4Uvbbnk23W ia/4PqNfkE8knqbCTonmKNmq16Hn3jRDsa8zwKelfHRwH9bL2zuAR+ocr Gs9t3idcKASwVNaW40YKefEeCApBaMFge6uupaaD8aK6IKu0/Fq1U/6CZ cXFjL3rEO+IgfcMwdwWlBYAEeBDMtFLimdHrNd84LxDpoKqadO4Ao8ise pGUJ4DAhrbbDhDkWYuKd792Z1oO0VvRBwydcer3RlqXXdzWTxTSGbJbRO 2LM9AJrvm5ZtsuwfdFckP+gykrDyy2B0Sbj7K7jjr8rMCSGk4A22+1vop g==; X-IronPort-AV: E=McAfee;i="6500,9779,10610"; a="391309373" X-IronPort-AV: E=Sophos;i="5.97,272,1669104000"; d="scan'208";a="391309373" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Feb 2023 20:06:48 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10610"; a="734573734" X-IronPort-AV: E=Sophos;i="5.97,272,1669104000"; d="scan'208";a="734573734" Received: from iweiny-mobl.amr.corp.intel.com (HELO localhost) ([10.209.125.166]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Feb 2023 20:06:47 -0800 From: Ira Weiny Date: Fri, 03 Feb 2023 20:06:33 -0800 Subject: [PATCH v2 2/4] tee: Remove vmalloc page support MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230203-get_kernel_pages-v2-2-f1dc4af273f1@intel.com> References: <20230203-get_kernel_pages-v2-0-f1dc4af273f1@intel.com> In-Reply-To: <20230203-get_kernel_pages-v2-0-f1dc4af273f1@intel.com> To: Sumit Garg , Andrew Morton Cc: Al Viro , Christoph Hellwig , linux-kernel@vger.kernel.org, op-tee@lists.trustedfirmware.org, linux-mm@kvack.org, Jens Wiklander , "Fabio M. De Francesco" , Ira Weiny , John Hubbard , Linus Torvalds X-Mailer: b4 0.12-dev-cc11a X-Developer-Signature: v=1; a=ed25519-sha256; t=1675483603; l=2347; i=ira.weiny@intel.com; s=20221211; h=from:subject:message-id; bh=xPznNTTYEOG4Wgd/WE5V34/CM30jMXDiAV2/7i6RFQ0=; b=zI8xrMYrd7xg0YhdT9eEp6Z83hAZpqExdK8hmPMgjoJ6qOuEy8ld7Ir/IYtcWFpxBVOS3FyxJzDM vG51TsTlAIyGPK7gBX8LG5wQeeEIUZ7KSW8JEbAuIHayiyf/Ewxa X-Developer-Key: i=ira.weiny@intel.com; a=ed25519; pk=noldbkG+Wp1qXRrrkfY1QJpDf7QsOEthbOT7vm0PqsE= Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: Al Viro Cc: "Fabio M. De Francesco" Cc: Christoph Hellwig Cc: Linus Torvalds Reviewed-by: Jens Wiklander Signed-off-by: Ira Weiny Reviewed-by: Christoph Hellwig Reviewed-by: Sumit Garg --- 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, s= ize_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; =20 - if (is_vmalloc_addr((void *)start)) { - struct page *page; - - for (n =3D 0; n < page_count; n++) { - page =3D vmalloc_to_page((void *)(start + PAGE_SIZE * n)); - if (!page) - return -ENOMEM; - - get_page(page); - pages[n] =3D page; - } - rc =3D page_count; - } else { - struct kvec *kiov; - - kiov =3D kcalloc(page_count, sizeof(*kiov), GFP_KERNEL); - if (!kiov) - return -ENOMEM; + if (WARN_ON_ONCE(is_vmalloc_addr((void *)start))) + return -EINVAL; =20 - for (n =3D 0; n < page_count; n++) { - kiov[n].iov_base =3D (void *)(start + n * PAGE_SIZE); - kiov[n].iov_len =3D PAGE_SIZE; - } + kiov =3D kcalloc(page_count, sizeof(*kiov), GFP_KERNEL); + if (!kiov) + return -ENOMEM; =20 - rc =3D get_kernel_pages(kiov, page_count, 0, pages); - kfree(kiov); + for (n =3D 0; n < page_count; n++) { + kiov[n].iov_base =3D (void *)(start + n * PAGE_SIZE); + kiov[n].iov_len =3D PAGE_SIZE; } =20 + rc =3D get_kernel_pages(kiov, page_count, 0, pages); + kfree(kiov); + return rc; } =20 --=20 2.39.1 From nobody Sat Sep 13 07:15:24 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA211C636D3 for ; Sat, 4 Feb 2023 04:07:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233133AbjBDEHC (ORCPT ); Fri, 3 Feb 2023 23:07:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233025AbjBDEGx (ORCPT ); Fri, 3 Feb 2023 23:06:53 -0500 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 886E1945F6 for ; Fri, 3 Feb 2023 20:06:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675483610; x=1707019610; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=JQRhs8fV+wugaMbuU/xsYw9mo1fl9vkSLqCGXzy9tz8=; b=Kba6PoV/VGGmY/+Hli75SQWZkwzpheJr7ktIit3+KFvEVUqxxeOYdIsJ GsrXN+p8bK72qldZ0cUa6d2N0md1TJxyTU1bM5V7uh07kGycEaxc5KqDw JwaZxjMlK9rSC119BrIIqrZkscSnkT4nCx/ReRw+KrVDaTvkMIDOzVvmD 3ifH3anQbbYjF1SS9BLrAQZ9jviYM0GW+92u2b9jdPJB/sFoU066zIhcz oZ9HuVv2DgOiqNw3rtlNcBkDYNxMd1gUroz0NlbgyXnMFkFsRAXIyunSI V5HzX82m4tmWNpQj0isUb35XPe3RI7QhX4W8OPpNzKAbeZg9UmaB8wyVh w==; X-IronPort-AV: E=McAfee;i="6500,9779,10610"; a="391309384" X-IronPort-AV: E=Sophos;i="5.97,272,1669104000"; d="scan'208";a="391309384" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Feb 2023 20:06:49 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10610"; a="734573743" X-IronPort-AV: E=Sophos;i="5.97,272,1669104000"; d="scan'208";a="734573743" Received: from iweiny-mobl.amr.corp.intel.com (HELO localhost) ([10.209.125.166]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Feb 2023 20:06:48 -0800 From: Ira Weiny Date: Fri, 03 Feb 2023 20:06:34 -0800 Subject: [PATCH v2 3/4] tee: Remove call to get_kernel_pages() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230203-get_kernel_pages-v2-3-f1dc4af273f1@intel.com> References: <20230203-get_kernel_pages-v2-0-f1dc4af273f1@intel.com> In-Reply-To: <20230203-get_kernel_pages-v2-0-f1dc4af273f1@intel.com> To: Sumit Garg , Andrew Morton Cc: Al Viro , Christoph Hellwig , linux-kernel@vger.kernel.org, op-tee@lists.trustedfirmware.org, linux-mm@kvack.org, Jens Wiklander , "Fabio M. De Francesco" , Ira Weiny , John Hubbard , Linus Torvalds X-Mailer: b4 0.12-dev-cc11a X-Developer-Signature: v=1; a=ed25519-sha256; t=1675483603; l=2426; i=ira.weiny@intel.com; s=20221211; h=from:subject:message-id; bh=JQRhs8fV+wugaMbuU/xsYw9mo1fl9vkSLqCGXzy9tz8=; b=AaCtTJ4OiWZ81WHjyg8HuDS5/qjKjXFczxneo+wuWXA1er0d3AbqF8WmVH8OPaOMT7MFHfqplc4h 8SdcI7hmA9jv/b3bsJlcrP/twziO9uzdZVNnfM9Qbjeiy1zfFBMX X-Developer-Key: i=ira.weiny@intel.com; a=ed25519; pk=noldbkG+Wp1qXRrrkfY1QJpDf7QsOEthbOT7vm0PqsE= Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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() Because the pages can't be from highmem get_kernel_pages() boils down to a get_page() call. Remove the get_kernel_pages() call and open code the get_page(). In case a highmem page does slip through warn on once for a kmap'ed address. Cc: Jens Wiklander Cc: Al Viro Cc: "Fabio M. De Francesco" Cc: Christoph Hellwig Cc: Linus Torvalds Signed-off-by: Ira Weiny Reviewed-by: Christoph Hellwig Reviewed-by: Sumit Garg --- Changes from v1: Al/Christoph: Remove kiov altogether --- drivers/tee/tee_shm.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/drivers/tee/tee_shm.c b/drivers/tee/tee_shm.c index 527a6eabc03e..b1c6231defad 100644 --- a/drivers/tee/tee_shm.c +++ b/drivers/tee/tee_shm.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "tee_private.h" =20 static void shm_put_kernel_pages(struct page **pages, size_t page_count) @@ -24,26 +25,20 @@ static void shm_put_kernel_pages(struct page **pages, s= ize_t page_count) static int shm_get_kernel_pages(unsigned long start, size_t page_count, struct page **pages) { - struct kvec *kiov; + struct page *page; size_t n; - int rc; =20 - if (WARN_ON_ONCE(is_vmalloc_addr((void *)start))) + if (WARN_ON_ONCE(is_vmalloc_addr((void *)start) || + is_kmap_addr((void *)start))) return -EINVAL; =20 - kiov =3D kcalloc(page_count, sizeof(*kiov), GFP_KERNEL); - if (!kiov) - return -ENOMEM; - + page =3D virt_to_page(start); for (n =3D 0; n < page_count; n++) { - kiov[n].iov_base =3D (void *)(start + n * PAGE_SIZE); - kiov[n].iov_len =3D PAGE_SIZE; + pages[n] =3D page + n; + get_page(pages[n]); } =20 - rc =3D get_kernel_pages(kiov, page_count, 0, pages); - kfree(kiov); - - return rc; + return page_count; } =20 static void release_registered_pages(struct tee_shm *shm) --=20 2.39.1 From nobody Sat Sep 13 07:15:24 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15CF5C636D3 for ; Sat, 4 Feb 2023 04:07:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233147AbjBDEHI (ORCPT ); Fri, 3 Feb 2023 23:07:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233034AbjBDEGy (ORCPT ); Fri, 3 Feb 2023 23:06:54 -0500 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0440D93E3F for ; Fri, 3 Feb 2023 20:06:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675483613; x=1707019613; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=Gn7LOPh68jC6rQtBAdzLGiAHS3AXRc2KQzYf1z3imZ8=; b=X3FfTmHWBRDVLCV4bSpXufeKBUz85bdW35WbIdU7grhq3LmIbh0bZACb 3sXYUYpwPdq3TfYApb32wcu8JzeyOLexGrP8OG2gTbRJlvPOhs82ObSkS dYj0e7TJssNHUf/W4+RQ8SqkGcyvL/pPa1R8qfCVCPwtOUmge4Mk+DE6I Vz8pCvw0wTo3299B0aMneAZREGpBUKB29bl22ADOnPTXYL6Sexz4gBbMo gptzVjeT9a9/jxXH95V0v3bMtvobyANnJSt1estD/zWN/MzK0ZeWV19JX DwirbfZsF9XXejQQF08s24T+DGwyNq0HCxcTwUiyXl5IwXMafNlUEuQmr Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10610"; a="391309393" X-IronPort-AV: E=Sophos;i="5.97,272,1669104000"; d="scan'208";a="391309393" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Feb 2023 20:06:51 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10610"; a="734573746" X-IronPort-AV: E=Sophos;i="5.97,272,1669104000"; d="scan'208";a="734573746" Received: from iweiny-mobl.amr.corp.intel.com (HELO localhost) ([10.209.125.166]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Feb 2023 20:06:50 -0800 From: Ira Weiny Date: Fri, 03 Feb 2023 20:06:35 -0800 Subject: [PATCH v2 4/4] mm: Remove get_kernel_pages() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230203-get_kernel_pages-v2-4-f1dc4af273f1@intel.com> References: <20230203-get_kernel_pages-v2-0-f1dc4af273f1@intel.com> In-Reply-To: <20230203-get_kernel_pages-v2-0-f1dc4af273f1@intel.com> To: Sumit Garg , Andrew Morton Cc: Al Viro , Christoph Hellwig , linux-kernel@vger.kernel.org, op-tee@lists.trustedfirmware.org, linux-mm@kvack.org, Jens Wiklander , "Fabio M. De Francesco" , Ira Weiny , John Hubbard , Mel Gorman X-Mailer: b4 0.12-dev-cc11a X-Developer-Signature: v=1; a=ed25519-sha256; t=1675483603; l=2399; i=ira.weiny@intel.com; s=20221211; h=from:subject:message-id; bh=Gn7LOPh68jC6rQtBAdzLGiAHS3AXRc2KQzYf1z3imZ8=; b=dtMl0p52IOZ2AWrZlNxQC0o566NNoARG+88pUiatsr9mZ3kAamW4p30F2cWrtR7TWfG/NlmQ5P46 nLpzu72hCrXm4hl+axUIWouYPD1240kahyv/zdlOeYxdAtDG2vnq X-Developer-Key: i=ira.weiny@intel.com; a=ed25519; pk=noldbkG+Wp1qXRrrkfY1QJpDf7QsOEthbOT7vm0PqsE= Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The only caller to get_kernel_pages() [shm_get_kernel_pages()] has been updated to not need it. Remove get_kernel_pages(). Cc: Mel Gorman Cc: Al Viro Cc: "Fabio M. De Francesco" Cc: Christoph Hellwig Cc: Andrew Morton Acked-by: John Hubbard Signed-off-by: Ira Weiny Acked-by: Andrew Morton Reviewed-by: Christoph Hellwig Reviewed-by: Sumit Garg --- include/linux/mm.h | 2 -- mm/swap.c | 30 ------------------------------ 2 files changed, 32 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 8f857163ac89..2041e6d4fa27 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2095,8 +2095,6 @@ int __account_locked_vm(struct mm_struct *mm, unsigne= d long pages, bool inc, struct task_struct *task, bool bypass_rlim); =20 struct kvec; -int get_kernel_pages(const struct kvec *iov, int nr_pages, int write, - struct page **pages); struct page *get_dump_page(unsigned long addr); =20 bool folio_mark_dirty(struct folio *folio); diff --git a/mm/swap.c b/mm/swap.c index 70e2063ef43a..4c03ecab698e 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -158,36 +158,6 @@ void put_pages_list(struct list_head *pages) } EXPORT_SYMBOL(put_pages_list); =20 -/* - * get_kernel_pages() - pin kernel pages in memory - * @kiov: An array of struct kvec structures - * @nr_segs: number of segments to pin - * @write: pinning for read/write, currently ignored - * @pages: array that receives pointers to the pages pinned. - * Should be at least nr_segs long. - * - * Returns number of pages pinned. This may be fewer than the number reque= sted. - * If nr_segs is 0 or negative, returns 0. If no pages were pinned, retur= ns 0. - * Each page returned must be released with a put_page() call when it is - * finished with. - */ -int get_kernel_pages(const struct kvec *kiov, int nr_segs, int write, - struct page **pages) -{ - int seg; - - for (seg =3D 0; seg < nr_segs; seg++) { - if (WARN_ON(kiov[seg].iov_len !=3D PAGE_SIZE)) - return seg; - - pages[seg] =3D kmap_to_page(kiov[seg].iov_base); - get_page(pages[seg]); - } - - return seg; -} -EXPORT_SYMBOL_GPL(get_kernel_pages); - typedef void (*move_fn_t)(struct lruvec *lruvec, struct folio *folio); =20 static void lru_add_fn(struct lruvec *lruvec, struct folio *folio) --=20 2.39.1