Robin Murphy | 21cfa0e | 2017-08-10 10:49:21 +0100 | [diff] [blame] | 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 | |
| 17 | #include <linux/uaccess.h> |
| 18 | #include <asm/barrier.h> |
| 19 | #include <asm/cacheflush.h> |
| 20 | |
| 21 | void memcpy_flushcache(void *dst, const void *src, size_t cnt) |
| 22 | { |
| 23 | /* |
| 24 | * We assume this should not be called with @dst pointing to |
| 25 | * non-cacheable memory, such that we don't need an explicit |
| 26 | * barrier to order the cache maintenance against the memcpy. |
| 27 | */ |
| 28 | memcpy(dst, src, cnt); |
| 29 | __clean_dcache_area_pop(dst, cnt); |
| 30 | } |
| 31 | EXPORT_SYMBOL_GPL(memcpy_flushcache); |
| 32 | |
| 33 | void memcpy_page_flushcache(char *to, struct page *page, size_t offset, |
| 34 | size_t len) |
| 35 | { |
| 36 | memcpy_flushcache(to, page_address(page) + offset, len); |
| 37 | } |
| 38 | |
| 39 | unsigned long __copy_user_flushcache(void *to, const void __user *from, |
| 40 | unsigned long n) |
| 41 | { |
| 42 | unsigned long rc = __arch_copy_from_user(to, from, n); |
| 43 | |
| 44 | /* See above */ |
| 45 | __clean_dcache_area_pop(to, n - rc); |
| 46 | return rc; |
| 47 | } |