uaccess_flushcache.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright (C) 2017 ARM Ltd.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include <linux/uaccess.h>
  17. #include <asm/barrier.h>
  18. #include <asm/cacheflush.h>
  19. void memcpy_flushcache(void *dst, const void *src, size_t cnt)
  20. {
  21. /*
  22. * We assume this should not be called with @dst pointing to
  23. * non-cacheable memory, such that we don't need an explicit
  24. * barrier to order the cache maintenance against the memcpy.
  25. */
  26. memcpy(dst, src, cnt);
  27. __clean_dcache_area_pop(dst, cnt);
  28. }
  29. EXPORT_SYMBOL_GPL(memcpy_flushcache);
  30. void memcpy_page_flushcache(char *to, struct page *page, size_t offset,
  31. size_t len)
  32. {
  33. memcpy_flushcache(to, page_address(page) + offset, len);
  34. }
  35. unsigned long __copy_user_flushcache(void *to, const void __user *from,
  36. unsigned long n)
  37. {
  38. unsigned long rc = __arch_copy_from_user(to, from, n);
  39. /* See above */
  40. __clean_dcache_area_pop(to, n - rc);
  41. return rc;
  42. }