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 4D84BC77B7A for ; Wed, 17 May 2023 19:25:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A6EFA900003; Wed, 17 May 2023 15:25:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A1E50280001; Wed, 17 May 2023 15:25:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8BF69900007; Wed, 17 May 2023 15:25:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 79F76900003 for ; Wed, 17 May 2023 15:25:41 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 49AF2160309 for ; Wed, 17 May 2023 19:25:41 +0000 (UTC) X-FDA: 80800726440.08.2794F2B Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) by imf25.hostedemail.com (Postfix) with ESMTP id 5A41BA000D for ; Wed, 17 May 2023 19:25:38 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=nfT3DV5j; spf=pass (imf25.hostedemail.com: domain of lstoakes@gmail.com designates 209.85.128.54 as permitted sender) smtp.mailfrom=lstoakes@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684351538; a=rsa-sha256; cv=none; b=PGdbVSgizsqMFHxMUPJzoxqDpVDuH0MZY2SkJaDEoCGKPlFX4bl3NUxQN1Z1egQ43/v4eW oSoCEp/tCOvCJdxqRRprGS2iLgU+4Gr/BglF2+zzEeOJf/+zFZyv/dkE8fmDH6qDus/WXQ XhpfGQZst6GNAb3Aqum3PDSyL6u470I= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=nfT3DV5j; spf=pass (imf25.hostedemail.com: domain of lstoakes@gmail.com designates 209.85.128.54 as permitted sender) smtp.mailfrom=lstoakes@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684351538; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=tvBvKq78j+8ZO0sz/gcDiszQ/0Gmc90EAVmVpzMrEXI=; b=SSKRoMJcg39UMjjR5ZY6AuSKNCSQOF06+knJ3MpkTckmYZ7Z6UkJzXmwH04zOrQgc14fey zUCX6A5QXZuD0IW/qYmKdWamLu4by+zDdYCgImkEapxOvVYu4Z0QtLUlB7J/9phN5TZfIc zcPKY7n/XukSPjzNMSimFtpwSq10SXk= Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-3f4449fa085so8032855e9.0 for ; Wed, 17 May 2023 12:25:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684351536; x=1686943536; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tvBvKq78j+8ZO0sz/gcDiszQ/0Gmc90EAVmVpzMrEXI=; b=nfT3DV5jdC7gxwPrB/ZKtPnYKQ25gnkriwDG+lhLVAFjGa2OetNGiE9gmXcXovGYCZ Q3kF9JnLaH5lvilBxfIpE1fO/wxjDmjWesKGbNm17C2MuNhCciajaM9AX2mvr64+T1pp tmFn0ISHaDw9UvQ0vkVUpL7vfPfkMQdv9i9dA1ycdyrdDtgoXSGJNQidYAU+sxl1Vl/Z xgRB1Pc4DOqGRA+7foY8MKfdB7FJRw/LCZhhzyQsCEEJEv1Q2jjwotxrXcQoTeFfMZFS ONu7altJvB7HoYyawfb5c4BafqJkYTmhOmtqrpwujLCHwMbnglsU9EG/H4SLt5bpbyNW X8aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684351536; x=1686943536; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tvBvKq78j+8ZO0sz/gcDiszQ/0Gmc90EAVmVpzMrEXI=; b=BXAQPhODXtrJEvoLIlnZJdrPDunn0Q4ZWmcbV2V06PDpXjFatUzc4MRVwHoH7/sD4r IPSL28FsJk3FBwoM2Dc99X2cxLnsU0pYF0A9vy3jNEmBsK/rikiZPRL/Si94kUBJQGYp B8m+78pt9p0j/x2ffHLqdNY7pP01YWO2784duRmPiIGVK5PyCLw6eEpAV6d5ZjbtXzze WfW4h4d843uaaSgjTMGReAmuzvRm4IWy3IMutJrU9Db5q/e4x1dgkiNabTx/jlucWkFa UDK7Eh9DmwfVXDd7io9FgCOW5KGEEsGZob/AzPw+cf7RhRpfg//cRnrmsfFSgiY0izos TI1g== X-Gm-Message-State: AC+VfDzqxTO8pu0PBvvfK8bFl4Xavyz6SCHSY06tWEC8igfbvdpVYPJA tYKQ62qvJIPAlVffuxUUTeKmQlKPQtX28A== X-Google-Smtp-Source: ACHHUZ6bsCbUCY0r6E6dZjjVwGP76WCyzce1QcEy5aU0k29CWJV6pgBDdw+tD0qwF6dXuTCLd2aOmQ== X-Received: by 2002:a1c:f711:0:b0:3f5:1a4:a08d with SMTP id v17-20020a1cf711000000b003f501a4a08dmr9995991wmh.7.1684351536409; Wed, 17 May 2023 12:25:36 -0700 (PDT) Received: from lucifer.home (host86-156-84-164.range86-156.btcentralplus.com. [86.156.84.164]) by smtp.googlemail.com with ESMTPSA id p4-20020a05600c358400b003f1738d0d13sm4252469wmq.1.2023.05.17.12.25.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 May 2023 12:25:35 -0700 (PDT) From: Lorenzo Stoakes To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton Cc: Matthew Wilcox , David Hildenbrand , x86@kernel.org, linux-sgx@vger.kernel.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, kvm@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Jarkko Sakkinen , "H . Peter Anvin" , Xinhui Pan , David Airlie , Daniel Vetter , Dimitri Sivanich , Arnd Bergmann , Greg Kroah-Hartman , Paolo Bonzini , Jens Axboe , Pavel Begunkov , Jason Gunthorpe , John Hubbard , Christian Konig , Lorenzo Stoakes , Jason Gunthorpe , Christoph Hellwig , Sean Christopherson Subject: [PATCH v6 1/6] mm/gup: remove unused vmas parameter from get_user_pages() Date: Wed, 17 May 2023 20:25:33 +0100 Message-Id: <589e0c64794668ffc799651e8d85e703262b1e9d.1684350871.git.lstoakes@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Stat-Signature: ui5zxows3kawcb9xb167q9cukrwiny5w X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 5A41BA000D X-HE-Tag: 1684351538-585266 X-HE-Meta: U2FsdGVkX19UhessWxNT71BsiXtSEcmm42zC3XrPYl5Bu55x7P+HdGL8r4dy4Ot2Ns4gS1u/9Swww6RYW1ayQEi5SunX3qoWXmSN8sgsEnArx0IMTdCJgRy5LVIPCNhVkIJZxGD+GMVsZ1vMeGiWn2Qz/VCemDX1db6kSD/XOAKBDyfTlffXczyNOC9K3VJYpESDqBFR6AK5oWDiKnRbGIJ/UTbe15wT7/ptTyO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Y2wV+nr0bXrWoTjqL4yCYZVoJc/bVRNEEBhy1dCkTNOgtkhLpVnm0Zj+jI+C2aW40rDqQ1TbRXr3PZ8ItxPBCbLYUgmRdDCF0fC+/gfQ1yhNPsfWOniZdErvLgvQh0oHApvHw30Ka6X+5jDScriF1/9cw+ruOpXTrn/dQZvsqvzcS/HiOlyuHHHUbwDQIToK8zC41OZmgEQrgUBTV2loocThDSpnxW9atppcXwU4TSA8yDHrB81V4L5x310bwIEvJCjhE4Gtx8TxSGt8917lXMmcLZ8tuw974iIbSwLP0k7wSFK8AAMwzvrsxE3BSYLBOVpiXdpuAYQjtUoFRikP3jsf6+Ow7RWt1GOVAnKFGi5H8a28bSJ5l2QLW+TXXTM+Eoeiwo1mV5g64MWzMMHZm7OhHjmBVF88OVNijWKUBsrzG9X3/du46QJr239nFCl1TO20eQ32BhgjsoxeILnmVLIOt6lcVIvuhhGp/GX1TVvkb8Nj+MUpVfH5XaIlALr4nYFWpNRw8ozbCoWXbCJRDthA== 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: No invocation of get_user_pages() use the vmas parameter, so remove it. The GUP API is confusing and caveated. Recent changes have done much to improve that, however there is more we can do. Exporting vmas is a prime target as the caller has to be extremely careful to preclude their use after the mmap_lock has expired or otherwise be left with dangling pointers. Removing the vmas parameter focuses the GUP functions upon their primary purpose - pinning (and outputting) pages as well as performing the actions implied by the input flags. This is part of a patch series aiming to remove the vmas parameter altogether. Suggested-by: Matthew Wilcox (Oracle) Acked-by: Greg Kroah-Hartman Acked-by: David Hildenbrand Reviewed-by: Jason Gunthorpe Acked-by: Christian König (for radeon parts) Acked-by: Jarkko Sakkinen Reviewed-by: Christoph Hellwig Acked-by: Sean Christopherson (KVM) Signed-off-by: Lorenzo Stoakes --- arch/x86/kernel/cpu/sgx/ioctl.c | 2 +- drivers/gpu/drm/radeon/radeon_ttm.c | 2 +- drivers/misc/sgi-gru/grufault.c | 2 +- include/linux/mm.h | 3 +-- mm/gup.c | 9 +++------ mm/gup_test.c | 5 ++--- virt/kvm/kvm_main.c | 2 +- 7 files changed, 10 insertions(+), 15 deletions(-) diff --git a/arch/x86/kernel/cpu/sgx/ioctl.c b/arch/x86/kernel/cpu/sgx/ioctl.c index 21ca0a831b70..5d390df21440 100644 --- a/arch/x86/kernel/cpu/sgx/ioctl.c +++ b/arch/x86/kernel/cpu/sgx/ioctl.c @@ -214,7 +214,7 @@ static int __sgx_encl_add_page(struct sgx_encl *encl, if (!(vma->vm_flags & VM_MAYEXEC)) return -EACCES; - ret = get_user_pages(src, 1, 0, &src_page, NULL); + ret = get_user_pages(src, 1, 0, &src_page); if (ret < 1) return -EFAULT; diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c index 2220cdf6a3f6..3a9db030f98f 100644 --- a/drivers/gpu/drm/radeon/radeon_ttm.c +++ b/drivers/gpu/drm/radeon/radeon_ttm.c @@ -359,7 +359,7 @@ static int radeon_ttm_tt_pin_userptr(struct ttm_device *bdev, struct ttm_tt *ttm struct page **pages = ttm->pages + pinned; r = get_user_pages(userptr, num_pages, write ? FOLL_WRITE : 0, - pages, NULL); + pages); if (r < 0) goto release_pages; diff --git a/drivers/misc/sgi-gru/grufault.c b/drivers/misc/sgi-gru/grufault.c index b836936e9747..378cf02a2aa1 100644 --- a/drivers/misc/sgi-gru/grufault.c +++ b/drivers/misc/sgi-gru/grufault.c @@ -185,7 +185,7 @@ static int non_atomic_pte_lookup(struct vm_area_struct *vma, #else *pageshift = PAGE_SHIFT; #endif - if (get_user_pages(vaddr, 1, write ? FOLL_WRITE : 0, &page, NULL) <= 0) + if (get_user_pages(vaddr, 1, write ? FOLL_WRITE : 0, &page) <= 0) return -EFAULT; *paddr = page_to_phys(page); put_page(page); diff --git a/include/linux/mm.h b/include/linux/mm.h index db3f66ed2f32..2c1a92bf5626 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2382,8 +2382,7 @@ long pin_user_pages_remote(struct mm_struct *mm, unsigned int gup_flags, struct page **pages, struct vm_area_struct **vmas, int *locked); long get_user_pages(unsigned long start, unsigned long nr_pages, - unsigned int gup_flags, struct page **pages, - struct vm_area_struct **vmas); + unsigned int gup_flags, struct page **pages); long pin_user_pages(unsigned long start, unsigned long nr_pages, unsigned int gup_flags, struct page **pages, struct vm_area_struct **vmas); diff --git a/mm/gup.c b/mm/gup.c index 90d9b65ff35c..b8189396f435 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -2294,8 +2294,6 @@ long get_user_pages_remote(struct mm_struct *mm, * @pages: array that receives pointers to the pages pinned. * Should be at least nr_pages long. Or NULL, if caller * only intends to ensure the pages are faulted in. - * @vmas: array of pointers to vmas corresponding to each page. - * Or NULL if the caller does not require them. * * This is the same as get_user_pages_remote(), just with a less-flexible * calling convention where we assume that the mm being operated on belongs to @@ -2303,16 +2301,15 @@ long get_user_pages_remote(struct mm_struct *mm, * obviously don't pass FOLL_REMOTE in here. */ long get_user_pages(unsigned long start, unsigned long nr_pages, - unsigned int gup_flags, struct page **pages, - struct vm_area_struct **vmas) + unsigned int gup_flags, struct page **pages) { int locked = 1; - if (!is_valid_gup_args(pages, vmas, NULL, &gup_flags, FOLL_TOUCH)) + if (!is_valid_gup_args(pages, NULL, NULL, &gup_flags, FOLL_TOUCH)) return -EINVAL; return __get_user_pages_locked(current->mm, start, nr_pages, pages, - vmas, &locked, gup_flags); + NULL, &locked, gup_flags); } EXPORT_SYMBOL(get_user_pages); diff --git a/mm/gup_test.c b/mm/gup_test.c index 8ae7307a1bb6..9ba8ea23f84e 100644 --- a/mm/gup_test.c +++ b/mm/gup_test.c @@ -139,8 +139,7 @@ static int __gup_test_ioctl(unsigned int cmd, pages + i); break; case GUP_BASIC_TEST: - nr = get_user_pages(addr, nr, gup->gup_flags, pages + i, - NULL); + nr = get_user_pages(addr, nr, gup->gup_flags, pages + i); break; case PIN_FAST_BENCHMARK: nr = pin_user_pages_fast(addr, nr, gup->gup_flags, @@ -161,7 +160,7 @@ static int __gup_test_ioctl(unsigned int cmd, pages + i, NULL); else nr = get_user_pages(addr, nr, gup->gup_flags, - pages + i, NULL); + pages + i); break; default: ret = -EINVAL; diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index cb5c13eee193..eaa5bb8dbadc 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2477,7 +2477,7 @@ static inline int check_user_page_hwpoison(unsigned long addr) { int rc, flags = FOLL_HWPOISON | FOLL_WRITE; - rc = get_user_pages(addr, 1, flags, NULL, NULL); + rc = get_user_pages(addr, 1, flags, NULL); return rc == -EHWPOISON; } -- 2.40.1