pgd = pgd_offset(current->mm, addr); if (unlikely(pgd_none(*pgd) || pgd_bad(*pgd))) return 0;
p4d = p4d_offset(pgd, addr); if (unlikely(p4d_none(*p4d) || p4d_bad(*p4d))) return 0;
pud = pud_offset(p4d, addr); if (unlikely(pud_none(*pud) || pud_bad(*pud))) return 0;
pmd = pmd_offset(pud, addr); if (unlikely(pmd_none(*pmd))) return 0;
/* * A pmd can be bad if it refers to a HugeTLB or THP page. * * Both THP and HugeTLB pages have the same pmd layout * and should not be manipulated by the pte functions. * * Lock the page table for the destination and check * to see that it's still huge and whether or not we will * need to fault on write.
*/ if (unlikely(pmd_leaf(*pmd))) {
ptl = ¤t->mm->page_table_lock;
spin_lock(ptl); if (unlikely(!pmd_leaf(*pmd)
|| pmd_hugewillfault(*pmd))) {
spin_unlock(ptl); return 0;
}
*ptep = NULL;
*ptlp = ptl; return 1;
}
if (unlikely(pmd_bad(*pmd))) return 0;
pte = pte_offset_map_lock(current->mm, pmd, addr, &ptl); if (unlikely(!pte)) return 0;
/* the mmap semaphore is taken only if not in an atomic context */
atomic = faulthandler_disabled();
if (!atomic)
mmap_read_lock(current->mm); while (n) {
pte_t *pte;
spinlock_t *ptl; int tocopy;
while (!pin_page_for_write(to, &pte, &ptl)) { if (!atomic)
mmap_read_unlock(current->mm); if (__put_user(0, (char __user *)to)) goto out; if (!atomic)
mmap_read_lock(current->mm);
}
ua_flags = uaccess_save_and_enable();
__memcpy((void *)to, from, tocopy);
uaccess_restore(ua_flags);
to += tocopy;
from += tocopy;
n -= tocopy;
if (pte)
pte_unmap_unlock(pte, ptl); else
spin_unlock(ptl);
} if (!atomic)
mmap_read_unlock(current->mm);
out: return n;
}
unsignedlong
arm_copy_to_user(void __user *to, constvoid *from, unsignedlong n)
{ /* * This test is stubbed out of the main function above to keep * the overhead for small copies low by avoiding a large * register dump on the stack just to reload them right away. * With frame pointer disabled, tail call optimization kicks in * as well making this test almost invisible.
*/ if (n < 64) { unsignedlong ua_flags = uaccess_save_and_enable();
n = __copy_to_user_std(to, from, n);
uaccess_restore(ua_flags);
} else {
n = __copy_to_user_memcpy(uaccess_mask_range_ptr(to, n),
from, n);
} return n;
}
if (pte)
pte_unmap_unlock(pte, ptl); else
spin_unlock(ptl);
}
mmap_read_unlock(current->mm);
out: return n;
}
unsignedlong arm_clear_user(void __user *addr, unsignedlong n)
{ /* See rational for this in __copy_to_user() above. */ if (n < 64) { unsignedlong ua_flags = uaccess_save_and_enable();
n = __clear_user_std(addr, n);
uaccess_restore(ua_flags);
} else {
n = __clear_user_memset(addr, n);
} return n;
}
#if 0
/* * This code is disabled by default, but kept around in case the chosen * thresholds need to be revalidated. Some overhead (small but still) * would be implied by a runtime determined variable threshold, and * so far the measurement on concerned targets didn't show a worthwhile * variation. * * Note that a fairly precise sched_clock() implementation is needed * for results to make some sense.
*/
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.