From a9bb1b1c188339ed7658103ff5843c161df08799 Mon Sep 17 00:00:00 2001 From: Dmitry Chagin Date: Thu, 29 Jul 2021 12:55:02 +0300 Subject: [PATCH] linux(4): Handle FUTEX_LOCK_PI2 oeration. FUTEX_LOCK_PI2 was added to support clock selection as FUTEX_LOCK_PI uses a CLOCK_REALTIME based absolute value since it was implemented, but it does not require that the FUTEX_CLOCK_REALTIME bit is set, because that was introduced later. MFC after: 2 weeks --- sys/compat/linux/linux_futex.c | 7 ++++++- sys/compat/linux/linux_futex.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/sys/compat/linux/linux_futex.c b/sys/compat/linux/linux_futex.c index cc3a685fb14e..fcac2eba4956 100644 --- a/sys/compat/linux/linux_futex.c +++ b/sys/compat/linux/linux_futex.c @@ -288,6 +288,9 @@ linux_futex(struct thread *td, struct linux_futex_args *args) case LINUX_FUTEX_LOCK_PI: args->clockrt = true; + /* FALLTHROUGH */ + + case LINUX_FUTEX_LOCK_PI2: LINUX_CTR2(sys_futex, "LOCKPI uaddr %p val 0x%x", args->uaddr, args->val); @@ -789,7 +792,7 @@ linux_umtx_abs_timeout_init(struct umtx_abs_timeout *timo, /* * The FUTEX_CLOCK_REALTIME option bit can be employed only with the - * FUTEX_WAIT_BITSET, FUTEX_WAIT_REQUEUE_PI. + * FUTEX_WAIT_BITSET, FUTEX_WAIT_REQUEUE_PI, FUTEX_LOCK_PI2. * For FUTEX_WAIT, timeout is interpreted as a relative value, for other * futex operations timeout is interpreted as an absolute value. * If FUTEX_CLOCK_REALTIME option bit is set, the Linux kernel measures @@ -820,6 +823,7 @@ linux_sys_futex(struct thread *td, struct linux_sys_futex_args *args) case LINUX_FUTEX_WAIT: case LINUX_FUTEX_WAIT_BITSET: case LINUX_FUTEX_LOCK_PI: + case LINUX_FUTEX_LOCK_PI2: if (args->timeout != NULL) { error = copyin(args->timeout, <s, sizeof(lts)); if (error != 0) @@ -857,6 +861,7 @@ linux_sys_futex_time64(struct thread *td, case LINUX_FUTEX_WAIT: case LINUX_FUTEX_WAIT_BITSET: case LINUX_FUTEX_LOCK_PI: + case LINUX_FUTEX_LOCK_PI2: if (args->timeout != NULL) { error = copyin(args->timeout, <s, sizeof(lts)); if (error != 0) diff --git a/sys/compat/linux/linux_futex.h b/sys/compat/linux/linux_futex.h index 4255cbdc7363..189db4e17c4f 100644 --- a/sys/compat/linux/linux_futex.h +++ b/sys/compat/linux/linux_futex.h @@ -51,6 +51,7 @@ #define LINUX_FUTEX_WAKE_BITSET 10 #define LINUX_FUTEX_WAIT_REQUEUE_PI 11 #define LINUX_FUTEX_CMP_REQUEUE_PI 12 +#define LINUX_FUTEX_LOCK_PI2 13 #define LINUX_FUTEX_PRIVATE_FLAG 128 #define LINUX_FUTEX_CLOCK_REALTIME 256