blob: bfa30b75b2b8e628f00502e911409b3116a7930e [file] [log] [blame]
Thomas Gleixnercaab2772019-06-03 07:44:50 +02001// SPDX-License-Identifier: GPL-2.0-only
Robin Murphy21cfa0e2017-08-10 10:49:21 +01002/*
3 * Copyright (C) 2017 ARM Ltd.
Robin Murphy21cfa0e2017-08-10 10:49:21 +01004 */
5
6#include <linux/uaccess.h>
7#include <asm/barrier.h>
8#include <asm/cacheflush.h>
9
10void memcpy_flushcache(void *dst, const void *src, size_t cnt)
11{
12 /*
13 * We assume this should not be called with @dst pointing to
14 * non-cacheable memory, such that we don't need an explicit
15 * barrier to order the cache maintenance against the memcpy.
16 */
17 memcpy(dst, src, cnt);
18 __clean_dcache_area_pop(dst, cnt);
19}
20EXPORT_SYMBOL_GPL(memcpy_flushcache);
21
22void memcpy_page_flushcache(char *to, struct page *page, size_t offset,
23 size_t len)
24{
25 memcpy_flushcache(to, page_address(page) + offset, len);
26}
27
28unsigned long __copy_user_flushcache(void *to, const void __user *from,
29 unsigned long n)
30{
Pavel Tatashine50be642019-11-20 12:07:40 -050031 unsigned long rc;
32
33 uaccess_enable_not_uao();
34 rc = __arch_copy_from_user(to, from, n);
35 uaccess_disable_not_uao();
Robin Murphy21cfa0e2017-08-10 10:49:21 +010036
37 /* See above */
38 __clean_dcache_area_pop(to, n - rc);
39 return rc;
40}