Re: [RFC PATCH 7/9] um: nommu: add SMP futex operations
Johannes Berg <[email protected]> Mon, 20 Jul 2026 21:06:13 +0200
| Newsgroups | org.infradead.lists.linux-um |
|---|---|
| Message-ID | <[email protected]> |
On Mon, 2026-07-20 at 20:26 +0200, Johannes Berg wrote:
>=20
> +static inline int
> +arch_futex_atomic_op_inuser(int op, u32 oparg, int *oval, u32 __user *ua=
ddr)
> +{
> + u32 oldval, newval;
> + u32 *p =3D (u32 __force *)uaddr;
> +
> + do {
> + oldval =3D READ_ONCE(*p);
> +
> + switch (op) {
> + case FUTEX_OP_SET:
> + newval =3D oparg;
> + break;
> + case FUTEX_OP_ADD:
> + newval =3D oldval + oparg;
> + break;
> + case FUTEX_OP_OR:
> + newval =3D oldval | oparg;
> + break;
> + case FUTEX_OP_ANDN:
> + newval =3D oldval & ~oparg;
> + break;
> + case FUTEX_OP_XOR:
> + newval =3D oldval ^ oparg;
> + break;
> + default:
> + return -ENOSYS;
> + }
> + } while (!try_cmpxchg(p, &oldval, newval));
> +
> + *oval =3D oldval;
Wait ... this is also garbage, it should just be the switch() and then
*oval =3D cmpxchg(p, oldval, newval);
not the loop...
> + /* FIXME - shouldn't it be *uval =3D cmpxchg()? */
> + *uval =3D *p;
> + cmpxchg(p, oldval, newval);
And yes, I think the FIXME is right and our uaccess.c implementation is
wrong.
johannes