|
@@ -3772,8 +3772,8 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
|
|
|
}
|
|
|
#endif /* __PAGETABLE_PMD_FOLDED */
|
|
|
|
|
|
-static int __follow_pte(struct mm_struct *mm, unsigned long address,
|
|
|
- pte_t **ptepp, spinlock_t **ptlp)
|
|
|
+static int __follow_pte_pmd(struct mm_struct *mm, unsigned long address,
|
|
|
+ pte_t **ptepp, pmd_t **pmdpp, spinlock_t **ptlp)
|
|
|
{
|
|
|
pgd_t *pgd;
|
|
|
pud_t *pud;
|
|
@@ -3790,11 +3790,20 @@ static int __follow_pte(struct mm_struct *mm, unsigned long address,
|
|
|
|
|
|
pmd = pmd_offset(pud, address);
|
|
|
VM_BUG_ON(pmd_trans_huge(*pmd));
|
|
|
- if (pmd_none(*pmd) || unlikely(pmd_bad(*pmd)))
|
|
|
- goto out;
|
|
|
|
|
|
- /* We cannot handle huge page PFN maps. Luckily they don't exist. */
|
|
|
- if (pmd_huge(*pmd))
|
|
|
+ if (pmd_huge(*pmd)) {
|
|
|
+ if (!pmdpp)
|
|
|
+ goto out;
|
|
|
+
|
|
|
+ *ptlp = pmd_lock(mm, pmd);
|
|
|
+ if (pmd_huge(*pmd)) {
|
|
|
+ *pmdpp = pmd;
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ spin_unlock(*ptlp);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pmd_none(*pmd) || unlikely(pmd_bad(*pmd)))
|
|
|
goto out;
|
|
|
|
|
|
ptep = pte_offset_map_lock(mm, pmd, address, ptlp);
|
|
@@ -3817,9 +3826,23 @@ int follow_pte(struct mm_struct *mm, unsigned long address, pte_t **ptepp,
|
|
|
|
|
|
/* (void) is needed to make gcc happy */
|
|
|
(void) __cond_lock(*ptlp,
|
|
|
- !(res = __follow_pte(mm, address, ptepp, ptlp)));
|
|
|
+ !(res = __follow_pte_pmd(mm, address, ptepp, NULL,
|
|
|
+ ptlp)));
|
|
|
+ return res;
|
|
|
+}
|
|
|
+
|
|
|
+int follow_pte_pmd(struct mm_struct *mm, unsigned long address,
|
|
|
+ pte_t **ptepp, pmd_t **pmdpp, spinlock_t **ptlp)
|
|
|
+{
|
|
|
+ int res;
|
|
|
+
|
|
|
+ /* (void) is needed to make gcc happy */
|
|
|
+ (void) __cond_lock(*ptlp,
|
|
|
+ !(res = __follow_pte_pmd(mm, address, ptepp, pmdpp,
|
|
|
+ ptlp)));
|
|
|
return res;
|
|
|
}
|
|
|
+EXPORT_SYMBOL(follow_pte_pmd);
|
|
|
|
|
|
/**
|
|
|
* follow_pfn - look up PFN at a user virtual address
|