1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26#include <linux/module.h>
27#include <linux/compiler.h>
28#include <linux/uaccess.h>
29
30#define get_user_space() (uaccess_kernel() ? 0 : mfsp(3))
31#define get_kernel_space() (0)
32
33
34extern unsigned long pa_memcpy(void *dst, const void *src,
35 unsigned long len);
36
37unsigned long raw_copy_to_user(void __user *dst, const void *src,
38 unsigned long len)
39{
40 mtsp(get_kernel_space(), 1);
41 mtsp(get_user_space(), 2);
42 return pa_memcpy((void __force *)dst, src, len);
43}
44EXPORT_SYMBOL(raw_copy_to_user);
45
46unsigned long raw_copy_from_user(void *dst, const void __user *src,
47 unsigned long len)
48{
49 mtsp(get_user_space(), 1);
50 mtsp(get_kernel_space(), 2);
51 return pa_memcpy(dst, (void __force *)src, len);
52}
53EXPORT_SYMBOL(raw_copy_from_user);
54
55unsigned long raw_copy_in_user(void __user *dst, const void __user *src, unsigned long len)
56{
57 mtsp(get_user_space(), 1);
58 mtsp(get_user_space(), 2);
59 return pa_memcpy((void __force *)dst, (void __force *)src, len);
60}
61
62
63void * memcpy(void * dst,const void *src, size_t count)
64{
65 mtsp(get_kernel_space(), 1);
66 mtsp(get_kernel_space(), 2);
67 pa_memcpy(dst, src, count);
68 return dst;
69}
70
71EXPORT_SYMBOL(raw_copy_in_user);
72EXPORT_SYMBOL(memcpy);
73
74long probe_kernel_read(void *dst, const void *src, size_t size)
75{
76 unsigned long addr = (unsigned long)src;
77
78 if (addr < PAGE_SIZE)
79 return -EFAULT;
80
81
82
83 return __probe_kernel_read(dst, src, size);
84}
85