|
|
|
@ -68,20 +68,25 @@ Co-developed-by: André Almeida <andrealmeid@collabora.com>
|
|
|
|
|
Signed-off-by: André Almeida <andrealmeid@collabora.com>
|
|
|
|
|
|
|
|
|
|
Adjusted for v5.9: Removed `put_futex_key` calls.
|
|
|
|
|
|
|
|
|
|
From bf820ac8e4e4a42eec27be2aed28798dfda519ab Mon Sep 17 00:00:00 2001
|
|
|
|
|
From: =?UTF-8?q?Andr=C3=A9=20Almeida?= <andrealmeid@collabora.com>
|
|
|
|
|
Date: Fri, 7 Feb 2020 23:28:02 -0300
|
|
|
|
|
Subject: [PATCH 2/2] futex: Add Proton compatibility code
|
|
|
|
|
---
|
|
|
|
|
include/uapi/linux/futex.h | 20 +++
|
|
|
|
|
kernel/futex.c | 352 ++++++++++++++++++++++++++++++++++++-
|
|
|
|
|
2 files changed, 370 insertions(+), 2 deletions(-)
|
|
|
|
|
|
|
|
|
|
diff --git a/include/uapi/linux/futex.h b/include/uapi/linux/futex.h
|
|
|
|
|
index a89eb0a..580001e 100644
|
|
|
|
|
index a89eb0acc..a3e760886 100644
|
|
|
|
|
--- a/include/uapi/linux/futex.h
|
|
|
|
|
+++ b/include/uapi/linux/futex.h
|
|
|
|
|
@@ -21,6 +21,7 @@
|
|
|
|
|
#define FUTEX_WAKE_BITSET 10
|
|
|
|
|
#define FUTEX_WAIT_REQUEUE_PI 11
|
|
|
|
|
#define FUTEX_CMP_REQUEUE_PI 12
|
|
|
|
|
+#define FUTEX_WAIT_MULTIPLE 13
|
|
|
|
|
+#define FUTEX_WAIT_MULTIPLE 31
|
|
|
|
|
|
|
|
|
|
#define FUTEX_PRIVATE_FLAG 128
|
|
|
|
|
#define FUTEX_CLOCK_REALTIME 256
|
|
|
|
@ -117,7 +122,7 @@ index a89eb0a..580001e 100644
|
|
|
|
|
+
|
|
|
|
|
#endif /* _UAPI_LINUX_FUTEX_H */
|
|
|
|
|
diff --git a/kernel/futex.c b/kernel/futex.c
|
|
|
|
|
index 00259c7..2170228 100644
|
|
|
|
|
index 00259c7e2..6cbbf06c9 100644
|
|
|
|
|
--- a/kernel/futex.c
|
|
|
|
|
+++ b/kernel/futex.c
|
|
|
|
|
@@ -198,6 +198,8 @@ struct futex_pi_state {
|
|
|
|
@ -428,6 +433,15 @@ index 00259c7..2170228 100644
|
|
|
|
|
if (unlikely(should_fail_futex(!(op & FUTEX_PRIVATE_FLAG))))
|
|
|
|
|
return -EFAULT;
|
|
|
|
|
if (get_timespec64(&ts, utime))
|
|
|
|
|
@@ -3811,7 +4075,7 @@ SYSCALL_DEFINE6(futex, u32 __user *, uaddr, int, op, u32, val,
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
|
|
t = timespec64_to_ktime(ts);
|
|
|
|
|
- if (cmd == FUTEX_WAIT)
|
|
|
|
|
+ if (cmd == FUTEX_WAIT || cmd == FUTEX_WAIT_MULTIPLE)
|
|
|
|
|
t = ktime_add_safe(ktime_get(), t);
|
|
|
|
|
else if (!(op & FUTEX_CLOCK_REALTIME))
|
|
|
|
|
t = timens_ktime_to_host(CLOCK_MONOTONIC, t);
|
|
|
|
|
@@ -3825,6 +4089,25 @@ SYSCALL_DEFINE6(futex, u32 __user *, uaddr, int, op, u32, val,
|
|
|
|
|
cmd == FUTEX_CMP_REQUEUE_PI || cmd == FUTEX_WAKE_OP)
|
|
|
|
|
val2 = (u32) (unsigned long) utime;
|
|
|
|
@ -454,7 +468,7 @@ index 00259c7..2170228 100644
|
|
|
|
|
return do_futex(uaddr, op, val, tp, uaddr2, val2, val3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -3987,6 +4270,57 @@ COMPAT_SYSCALL_DEFINE3(get_robust_list, int, pid,
|
|
|
|
|
@@ -3987,6 +4270,58 @@ COMPAT_SYSCALL_DEFINE3(get_robust_list, int, pid,
|
|
|
|
|
#endif /* CONFIG_COMPAT */
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_COMPAT_32BIT_TIME
|
|
|
|
@ -466,6 +480,7 @@ index 00259c7..2170228 100644
|
|
|
|
|
+ */
|
|
|
|
|
+struct compat_futex_wait_block {
|
|
|
|
|
+ compat_uptr_t uaddr;
|
|
|
|
|
+ __u32 pad;
|
|
|
|
|
+ __u32 val;
|
|
|
|
|
+ __u32 bitset;
|
|
|
|
|
+};
|
|
|
|
@ -512,7 +527,7 @@ index 00259c7..2170228 100644
|
|
|
|
|
SYSCALL_DEFINE6(futex_time32, u32 __user *, uaddr, int, op, u32, val,
|
|
|
|
|
struct old_timespec32 __user *, utime, u32 __user *, uaddr2,
|
|
|
|
|
u32, val3)
|
|
|
|
|
@@ -3998,7 +4332,8 @@ SYSCALL_DEFINE6(futex_time32, u32 __user *, uaddr, int, op, u32, val,
|
|
|
|
|
@@ -3998,14 +4333,15 @@ SYSCALL_DEFINE6(futex_time32, u32 __user *, uaddr, int, op, u32, val,
|
|
|
|
|
|
|
|
|
|
if (utime && (cmd == FUTEX_WAIT || cmd == FUTEX_LOCK_PI ||
|
|
|
|
|
cmd == FUTEX_WAIT_BITSET ||
|
|
|
|
@ -522,7 +537,15 @@ index 00259c7..2170228 100644
|
|
|
|
|
if (get_old_timespec32(&ts, utime))
|
|
|
|
|
return -EFAULT;
|
|
|
|
|
if (!timespec64_valid(&ts))
|
|
|
|
|
@@ -4015,6 +4350,19 @@ SYSCALL_DEFINE6(futex_time32, u32 __user *, uaddr, int, op, u32, val,
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
|
|
t = timespec64_to_ktime(ts);
|
|
|
|
|
- if (cmd == FUTEX_WAIT)
|
|
|
|
|
+ if (cmd == FUTEX_WAIT || cmd == FUTEX_WAIT_MULTIPLE)
|
|
|
|
|
t = ktime_add_safe(ktime_get(), t);
|
|
|
|
|
else if (!(op & FUTEX_CLOCK_REALTIME))
|
|
|
|
|
t = timens_ktime_to_host(CLOCK_MONOTONIC, t);
|
|
|
|
|
@@ -4015,6 +4351,19 @@ SYSCALL_DEFINE6(futex_time32, u32 __user *, uaddr, int, op, u32, val,
|
|
|
|
|
cmd == FUTEX_CMP_REQUEUE_PI || cmd == FUTEX_WAKE_OP)
|
|
|
|
|
val2 = (int) (unsigned long) utime;
|
|
|
|
|
|
|
|
|
@ -542,63 +565,3 @@ index 00259c7..2170228 100644
|
|
|
|
|
return do_futex(uaddr, op, val, tp, uaddr2, val2, val3);
|
|
|
|
|
}
|
|
|
|
|
#endif /* CONFIG_COMPAT_32BIT_TIME */
|
|
|
|
|
--
|
|
|
|
|
2.29.2.456.g3a0b884cab
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
From bf820ac8e4e4a42eec27be2aed28798dfda519ab Mon Sep 17 00:00:00 2001
|
|
|
|
|
From: =?UTF-8?q?Andr=C3=A9=20Almeida?= <andrealmeid@collabora.com>
|
|
|
|
|
Date: Fri, 7 Feb 2020 23:28:02 -0300
|
|
|
|
|
Subject: [PATCH 2/2] futex: Add Proton compatibility code
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
include/uapi/linux/futex.h | 2 +-
|
|
|
|
|
kernel/futex.c | 5 +++--
|
|
|
|
|
2 files changed, 4 insertions(+), 3 deletions(-)
|
|
|
|
|
|
|
|
|
|
diff --git a/include/uapi/linux/futex.h b/include/uapi/linux/futex.h
|
|
|
|
|
index 580001e..a3e7608 100644
|
|
|
|
|
--- a/include/uapi/linux/futex.h
|
|
|
|
|
+++ b/include/uapi/linux/futex.h
|
|
|
|
|
@@ -21,7 +21,7 @@
|
|
|
|
|
#define FUTEX_WAKE_BITSET 10
|
|
|
|
|
#define FUTEX_WAIT_REQUEUE_PI 11
|
|
|
|
|
#define FUTEX_CMP_REQUEUE_PI 12
|
|
|
|
|
-#define FUTEX_WAIT_MULTIPLE 13
|
|
|
|
|
+#define FUTEX_WAIT_MULTIPLE 31
|
|
|
|
|
|
|
|
|
|
#define FUTEX_PRIVATE_FLAG 128
|
|
|
|
|
#define FUTEX_CLOCK_REALTIME 256
|
|
|
|
|
diff --git a/kernel/futex.c b/kernel/futex.c
|
|
|
|
|
index 2170228..6cbbf06 100644
|
|
|
|
|
--- a/kernel/futex.c
|
|
|
|
|
+++ b/kernel/futex.c
|
|
|
|
|
@@ -4075,7 +4075,7 @@ SYSCALL_DEFINE6(futex, u32 __user *, uaddr, int, op, u32, val,
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
|
|
t = timespec64_to_ktime(ts);
|
|
|
|
|
- if (cmd == FUTEX_WAIT)
|
|
|
|
|
+ if (cmd == FUTEX_WAIT || cmd == FUTEX_WAIT_MULTIPLE)
|
|
|
|
|
t = ktime_add_safe(ktime_get(), t);
|
|
|
|
|
else if (!(op & FUTEX_CLOCK_REALTIME))
|
|
|
|
|
t = timens_ktime_to_host(CLOCK_MONOTONIC, t);
|
|
|
|
|
@@ -4278,6 +4278,7 @@ COMPAT_SYSCALL_DEFINE3(get_robust_list, int, pid,
|
|
|
|
|
*/
|
|
|
|
|
struct compat_futex_wait_block {
|
|
|
|
|
compat_uptr_t uaddr;
|
|
|
|
|
+ __u32 pad;
|
|
|
|
|
__u32 val;
|
|
|
|
|
__u32 bitset;
|
|
|
|
|
};
|
|
|
|
|
@@ -4340,7 +4341,7 @@ SYSCALL_DEFINE6(futex_time32, u32 __user *, uaddr, int, op, u32, val,
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
|
|
t = timespec64_to_ktime(ts);
|
|
|
|
|
- if (cmd == FUTEX_WAIT)
|
|
|
|
|
+ if (cmd == FUTEX_WAIT || cmd == FUTEX_WAIT_MULTIPLE)
|
|
|
|
|
t = ktime_add_safe(ktime_get(), t);
|
|
|
|
|
else if (!(op & FUTEX_CLOCK_REALTIME))
|
|
|
|
|
t = timens_ktime_to_host(CLOCK_MONOTONIC, t);
|
|
|
|
|
--
|
|
|
|
|
2.29.2.456.g3a0b884cab
|
|
|
|
|
|
|
|
|
|