]>
git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blob - arch/parisc/include/asm/futex.h
1 #ifndef _ASM_PARISC_FUTEX_H
2 #define _ASM_PARISC_FUTEX_H
6 #include <linux/futex.h>
7 #include <linux/uaccess.h>
8 #include <asm/atomic.h>
11 /* The following has to match the LWS code in syscall.S. We have
12 sixteen four-word locks. */
15 _futex_spin_lock_irqsave(u32 __user
*uaddr
, unsigned long int *flags
)
17 extern u32 lws_lock_start
[];
18 long index
= ((long)uaddr
& 0xf0) >> 2;
19 arch_spinlock_t
*s
= (arch_spinlock_t
*)&lws_lock_start
[index
];
20 local_irq_save(*flags
);
25 _futex_spin_unlock_irqrestore(u32 __user
*uaddr
, unsigned long int *flags
)
27 extern u32 lws_lock_start
[];
28 long index
= ((long)uaddr
& 0xf0) >> 2;
29 arch_spinlock_t
*s
= (arch_spinlock_t
*)&lws_lock_start
[index
];
31 local_irq_restore(*flags
);
35 arch_futex_atomic_op_inuser(int op
, int oparg
, int *oval
, u32 __user
*uaddr
)
37 unsigned long int flags
;
41 _futex_spin_lock_irqsave(uaddr
, &flags
);
45 if (unlikely(get_user(oldval
, uaddr
) != 0))
46 goto out_pagefault_enable
;
71 if (ret
== 0 && unlikely(put_user(tmp
, uaddr
) != 0))
76 _futex_spin_unlock_irqrestore(uaddr
, &flags
);
85 futex_atomic_cmpxchg_inatomic(u32
*uval
, u32 __user
*uaddr
,
86 u32 oldval
, u32 newval
)
91 /* futex.c wants to do a cmpxchg_inatomic on kernel NULL, which is
92 * our gateway page, and causes no end of trouble...
94 if (uaccess_kernel() && !uaddr
)
97 if (!access_ok(VERIFY_WRITE
, uaddr
, sizeof(u32
)))
100 /* HPPA has no cmpxchg in hardware and therefore the
101 * best we can do here is use an array of locks. The
102 * lock selected is based on a hash of the userspace
103 * address. This should scale to a couple of CPUs.
106 _futex_spin_lock_irqsave(uaddr
, &flags
);
107 if (unlikely(get_user(val
, uaddr
) != 0)) {
108 _futex_spin_unlock_irqrestore(uaddr
, &flags
);
112 if (val
== oldval
&& unlikely(put_user(newval
, uaddr
) != 0)) {
113 _futex_spin_unlock_irqrestore(uaddr
, &flags
);
118 _futex_spin_unlock_irqrestore(uaddr
, &flags
);
123 #endif /*__KERNEL__*/
124 #endif /*_ASM_PARISC_FUTEX_H*/