From patchwork Fri Aug 9 16:09:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13758941 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 6E597C52D7C for ; Fri, 9 Aug 2024 16:10:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C266B6B00B3; Fri, 9 Aug 2024 12:09:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BD76E6B00B4; Fri, 9 Aug 2024 12:09:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A2B626B00B5; Fri, 9 Aug 2024 12:09:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 6937F6B00B3 for ; Fri, 9 Aug 2024 12:09:56 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 205F01A10A7 for ; Fri, 9 Aug 2024 16:09:56 +0000 (UTC) X-FDA: 82433193192.18.46F404D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf09.hostedemail.com (Postfix) with ESMTP id EA2DF14001B for ; Fri, 9 Aug 2024 16:09:53 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="D/yHJWk5"; spf=pass (imf09.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723219728; 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=rQ5uhZ2uiWdH1/UlOzJ8LVGX9FzFBDg5i1FarWNBfgY=; b=L/TVFcN3b/NyCzzesVpz2/2lE56ZXQihkt+fp6x8+sNH8FE1yNg6pzenOZqmydvdaSVmoZ /H1K61zgW1IKB6cxB0sRRH74+rBsTI71lXz75l7NLZPtyQ4/bndh2ny5kyHk3L6aKRAFQm xJAVihtmYkACUjpPsloUenWjPD4eZwo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723219728; a=rsa-sha256; cv=none; b=Ww5UYP+KjIMxkSirixv473LE1+eBE9v8fbhUrEicEVDlyd0WFmw9LYWAyMKjOGBBNu9UJj OL02F74N3bWNSQ3ldViscllT9mH3COSvqPscGoMnOtcJSuufuaGbb5xBNdRZgNXfqsp3BV P7ti+9Gz2ebvu1SZMEdJlCm3lQv619I= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="D/yHJWk5"; spf=pass (imf09.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723219793; h=from:from: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; bh=rQ5uhZ2uiWdH1/UlOzJ8LVGX9FzFBDg5i1FarWNBfgY=; b=D/yHJWk542YQuqv98dJ1Lz39VKd6FMmXeCkRhZgOQ0ZAhJctotI2zvckv8tJzeK8F7q8QM VWPAydnVlKDIGI4XuAa+n6e5EWr1eV/5fOzRRgx8zPrVnaHUNNNY/GxTYsXct8i6C6VE5l ZnFZoNM50MBLM65mwY2UQJyHgycaQGU= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-124-GVWj-RqTPIWetj5oBnv1bA-1; Fri, 09 Aug 2024 12:09:51 -0400 X-MC-Unique: GVWj-RqTPIWetj5oBnv1bA-1 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-44fe28cd027so3758651cf.0 for ; Fri, 09 Aug 2024 09:09:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723219791; x=1723824591; 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=rQ5uhZ2uiWdH1/UlOzJ8LVGX9FzFBDg5i1FarWNBfgY=; b=SuvKu7yk/9aw3ksoPH+aOtVhqVRDeoL8d32B81FhNt7jSmsX5KgG0oaMM9/WZfGlKc 2GfdsTJyZrmLmoqnQ8CTZ3Zv0SfIMws/zFP3Kkq115ANdkBvbBre3BZ8cpINx2LqIIck xSm7WIe6dY4fBBKalPd/1kugeaywipif8IwWykY4i1+ZuSw9XcEBfSiyKZjh/3plUTAj ZQzz2mNSIReJVDCwKIvTkwPKXHvXqK4OZ7gg2r9oMV2iProOfuyPCNbNYgDEI3HOqOR9 5l7i5J3TQIERx8H/d4cZv3JlCFlEcncBftbyhJwmpCAf837hRdbonMejwJqbI/iFHwVA JFPA== X-Gm-Message-State: AOJu0YxjPyxhl+xEidPVb4Rrq+ywVs1MBTlx6OUTKi7zrsYUjTQHUrB8 6o2W61MzrPaQnwqZrDtYRmbBxcqQMhbk4RGF+OGzywnU2ErexTB8xax+gBfoGSEi3M3ZVeI5NZT t7n3lvgmmeHzjvocqpMuFQVpRouOfqjFwnS7Mq4kt9emDOvt8EckfEIwrhMs67Y4hp00Dqnfg4h +VLv4WMKsk6WnDHmwlsuyfs13QQaILR5dj X-Received: by 2002:a05:622a:412:b0:444:b935:ebb5 with SMTP id d75a77b69052e-45312359fbcmr13373751cf.0.1723219790923; Fri, 09 Aug 2024 09:09:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH2UCzm8Bb1pveediLGLwWSJm3e36K8ZWtfh9bSQqsAnCTBAfRwieQENSqzRtCTpHEz3lk41Q== X-Received: by 2002:a05:622a:412:b0:444:b935:ebb5 with SMTP id d75a77b69052e-45312359fbcmr13373301cf.0.1723219790408; Fri, 09 Aug 2024 09:09:50 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-451c870016csm22526741cf.19.2024.08.09.09.09.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Aug 2024 09:09:49 -0700 (PDT) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Sean Christopherson , Oscar Salvador , Jason Gunthorpe , Axel Rasmussen , linux-arm-kernel@lists.infradead.org, x86@kernel.org, peterx@redhat.com, Will Deacon , Gavin Shan , Paolo Bonzini , Zi Yan , Andrew Morton , Catalin Marinas , Ingo Molnar , Alistair Popple , Borislav Petkov , David Hildenbrand , Thomas Gleixner , kvm@vger.kernel.org, Dave Hansen , Alex Williamson , Yan Zhao Subject: [PATCH 16/19] mm: Remove follow_pte() Date: Fri, 9 Aug 2024 12:09:06 -0400 Message-ID: <20240809160909.1023470-17-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240809160909.1023470-1-peterx@redhat.com> References: <20240809160909.1023470-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspamd-Queue-Id: EA2DF14001B X-Stat-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D TUMR+sH308Anq1C+HaYIwWSFdTD39LIY3QDzArSkMwGmo3IH2fg7xglGPPrwvrW0q2dfORFCtvd6ybuYf098pfn7aKs7fNsB6Qzj3Iugltrp3do+SILm/v2YxR7+UyxYL1AcI241yU7hl1SipF8OVSLrATByPDD2rd6/k3zS7ijdjKiuQUlG8exjPaKkME3uhmisU0ZyFLcOC20FStsfXLPCWU0afItVmXizmmh+o4+YZ2/79z8h99+YZzM/ALYheUXzbztZG+5nCgCg4Ax/hTSxnF0BrlRpjV3qRUUtAjF0sYh0Hl33ypXkOirLbPPctdudlfeVCAbyWlqGs5m8Dc4AqKHXSAx/2ANNt/YbbPpwytibwfv18HRVE6Wl4uPTGNbEUMEE1p2NoyMOnTDz75w1tfal/mlWFhp0RrOP8f4C/3IEOz49XqTV1rQnz1KP8UFklGnW2rtcrIZ7mid49XnQjJg== 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: List-Subscribe: List-Unsubscribe: follow_pte() users have been converted to follow_pfnmap*(). Remove the API. Signed-off-by: Peter Xu --- include/linux/mm.h | 2 -- mm/memory.c | 73 ---------------------------------------------- 2 files changed, 75 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 7471302658af..c5949b8052c6 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2369,8 +2369,6 @@ void free_pgd_range(struct mmu_gather *tlb, unsigned long addr, unsigned long end, unsigned long floor, unsigned long ceiling); int copy_page_range(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma); -int follow_pte(struct vm_area_struct *vma, unsigned long address, - pte_t **ptepp, spinlock_t **ptlp); int generic_access_phys(struct vm_area_struct *vma, unsigned long addr, void *buf, int len, int write); diff --git a/mm/memory.c b/mm/memory.c index 313c17eedf56..72f61fffdda2 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -6265,79 +6265,6 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address) } #endif /* __PAGETABLE_PMD_FOLDED */ -/** - * follow_pte - look up PTE at a user virtual address - * @vma: the memory mapping - * @address: user virtual address - * @ptepp: location to store found PTE - * @ptlp: location to store the lock for the PTE - * - * On a successful return, the pointer to the PTE is stored in @ptepp; - * the corresponding lock is taken and its location is stored in @ptlp. - * - * The contents of the PTE are only stable until @ptlp is released using - * pte_unmap_unlock(). This function will fail if the PTE is non-present. - * Present PTEs may include PTEs that map refcounted pages, such as - * anonymous folios in COW mappings. - * - * Callers must be careful when relying on PTE content after - * pte_unmap_unlock(). Especially if the PTE maps a refcounted page, - * callers must protect against invalidation with MMU notifiers; otherwise - * access to the PFN at a later point in time can trigger use-after-free. - * - * Only IO mappings and raw PFN mappings are allowed. The mmap semaphore - * should be taken for read. - * - * This function must not be used to modify PTE content. - * - * Return: zero on success, -ve otherwise. - */ -int follow_pte(struct vm_area_struct *vma, unsigned long address, - pte_t **ptepp, spinlock_t **ptlp) -{ - struct mm_struct *mm = vma->vm_mm; - pgd_t *pgd; - p4d_t *p4d; - pud_t *pud; - pmd_t *pmd; - pte_t *ptep; - - mmap_assert_locked(mm); - if (unlikely(address < vma->vm_start || address >= vma->vm_end)) - goto out; - - if (!(vma->vm_flags & (VM_IO | VM_PFNMAP))) - goto out; - - pgd = pgd_offset(mm, address); - if (pgd_none(*pgd) || unlikely(pgd_bad(*pgd))) - goto out; - - p4d = p4d_offset(pgd, address); - if (p4d_none(*p4d) || unlikely(p4d_bad(*p4d))) - goto out; - - pud = pud_offset(p4d, address); - if (pud_none(*pud) || unlikely(pud_bad(*pud))) - goto out; - - pmd = pmd_offset(pud, address); - VM_BUG_ON(pmd_trans_huge(*pmd)); - - ptep = pte_offset_map_lock(mm, pmd, address, ptlp); - if (!ptep) - goto out; - if (!pte_present(ptep_get(ptep))) - goto unlock; - *ptepp = ptep; - return 0; -unlock: - pte_unmap_unlock(ptep, *ptlp); -out: - return -EINVAL; -} -EXPORT_SYMBOL_GPL(follow_pte); - static inline void pfnmap_args_setup(struct follow_pfnmap_args *args, spinlock_t *lock, pte_t *ptep, pgprot_t pgprot, unsigned long pfn_base,