Skip to content

Commit b0a1c0d

Browse files
xzpeterakpm00
authored andcommitted
mm: remove follow_pte()
follow_pte() users have been converted to follow_pfnmap*(). Remove the API. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Peter Xu <[email protected]> Cc: Alexander Gordeev <[email protected]> Cc: Alex Williamson <[email protected]> Cc: Aneesh Kumar K.V <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Christian Borntraeger <[email protected]> Cc: Dave Hansen <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: Gavin Shan <[email protected]> Cc: Gerald Schaefer <[email protected]> Cc: Heiko Carstens <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jason Gunthorpe <[email protected]> Cc: Matthew Wilcox <[email protected]> Cc: Niklas Schnelle <[email protected]> Cc: Paolo Bonzini <[email protected]> Cc: Ryan Roberts <[email protected]> Cc: Sean Christopherson <[email protected]> Cc: Sven Schnelle <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Vasily Gorbik <[email protected]> Cc: Will Deacon <[email protected]> Cc: Zi Yan <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent b17269a commit b0a1c0d

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
@@ -2368,8 +2368,6 @@ void free_pgd_range(struct mmu_gather *tlb, unsigned long addr,
23682368
unsigned long end, unsigned long floor, unsigned long ceiling);
23692369
int
23702370
copy_page_range(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma);
2371-
int follow_pte(struct vm_area_struct *vma, unsigned long address,
2372-
pte_t **ptepp, spinlock_t **ptlp);
23732371
int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
23742372
void *buf, int len, int write);
23752373

mm/memory.c

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

6102-
/**
6103-
* follow_pte - look up PTE at a user virtual address
6104-
* @vma: the memory mapping
6105-
* @address: user virtual address
6106-
* @ptepp: location to store found PTE
6107-
* @ptlp: location to store the lock for the PTE
6108-
*
6109-
* On a successful return, the pointer to the PTE is stored in @ptepp;
6110-
* the corresponding lock is taken and its location is stored in @ptlp.
6111-
*
6112-
* The contents of the PTE are only stable until @ptlp is released using
6113-
* pte_unmap_unlock(). This function will fail if the PTE is non-present.
6114-
* Present PTEs may include PTEs that map refcounted pages, such as
6115-
* anonymous folios in COW mappings.
6116-
*
6117-
* Callers must be careful when relying on PTE content after
6118-
* pte_unmap_unlock(). Especially if the PTE maps a refcounted page,
6119-
* callers must protect against invalidation with MMU notifiers; otherwise
6120-
* access to the PFN at a later point in time can trigger use-after-free.
6121-
*
6122-
* Only IO mappings and raw PFN mappings are allowed. The mmap semaphore
6123-
* should be taken for read.
6124-
*
6125-
* This function must not be used to modify PTE content.
6126-
*
6127-
* Return: zero on success, -ve otherwise.
6128-
*/
6129-
int follow_pte(struct vm_area_struct *vma, unsigned long address,
6130-
pte_t **ptepp, spinlock_t **ptlp)
6131-
{
6132-
struct mm_struct *mm = vma->vm_mm;
6133-
pgd_t *pgd;
6134-
p4d_t *p4d;
6135-
pud_t *pud;
6136-
pmd_t *pmd;
6137-
pte_t *ptep;
6138-
6139-
mmap_assert_locked(mm);
6140-
if (unlikely(address < vma->vm_start || address >= vma->vm_end))
6141-
goto out;
6142-
6143-
if (!(vma->vm_flags & (VM_IO | VM_PFNMAP)))
6144-
goto out;
6145-
6146-
pgd = pgd_offset(mm, address);
6147-
if (pgd_none(*pgd) || unlikely(pgd_bad(*pgd)))
6148-
goto out;
6149-
6150-
p4d = p4d_offset(pgd, address);
6151-
if (p4d_none(*p4d) || unlikely(p4d_bad(*p4d)))
6152-
goto out;
6153-
6154-
pud = pud_offset(p4d, address);
6155-
if (pud_none(*pud) || unlikely(pud_bad(*pud)))
6156-
goto out;
6157-
6158-
pmd = pmd_offset(pud, address);
6159-
VM_BUG_ON(pmd_trans_huge(*pmd));
6160-
6161-
ptep = pte_offset_map_lock(mm, pmd, address, ptlp);
6162-
if (!ptep)
6163-
goto out;
6164-
if (!pte_present(ptep_get(ptep)))
6165-
goto unlock;
6166-
*ptepp = ptep;
6167-
return 0;
6168-
unlock:
6169-
pte_unmap_unlock(ptep, *ptlp);
6170-
out:
6171-
return -EINVAL;
6172-
}
6173-
EXPORT_SYMBOL_GPL(follow_pte);
6174-
61756102
static inline void pfnmap_args_setup(struct follow_pfnmap_args *args,
61766103
spinlock_t *lock, pte_t *ptep,
61776104
pgprot_t pgprot, unsigned long pfn_base,

0 commit comments

Comments
 (0)