From 6c44741d75a27985a0496cd58b123a58c7177108 Mon Sep 17 00:00:00 2001 From: Oliver O'Halloran Date: Thu, 19 Oct 2017 18:13:55 +1100 Subject: powerpc/lib: Implement UACCESS_FLUSHCACHE API Implement the architecture specific portitions of the UACCESS_FLUSHCACHE API. This provides functions for the copy_user_flushcache iterator that ensure that when the copy is finished the destination buffer contains a copy of the original and that the destination buffer is clean in the processor caches. Signed-off-by: Oliver O'Halloran Signed-off-by: Michael Ellerman --- arch/powerpc/lib/pmem.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'arch/powerpc/lib') diff --git a/arch/powerpc/lib/pmem.c b/arch/powerpc/lib/pmem.c index 0fa09262ca13..53c018762e1c 100644 --- a/arch/powerpc/lib/pmem.c +++ b/arch/powerpc/lib/pmem.c @@ -13,6 +13,7 @@ #include #include +#include #include @@ -32,3 +33,35 @@ void arch_invalidate_pmem(void *addr, size_t size) flush_inval_dcache_range(start, start + size); } EXPORT_SYMBOL(arch_invalidate_pmem); + +/* + * CONFIG_ARCH_HAS_UACCESS_FLUSHCACHE symbols + */ +long __copy_from_user_flushcache(void *dest, const void __user *src, + unsigned size) +{ + unsigned long copied, start = (unsigned long) dest; + + copied = __copy_from_user(dest, src, size); + flush_inval_dcache_range(start, start + size); + + return copied; +} + +void *memcpy_flushcache(void *dest, const void *src, size_t size) +{ + unsigned long start = (unsigned long) dest; + + memcpy(dest, src, size); + flush_inval_dcache_range(start, start + size); + + return dest; +} +EXPORT_SYMBOL(memcpy_flushcache); + +void memcpy_page_flushcache(char *to, struct page *page, size_t offset, + size_t len) +{ + memcpy_flushcache(to, page_to_virt(page) + offset, len); +} +EXPORT_SYMBOL(memcpy_page_flushcache); -- cgit v1.2.3