Skip to content

Commit 50863d4

Browse files
committed
mm: remove follow_pte()
JIRA: https://issues.redhat.com/browse/RHEL-73613 commit b0a1c0d Author: Peter Xu <peterx@redhat.com> Date: Mon Aug 26 16:43:50 2024 -0400 mm: remove follow_pte() follow_pte() users have been converted to follow_pfnmap*(). Remove the API. Link: https://lkml.kernel.org/r/20240826204353.2228736-17-peterx@redhat.com Signed-off-by: Peter Xu <peterx@redhat.com> Cc: Alexander Gordeev <agordeev@linux.ibm.com> Cc: Alex Williamson <alex.williamson@redhat.com> Cc: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com> Cc: Borislav Petkov <bp@alien8.de> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Christian Borntraeger <borntraeger@linux.ibm.com> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: David Hildenbrand <david@redhat.com> Cc: Gavin Shan <gshan@redhat.com> Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com> Cc: Heiko Carstens <hca@linux.ibm.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jason Gunthorpe <jgg@nvidia.com> Cc: Matthew Wilcox <willy@infradead.org> Cc: Niklas Schnelle <schnelle@linux.ibm.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Ryan Roberts <ryan.roberts@arm.com> Cc: Sean Christopherson <seanjc@google.com> Cc: Sven Schnelle <svens@linux.ibm.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Vasily Gorbik <gor@linux.ibm.com> Cc: Will Deacon <will@kernel.org> Cc: Zi Yan <ziy@nvidia.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Donald Dutile <ddutile@redhat.com>
1 parent 695754d commit 50863d4

File tree

2 files changed

+0
-75
lines changed

2 files changed

+0
-75
lines changed

include/linux/mm.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2369,8 +2369,6 @@ void free_pgd_range(struct mmu_gather *tlb, unsigned long addr,
23692369
unsigned long end, unsigned long floor, unsigned long ceiling);
23702370
int
23712371
copy_page_range(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma);
2372-
int follow_pte(struct vm_area_struct *vma, unsigned long address,
2373-
pte_t **ptepp, spinlock_t **ptlp);
23742372
int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
23752373
void *buf, int len, int write);
23762374

mm/memory.c

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -5606,79 +5606,6 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
56065606
}
56075607
#endif /* __PAGETABLE_PMD_FOLDED */
56085608

5609-
/**
5610-
* follow_pte - look up PTE at a user virtual address
5611-
* @vma: the memory mapping
5612-
* @address: user virtual address
5613-
* @ptepp: location to store found PTE
5614-
* @ptlp: location to store the lock for the PTE
5615-
*
5616-
* On a successful return, the pointer to the PTE is stored in @ptepp;
5617-
* the corresponding lock is taken and its location is stored in @ptlp.
5618-
*
5619-
* The contents of the PTE are only stable until @ptlp is released using
5620-
* pte_unmap_unlock(). This function will fail if the PTE is non-present.
5621-
* Present PTEs may include PTEs that map refcounted pages, such as
5622-
* anonymous folios in COW mappings.
5623-
*
5624-
* Callers must be careful when relying on PTE content after
5625-
* pte_unmap_unlock(). Especially if the PTE maps a refcounted page,
5626-
* callers must protect against invalidation with MMU notifiers; otherwise
5627-
* access to the PFN at a later point in time can trigger use-after-free.
5628-
*
5629-
* Only IO mappings and raw PFN mappings are allowed. The mmap semaphore
5630-
* should be taken for read.
5631-
*
5632-
* This function must not be used to modify PTE content.
5633-
*
5634-
* Return: zero on success, -ve otherwise.
5635-
*/
5636-
int follow_pte(struct vm_area_struct *vma, unsigned long address,
5637-
pte_t **ptepp, spinlock_t **ptlp)
5638-
{
5639-
struct mm_struct *mm = vma->vm_mm;
5640-
pgd_t *pgd;
5641-
p4d_t *p4d;
5642-
pud_t *pud;
5643-
pmd_t *pmd;
5644-
pte_t *ptep;
5645-
5646-
mmap_assert_locked(mm);
5647-
if (unlikely(address < vma->vm_start || address >= vma->vm_end))
5648-
goto out;
5649-
5650-
if (!(vma->vm_flags & (VM_IO | VM_PFNMAP)))
5651-
goto out;
5652-
5653-
pgd = pgd_offset(mm, address);
5654-
if (pgd_none(*pgd) || unlikely(pgd_bad(*pgd)))
5655-
goto out;
5656-
5657-
p4d = p4d_offset(pgd, address);
5658-
if (p4d_none(*p4d) || unlikely(p4d_bad(*p4d)))
5659-
goto out;
5660-
5661-
pud = pud_offset(p4d, address);
5662-
if (pud_none(*pud) || unlikely(pud_bad(*pud)))
5663-
goto out;
5664-
5665-
pmd = pmd_offset(pud, address);
5666-
VM_BUG_ON(pmd_trans_huge(*pmd));
5667-
5668-
ptep = pte_offset_map_lock(mm, pmd, address, ptlp);
5669-
if (!ptep)
5670-
goto out;
5671-
if (!pte_present(ptep_get(ptep)))
5672-
goto unlock;
5673-
*ptepp = ptep;
5674-
return 0;
5675-
unlock:
5676-
pte_unmap_unlock(ptep, *ptlp);
5677-
out:
5678-
return -EINVAL;
5679-
}
5680-
EXPORT_SYMBOL_GPL(follow_pte);
5681-
56825609
static inline void pfnmap_args_setup(struct follow_pfnmap_args *args,
56835610
spinlock_t *lock, pte_t *ptep,
56845611
pgprot_t pgprot, unsigned long pfn_base,

0 commit comments

Comments
 (0)