uaccess_flushcache.c 963 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (C) 2017 ARM Ltd.
  4. */
  5. #include <linux/uaccess.h>
  6. #include <asm/barrier.h>
  7. #include <asm/cacheflush.h>
  8. void memcpy_flushcache(void *dst, const void *src, size_t cnt)
  9. {
  10. /*
  11. * We assume this should not be called with @dst pointing to
  12. * non-cacheable memory, such that we don't need an explicit
  13. * barrier to order the cache maintenance against the memcpy.
  14. */
  15. memcpy(dst, src, cnt);
  16. dcache_clean_pop((unsigned long)dst, (unsigned long)dst + cnt);
  17. }
  18. EXPORT_SYMBOL_GPL(memcpy_flushcache);
  19. void memcpy_page_flushcache(char *to, struct page *page, size_t offset,
  20. size_t len)
  21. {
  22. memcpy_flushcache(to, page_address(page) + offset, len);
  23. }
  24. unsigned long __copy_user_flushcache(void *to, const void __user *from,
  25. unsigned long n)
  26. {
  27. unsigned long rc;
  28. rc = raw_copy_from_user(to, from, n);
  29. /* See above */
  30. dcache_clean_pop((unsigned long)to, (unsigned long)to + n - rc);
  31. return rc;
  32. }