1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_PARISC_FUTEX_H
3 #define _ASM_PARISC_FUTEX_H
5 #include <linux/futex.h>
6 #include <linux/uaccess.h>
7 #include <asm/atomic.h>
10 /* The following has to match the LWS code in syscall.S. We have
11 sixteen four-word locks. */
14 _futex_spin_lock(u32 __user *uaddr)
16 extern u32 lws_lock_start[];
17 long index = ((long)uaddr & 0x3f8) >> 1;
18 arch_spinlock_t *s = (arch_spinlock_t *)&lws_lock_start[index];
24 _futex_spin_unlock(u32 __user *uaddr)
26 extern u32 lws_lock_start[];
27 long index = ((long)uaddr & 0x3f8) >> 1;
28 arch_spinlock_t *s = (arch_spinlock_t *)&lws_lock_start[index];
34 arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr)
41 _futex_spin_lock(uaddr);
42 if (unlikely(get_user(oldval, uaddr) != 0))
43 goto out_pagefault_enable;
68 if (ret == 0 && unlikely(put_user(tmp, uaddr) != 0))
72 _futex_spin_unlock(uaddr);
81 futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
82 u32 oldval, u32 newval)
86 /* futex.c wants to do a cmpxchg_inatomic on kernel NULL, which is
87 * our gateway page, and causes no end of trouble...
89 if (uaccess_kernel() && !uaddr)
92 if (!access_ok(uaddr, sizeof(u32)))
95 /* HPPA has no cmpxchg in hardware and therefore the
96 * best we can do here is use an array of locks. The
97 * lock selected is based on a hash of the userspace
98 * address. This should scale to a couple of CPUs.
101 _futex_spin_lock(uaddr);
102 if (unlikely(get_user(val, uaddr) != 0)) {
103 _futex_spin_unlock(uaddr);
107 if (val == oldval && unlikely(put_user(newval, uaddr) != 0)) {
108 _futex_spin_unlock(uaddr);
113 _futex_spin_unlock(uaddr);
118 #endif /*_ASM_PARISC_FUTEX_H*/