1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21#include <linux/compat.h>
22#include <linux/personality.h>
23#include <linux/sched.h>
24#include <linux/sched/signal.h>
25#include <linux/slab.h>
26#include <linux/syscalls.h>
27#include <linux/uaccess.h>
28
29#include <asm/cacheflush.h>
30#include <asm/system_misc.h>
31#include <asm/unistd.h>
32
33static long
34__do_compat_cache_op(unsigned long start, unsigned long end)
35{
36 long ret;
37
38 do {
39 unsigned long chunk = min(PAGE_SIZE, end - start);
40
41 if (fatal_signal_pending(current))
42 return 0;
43
44 ret = __flush_cache_user_range(start, start + chunk);
45 if (ret)
46 return ret;
47
48 cond_resched();
49 start += chunk;
50 } while (start < end);
51
52 return 0;
53}
54
55static inline long
56do_compat_cache_op(unsigned long start, unsigned long end, int flags)
57{
58 if (end < start || flags)
59 return -EINVAL;
60
61 if (!access_ok(VERIFY_READ, (const void __user *)start, end - start))
62 return -EFAULT;
63
64 return __do_compat_cache_op(start, end);
65}
66
67
68
69long compat_arm_syscall(struct pt_regs *regs)
70{
71 siginfo_t info;
72 unsigned int no = regs->regs[7];
73
74 switch (no) {
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89 case __ARM_NR_compat_cacheflush:
90 return do_compat_cache_op(regs->regs[0], regs->regs[1], regs->regs[2]);
91
92 case __ARM_NR_compat_set_tls:
93 current->thread.uw.tp_value = regs->regs[0];
94
95
96
97
98
99 barrier();
100 write_sysreg(regs->regs[0], tpidrro_el0);
101 return 0;
102
103 default:
104
105
106
107
108
109
110 if ((no & 0xffff) <= 0x7ff)
111 return -ENOSYS;
112 break;
113 }
114
115 info.si_signo = SIGILL;
116 info.si_errno = 0;
117 info.si_code = ILL_ILLTRP;
118 info.si_addr = (void __user *)instruction_pointer(regs) -
119 (compat_thumb_mode(regs) ? 2 : 4);
120
121 arm64_notify_die("Oops - bad compat syscall(2)", regs, &info, no);
122 return 0;
123}
124