mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
um: nommu: add SMP futex operations
The asm-generic futex implementation only supports UP operations, and the normal (MMU) implementation from uaccess.c isn't built nor would it work. Since NOMMU shares address space anyway, it's all trivial and we can just make a trivial implementation. Link: https://patch.msgid.link/20260723113633.d8373755f77c.I0a83e5ca6be6c95a81d4b2ec69677bbea5889d7d@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
parent
f979f93c1c
commit
282d0be410
|
|
@ -12,7 +12,56 @@ int arch_futex_atomic_op_inuser(int op, u32 oparg, int *oval, u32 __user *uaddr)
|
|||
int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
|
||||
u32 oldval, u32 newval);
|
||||
#else
|
||||
#include <linux/atomic.h>
|
||||
#include <asm-generic/futex.h>
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
static inline int
|
||||
arch_futex_atomic_op_inuser(int op, u32 oparg, int *oval, u32 __user *uaddr)
|
||||
{
|
||||
u32 oldval, newval;
|
||||
u32 *p = (u32 __force *)uaddr;
|
||||
|
||||
do {
|
||||
oldval = READ_ONCE(*p);
|
||||
|
||||
switch (op) {
|
||||
case FUTEX_OP_SET:
|
||||
newval = oparg;
|
||||
break;
|
||||
case FUTEX_OP_ADD:
|
||||
newval = oldval + oparg;
|
||||
break;
|
||||
case FUTEX_OP_OR:
|
||||
newval = oldval | oparg;
|
||||
break;
|
||||
case FUTEX_OP_ANDN:
|
||||
newval = oldval & ~oparg;
|
||||
break;
|
||||
case FUTEX_OP_XOR:
|
||||
newval = oldval ^ oparg;
|
||||
break;
|
||||
default:
|
||||
return -ENOSYS;
|
||||
}
|
||||
} while (!try_cmpxchg(p, &oldval, newval));
|
||||
|
||||
*oval = oldval;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
|
||||
u32 oldval, u32 newval)
|
||||
{
|
||||
u32 *p = (u32 __force *)uaddr;
|
||||
|
||||
*uval = cmpxchg(p, oldval, newval);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_SMP */
|
||||
|
||||
#endif /* CONFIG_MMU */
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user