Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * Copyright (C) 2017 ARM Ltd.
0004  */
0005 
0006 #include <linux/uaccess.h>
0007 #include <asm/barrier.h>
0008 #include <asm/cacheflush.h>
0009 
0010 void memcpy_flushcache(void *dst, const void *src, size_t cnt)
0011 {
0012     /*
0013      * We assume this should not be called with @dst pointing to
0014      * non-cacheable memory, such that we don't need an explicit
0015      * barrier to order the cache maintenance against the memcpy.
0016      */
0017     memcpy(dst, src, cnt);
0018     dcache_clean_pop((unsigned long)dst, (unsigned long)dst + cnt);
0019 }
0020 EXPORT_SYMBOL_GPL(memcpy_flushcache);
0021 
0022 void memcpy_page_flushcache(char *to, struct page *page, size_t offset,
0023                 size_t len)
0024 {
0025     memcpy_flushcache(to, page_address(page) + offset, len);
0026 }
0027 
0028 unsigned long __copy_user_flushcache(void *to, const void __user *from,
0029                      unsigned long n)
0030 {
0031     unsigned long rc;
0032 
0033     rc = raw_copy_from_user(to, from, n);
0034 
0035     /* See above */
0036     dcache_clean_pop((unsigned long)to, (unsigned long)to + n - rc);
0037     return rc;
0038 }