aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arc/kernel/process.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arc/kernel/process.c')
-rw-r--r--arch/arc/kernel/process.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/arch/arc/kernel/process.c b/arch/arc/kernel/process.c
index be1972bd2729..a41a79a4f4fe 100644
--- a/arch/arc/kernel/process.c
+++ b/arch/arc/kernel/process.c
@@ -41,6 +41,41 @@ SYSCALL_DEFINE0(arc_gettls)
41 return task_thread_info(current)->thr_ptr; 41 return task_thread_info(current)->thr_ptr;
42} 42}
43 43
44SYSCALL_DEFINE3(arc_usr_cmpxchg, int *, uaddr, int, expected, int, new)
45{
46 struct pt_regs *regs = current_pt_regs();
47 int uval = -EFAULT;
48
49 /*
50 * This is only for old cores lacking LLOCK/SCOND, which by defintion
51 * can't possibly be SMP. Thus doesn't need to be SMP safe.
52 * And this also helps reduce the overhead for serializing in
53 * the UP case
54 */
55 WARN_ON_ONCE(IS_ENABLED(CONFIG_SMP));
56
57 /* Z indicates to userspace if operation succeded */
58 regs->status32 &= ~STATUS_Z_MASK;
59
60 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int)))
61 return -EFAULT;
62
63 preempt_disable();
64
65 if (__get_user(uval, uaddr))
66 goto done;
67
68 if (uval == expected) {
69 if (!__put_user(new, uaddr))
70 regs->status32 |= STATUS_Z_MASK;
71 }
72
73done:
74 preempt_enable();
75
76 return uval;
77}
78
44void arch_cpu_idle(void) 79void arch_cpu_idle(void)
45{ 80{
46 /* sleep, but enable all interrupts before committing */ 81 /* sleep, but enable all interrupts before committing */