Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / arch / parisc / lib / memcpy.c
blob5fc0c852c84c8dc28b44accd2bf00d249649cb45
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Optimized memory copy routines.
5 * Copyright (C) 2004 Randolph Chung <tausq@debian.org>
6 * Copyright (C) 2013-2017 Helge Deller <deller@gmx.de>
8 * Portions derived from the GNU C Library
9 * Copyright (C) 1991, 1997, 2003 Free Software Foundation, Inc.
12 #include <linux/module.h>
13 #include <linux/compiler.h>
14 #include <linux/uaccess.h>
16 #define get_user_space() mfsp(SR_USER)
17 #define get_kernel_space() SR_KERNEL
19 /* Returns 0 for success, otherwise, returns number of bytes not transferred. */
20 extern unsigned long pa_memcpy(void *dst, const void *src,
21 unsigned long len);
23 unsigned long raw_copy_to_user(void __user *dst, const void *src,
24 unsigned long len)
26 mtsp(get_kernel_space(), SR_TEMP1);
27 mtsp(get_user_space(), SR_TEMP2);
28 return pa_memcpy((void __force *)dst, src, len);
30 EXPORT_SYMBOL(raw_copy_to_user);
32 unsigned long raw_copy_from_user(void *dst, const void __user *src,
33 unsigned long len)
35 mtsp(get_user_space(), SR_TEMP1);
36 mtsp(get_kernel_space(), SR_TEMP2);
37 return pa_memcpy(dst, (void __force *)src, len);
39 EXPORT_SYMBOL(raw_copy_from_user);
41 void * memcpy(void * dst,const void *src, size_t count)
43 mtsp(get_kernel_space(), SR_TEMP1);
44 mtsp(get_kernel_space(), SR_TEMP2);
45 pa_memcpy(dst, src, count);
46 return dst;
49 EXPORT_SYMBOL(memcpy);
51 bool copy_from_kernel_nofault_allowed(const void *unsafe_src, size_t size)
53 if ((unsigned long)unsafe_src < PAGE_SIZE)
54 return false;
55 /* check for I/O space F_EXTEND(0xfff00000) access as well? */
56 return true;