Updated for version 6.7.6-zen1 & NTSync V2

This commit is contained in:
Wizzard 2024-02-23 22:34:28 -05:00
parent 058b098827
commit 45b8d146cb
62 changed files with 928 additions and 984 deletions

View File

@ -1,13 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 1/29] ntsync: Introduce the ntsync driver and
character device.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:28 -0600
Message-Id: <20240131021356.10322-2-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
ntsync uses a misc device as the simplest and least intrusive uAPI interface. ntsync uses a misc device as the simplest and least intrusive uAPI interface.
Each file description on the device represents an isolated NT instance, intended Each file description on the device represents an isolated NT instance, intended
@ -15,19 +5,19 @@ to correspond to a single NT virtual machine.
Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com> Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
--- ---
drivers/misc/Kconfig | 9 ++++++++ drivers/misc/Kconfig | 11 +++++++++
drivers/misc/Makefile | 1 + drivers/misc/Makefile | 1 +
drivers/misc/ntsync.c | 52 +++++++++++++++++++++++++++++++++++++++++++ drivers/misc/ntsync.c | 52 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 62 insertions(+) 3 files changed, 64 insertions(+)
create mode 100644 drivers/misc/ntsync.c create mode 100644 drivers/misc/ntsync.c
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 4fb291f0bf7c..bdd8a71bd853 100644 index 4fb291f0bf7c..801ed229ed7d 100644
--- a/drivers/misc/Kconfig --- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig
@@ -504,6 +504,15 @@ config OPEN_DICE @@ -506,6 +506,17 @@ config OPEN_DICE
measured boot flow. Userspace can use CDIs for remote attestation
and sealing. If unsure, say N.
+config NTSYNC +config NTSYNC
+ tristate "NT synchronization primitive emulation" + tristate "NT synchronization primitive emulation"
@ -38,9 +28,11 @@ index 4fb291f0bf7c..bdd8a71bd853 100644
+ To compile this driver as a module, choose M here: the + To compile this driver as a module, choose M here: the
+ module will be called ntsync. + module will be called ntsync.
+ +
If unsure, say N. + If unsure, say N.
+
config VCPU_STALL_DETECTOR config VCPU_STALL_DETECTOR
tristate "Guest vCPU stall detector"
depends on OF && HAS_IOMEM
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index ea6ea5bbbc9c..153a3f4837e8 100644 index ea6ea5bbbc9c..153a3f4837e8 100644
--- a/drivers/misc/Makefile --- a/drivers/misc/Makefile
@ -55,7 +47,7 @@ index ea6ea5bbbc9c..153a3f4837e8 100644
obj-$(CONFIG_GP_PCI1XXXX) += mchp_pci1xxxx/ obj-$(CONFIG_GP_PCI1XXXX) += mchp_pci1xxxx/
diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c
new file mode 100644 new file mode 100644
index 000000000000..e4969ef90722 index 000000000000..bd76e653d83e
--- /dev/null --- /dev/null
+++ b/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c
@@ -0,0 +1,52 @@ @@ -0,0 +1,52 @@
@ -63,7 +55,7 @@ index 000000000000..e4969ef90722
+/* +/*
+ * ntsync.c - Kernel driver for NT synchronization primitives + * ntsync.c - Kernel driver for NT synchronization primitives
+ * + *
+ * Copyright (C) 2024 Elizabeth Figura + * Copyright (C) 2024 Elizabeth Figura <zfigura@codeweavers.com>
+ */ + */
+ +
+#include <linux/fs.h> +#include <linux/fs.h>
@ -108,9 +100,8 @@ index 000000000000..e4969ef90722
+ +
+module_misc_device(ntsync_misc); +module_misc_device(ntsync_misc);
+ +
+MODULE_AUTHOR("Elizabeth Figura"); +MODULE_AUTHOR("Elizabeth Figura <zfigura@codeweavers.com>");
+MODULE_DESCRIPTION("Kernel driver for NT synchronization primitives"); +MODULE_DESCRIPTION("Kernel driver for NT synchronization primitives");
+MODULE_LICENSE("GPL"); +MODULE_LICENSE("GPL");
-- --
2.43.0 2.43.0

View File

@ -1,12 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 2/29] ntsync: Introduce NTSYNC_IOC_CREATE_SEM.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:29 -0600
Message-Id: <20240131021356.10322-3-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
This corresponds to the NT syscall NtCreateSemaphore(). This corresponds to the NT syscall NtCreateSemaphore().
Semaphores are one of three types of object to be implemented in this driver, Semaphores are one of three types of object to be implemented in this driver,
@ -20,12 +11,15 @@ creation time. There are no restrictions on the maximum and initial value.
Each object is exposed as an file, to which any number of fds may be opened. Each object is exposed as an file, to which any number of fds may be opened.
When all fds are closed, the object is deleted. When all fds are closed, the object is deleted.
Objects hold a pointer to the ntsync_device that created them. The device's
reference count is driven by struct file.
Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com> Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
--- ---
.../userspace-api/ioctl/ioctl-number.rst | 2 + .../userspace-api/ioctl/ioctl-number.rst | 2 +
drivers/misc/ntsync.c | 120 ++++++++++++++++++ drivers/misc/ntsync.c | 131 ++++++++++++++++++
include/uapi/linux/ntsync.h | 21 +++ include/uapi/linux/ntsync.h | 21 +++
3 files changed, 143 insertions(+) 3 files changed, 154 insertions(+)
create mode 100644 include/uapi/linux/ntsync.h create mode 100644 include/uapi/linux/ntsync.h
diff --git a/Documentation/userspace-api/ioctl/ioctl-number.rst b/Documentation/userspace-api/ioctl/ioctl-number.rst diff --git a/Documentation/userspace-api/ioctl/ioctl-number.rst b/Documentation/userspace-api/ioctl/ioctl-number.rst
@ -42,11 +36,11 @@ index 457e16f06e04..2f5c6994f042 100644
'P' all linux/soundcard.h conflict! 'P' all linux/soundcard.h conflict!
'P' 60-6F sound/sscape_ioctl.h conflict! 'P' 60-6F sound/sscape_ioctl.h conflict!
diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c
index e4969ef90722..3ad86d98b82d 100644 index bd76e653d83e..20158ec148bc 100644
--- a/drivers/misc/ntsync.c --- a/drivers/misc/ntsync.c
+++ b/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c
@@ -5,26 +5,146 @@ @@ -5,26 +5,157 @@
* Copyright (C) 2024 Elizabeth Figura * Copyright (C) 2024 Elizabeth Figura <zfigura@codeweavers.com>
*/ */
+#include <linux/anon_inodes.h> +#include <linux/anon_inodes.h>
@ -63,6 +57,17 @@ index e4969ef90722..3ad86d98b82d 100644
+ NTSYNC_TYPE_SEM, + NTSYNC_TYPE_SEM,
+}; +};
+ +
+/*
+ * Individual synchronization primitives are represented by
+ * struct ntsync_obj, and each primitive is backed by a file.
+ *
+ * The whole namespace is represented by a struct ntsync_device also
+ * backed by a file.
+ *
+ * Both rely on struct file for reference counting. Individual
+ * ntsync_obj objects take a reference to the device when created.
+ */
+
+struct ntsync_obj { +struct ntsync_obj {
+ enum ntsync_type type; + enum ntsync_type type;
+ +
@ -194,7 +199,7 @@ index e4969ef90722..3ad86d98b82d 100644
} }
diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h
new file mode 100644 new file mode 100644
index 000000000000..f38818e7759d index 000000000000..6a4867a6c97b
--- /dev/null --- /dev/null
+++ b/include/uapi/linux/ntsync.h +++ b/include/uapi/linux/ntsync.h
@@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
@ -202,7 +207,7 @@ index 000000000000..f38818e7759d
+/* +/*
+ * Kernel support for NT synchronization primitive emulation + * Kernel support for NT synchronization primitive emulation
+ * + *
+ * Copyright (C) 2021-2022 Elizabeth Figura + * Copyright (C) 2021-2022 Elizabeth Figura <zfigura@codeweavers.com>
+ */ + */
+ +
+#ifndef __LINUX_NTSYNC_H +#ifndef __LINUX_NTSYNC_H
@ -221,4 +226,3 @@ index 000000000000..f38818e7759d
+#endif +#endif
-- --
2.43.0 2.43.0

View File

@ -1,12 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 3/29] ntsync: Introduce NTSYNC_IOC_SEM_POST.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:30 -0600
Message-Id: <20240131021356.10322-4-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
This corresponds to the NT syscall NtReleaseSemaphore(). This corresponds to the NT syscall NtReleaseSemaphore().
This increases the semaphore's internal counter by the given value, and returns This increases the semaphore's internal counter by the given value, and returns
@ -15,16 +6,26 @@ function instead fails and returns -EOVERFLOW.
Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com> Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
--- ---
drivers/misc/ntsync.c | 68 +++++++++++++++++++++++++++++++++++-- drivers/misc/ntsync.c | 72 +++++++++++++++++++++++++++++++++++--
include/uapi/linux/ntsync.h | 2 ++ include/uapi/linux/ntsync.h | 2 ++
2 files changed, 67 insertions(+), 3 deletions(-) 2 files changed, 71 insertions(+), 3 deletions(-)
diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c
index 3ad86d98b82d..1af38969f9a2 100644 index 20158ec148bc..3c2f743c58b0 100644
--- a/drivers/misc/ntsync.c --- a/drivers/misc/ntsync.c
+++ b/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c
@@ -20,23 +20,68 @@ enum ntsync_type { @@ -10,7 +10,9 @@
}; #include <linux/fs.h>
#include <linux/miscdevice.h>
#include <linux/module.h>
+#include <linux/overflow.h>
#include <linux/slab.h>
+#include <linux/spinlock.h>
#include <uapi/linux/ntsync.h>
#define NTSYNC_NAME "ntsync"
@@ -31,23 +33,70 @@ enum ntsync_type {
*/
struct ntsync_obj { struct ntsync_obj {
+ spinlock_t lock; + spinlock_t lock;
@ -56,13 +57,15 @@ index 3ad86d98b82d..1af38969f9a2 100644
+ */ + */
+static int post_sem_state(struct ntsync_obj *sem, __u32 count) +static int post_sem_state(struct ntsync_obj *sem, __u32 count)
+{ +{
+ __u32 sum;
+
+ lockdep_assert_held(&sem->lock); + lockdep_assert_held(&sem->lock);
+ +
+ if (sem->u.sem.count + count < sem->u.sem.count || + if (check_add_overflow(sem->u.sem.count, count, &sum) ||
+ sem->u.sem.count + count > sem->u.sem.max) + sum > sem->u.sem.max)
+ return -EOVERFLOW; + return -EOVERFLOW;
+ +
+ sem->u.sem.count += count; + sem->u.sem.count = sum;
+ return 0; + return 0;
+} +}
+ +
@ -95,7 +98,7 @@ index 3ad86d98b82d..1af38969f9a2 100644
static int ntsync_obj_release(struct inode *inode, struct file *file) static int ntsync_obj_release(struct inode *inode, struct file *file)
{ {
struct ntsync_obj *obj = file->private_data; struct ntsync_obj *obj = file->private_data;
@@ -47,9 +92,25 @@ static int ntsync_obj_release(struct inode *inode, struct file *file) @@ -58,9 +107,25 @@ static int ntsync_obj_release(struct inode *inode, struct file *file)
return 0; return 0;
} }
@ -121,7 +124,7 @@ index 3ad86d98b82d..1af38969f9a2 100644
.llseek = no_llseek, .llseek = no_llseek,
}; };
@@ -64,6 +125,7 @@ static struct ntsync_obj *ntsync_alloc_obj(struct ntsync_device *dev, @@ -75,6 +140,7 @@ static struct ntsync_obj *ntsync_alloc_obj(struct ntsync_device *dev,
obj->type = type; obj->type = type;
obj->dev = dev; obj->dev = dev;
get_file(dev->file); get_file(dev->file);
@ -130,7 +133,7 @@ index 3ad86d98b82d..1af38969f9a2 100644
return obj; return obj;
} }
diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h
index f38818e7759d..878ec4f0f2e8 100644 index 6a4867a6c97b..dcfa38fdc93c 100644
--- a/include/uapi/linux/ntsync.h --- a/include/uapi/linux/ntsync.h
+++ b/include/uapi/linux/ntsync.h +++ b/include/uapi/linux/ntsync.h
@@ -18,4 +18,6 @@ struct ntsync_sem_args { @@ -18,4 +18,6 @@ struct ntsync_sem_args {
@ -142,4 +145,3 @@ index f38818e7759d..878ec4f0f2e8 100644
#endif #endif
-- --
2.43.0 2.43.0

View File

@ -1,12 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 4/29] ntsync: Introduce NTSYNC_IOC_WAIT_ANY.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:31 -0600
Message-Id: <20240131021356.10322-5-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
This corresponds to part of the functionality of the NT syscall This corresponds to part of the functionality of the NT syscall
NtWaitForMultipleObjects(). Specifically, it implements the behaviour where NtWaitForMultipleObjects(). Specifically, it implements the behaviour where
the third argument (wait_any) is TRUE, and it does not handle alertable waits. the third argument (wait_any) is TRUE, and it does not handle alertable waits.
@ -29,17 +20,46 @@ This ioctl validates that all objects belong to the relevant device. This is not
necessary for any technical reason related to NTSYNC_IOC_WAIT_ANY, but will be necessary for any technical reason related to NTSYNC_IOC_WAIT_ANY, but will be
necessary for NTSYNC_IOC_WAIT_ALL introduced in the following patch. necessary for NTSYNC_IOC_WAIT_ALL introduced in the following patch.
Wait ioctls need to take a temporary reference to each object being waited on.
As with the device, the reference count of struct file is used for ntsync_obj.
Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com> Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
--- ---
drivers/misc/ntsync.c | 232 ++++++++++++++++++++++++++++++++++++ drivers/misc/ntsync.c | 239 ++++++++++++++++++++++++++++++++++++
include/uapi/linux/ntsync.h | 12 ++ include/uapi/linux/ntsync.h | 12 ++
2 files changed, 244 insertions(+) 2 files changed, 251 insertions(+)
diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c
index 1af38969f9a2..0a0ab755d57f 100644 index 3c2f743c58b0..ad93ca0f8b84 100644
--- a/drivers/misc/ntsync.c --- a/drivers/misc/ntsync.c
+++ b/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c
@@ -34,12 +34,55 @@ struct ntsync_obj { @@ -6,11 +6,16 @@
*/
#include <linux/anon_inodes.h>
+#include <linux/atomic.h>
#include <linux/file.h>
#include <linux/fs.h>
+#include <linux/hrtimer.h>
+#include <linux/ktime.h>
#include <linux/miscdevice.h>
#include <linux/module.h>
#include <linux/overflow.h>
+#include <linux/sched.h>
+#include <linux/sched/signal.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <uapi/linux/ntsync.h>
@@ -30,6 +35,8 @@ enum ntsync_type {
*
* Both rely on struct file for reference counting. Individual
* ntsync_obj objects take a reference to the device when created.
+ * Wait operations take a reference to each object being waited on for
+ * the duration of the wait.
*/
struct ntsync_obj {
@@ -47,12 +54,55 @@ struct ntsync_obj {
__u32 max; __u32 max;
} sem; } sem;
} u; } u;
@ -95,7 +115,7 @@ index 1af38969f9a2..0a0ab755d57f 100644
/* /*
* Actually change the semaphore state, returning -EOVERFLOW if it is made * Actually change the semaphore state, returning -EOVERFLOW if it is made
* invalid. * invalid.
@@ -73,6 +116,8 @@ static int ntsync_sem_post(struct ntsync_obj *sem, void __user *argp) @@ -88,6 +138,8 @@ static int ntsync_sem_post(struct ntsync_obj *sem, void __user *argp)
prev_count = sem->u.sem.count; prev_count = sem->u.sem.count;
ret = post_sem_state(sem, args); ret = post_sem_state(sem, args);
@ -104,7 +124,7 @@ index 1af38969f9a2..0a0ab755d57f 100644
spin_unlock(&sem->lock); spin_unlock(&sem->lock);
@@ -126,6 +171,7 @@ static struct ntsync_obj *ntsync_alloc_obj(struct ntsync_device *dev, @@ -141,6 +193,7 @@ static struct ntsync_obj *ntsync_alloc_obj(struct ntsync_device *dev,
obj->dev = dev; obj->dev = dev;
get_file(dev->file); get_file(dev->file);
spin_lock_init(&obj->lock); spin_lock_init(&obj->lock);
@ -112,7 +132,7 @@ index 1af38969f9a2..0a0ab755d57f 100644
return obj; return obj;
} }
@@ -176,6 +222,190 @@ static int ntsync_create_sem(struct ntsync_device *dev, void __user *argp) @@ -191,6 +244,190 @@ static int ntsync_create_sem(struct ntsync_device *dev, void __user *argp)
return put_user(fd, &user_args->sem); return put_user(fd, &user_args->sem);
} }
@ -121,15 +141,13 @@ index 1af38969f9a2..0a0ab755d57f 100644
+ struct file *file = fget(fd); + struct file *file = fget(fd);
+ struct ntsync_obj *obj; + struct ntsync_obj *obj;
+ +
+ if (file->f_op != &ntsync_obj_fops) + if (file->f_op != &ntsync_obj_fops) {
+ {
+ fput(file); + fput(file);
+ return NULL; + return NULL;
+ } + }
+ +
+ obj = file->private_data; + obj = file->private_data;
+ if (obj->dev != dev) + if (obj->dev != dev) {
+ {
+ fput(file); + fput(file);
+ return NULL; + return NULL;
+ } + }
@ -142,10 +160,14 @@ index 1af38969f9a2..0a0ab755d57f 100644
+ fput(obj->file); + fput(obj->file);
+} +}
+ +
+static int ntsync_schedule(const struct ntsync_q *q, ktime_t *timeout) +static int ntsync_schedule(const struct ntsync_q *q, const struct ntsync_wait_args *args)
+{ +{
+ ktime_t timeout = ns_to_ktime(args->timeout);
+ ktime_t *timeout_ptr;
+ int ret = 0; + int ret = 0;
+ +
+ timeout_ptr = (args->timeout == U64_MAX ? NULL : &timeout);
+
+ do { + do {
+ if (signal_pending(current)) { + if (signal_pending(current)) {
+ ret = -ERESTARTSYS; + ret = -ERESTARTSYS;
@ -157,7 +179,7 @@ index 1af38969f9a2..0a0ab755d57f 100644
+ ret = 0; + ret = 0;
+ break; + break;
+ } + }
+ ret = schedule_hrtimeout(timeout, HRTIMER_MODE_ABS); + ret = schedule_hrtimeout(timeout_ptr, HRTIMER_MODE_ABS);
+ } while (ret < 0); + } while (ret < 0);
+ __set_current_state(TASK_RUNNING); + __set_current_state(TASK_RUNNING);
+ +
@ -229,7 +251,6 @@ index 1af38969f9a2..0a0ab755d57f 100644
+{ +{
+ struct ntsync_wait_args args; + struct ntsync_wait_args args;
+ struct ntsync_q *q; + struct ntsync_q *q;
+ ktime_t timeout;
+ int signaled; + int signaled;
+ __u32 i; + __u32 i;
+ int ret; + int ret;
@ -267,8 +288,7 @@ index 1af38969f9a2..0a0ab755d57f 100644
+ +
+ /* sleep */ + /* sleep */
+ +
+ timeout = ns_to_ktime(args.timeout); + ret = ntsync_schedule(q, &args);
+ ret = ntsync_schedule(q, args.timeout == U64_MAX ? NULL : &timeout);
+ +
+ /* and finally, unqueue */ + /* and finally, unqueue */
+ +
@ -303,7 +323,7 @@ index 1af38969f9a2..0a0ab755d57f 100644
static int ntsync_char_open(struct inode *inode, struct file *file) static int ntsync_char_open(struct inode *inode, struct file *file)
{ {
struct ntsync_device *dev; struct ntsync_device *dev;
@@ -207,6 +437,8 @@ static long ntsync_char_ioctl(struct file *file, unsigned int cmd, @@ -222,6 +459,8 @@ static long ntsync_char_ioctl(struct file *file, unsigned int cmd,
switch (cmd) { switch (cmd) {
case NTSYNC_IOC_CREATE_SEM: case NTSYNC_IOC_CREATE_SEM:
return ntsync_create_sem(dev, argp); return ntsync_create_sem(dev, argp);
@ -313,7 +333,7 @@ index 1af38969f9a2..0a0ab755d57f 100644
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
} }
diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h
index 878ec4f0f2e8..9cd1dd05d971 100644 index dcfa38fdc93c..56b643fab611 100644
--- a/include/uapi/linux/ntsync.h --- a/include/uapi/linux/ntsync.h
+++ b/include/uapi/linux/ntsync.h +++ b/include/uapi/linux/ntsync.h
@@ -16,7 +16,19 @@ struct ntsync_sem_args { @@ -16,7 +16,19 @@ struct ntsync_sem_args {
@ -338,4 +358,3 @@ index 878ec4f0f2e8..9cd1dd05d971 100644
-- --
2.43.0 2.43.0

View File

@ -1,27 +1,18 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 5/29] ntsync: Introduce NTSYNC_IOC_WAIT_ALL.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:32 -0600
Message-Id: <20240131021356.10322-6-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
This is similar to NTSYNC_IOC_WAIT_ANY, but waits until all of the objects are This is similar to NTSYNC_IOC_WAIT_ANY, but waits until all of the objects are
simultaneously signaled, and then acquires all of them as a single atomic simultaneously signaled, and then acquires all of them as a single atomic
operation. operation.
Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com> Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
--- ---
drivers/misc/ntsync.c | 244 ++++++++++++++++++++++++++++++++++-- drivers/misc/ntsync.c | 242 ++++++++++++++++++++++++++++++++++--
include/uapi/linux/ntsync.h | 1 + include/uapi/linux/ntsync.h | 1 +
2 files changed, 237 insertions(+), 8 deletions(-) 2 files changed, 235 insertions(+), 8 deletions(-)
diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c
index 0a0ab755d57f..b86d62094344 100644 index ad93ca0f8b84..d5759e9a3a8e 100644
--- a/drivers/misc/ntsync.c --- a/drivers/misc/ntsync.c
+++ b/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c
@@ -35,7 +35,34 @@ struct ntsync_obj { @@ -55,7 +55,34 @@ struct ntsync_obj {
} sem; } sem;
} u; } u;
@ -56,7 +47,7 @@ index 0a0ab755d57f..b86d62094344 100644
}; };
struct ntsync_q_entry { struct ntsync_q_entry {
@@ -56,14 +83,99 @@ struct ntsync_q { @@ -76,14 +103,99 @@ struct ntsync_q {
*/ */
atomic_t signaled; atomic_t signaled;
@ -156,7 +147,7 @@ index 0a0ab755d57f..b86d62094344 100644
static void try_wake_any_sem(struct ntsync_obj *sem) static void try_wake_any_sem(struct ntsync_obj *sem)
{ {
struct ntsync_q_entry *entry; struct ntsync_q_entry *entry;
@@ -101,6 +213,7 @@ static int post_sem_state(struct ntsync_obj *sem, __u32 count) @@ -123,6 +235,7 @@ static int post_sem_state(struct ntsync_obj *sem, __u32 count)
static int ntsync_sem_post(struct ntsync_obj *sem, void __user *argp) static int ntsync_sem_post(struct ntsync_obj *sem, void __user *argp)
{ {
@ -164,7 +155,7 @@ index 0a0ab755d57f..b86d62094344 100644
__u32 __user *user_args = argp; __u32 __user *user_args = argp;
__u32 prev_count; __u32 prev_count;
__u32 args; __u32 args;
@@ -112,14 +225,29 @@ static int ntsync_sem_post(struct ntsync_obj *sem, void __user *argp) @@ -134,14 +247,29 @@ static int ntsync_sem_post(struct ntsync_obj *sem, void __user *argp)
if (sem->type != NTSYNC_TYPE_SEM) if (sem->type != NTSYNC_TYPE_SEM)
return -EINVAL; return -EINVAL;
@ -200,7 +191,7 @@ index 0a0ab755d57f..b86d62094344 100644
if (!ret && put_user(prev_count, user_args)) if (!ret && put_user(prev_count, user_args))
ret = -EFAULT; ret = -EFAULT;
@@ -172,6 +300,8 @@ static struct ntsync_obj *ntsync_alloc_obj(struct ntsync_device *dev, @@ -194,6 +322,8 @@ static struct ntsync_obj *ntsync_alloc_obj(struct ntsync_device *dev,
get_file(dev->file); get_file(dev->file);
spin_lock_init(&obj->lock); spin_lock_init(&obj->lock);
INIT_LIST_HEAD(&obj->any_waiters); INIT_LIST_HEAD(&obj->any_waiters);
@ -209,7 +200,7 @@ index 0a0ab755d57f..b86d62094344 100644
return obj; return obj;
} }
@@ -274,7 +404,7 @@ static int ntsync_schedule(const struct ntsync_q *q, ktime_t *timeout) @@ -298,7 +428,7 @@ static int ntsync_schedule(const struct ntsync_q *q, const struct ntsync_wait_ar
* Allocate and initialize the ntsync_q structure, but do not queue us yet. * Allocate and initialize the ntsync_q structure, but do not queue us yet.
*/ */
static int setup_wait(struct ntsync_device *dev, static int setup_wait(struct ntsync_device *dev,
@ -218,7 +209,7 @@ index 0a0ab755d57f..b86d62094344 100644
struct ntsync_q **ret_q) struct ntsync_q **ret_q)
{ {
const __u32 count = args->count; const __u32 count = args->count;
@@ -298,6 +428,7 @@ static int setup_wait(struct ntsync_device *dev, @@ -322,6 +452,7 @@ static int setup_wait(struct ntsync_device *dev,
q->task = current; q->task = current;
q->owner = args->owner; q->owner = args->owner;
atomic_set(&q->signaled, -1); atomic_set(&q->signaled, -1);
@ -226,7 +217,7 @@ index 0a0ab755d57f..b86d62094344 100644
q->count = count; q->count = count;
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
@@ -307,6 +438,16 @@ static int setup_wait(struct ntsync_device *dev, @@ -331,6 +462,16 @@ static int setup_wait(struct ntsync_device *dev,
if (!obj) if (!obj)
goto err; goto err;
@ -243,7 +234,7 @@ index 0a0ab755d57f..b86d62094344 100644
entry->obj = obj; entry->obj = obj;
entry->q = q; entry->q = q;
entry->index = i; entry->index = i;
@@ -343,7 +484,7 @@ static int ntsync_wait_any(struct ntsync_device *dev, void __user *argp) @@ -366,7 +507,7 @@ static int ntsync_wait_any(struct ntsync_device *dev, void __user *argp)
if (copy_from_user(&args, argp, sizeof(args))) if (copy_from_user(&args, argp, sizeof(args)))
return -EFAULT; return -EFAULT;
@ -252,7 +243,7 @@ index 0a0ab755d57f..b86d62094344 100644
if (ret < 0) if (ret < 0)
return ret; return ret;
@@ -406,6 +547,89 @@ static int ntsync_wait_any(struct ntsync_device *dev, void __user *argp) @@ -428,6 +569,87 @@ static int ntsync_wait_any(struct ntsync_device *dev, void __user *argp)
return ret; return ret;
} }
@ -260,7 +251,6 @@ index 0a0ab755d57f..b86d62094344 100644
+{ +{
+ struct ntsync_wait_args args; + struct ntsync_wait_args args;
+ struct ntsync_q *q; + struct ntsync_q *q;
+ ktime_t timeout;
+ int signaled; + int signaled;
+ __u32 i; + __u32 i;
+ int ret; + int ret;
@ -298,8 +288,7 @@ index 0a0ab755d57f..b86d62094344 100644
+ +
+ /* sleep */ + /* sleep */
+ +
+ timeout = ns_to_ktime(args.timeout); + ret = ntsync_schedule(q, &args);
+ ret = ntsync_schedule(q, args.timeout == U64_MAX ? NULL : &timeout);
+ +
+ /* and finally, unqueue */ + /* and finally, unqueue */
+ +
@ -342,7 +331,7 @@ index 0a0ab755d57f..b86d62094344 100644
static int ntsync_char_open(struct inode *inode, struct file *file) static int ntsync_char_open(struct inode *inode, struct file *file)
{ {
struct ntsync_device *dev; struct ntsync_device *dev;
@@ -414,6 +638,8 @@ static int ntsync_char_open(struct inode *inode, struct file *file) @@ -436,6 +658,8 @@ static int ntsync_char_open(struct inode *inode, struct file *file)
if (!dev) if (!dev)
return -ENOMEM; return -ENOMEM;
@ -351,7 +340,7 @@ index 0a0ab755d57f..b86d62094344 100644
file->private_data = dev; file->private_data = dev;
dev->file = file; dev->file = file;
return nonseekable_open(inode, file); return nonseekable_open(inode, file);
@@ -437,6 +663,8 @@ static long ntsync_char_ioctl(struct file *file, unsigned int cmd, @@ -459,6 +683,8 @@ static long ntsync_char_ioctl(struct file *file, unsigned int cmd,
switch (cmd) { switch (cmd) {
case NTSYNC_IOC_CREATE_SEM: case NTSYNC_IOC_CREATE_SEM:
return ntsync_create_sem(dev, argp); return ntsync_create_sem(dev, argp);
@ -361,7 +350,7 @@ index 0a0ab755d57f..b86d62094344 100644
return ntsync_wait_any(dev, argp); return ntsync_wait_any(dev, argp);
default: default:
diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h
index 9cd1dd05d971..524404f6aceb 100644 index 56b643fab611..19c37e27a4f8 100644
--- a/include/uapi/linux/ntsync.h --- a/include/uapi/linux/ntsync.h
+++ b/include/uapi/linux/ntsync.h +++ b/include/uapi/linux/ntsync.h
@@ -29,6 +29,7 @@ struct ntsync_wait_args { @@ -29,6 +29,7 @@ struct ntsync_wait_args {
@ -374,4 +363,3 @@ index 9cd1dd05d971..524404f6aceb 100644
-- --
2.43.0 2.43.0

View File

@ -1,12 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 6/29] ntsync: Introduce NTSYNC_IOC_CREATE_MUTEX.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:33 -0600
Message-Id: <20240131021356.10322-7-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
This corresponds to the NT syscall NtCreateMutant(). This corresponds to the NT syscall NtCreateMutant().
An NT mutex is recursive, with a 32-bit recursion counter. When acquired via An NT mutex is recursive, with a 32-bit recursion counter. When acquired via
@ -26,18 +17,18 @@ Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
2 files changed, 74 insertions(+) 2 files changed, 74 insertions(+)
diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c
index b86d62094344..484219a266ae 100644 index d5759e9a3a8e..6f7086d0440a 100644
--- a/drivers/misc/ntsync.c --- a/drivers/misc/ntsync.c
+++ b/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c
@@ -17,6 +17,7 @@ @@ -24,6 +24,7 @@
enum ntsync_type { enum ntsync_type {
NTSYNC_TYPE_SEM, NTSYNC_TYPE_SEM,
+ NTSYNC_TYPE_MUTEX, + NTSYNC_TYPE_MUTEX,
}; };
struct ntsync_obj { /*
@@ -33,6 +34,10 @@ struct ntsync_obj { @@ -53,6 +54,10 @@ struct ntsync_obj {
__u32 count; __u32 count;
__u32 max; __u32 max;
} sem; } sem;
@ -48,7 +39,7 @@ index b86d62094344..484219a266ae 100644
} u; } u;
/* /*
@@ -112,6 +117,10 @@ static bool is_signaled(struct ntsync_obj *obj, __u32 owner) @@ -132,6 +137,10 @@ static bool is_signaled(struct ntsync_obj *obj, __u32 owner)
switch (obj->type) { switch (obj->type) {
case NTSYNC_TYPE_SEM: case NTSYNC_TYPE_SEM:
return !!obj->u.sem.count; return !!obj->u.sem.count;
@ -59,7 +50,7 @@ index b86d62094344..484219a266ae 100644
} }
WARN(1, "bad object type %#x\n", obj->type); WARN(1, "bad object type %#x\n", obj->type);
@@ -154,6 +163,10 @@ static void try_wake_all(struct ntsync_device *dev, struct ntsync_q *q, @@ -174,6 +183,10 @@ static void try_wake_all(struct ntsync_device *dev, struct ntsync_q *q,
case NTSYNC_TYPE_SEM: case NTSYNC_TYPE_SEM:
obj->u.sem.count--; obj->u.sem.count--;
break; break;
@ -70,7 +61,7 @@ index b86d62094344..484219a266ae 100644
} }
} }
wake_up_process(q->task); wake_up_process(q->task);
@@ -195,6 +208,28 @@ static void try_wake_any_sem(struct ntsync_obj *sem) @@ -215,6 +228,28 @@ static void try_wake_any_sem(struct ntsync_obj *sem)
} }
} }
@ -99,7 +90,7 @@ index b86d62094344..484219a266ae 100644
/* /*
* Actually change the semaphore state, returning -EOVERFLOW if it is made * Actually change the semaphore state, returning -EOVERFLOW if it is made
* invalid. * invalid.
@@ -352,6 +387,33 @@ static int ntsync_create_sem(struct ntsync_device *dev, void __user *argp) @@ -374,6 +409,33 @@ static int ntsync_create_sem(struct ntsync_device *dev, void __user *argp)
return put_user(fd, &user_args->sem); return put_user(fd, &user_args->sem);
} }
@ -133,7 +124,7 @@ index b86d62094344..484219a266ae 100644
static struct ntsync_obj *get_obj(struct ntsync_device *dev, int fd) static struct ntsync_obj *get_obj(struct ntsync_device *dev, int fd)
{ {
struct file *file = fget(fd); struct file *file = fget(fd);
@@ -469,6 +531,9 @@ static void try_wake_any_obj(struct ntsync_obj *obj) @@ -493,6 +555,9 @@ static void try_wake_any_obj(struct ntsync_obj *obj)
case NTSYNC_TYPE_SEM: case NTSYNC_TYPE_SEM:
try_wake_any_sem(obj); try_wake_any_sem(obj);
break; break;
@ -143,7 +134,7 @@ index b86d62094344..484219a266ae 100644
} }
} }
@@ -661,6 +726,8 @@ static long ntsync_char_ioctl(struct file *file, unsigned int cmd, @@ -681,6 +746,8 @@ static long ntsync_char_ioctl(struct file *file, unsigned int cmd,
void __user *argp = (void __user *)parm; void __user *argp = (void __user *)parm;
switch (cmd) { switch (cmd) {
@ -153,7 +144,7 @@ index b86d62094344..484219a266ae 100644
return ntsync_create_sem(dev, argp); return ntsync_create_sem(dev, argp);
case NTSYNC_IOC_WAIT_ALL: case NTSYNC_IOC_WAIT_ALL:
diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h
index 524404f6aceb..d68f24fd75a2 100644 index 19c37e27a4f8..8ac9d419c360 100644
--- a/include/uapi/linux/ntsync.h --- a/include/uapi/linux/ntsync.h
+++ b/include/uapi/linux/ntsync.h +++ b/include/uapi/linux/ntsync.h
@@ -16,6 +16,12 @@ struct ntsync_sem_args { @@ -16,6 +16,12 @@ struct ntsync_sem_args {
@ -179,4 +170,3 @@ index 524404f6aceb..d68f24fd75a2 100644
-- --
2.43.0 2.43.0

View File

@ -1,12 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 7/29] ntsync: Introduce NTSYNC_IOC_MUTEX_UNLOCK.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:34 -0600
Message-Id: <20240131021356.10322-8-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
This corresponds to the NT syscall NtReleaseMutant(). This corresponds to the NT syscall NtReleaseMutant().
This syscall decrements the mutex's recursion count by one, and returns the This syscall decrements the mutex's recursion count by one, and returns the
@ -20,10 +11,10 @@ Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
2 files changed, 65 insertions(+) 2 files changed, 65 insertions(+)
diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c
index 484219a266ae..1770ec4008af 100644 index 6f7086d0440a..222ebead8eba 100644
--- a/drivers/misc/ntsync.c --- a/drivers/misc/ntsync.c
+++ b/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c
@@ -290,6 +290,68 @@ static int ntsync_sem_post(struct ntsync_obj *sem, void __user *argp) @@ -312,6 +312,68 @@ static int ntsync_sem_post(struct ntsync_obj *sem, void __user *argp)
return ret; return ret;
} }
@ -92,7 +83,7 @@ index 484219a266ae..1770ec4008af 100644
static int ntsync_obj_release(struct inode *inode, struct file *file) static int ntsync_obj_release(struct inode *inode, struct file *file)
{ {
struct ntsync_obj *obj = file->private_data; struct ntsync_obj *obj = file->private_data;
@@ -309,6 +371,8 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd, @@ -331,6 +393,8 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd,
switch (cmd) { switch (cmd) {
case NTSYNC_IOC_SEM_POST: case NTSYNC_IOC_SEM_POST:
return ntsync_sem_post(obj, argp); return ntsync_sem_post(obj, argp);
@ -102,7 +93,7 @@ index 484219a266ae..1770ec4008af 100644
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
} }
diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h
index d68f24fd75a2..a3f5f4f13798 100644 index 8ac9d419c360..265503d441b1 100644
--- a/include/uapi/linux/ntsync.h --- a/include/uapi/linux/ntsync.h
+++ b/include/uapi/linux/ntsync.h +++ b/include/uapi/linux/ntsync.h
@@ -39,5 +39,6 @@ struct ntsync_wait_args { @@ -39,5 +39,6 @@ struct ntsync_wait_args {
@ -114,4 +105,3 @@ index d68f24fd75a2..a3f5f4f13798 100644
#endif #endif
-- --
2.43.0 2.43.0

View File

@ -1,12 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 8/29] ntsync: Introduce NTSYNC_IOC_MUTEX_KILL.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:35 -0600
Message-Id: <20240131021356.10322-9-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
This does not correspond to any NT syscall. Rather, when a thread dies, it This does not correspond to any NT syscall. Rather, when a thread dies, it
should be called by the NT emulator for each mutex. should be called by the NT emulator for each mutex.
@ -23,10 +14,10 @@ Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
2 files changed, 70 insertions(+), 2 deletions(-) 2 files changed, 70 insertions(+), 2 deletions(-)
diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c
index 1770ec4008af..aadf01c65ca0 100644 index 222ebead8eba..a3466be50c45 100644
--- a/drivers/misc/ntsync.c --- a/drivers/misc/ntsync.c
+++ b/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c
@@ -37,6 +37,7 @@ struct ntsync_obj { @@ -57,6 +57,7 @@ struct ntsync_obj {
struct { struct {
__u32 count; __u32 count;
__u32 owner; __u32 owner;
@ -34,7 +25,7 @@ index 1770ec4008af..aadf01c65ca0 100644
} mutex; } mutex;
} u; } u;
@@ -89,6 +90,7 @@ struct ntsync_q { @@ -109,6 +110,7 @@ struct ntsync_q {
atomic_t signaled; atomic_t signaled;
bool all; bool all;
@ -42,7 +33,7 @@ index 1770ec4008af..aadf01c65ca0 100644
__u32 count; __u32 count;
struct ntsync_q_entry entries[]; struct ntsync_q_entry entries[];
}; };
@@ -164,6 +166,9 @@ static void try_wake_all(struct ntsync_device *dev, struct ntsync_q *q, @@ -184,6 +186,9 @@ static void try_wake_all(struct ntsync_device *dev, struct ntsync_q *q,
obj->u.sem.count--; obj->u.sem.count--;
break; break;
case NTSYNC_TYPE_MUTEX: case NTSYNC_TYPE_MUTEX:
@ -52,7 +43,7 @@ index 1770ec4008af..aadf01c65ca0 100644
obj->u.mutex.count++; obj->u.mutex.count++;
obj->u.mutex.owner = q->owner; obj->u.mutex.owner = q->owner;
break; break;
@@ -223,6 +228,9 @@ static void try_wake_any_mutex(struct ntsync_obj *mutex) @@ -243,6 +248,9 @@ static void try_wake_any_mutex(struct ntsync_obj *mutex)
continue; continue;
if (atomic_cmpxchg(&q->signaled, -1, entry->index) == -1) { if (atomic_cmpxchg(&q->signaled, -1, entry->index) == -1) {
@ -62,7 +53,7 @@ index 1770ec4008af..aadf01c65ca0 100644
mutex->u.mutex.count++; mutex->u.mutex.count++;
mutex->u.mutex.owner = q->owner; mutex->u.mutex.owner = q->owner;
wake_up_process(q->task); wake_up_process(q->task);
@@ -352,6 +360,62 @@ static int ntsync_mutex_unlock(struct ntsync_obj *mutex, void __user *argp) @@ -374,6 +382,62 @@ static int ntsync_mutex_unlock(struct ntsync_obj *mutex, void __user *argp)
return ret; return ret;
} }
@ -125,7 +116,7 @@ index 1770ec4008af..aadf01c65ca0 100644
static int ntsync_obj_release(struct inode *inode, struct file *file) static int ntsync_obj_release(struct inode *inode, struct file *file)
{ {
struct ntsync_obj *obj = file->private_data; struct ntsync_obj *obj = file->private_data;
@@ -373,6 +437,8 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd, @@ -395,6 +459,8 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd,
return ntsync_sem_post(obj, argp); return ntsync_sem_post(obj, argp);
case NTSYNC_IOC_MUTEX_UNLOCK: case NTSYNC_IOC_MUTEX_UNLOCK:
return ntsync_mutex_unlock(obj, argp); return ntsync_mutex_unlock(obj, argp);
@ -134,7 +125,7 @@ index 1770ec4008af..aadf01c65ca0 100644
default: default:
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
} }
@@ -555,6 +621,7 @@ static int setup_wait(struct ntsync_device *dev, @@ -579,6 +645,7 @@ static int setup_wait(struct ntsync_device *dev,
q->owner = args->owner; q->owner = args->owner;
atomic_set(&q->signaled, -1); atomic_set(&q->signaled, -1);
q->all = all; q->all = all;
@ -142,7 +133,7 @@ index 1770ec4008af..aadf01c65ca0 100644
q->count = count; q->count = count;
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
@@ -664,7 +731,7 @@ static int ntsync_wait_any(struct ntsync_device *dev, void __user *argp) @@ -686,7 +753,7 @@ static int ntsync_wait_any(struct ntsync_device *dev, void __user *argp)
struct ntsync_wait_args __user *user_args = argp; struct ntsync_wait_args __user *user_args = argp;
/* even if we caught a signal, we need to communicate success */ /* even if we caught a signal, we need to communicate success */
@ -151,7 +142,7 @@ index 1770ec4008af..aadf01c65ca0 100644
if (put_user(signaled, &user_args->index)) if (put_user(signaled, &user_args->index))
ret = -EFAULT; ret = -EFAULT;
@@ -747,7 +814,7 @@ static int ntsync_wait_all(struct ntsync_device *dev, void __user *argp) @@ -767,7 +834,7 @@ static int ntsync_wait_all(struct ntsync_device *dev, void __user *argp)
struct ntsync_wait_args __user *user_args = argp; struct ntsync_wait_args __user *user_args = argp;
/* even if we caught a signal, we need to communicate success */ /* even if we caught a signal, we need to communicate success */
@ -161,7 +152,7 @@ index 1770ec4008af..aadf01c65ca0 100644
if (put_user(signaled, &user_args->index)) if (put_user(signaled, &user_args->index))
ret = -EFAULT; ret = -EFAULT;
diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h
index a3f5f4f13798..3861397c6c2f 100644 index 265503d441b1..4800941fcbda 100644
--- a/include/uapi/linux/ntsync.h --- a/include/uapi/linux/ntsync.h
+++ b/include/uapi/linux/ntsync.h +++ b/include/uapi/linux/ntsync.h
@@ -40,5 +40,6 @@ struct ntsync_wait_args { @@ -40,5 +40,6 @@ struct ntsync_wait_args {
@ -173,4 +164,3 @@ index a3f5f4f13798..3861397c6c2f 100644
#endif #endif
-- --
2.43.0 2.43.0

View File

@ -1,12 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 9/29] ntsync: Introduce NTSYNC_IOC_CREATE_EVENT.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:36 -0600
Message-Id: <20240131021356.10322-10-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
This correspond to the NT syscall NtCreateEvent(). This correspond to the NT syscall NtCreateEvent().
An NT event holds a single bit of state denoting whether it is signaled or An NT event holds a single bit of state denoting whether it is signaled or
@ -26,18 +17,18 @@ Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
2 files changed, 67 insertions(+) 2 files changed, 67 insertions(+)
diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c
index aadf01c65ca0..c719ddd9f6d7 100644 index a3466be50c45..17dd47d06e0a 100644
--- a/drivers/misc/ntsync.c --- a/drivers/misc/ntsync.c
+++ b/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c
@@ -18,6 +18,7 @@ @@ -25,6 +25,7 @@
enum ntsync_type { enum ntsync_type {
NTSYNC_TYPE_SEM, NTSYNC_TYPE_SEM,
NTSYNC_TYPE_MUTEX, NTSYNC_TYPE_MUTEX,
+ NTSYNC_TYPE_EVENT, + NTSYNC_TYPE_EVENT,
}; };
struct ntsync_obj { /*
@@ -39,6 +40,10 @@ struct ntsync_obj { @@ -59,6 +60,10 @@ struct ntsync_obj {
__u32 owner; __u32 owner;
bool ownerdead; bool ownerdead;
} mutex; } mutex;
@ -48,7 +39,7 @@ index aadf01c65ca0..c719ddd9f6d7 100644
} u; } u;
/* /*
@@ -123,6 +128,8 @@ static bool is_signaled(struct ntsync_obj *obj, __u32 owner) @@ -143,6 +148,8 @@ static bool is_signaled(struct ntsync_obj *obj, __u32 owner)
if (obj->u.mutex.owner && obj->u.mutex.owner != owner) if (obj->u.mutex.owner && obj->u.mutex.owner != owner)
return false; return false;
return obj->u.mutex.count < UINT_MAX; return obj->u.mutex.count < UINT_MAX;
@ -57,7 +48,7 @@ index aadf01c65ca0..c719ddd9f6d7 100644
} }
WARN(1, "bad object type %#x\n", obj->type); WARN(1, "bad object type %#x\n", obj->type);
@@ -172,6 +179,10 @@ static void try_wake_all(struct ntsync_device *dev, struct ntsync_q *q, @@ -192,6 +199,10 @@ static void try_wake_all(struct ntsync_device *dev, struct ntsync_q *q,
obj->u.mutex.count++; obj->u.mutex.count++;
obj->u.mutex.owner = q->owner; obj->u.mutex.owner = q->owner;
break; break;
@ -68,7 +59,7 @@ index aadf01c65ca0..c719ddd9f6d7 100644
} }
} }
wake_up_process(q->task); wake_up_process(q->task);
@@ -238,6 +249,26 @@ static void try_wake_any_mutex(struct ntsync_obj *mutex) @@ -258,6 +269,26 @@ static void try_wake_any_mutex(struct ntsync_obj *mutex)
} }
} }
@ -95,7 +86,7 @@ index aadf01c65ca0..c719ddd9f6d7 100644
/* /*
* Actually change the semaphore state, returning -EOVERFLOW if it is made * Actually change the semaphore state, returning -EOVERFLOW if it is made
* invalid. * invalid.
@@ -544,6 +575,30 @@ static int ntsync_create_mutex(struct ntsync_device *dev, void __user *argp) @@ -566,6 +597,30 @@ static int ntsync_create_mutex(struct ntsync_device *dev, void __user *argp)
return put_user(fd, &user_args->mutex); return put_user(fd, &user_args->mutex);
} }
@ -126,7 +117,7 @@ index aadf01c65ca0..c719ddd9f6d7 100644
static struct ntsync_obj *get_obj(struct ntsync_device *dev, int fd) static struct ntsync_obj *get_obj(struct ntsync_device *dev, int fd)
{ {
struct file *file = fget(fd); struct file *file = fget(fd);
@@ -665,6 +720,9 @@ static void try_wake_any_obj(struct ntsync_obj *obj) @@ -689,6 +744,9 @@ static void try_wake_any_obj(struct ntsync_obj *obj)
case NTSYNC_TYPE_MUTEX: case NTSYNC_TYPE_MUTEX:
try_wake_any_mutex(obj); try_wake_any_mutex(obj);
break; break;
@ -136,7 +127,7 @@ index aadf01c65ca0..c719ddd9f6d7 100644
} }
} }
@@ -857,6 +915,8 @@ static long ntsync_char_ioctl(struct file *file, unsigned int cmd, @@ -877,6 +935,8 @@ static long ntsync_char_ioctl(struct file *file, unsigned int cmd,
void __user *argp = (void __user *)parm; void __user *argp = (void __user *)parm;
switch (cmd) { switch (cmd) {
@ -146,7 +137,7 @@ index aadf01c65ca0..c719ddd9f6d7 100644
return ntsync_create_mutex(dev, argp); return ntsync_create_mutex(dev, argp);
case NTSYNC_IOC_CREATE_SEM: case NTSYNC_IOC_CREATE_SEM:
diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h
index 3861397c6c2f..b8cf503365ef 100644 index 4800941fcbda..040cbdb39033 100644
--- a/include/uapi/linux/ntsync.h --- a/include/uapi/linux/ntsync.h
+++ b/include/uapi/linux/ntsync.h +++ b/include/uapi/linux/ntsync.h
@@ -22,6 +22,12 @@ struct ntsync_mutex_args { @@ -22,6 +22,12 @@ struct ntsync_mutex_args {
@ -172,4 +163,3 @@ index 3861397c6c2f..b8cf503365ef 100644
#define NTSYNC_IOC_MUTEX_UNLOCK _IOWR('N', 0x85, struct ntsync_mutex_args) #define NTSYNC_IOC_MUTEX_UNLOCK _IOWR('N', 0x85, struct ntsync_mutex_args)
-- --
2.43.0 2.43.0

View File

@ -1,12 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 10/29] ntsync: Introduce NTSYNC_IOC_EVENT_SET.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:37 -0600
Message-Id: <20240131021356.10322-11-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
This corresponds to the NT syscall NtSetEvent(). This corresponds to the NT syscall NtSetEvent().
This sets the event to the signaled state, and returns its previous state. This sets the event to the signaled state, and returns its previous state.
@ -18,10 +9,10 @@ Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
2 files changed, 38 insertions(+) 2 files changed, 38 insertions(+)
diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c
index c719ddd9f6d7..b2da50989953 100644 index 17dd47d06e0a..edfbf11cafe0 100644
--- a/drivers/misc/ntsync.c --- a/drivers/misc/ntsync.c
+++ b/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c
@@ -447,6 +447,41 @@ static int ntsync_mutex_kill(struct ntsync_obj *mutex, void __user *argp) @@ -469,6 +469,41 @@ static int ntsync_mutex_kill(struct ntsync_obj *mutex, void __user *argp)
return ret; return ret;
} }
@ -63,7 +54,7 @@ index c719ddd9f6d7..b2da50989953 100644
static int ntsync_obj_release(struct inode *inode, struct file *file) static int ntsync_obj_release(struct inode *inode, struct file *file)
{ {
struct ntsync_obj *obj = file->private_data; struct ntsync_obj *obj = file->private_data;
@@ -470,6 +505,8 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd, @@ -492,6 +527,8 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd,
return ntsync_mutex_unlock(obj, argp); return ntsync_mutex_unlock(obj, argp);
case NTSYNC_IOC_MUTEX_KILL: case NTSYNC_IOC_MUTEX_KILL:
return ntsync_mutex_kill(obj, argp); return ntsync_mutex_kill(obj, argp);
@ -73,7 +64,7 @@ index c719ddd9f6d7..b2da50989953 100644
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
} }
diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h
index b8cf503365ef..782057552483 100644 index 040cbdb39033..af518530bffd 100644
--- a/include/uapi/linux/ntsync.h --- a/include/uapi/linux/ntsync.h
+++ b/include/uapi/linux/ntsync.h +++ b/include/uapi/linux/ntsync.h
@@ -48,5 +48,6 @@ struct ntsync_wait_args { @@ -48,5 +48,6 @@ struct ntsync_wait_args {
@ -85,4 +76,3 @@ index b8cf503365ef..782057552483 100644
#endif #endif
-- --
2.43.0 2.43.0

View File

@ -1,12 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 11/29] ntsync: Introduce NTSYNC_IOC_EVENT_RESET.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:38 -0600
Message-Id: <20240131021356.10322-12-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
This corresponds to the NT syscall NtResetEvent(). This corresponds to the NT syscall NtResetEvent().
This sets the event to the unsignaled state, and returns its previous state. This sets the event to the unsignaled state, and returns its previous state.
@ -18,10 +9,10 @@ Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
2 files changed, 23 insertions(+) 2 files changed, 23 insertions(+)
diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c
index b2da50989953..009d927739b8 100644 index edfbf11cafe0..fa4c3fa1e496 100644
--- a/drivers/misc/ntsync.c --- a/drivers/misc/ntsync.c
+++ b/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c
@@ -482,6 +482,26 @@ static int ntsync_event_set(struct ntsync_obj *event, void __user *argp) @@ -504,6 +504,26 @@ static int ntsync_event_set(struct ntsync_obj *event, void __user *argp)
return 0; return 0;
} }
@ -48,7 +39,7 @@ index b2da50989953..009d927739b8 100644
static int ntsync_obj_release(struct inode *inode, struct file *file) static int ntsync_obj_release(struct inode *inode, struct file *file)
{ {
struct ntsync_obj *obj = file->private_data; struct ntsync_obj *obj = file->private_data;
@@ -507,6 +527,8 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd, @@ -529,6 +549,8 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd,
return ntsync_mutex_kill(obj, argp); return ntsync_mutex_kill(obj, argp);
case NTSYNC_IOC_EVENT_SET: case NTSYNC_IOC_EVENT_SET:
return ntsync_event_set(obj, argp); return ntsync_event_set(obj, argp);
@ -58,7 +49,7 @@ index b2da50989953..009d927739b8 100644
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
} }
diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h
index 782057552483..f2d7507d8438 100644 index af518530bffd..6963356ee3f7 100644
--- a/include/uapi/linux/ntsync.h --- a/include/uapi/linux/ntsync.h
+++ b/include/uapi/linux/ntsync.h +++ b/include/uapi/linux/ntsync.h
@@ -49,5 +49,6 @@ struct ntsync_wait_args { @@ -49,5 +49,6 @@ struct ntsync_wait_args {
@ -70,4 +61,3 @@ index 782057552483..f2d7507d8438 100644
#endif #endif
-- --
2.43.0 2.43.0

View File

@ -1,12 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 12/29] ntsync: Introduce NTSYNC_IOC_EVENT_PULSE.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:39 -0600
Message-Id: <20240131021356.10322-13-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
This corresponds to the NT syscall NtPulseEvent(). This corresponds to the NT syscall NtPulseEvent().
This wakes up any waiters as if the event had been set, but does not set the This wakes up any waiters as if the event had been set, but does not set the
@ -21,10 +12,10 @@ Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
2 files changed, 9 insertions(+), 2 deletions(-) 2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c
index 009d927739b8..240ae858fa96 100644 index fa4c3fa1e496..b9b4127a6c9f 100644
--- a/drivers/misc/ntsync.c --- a/drivers/misc/ntsync.c
+++ b/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c
@@ -447,7 +447,7 @@ static int ntsync_mutex_kill(struct ntsync_obj *mutex, void __user *argp) @@ -469,7 +469,7 @@ static int ntsync_mutex_kill(struct ntsync_obj *mutex, void __user *argp)
return ret; return ret;
} }
@ -33,7 +24,7 @@ index 009d927739b8..240ae858fa96 100644
{ {
struct ntsync_device *dev = event->dev; struct ntsync_device *dev = event->dev;
__u32 prev_state; __u32 prev_state;
@@ -463,6 +463,8 @@ static int ntsync_event_set(struct ntsync_obj *event, void __user *argp) @@ -485,6 +485,8 @@ static int ntsync_event_set(struct ntsync_obj *event, void __user *argp)
event->u.event.signaled = true; event->u.event.signaled = true;
try_wake_all_obj(dev, event); try_wake_all_obj(dev, event);
try_wake_any_event(event); try_wake_any_event(event);
@ -42,7 +33,7 @@ index 009d927739b8..240ae858fa96 100644
spin_unlock(&event->lock); spin_unlock(&event->lock);
spin_unlock(&dev->wait_all_lock); spin_unlock(&dev->wait_all_lock);
@@ -472,6 +474,8 @@ static int ntsync_event_set(struct ntsync_obj *event, void __user *argp) @@ -494,6 +496,8 @@ static int ntsync_event_set(struct ntsync_obj *event, void __user *argp)
prev_state = event->u.event.signaled; prev_state = event->u.event.signaled;
event->u.event.signaled = true; event->u.event.signaled = true;
try_wake_any_event(event); try_wake_any_event(event);
@ -51,7 +42,7 @@ index 009d927739b8..240ae858fa96 100644
spin_unlock(&event->lock); spin_unlock(&event->lock);
} }
@@ -526,9 +530,11 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd, @@ -548,9 +552,11 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd,
case NTSYNC_IOC_MUTEX_KILL: case NTSYNC_IOC_MUTEX_KILL:
return ntsync_mutex_kill(obj, argp); return ntsync_mutex_kill(obj, argp);
case NTSYNC_IOC_EVENT_SET: case NTSYNC_IOC_EVENT_SET:
@ -65,7 +56,7 @@ index 009d927739b8..240ae858fa96 100644
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
} }
diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h
index f2d7507d8438..598f894f868d 100644 index 6963356ee3f7..72047f36c45d 100644
--- a/include/uapi/linux/ntsync.h --- a/include/uapi/linux/ntsync.h
+++ b/include/uapi/linux/ntsync.h +++ b/include/uapi/linux/ntsync.h
@@ -50,5 +50,6 @@ struct ntsync_wait_args { @@ -50,5 +50,6 @@ struct ntsync_wait_args {
@ -77,4 +68,3 @@ index f2d7507d8438..598f894f868d 100644
#endif #endif
-- --
2.43.0 2.43.0

View File

@ -1,12 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 13/29] ntsync: Introduce NTSYNC_IOC_SEM_READ.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:40 -0600
Message-Id: <20240131021356.10322-14-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
This corresponds to the NT syscall NtQuerySemaphore(). This corresponds to the NT syscall NtQuerySemaphore().
This returns the current count and maximum count of the semaphore. This returns the current count and maximum count of the semaphore.
@ -18,10 +9,10 @@ Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
2 files changed, 22 insertions(+) 2 files changed, 22 insertions(+)
diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c
index 240ae858fa96..6dccfbfb2512 100644 index b9b4127a6c9f..0daaeeeba051 100644
--- a/drivers/misc/ntsync.c --- a/drivers/misc/ntsync.c
+++ b/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c
@@ -506,6 +506,25 @@ static int ntsync_event_reset(struct ntsync_obj *event, void __user *argp) @@ -528,6 +528,25 @@ static int ntsync_event_reset(struct ntsync_obj *event, void __user *argp)
return 0; return 0;
} }
@ -47,7 +38,7 @@ index 240ae858fa96..6dccfbfb2512 100644
static int ntsync_obj_release(struct inode *inode, struct file *file) static int ntsync_obj_release(struct inode *inode, struct file *file)
{ {
struct ntsync_obj *obj = file->private_data; struct ntsync_obj *obj = file->private_data;
@@ -525,6 +544,8 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd, @@ -547,6 +566,8 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd,
switch (cmd) { switch (cmd) {
case NTSYNC_IOC_SEM_POST: case NTSYNC_IOC_SEM_POST:
return ntsync_sem_post(obj, argp); return ntsync_sem_post(obj, argp);
@ -57,7 +48,7 @@ index 240ae858fa96..6dccfbfb2512 100644
return ntsync_mutex_unlock(obj, argp); return ntsync_mutex_unlock(obj, argp);
case NTSYNC_IOC_MUTEX_KILL: case NTSYNC_IOC_MUTEX_KILL:
diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h
index 598f894f868d..6017f621687e 100644 index 72047f36c45d..42f51dc4e57e 100644
--- a/include/uapi/linux/ntsync.h --- a/include/uapi/linux/ntsync.h
+++ b/include/uapi/linux/ntsync.h +++ b/include/uapi/linux/ntsync.h
@@ -51,5 +51,6 @@ struct ntsync_wait_args { @@ -51,5 +51,6 @@ struct ntsync_wait_args {
@ -69,4 +60,3 @@ index 598f894f868d..6017f621687e 100644
#endif #endif
-- --
2.43.0 2.43.0

View File

@ -1,12 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 14/29] ntsync: Introduce NTSYNC_IOC_MUTEX_READ.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:41 -0600
Message-Id: <20240131021356.10322-15-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
This corresponds to the NT syscall NtQueryMutant(). This corresponds to the NT syscall NtQueryMutant().
This returns the recursion count, owner, and abandoned state of the mutex. This returns the recursion count, owner, and abandoned state of the mutex.
@ -18,10 +9,10 @@ Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
2 files changed, 24 insertions(+) 2 files changed, 24 insertions(+)
diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c
index 6dccfbfb2512..7f5f96ec7c69 100644 index 0daaeeeba051..b07510035c1f 100644
--- a/drivers/misc/ntsync.c --- a/drivers/misc/ntsync.c
+++ b/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c
@@ -525,6 +525,27 @@ static int ntsync_sem_read(struct ntsync_obj *sem, void __user *argp) @@ -547,6 +547,27 @@ static int ntsync_sem_read(struct ntsync_obj *sem, void __user *argp)
return 0; return 0;
} }
@ -49,7 +40,7 @@ index 6dccfbfb2512..7f5f96ec7c69 100644
static int ntsync_obj_release(struct inode *inode, struct file *file) static int ntsync_obj_release(struct inode *inode, struct file *file)
{ {
struct ntsync_obj *obj = file->private_data; struct ntsync_obj *obj = file->private_data;
@@ -550,6 +571,8 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd, @@ -572,6 +593,8 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd,
return ntsync_mutex_unlock(obj, argp); return ntsync_mutex_unlock(obj, argp);
case NTSYNC_IOC_MUTEX_KILL: case NTSYNC_IOC_MUTEX_KILL:
return ntsync_mutex_kill(obj, argp); return ntsync_mutex_kill(obj, argp);
@ -59,7 +50,7 @@ index 6dccfbfb2512..7f5f96ec7c69 100644
return ntsync_event_set(obj, argp, false); return ntsync_event_set(obj, argp, false);
case NTSYNC_IOC_EVENT_RESET: case NTSYNC_IOC_EVENT_RESET:
diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h
index 6017f621687e..a1d0ef581212 100644 index 42f51dc4e57e..25f3296cfabf 100644
--- a/include/uapi/linux/ntsync.h --- a/include/uapi/linux/ntsync.h
+++ b/include/uapi/linux/ntsync.h +++ b/include/uapi/linux/ntsync.h
@@ -52,5 +52,6 @@ struct ntsync_wait_args { @@ -52,5 +52,6 @@ struct ntsync_wait_args {
@ -71,4 +62,3 @@ index 6017f621687e..a1d0ef581212 100644
#endif #endif
-- --
2.43.0 2.43.0

View File

@ -1,12 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 15/29] ntsync: Introduce NTSYNC_IOC_EVENT_READ.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:42 -0600
Message-Id: <20240131021356.10322-16-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
This corresponds to the NT syscall NtQueryEvent(). This corresponds to the NT syscall NtQueryEvent().
This returns the signaled state of the event and whether it is manual-reset. This returns the signaled state of the event and whether it is manual-reset.
@ -18,10 +9,10 @@ Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
2 files changed, 22 insertions(+) 2 files changed, 22 insertions(+)
diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c
index 7f5f96ec7c69..5439c1c9e90f 100644 index b07510035c1f..981a1545192c 100644
--- a/drivers/misc/ntsync.c --- a/drivers/misc/ntsync.c
+++ b/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c
@@ -546,6 +546,25 @@ static int ntsync_mutex_read(struct ntsync_obj *mutex, void __user *argp) @@ -568,6 +568,25 @@ static int ntsync_mutex_read(struct ntsync_obj *mutex, void __user *argp)
return ret; return ret;
} }
@ -47,7 +38,7 @@ index 7f5f96ec7c69..5439c1c9e90f 100644
static int ntsync_obj_release(struct inode *inode, struct file *file) static int ntsync_obj_release(struct inode *inode, struct file *file)
{ {
struct ntsync_obj *obj = file->private_data; struct ntsync_obj *obj = file->private_data;
@@ -579,6 +598,8 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd, @@ -601,6 +620,8 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd,
return ntsync_event_reset(obj, argp); return ntsync_event_reset(obj, argp);
case NTSYNC_IOC_EVENT_PULSE: case NTSYNC_IOC_EVENT_PULSE:
return ntsync_event_set(obj, argp, true); return ntsync_event_set(obj, argp, true);
@ -57,7 +48,7 @@ index 7f5f96ec7c69..5439c1c9e90f 100644
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
} }
diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h
index a1d0ef581212..582d33b0dcac 100644 index 25f3296cfabf..03c95e5a398f 100644
--- a/include/uapi/linux/ntsync.h --- a/include/uapi/linux/ntsync.h
+++ b/include/uapi/linux/ntsync.h +++ b/include/uapi/linux/ntsync.h
@@ -53,5 +53,6 @@ struct ntsync_wait_args { @@ -53,5 +53,6 @@ struct ntsync_wait_args {
@ -69,4 +60,3 @@ index a1d0ef581212..582d33b0dcac 100644
#endif #endif
-- --
2.43.0 2.43.0

View File

@ -1,12 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 16/29] ntsync: Introduce alertable waits.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:43 -0600
Message-Id: <20240131021356.10322-17-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
NT waits can optionally be made "alertable". This is a special channel for NT waits can optionally be made "alertable". This is a special channel for
thread wakeup that is mildly similar to SIGIO. A thread has an internal single thread wakeup that is mildly similar to SIGIO. A thread has an internal single
bit of "alerted" state, and if a thread is made alerted while an alertable wait, bit of "alerted" state, and if a thread is made alerted while an alertable wait,
@ -24,10 +15,10 @@ Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
2 files changed, 60 insertions(+), 10 deletions(-) 2 files changed, 60 insertions(+), 10 deletions(-)
diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c
index 5439c1c9e90f..1e619e1ce6a6 100644 index 981a1545192c..0055b4671808 100644
--- a/drivers/misc/ntsync.c --- a/drivers/misc/ntsync.c
+++ b/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c
@@ -784,22 +784,29 @@ static int setup_wait(struct ntsync_device *dev, @@ -808,22 +808,29 @@ static int setup_wait(struct ntsync_device *dev,
const struct ntsync_wait_args *args, bool all, const struct ntsync_wait_args *args, bool all,
struct ntsync_q **ret_q) struct ntsync_q **ret_q)
{ {
@ -60,7 +51,7 @@ index 5439c1c9e90f..1e619e1ce6a6 100644
if (!q) if (!q)
return -ENOMEM; return -ENOMEM;
q->task = current; q->task = current;
@@ -809,7 +816,7 @@ static int setup_wait(struct ntsync_device *dev, @@ -833,7 +840,7 @@ static int setup_wait(struct ntsync_device *dev,
q->ownerdead = false; q->ownerdead = false;
q->count = count; q->count = count;
@ -69,18 +60,18 @@ index 5439c1c9e90f..1e619e1ce6a6 100644
struct ntsync_q_entry *entry = &q->entries[i]; struct ntsync_q_entry *entry = &q->entries[i];
struct ntsync_obj *obj = get_obj(dev, fds[i]); struct ntsync_obj *obj = get_obj(dev, fds[i]);
@@ -860,9 +867,9 @@ static int ntsync_wait_any(struct ntsync_device *dev, void __user *argp) @@ -883,9 +890,9 @@ static void try_wake_any_obj(struct ntsync_obj *obj)
static int ntsync_wait_any(struct ntsync_device *dev, void __user *argp)
{ {
struct ntsync_wait_args args; struct ntsync_wait_args args;
struct ntsync_q *q;
+ __u32 i, total_count; + __u32 i, total_count;
ktime_t timeout; struct ntsync_q *q;
int signaled; int signaled;
- __u32 i; - __u32 i;
int ret; int ret;
if (copy_from_user(&args, argp, sizeof(args))) if (copy_from_user(&args, argp, sizeof(args)))
@@ -872,9 +879,13 @@ static int ntsync_wait_any(struct ntsync_device *dev, void __user *argp) @@ -895,9 +902,13 @@ static int ntsync_wait_any(struct ntsync_device *dev, void __user *argp)
if (ret < 0) if (ret < 0)
return ret; return ret;
@ -95,7 +86,7 @@ index 5439c1c9e90f..1e619e1ce6a6 100644
struct ntsync_q_entry *entry = &q->entries[i]; struct ntsync_q_entry *entry = &q->entries[i];
struct ntsync_obj *obj = entry->obj; struct ntsync_obj *obj = entry->obj;
@@ -883,9 +894,15 @@ static int ntsync_wait_any(struct ntsync_device *dev, void __user *argp) @@ -906,9 +917,15 @@ static int ntsync_wait_any(struct ntsync_device *dev, void __user *argp)
spin_unlock(&obj->lock); spin_unlock(&obj->lock);
} }
@ -113,7 +104,7 @@ index 5439c1c9e90f..1e619e1ce6a6 100644
struct ntsync_obj *obj = q->entries[i].obj; struct ntsync_obj *obj = q->entries[i].obj;
if (atomic_read(&q->signaled) != -1) if (atomic_read(&q->signaled) != -1)
@@ -903,7 +920,7 @@ static int ntsync_wait_any(struct ntsync_device *dev, void __user *argp) @@ -925,7 +942,7 @@ static int ntsync_wait_any(struct ntsync_device *dev, void __user *argp)
/* and finally, unqueue */ /* and finally, unqueue */
@ -122,7 +113,7 @@ index 5439c1c9e90f..1e619e1ce6a6 100644
struct ntsync_q_entry *entry = &q->entries[i]; struct ntsync_q_entry *entry = &q->entries[i];
struct ntsync_obj *obj = entry->obj; struct ntsync_obj *obj = entry->obj;
@@ -964,6 +981,14 @@ static int ntsync_wait_all(struct ntsync_device *dev, void __user *argp) @@ -985,6 +1002,14 @@ static int ntsync_wait_all(struct ntsync_device *dev, void __user *argp)
*/ */
list_add_tail(&entry->node, &obj->all_waiters); list_add_tail(&entry->node, &obj->all_waiters);
} }
@ -137,7 +128,7 @@ index 5439c1c9e90f..1e619e1ce6a6 100644
/* check if we are already signaled */ /* check if we are already signaled */
@@ -971,6 +996,21 @@ static int ntsync_wait_all(struct ntsync_device *dev, void __user *argp) @@ -992,6 +1017,21 @@ static int ntsync_wait_all(struct ntsync_device *dev, void __user *argp)
spin_unlock(&dev->wait_all_lock); spin_unlock(&dev->wait_all_lock);
@ -158,8 +149,8 @@ index 5439c1c9e90f..1e619e1ce6a6 100644
+ +
/* sleep */ /* sleep */
timeout = ns_to_ktime(args.timeout); ret = ntsync_schedule(q, &args);
@@ -994,6 +1034,16 @@ static int ntsync_wait_all(struct ntsync_device *dev, void __user *argp) @@ -1014,6 +1054,16 @@ static int ntsync_wait_all(struct ntsync_device *dev, void __user *argp)
put_obj(obj); put_obj(obj);
} }
@ -177,7 +168,7 @@ index 5439c1c9e90f..1e619e1ce6a6 100644
spin_unlock(&dev->wait_all_lock); spin_unlock(&dev->wait_all_lock);
diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h
index 582d33b0dcac..7c91af7011e4 100644 index 03c95e5a398f..555ae81b479a 100644
--- a/include/uapi/linux/ntsync.h --- a/include/uapi/linux/ntsync.h
+++ b/include/uapi/linux/ntsync.h +++ b/include/uapi/linux/ntsync.h
@@ -34,7 +34,7 @@ struct ntsync_wait_args { @@ -34,7 +34,7 @@ struct ntsync_wait_args {
@ -191,4 +182,3 @@ index 582d33b0dcac..7c91af7011e4 100644
#define NTSYNC_MAX_WAIT_COUNT 64 #define NTSYNC_MAX_WAIT_COUNT 64
-- --
2.43.0 2.43.0

View File

@ -0,0 +1,79 @@
NtWaitForMultipleObjects() can receive a timeout in two forms, relative or
absolute. Relative timeouts are unaffected by changes to the system time and do
not count down while the system suspends; for absolute timeouts the opposite is
true.
In order to make the interface and implementation simpler, the ntsync driver
only deals in absolute timeouts. However, we need to be able to emulate both
behaviours apropos suspension and time adjustment, which is achieved by allowing
either the MONOTONIC or REALTIME clock to be used.
Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
---
drivers/misc/ntsync.c | 9 ++++++++-
include/uapi/linux/ntsync.h | 4 ++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c
index 0055b4671808..f54c81dada3d 100644
--- a/drivers/misc/ntsync.c
+++ b/drivers/misc/ntsync.c
@@ -778,11 +778,15 @@ static void put_obj(struct ntsync_obj *obj)
static int ntsync_schedule(const struct ntsync_q *q, const struct ntsync_wait_args *args)
{
ktime_t timeout = ns_to_ktime(args->timeout);
+ clockid_t clock = CLOCK_MONOTONIC;
ktime_t *timeout_ptr;
int ret = 0;
timeout_ptr = (args->timeout == U64_MAX ? NULL : &timeout);
+ if (args->flags & NTSYNC_WAIT_REALTIME)
+ clock = CLOCK_REALTIME;
+
do {
if (signal_pending(current)) {
ret = -ERESTARTSYS;
@@ -794,7 +798,7 @@ static int ntsync_schedule(const struct ntsync_q *q, const struct ntsync_wait_ar
ret = 0;
break;
}
- ret = schedule_hrtimeout(timeout_ptr, HRTIMER_MODE_ABS);
+ ret = schedule_hrtimeout_range_clock(timeout_ptr, 0, HRTIMER_MODE_ABS, clock);
} while (ret < 0);
__set_current_state(TASK_RUNNING);
@@ -817,6 +821,9 @@ static int setup_wait(struct ntsync_device *dev,
if (!args->owner)
return -EINVAL;
+ if (args->pad || (args->flags & ~NTSYNC_WAIT_REALTIME))
+ return -EINVAL;
+
if (args->count > NTSYNC_MAX_WAIT_COUNT)
return -EINVAL;
diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h
index 555ae81b479a..b5e835d8dba8 100644
--- a/include/uapi/linux/ntsync.h
+++ b/include/uapi/linux/ntsync.h
@@ -28,6 +28,8 @@ struct ntsync_event_args {
__u32 signaled;
};
+#define NTSYNC_WAIT_REALTIME 0x1
+
struct ntsync_wait_args {
__u64 timeout;
__u64 objs;
@@ -35,6 +37,8 @@ struct ntsync_wait_args {
__u32 owner;
__u32 index;
__u32 alert;
+ __u32 flags;
+ __u32 pad;
};
#define NTSYNC_MAX_WAIT_COUNT 64
--
2.43.0

View File

@ -1,13 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 17/29] selftests: ntsync: Add some tests for
semaphore state.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:44 -0600
Message-Id: <20240131021356.10322-18-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Wine has tests for its synchronization primitives, but these are more accessible Wine has tests for its synchronization primitives, but these are more accessible
to kernel developers, and also allow us to test some edge cases that Wine does to kernel developers, and also allow us to test some edge cases that Wine does
not care about. not care about.
@ -20,8 +10,8 @@ Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
tools/testing/selftests/Makefile | 1 + tools/testing/selftests/Makefile | 1 +
.../testing/selftests/drivers/ntsync/Makefile | 8 + .../testing/selftests/drivers/ntsync/Makefile | 8 +
tools/testing/selftests/drivers/ntsync/config | 1 + tools/testing/selftests/drivers/ntsync/config | 1 +
.../testing/selftests/drivers/ntsync/ntsync.c | 143 ++++++++++++++++++ .../testing/selftests/drivers/ntsync/ntsync.c | 149 ++++++++++++++++++
4 files changed, 153 insertions(+) 4 files changed, 159 insertions(+)
create mode 100644 tools/testing/selftests/drivers/ntsync/Makefile create mode 100644 tools/testing/selftests/drivers/ntsync/Makefile
create mode 100644 tools/testing/selftests/drivers/ntsync/config create mode 100644 tools/testing/selftests/drivers/ntsync/config
create mode 100644 tools/testing/selftests/drivers/ntsync/ntsync.c create mode 100644 tools/testing/selftests/drivers/ntsync/ntsync.c
@ -61,15 +51,15 @@ index 000000000000..60539c826d06
+CONFIG_WINESYNC=y +CONFIG_WINESYNC=y
diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c
new file mode 100644 new file mode 100644
index 000000000000..6ceb48fb42e3 index 000000000000..1e145c6dfded
--- /dev/null --- /dev/null
+++ b/tools/testing/selftests/drivers/ntsync/ntsync.c +++ b/tools/testing/selftests/drivers/ntsync/ntsync.c
@@ -0,0 +1,143 @@ @@ -0,0 +1,149 @@
+// SPDX-License-Identifier: GPL-2.0-or-later +// SPDX-License-Identifier: GPL-2.0-or-later
+/* +/*
+ * Various unit tests for the "ntsync" synchronization primitive driver. + * Various unit tests for the "ntsync" synchronization primitive driver.
+ * + *
+ * Copyright (C) 2021-2022 Elizabeth Figura + * Copyright (C) 2021-2022 Elizabeth Figura <zfigura@codeweavers.com>
+ */ + */
+ +
+#define _GNU_SOURCE +#define _GNU_SOURCE
@ -202,6 +192,12 @@ index 000000000000..6ceb48fb42e3
+ EXPECT_EQ(0, count); + EXPECT_EQ(0, count);
+ check_sem_state(sem, 1, 2); + check_sem_state(sem, 1, 2);
+ +
+ count = ~0u;
+ ret = post_sem(sem, &count);
+ EXPECT_EQ(-1, ret);
+ EXPECT_EQ(EOVERFLOW, errno);
+ check_sem_state(sem, 1, 2);
+
+ close(sem); + close(sem);
+ +
+ close(fd); + close(fd);
@ -210,4 +206,3 @@ index 000000000000..6ceb48fb42e3
+TEST_HARNESS_MAIN +TEST_HARNESS_MAIN
-- --
2.43.0 2.43.0

View File

@ -1,23 +1,13 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 18/29] selftests: ntsync: Add some tests for mutex
state.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:45 -0600
Message-Id: <20240131021356.10322-19-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Test mutex-specific ioctls NTSYNC_IOC_MUTEX_UNLOCK and NTSYNC_IOC_MUTEX_READ, Test mutex-specific ioctls NTSYNC_IOC_MUTEX_UNLOCK and NTSYNC_IOC_MUTEX_READ,
and waiting on mutexes. and waiting on mutexes.
Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com> Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
--- ---
.../testing/selftests/drivers/ntsync/ntsync.c | 181 ++++++++++++++++++ .../testing/selftests/drivers/ntsync/ntsync.c | 196 ++++++++++++++++++
1 file changed, 181 insertions(+) 1 file changed, 196 insertions(+)
diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c
index 6ceb48fb42e3..80c8bd409d68 100644 index 1e145c6dfded..7cd0f40594fd 100644
--- a/tools/testing/selftests/drivers/ntsync/ntsync.c --- a/tools/testing/selftests/drivers/ntsync/ntsync.c
+++ b/tools/testing/selftests/drivers/ntsync/ntsync.c +++ b/tools/testing/selftests/drivers/ntsync/ntsync.c
@@ -40,6 +40,39 @@ static int post_sem(int sem, __u32 *count) @@ -40,6 +40,39 @@ static int post_sem(int sem, __u32 *count)
@ -60,7 +50,7 @@ index 6ceb48fb42e3..80c8bd409d68 100644
static int wait_any(int fd, __u32 count, const int *objs, __u32 owner, __u32 *index) static int wait_any(int fd, __u32 count, const int *objs, __u32 owner, __u32 *index)
{ {
struct ntsync_wait_args args = {0}; struct ntsync_wait_args args = {0};
@@ -140,4 +173,152 @@ TEST(semaphore_state) @@ -146,4 +179,167 @@ TEST(semaphore_state)
close(fd); close(fd);
} }
@ -209,10 +199,24 @@ index 6ceb48fb42e3..80c8bd409d68 100644
+ +
+ close(mutex); + close(mutex);
+ +
+ mutex_args.owner = 123;
+ mutex_args.count = ~0u;
+ mutex_args.mutex = 0xdeadbeef;
+ ret = ioctl(fd, NTSYNC_IOC_CREATE_MUTEX, &mutex_args);
+ EXPECT_EQ(0, ret);
+ EXPECT_NE(0xdeadbeef, mutex_args.mutex);
+ mutex = mutex_args.mutex;
+ check_mutex_state(mutex, ~0u, 123);
+
+ ret = wait_any(fd, 1, &mutex, 123, &index);
+ EXPECT_EQ(-1, ret);
+ EXPECT_EQ(ETIMEDOUT, errno);
+
+ close(mutex);
+
+ close(fd); + close(fd);
+} +}
+ +
TEST_HARNESS_MAIN TEST_HARNESS_MAIN
-- --
2.43.0 2.43.0

View File

@ -1,38 +1,27 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 19/29] selftests: ntsync: Add some tests for
NTSYNC_IOC_WAIT_ANY.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:46 -0600
Message-Id: <20240131021356.10322-20-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Test basic synchronous functionality of NTSYNC_IOC_WAIT_ANY, when objects are Test basic synchronous functionality of NTSYNC_IOC_WAIT_ANY, when objects are
considered signaled or not signaled, and how they are affected by a successful considered signaled or not signaled, and how they are affected by a successful
wait. wait.
Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com> Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
--- ---
.../testing/selftests/drivers/ntsync/ntsync.c | 105 ++++++++++++++++++ .../testing/selftests/drivers/ntsync/ntsync.c | 119 ++++++++++++++++++
1 file changed, 105 insertions(+) 1 file changed, 119 insertions(+)
diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c
index 80c8bd409d68..13e7c9d7441e 100644 index 7cd0f40594fd..40ad8cbd3138 100644
--- a/tools/testing/selftests/drivers/ntsync/ntsync.c --- a/tools/testing/selftests/drivers/ntsync/ntsync.c
+++ b/tools/testing/selftests/drivers/ntsync/ntsync.c +++ b/tools/testing/selftests/drivers/ntsync/ntsync.c
@@ -321,4 +321,109 @@ TEST(mutex_state) @@ -342,4 +342,123 @@ TEST(mutex_state)
close(fd); close(fd);
} }
+TEST(test_wait_any) +TEST(test_wait_any)
+{ +{
+ int objs[NTSYNC_MAX_WAIT_COUNT + 1], fd, ret;
+ struct ntsync_mutex_args mutex_args = {0}; + struct ntsync_mutex_args mutex_args = {0};
+ struct ntsync_wait_args wait_args = {0};
+ struct ntsync_sem_args sem_args = {0}; + struct ntsync_sem_args sem_args = {0};
+ __u32 owner, index, count; + __u32 owner, index, count, i;
+ struct timespec timeout; + struct timespec timeout;
+ int objs[2], fd, ret;
+ +
+ clock_gettime(CLOCK_MONOTONIC, &timeout); + clock_gettime(CLOCK_MONOTONIC, &timeout);
+ +
@ -117,13 +106,28 @@ index 80c8bd409d68..13e7c9d7441e 100644
+ objs[0] = objs[1] = sem_args.sem; + objs[0] = objs[1] = sem_args.sem;
+ ret = wait_any(fd, 2, objs, 456, &index); + ret = wait_any(fd, 2, objs, 456, &index);
+ EXPECT_EQ(0, ret); + EXPECT_EQ(0, ret);
+ EXPECT_EQ(0, wait_args.index); + EXPECT_EQ(0, index);
+ check_sem_state(sem_args.sem, 1, 3); + check_sem_state(sem_args.sem, 1, 3);
+ +
+ ret = wait_any(fd, 0, NULL, 456, &index); + ret = wait_any(fd, 0, NULL, 456, &index);
+ EXPECT_EQ(-1, ret); + EXPECT_EQ(-1, ret);
+ EXPECT_EQ(ETIMEDOUT, errno); + EXPECT_EQ(ETIMEDOUT, errno);
+ +
+ for (i = 0; i < NTSYNC_MAX_WAIT_COUNT + 1; ++i)
+ objs[i] = sem_args.sem;
+
+ ret = wait_any(fd, NTSYNC_MAX_WAIT_COUNT, objs, 123, &index);
+ EXPECT_EQ(0, ret);
+ EXPECT_EQ(0, index);
+
+ ret = wait_any(fd, NTSYNC_MAX_WAIT_COUNT + 1, objs, 123, &index);
+ EXPECT_EQ(-1, ret);
+ EXPECT_EQ(EINVAL, errno);
+
+ ret = wait_any(fd, -1, objs, 123, &index);
+ EXPECT_EQ(-1, ret);
+ EXPECT_EQ(EINVAL, errno);
+
+ close(sem_args.sem); + close(sem_args.sem);
+ close(mutex_args.mutex); + close(mutex_args.mutex);
+ +
@ -133,4 +137,3 @@ index 80c8bd409d68..13e7c9d7441e 100644
TEST_HARNESS_MAIN TEST_HARNESS_MAIN
-- --
2.43.0 2.43.0

View File

@ -1,13 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 20/29] selftests: ntsync: Add some tests for
NTSYNC_IOC_WAIT_ALL.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:47 -0600
Message-Id: <20240131021356.10322-21-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Test basic synchronous functionality of NTSYNC_IOC_WAIT_ALL, and when objects Test basic synchronous functionality of NTSYNC_IOC_WAIT_ALL, and when objects
are considered simultaneously signaled. are considered simultaneously signaled.
@ -17,7 +7,7 @@ Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
1 file changed, 97 insertions(+), 2 deletions(-) 1 file changed, 97 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c
index 13e7c9d7441e..77f1b7e42d76 100644 index 40ad8cbd3138..c0f372167557 100644
--- a/tools/testing/selftests/drivers/ntsync/ntsync.c --- a/tools/testing/selftests/drivers/ntsync/ntsync.c
+++ b/tools/testing/selftests/drivers/ntsync/ntsync.c +++ b/tools/testing/selftests/drivers/ntsync/ntsync.c
@@ -73,7 +73,8 @@ static int unlock_mutex(int mutex, __u32 owner, __u32 *count) @@ -73,7 +73,8 @@ static int unlock_mutex(int mutex, __u32 owner, __u32 *count)
@ -53,7 +43,7 @@ index 13e7c9d7441e..77f1b7e42d76 100644
TEST(semaphore_state) TEST(semaphore_state)
{ {
struct ntsync_sem_args sem_args; struct ntsync_sem_args sem_args;
@@ -426,4 +437,88 @@ TEST(test_wait_any) @@ -461,4 +472,88 @@ TEST(test_wait_any)
close(fd); close(fd);
} }
@ -144,4 +134,3 @@ index 13e7c9d7441e..77f1b7e42d76 100644
TEST_HARNESS_MAIN TEST_HARNESS_MAIN
-- --
2.43.0 2.43.0

View File

@ -1,37 +1,25 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 21/29] selftests: ntsync: Add some tests for wakeup
signaling with WINESYNC_IOC_WAIT_ANY.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:48 -0600
Message-Id: <20240131021356.10322-22-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Test contended "wait-for-any" waits, to make sure that scheduling and wakeup Test contended "wait-for-any" waits, to make sure that scheduling and wakeup
logic works correctly. logic works correctly.
Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com> Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
--- ---
.../testing/selftests/drivers/ntsync/ntsync.c | 152 ++++++++++++++++++ .../testing/selftests/drivers/ntsync/ntsync.c | 150 ++++++++++++++++++
1 file changed, 152 insertions(+) 1 file changed, 150 insertions(+)
diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c
index 77f1b7e42d76..96a866ef235f 100644 index c0f372167557..993f5db23768 100644
--- a/tools/testing/selftests/drivers/ntsync/ntsync.c --- a/tools/testing/selftests/drivers/ntsync/ntsync.c
+++ b/tools/testing/selftests/drivers/ntsync/ntsync.c +++ b/tools/testing/selftests/drivers/ntsync/ntsync.c
@@ -521,4 +521,156 @@ TEST(test_wait_all) @@ -556,4 +556,154 @@ TEST(test_wait_all)
close(fd); close(fd);
} }
+struct wake_args +struct wake_args {
+{
+ int fd; + int fd;
+ int obj; + int obj;
+}; +};
+ +
+struct wait_args +struct wait_args {
+{
+ int fd; + int fd;
+ unsigned long request; + unsigned long request;
+ struct ntsync_wait_args *args; + struct ntsync_wait_args *args;
@ -179,4 +167,3 @@ index 77f1b7e42d76..96a866ef235f 100644
TEST_HARNESS_MAIN TEST_HARNESS_MAIN
-- --
2.43.0 2.43.0

View File

@ -1,13 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 22/29] selftests: ntsync: Add some tests for wakeup
signaling with WINESYNC_IOC_WAIT_ALL.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:49 -0600
Message-Id: <20240131021356.10322-23-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Test contended "wait-for-all" waits, to make sure that scheduling and wakeup Test contended "wait-for-all" waits, to make sure that scheduling and wakeup
logic works correctly, and that the wait only exits once objects are all logic works correctly, and that the wait only exits once objects are all
simultaneously signaled. simultaneously signaled.
@ -18,10 +8,10 @@ Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
1 file changed, 98 insertions(+) 1 file changed, 98 insertions(+)
diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c
index 96a866ef235f..7776fe71b8ef 100644 index 993f5db23768..b77fb0b2c4b1 100644
--- a/tools/testing/selftests/drivers/ntsync/ntsync.c --- a/tools/testing/selftests/drivers/ntsync/ntsync.c
+++ b/tools/testing/selftests/drivers/ntsync/ntsync.c +++ b/tools/testing/selftests/drivers/ntsync/ntsync.c
@@ -673,4 +673,102 @@ TEST(wake_any) @@ -706,4 +706,102 @@ TEST(wake_any)
close(fd); close(fd);
} }
@ -126,4 +116,3 @@ index 96a866ef235f..7776fe71b8ef 100644
TEST_HARNESS_MAIN TEST_HARNESS_MAIN
-- --
2.43.0 2.43.0

View File

@ -1,13 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 23/29] selftests: ntsync: Add some tests for
manual-reset event state.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:50 -0600
Message-Id: <20240131021356.10322-24-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Test event-specific ioctls NTSYNC_IOC_EVENT_SET, NTSYNC_IOC_EVENT_RESET, Test event-specific ioctls NTSYNC_IOC_EVENT_SET, NTSYNC_IOC_EVENT_RESET,
NTSYNC_IOC_EVENT_PULSE, NTSYNC_IOC_EVENT_READ for manual-reset events, and NTSYNC_IOC_EVENT_PULSE, NTSYNC_IOC_EVENT_READ for manual-reset events, and
waiting on manual-reset events. waiting on manual-reset events.
@ -18,7 +8,7 @@ Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
1 file changed, 89 insertions(+) 1 file changed, 89 insertions(+)
diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c
index 7776fe71b8ef..98fc70a9a58b 100644 index b77fb0b2c4b1..b6481c2b85cc 100644
--- a/tools/testing/selftests/drivers/ntsync/ntsync.c --- a/tools/testing/selftests/drivers/ntsync/ntsync.c
+++ b/tools/testing/selftests/drivers/ntsync/ntsync.c +++ b/tools/testing/selftests/drivers/ntsync/ntsync.c
@@ -73,6 +73,27 @@ static int unlock_mutex(int mutex, __u32 owner, __u32 *count) @@ -73,6 +73,27 @@ static int unlock_mutex(int mutex, __u32 owner, __u32 *count)
@ -49,7 +39,7 @@ index 7776fe71b8ef..98fc70a9a58b 100644
static int wait_objs(int fd, unsigned long request, __u32 count, static int wait_objs(int fd, unsigned long request, __u32 count,
const int *objs, __u32 owner, __u32 *index) const int *objs, __u32 owner, __u32 *index)
{ {
@@ -332,6 +353,74 @@ TEST(mutex_state) @@ -353,6 +374,74 @@ TEST(mutex_state)
close(fd); close(fd);
} }
@ -123,7 +113,6 @@ index 7776fe71b8ef..98fc70a9a58b 100644
+ +
TEST(test_wait_any) TEST(test_wait_any)
{ {
struct ntsync_mutex_args mutex_args = {0}; int objs[NTSYNC_MAX_WAIT_COUNT + 1], fd, ret;
-- --
2.43.0 2.43.0

View File

@ -1,13 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 24/29] selftests: ntsync: Add some tests for
auto-reset event state.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:51 -0600
Message-Id: <20240131021356.10322-25-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Test event-specific ioctls NTSYNC_IOC_EVENT_SET, NTSYNC_IOC_EVENT_RESET, Test event-specific ioctls NTSYNC_IOC_EVENT_SET, NTSYNC_IOC_EVENT_RESET,
NTSYNC_IOC_EVENT_PULSE, NTSYNC_IOC_EVENT_READ for auto-reset events, and NTSYNC_IOC_EVENT_PULSE, NTSYNC_IOC_EVENT_READ for auto-reset events, and
waiting on auto-reset events. waiting on auto-reset events.
@ -18,10 +8,10 @@ Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
1 file changed, 59 insertions(+) 1 file changed, 59 insertions(+)
diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c
index 98fc70a9a58b..f1fb28949367 100644 index b6481c2b85cc..12ccb4ec28e4 100644
--- a/tools/testing/selftests/drivers/ntsync/ntsync.c --- a/tools/testing/selftests/drivers/ntsync/ntsync.c
+++ b/tools/testing/selftests/drivers/ntsync/ntsync.c +++ b/tools/testing/selftests/drivers/ntsync/ntsync.c
@@ -421,6 +421,65 @@ TEST(manual_event_state) @@ -442,6 +442,65 @@ TEST(manual_event_state)
close(fd); close(fd);
} }
@ -86,7 +76,6 @@ index 98fc70a9a58b..f1fb28949367 100644
+ +
TEST(test_wait_any) TEST(test_wait_any)
{ {
struct ntsync_mutex_args mutex_args = {0}; int objs[NTSYNC_MAX_WAIT_COUNT + 1], fd, ret;
-- --
2.43.0 2.43.0

View File

@ -1,13 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 25/29] selftests: ntsync: Add some tests for wakeup
signaling with events.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:52 -0600
Message-Id: <20240131021356.10322-26-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Expand the contended wait tests, which previously only covered events and Expand the contended wait tests, which previously only covered events and
semaphores, to cover events as well. semaphores, to cover events as well.
@ -17,10 +7,10 @@ Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
1 file changed, 147 insertions(+), 4 deletions(-) 1 file changed, 147 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c
index f1fb28949367..598333df3e6d 100644 index 12ccb4ec28e4..5d17eff6a370 100644
--- a/tools/testing/selftests/drivers/ntsync/ntsync.c --- a/tools/testing/selftests/drivers/ntsync/ntsync.c
+++ b/tools/testing/selftests/drivers/ntsync/ntsync.c +++ b/tools/testing/selftests/drivers/ntsync/ntsync.c
@@ -587,6 +587,7 @@ TEST(test_wait_any) @@ -622,6 +622,7 @@ TEST(test_wait_any)
TEST(test_wait_all) TEST(test_wait_all)
{ {
@ -28,7 +18,7 @@ index f1fb28949367..598333df3e6d 100644
struct ntsync_mutex_args mutex_args = {0}; struct ntsync_mutex_args mutex_args = {0};
struct ntsync_sem_args sem_args = {0}; struct ntsync_sem_args sem_args = {0};
__u32 owner, index, count; __u32 owner, index, count;
@@ -609,6 +610,11 @@ TEST(test_wait_all) @@ -644,6 +645,11 @@ TEST(test_wait_all)
EXPECT_EQ(0, ret); EXPECT_EQ(0, ret);
EXPECT_NE(0xdeadbeef, mutex_args.mutex); EXPECT_NE(0xdeadbeef, mutex_args.mutex);
@ -40,7 +30,7 @@ index f1fb28949367..598333df3e6d 100644
objs[0] = sem_args.sem; objs[0] = sem_args.sem;
objs[1] = mutex_args.mutex; objs[1] = mutex_args.mutex;
@@ -657,6 +663,14 @@ TEST(test_wait_all) @@ -692,6 +698,14 @@ TEST(test_wait_all)
check_sem_state(sem_args.sem, 1, 3); check_sem_state(sem_args.sem, 1, 3);
check_mutex_state(mutex_args.mutex, 1, 123); check_mutex_state(mutex_args.mutex, 1, 123);
@ -55,7 +45,7 @@ index f1fb28949367..598333df3e6d 100644
/* test waiting on the same object twice */ /* test waiting on the same object twice */
objs[0] = objs[1] = sem_args.sem; objs[0] = objs[1] = sem_args.sem;
ret = wait_all(fd, 2, objs, 123, &index); ret = wait_all(fd, 2, objs, 123, &index);
@@ -665,6 +679,7 @@ TEST(test_wait_all) @@ -700,6 +714,7 @@ TEST(test_wait_all)
close(sem_args.sem); close(sem_args.sem);
close(mutex_args.mutex); close(mutex_args.mutex);
@ -63,7 +53,7 @@ index f1fb28949367..598333df3e6d 100644
close(fd); close(fd);
} }
@@ -713,12 +728,13 @@ static int wait_for_thread(pthread_t thread, unsigned int ms) @@ -746,12 +761,13 @@ static int wait_for_thread(pthread_t thread, unsigned int ms)
TEST(wake_any) TEST(wake_any)
{ {
@ -78,7 +68,7 @@ index f1fb28949367..598333df3e6d 100644
pthread_t thread; pthread_t thread;
fd = open("/dev/ntsync", O_CLOEXEC | O_RDONLY); fd = open("/dev/ntsync", O_CLOEXEC | O_RDONLY);
@@ -800,10 +816,101 @@ TEST(wake_any) @@ -833,10 +849,101 @@ TEST(wake_any)
EXPECT_EQ(0, thread_args.ret); EXPECT_EQ(0, thread_args.ret);
EXPECT_EQ(1, wait_args.index); EXPECT_EQ(1, wait_args.index);
@ -180,7 +170,7 @@ index f1fb28949367..598333df3e6d 100644
ret = pthread_create(&thread, NULL, wait_thread, &thread_args); ret = pthread_create(&thread, NULL, wait_thread, &thread_args);
EXPECT_EQ(0, ret); EXPECT_EQ(0, ret);
@@ -823,12 +930,14 @@ TEST(wake_any) @@ -856,12 +963,14 @@ TEST(wake_any)
TEST(wake_all) TEST(wake_all)
{ {
@ -197,7 +187,7 @@ index f1fb28949367..598333df3e6d 100644
pthread_t thread; pthread_t thread;
fd = open("/dev/ntsync", O_CLOEXEC | O_RDONLY); fd = open("/dev/ntsync", O_CLOEXEC | O_RDONLY);
@@ -848,12 +957,24 @@ TEST(wake_all) @@ -881,12 +990,24 @@ TEST(wake_all)
EXPECT_EQ(0, ret); EXPECT_EQ(0, ret);
EXPECT_NE(0xdeadbeef, mutex_args.mutex); EXPECT_NE(0xdeadbeef, mutex_args.mutex);
@ -223,7 +213,7 @@ index f1fb28949367..598333df3e6d 100644
wait_args.owner = 456; wait_args.owner = 456;
thread_args.fd = fd; thread_args.fd = fd;
thread_args.args = &wait_args; thread_args.args = &wait_args;
@@ -887,12 +1008,32 @@ TEST(wake_all) @@ -920,12 +1041,32 @@ TEST(wake_all)
check_mutex_state(mutex_args.mutex, 0, 0); check_mutex_state(mutex_args.mutex, 0, 0);
@ -256,7 +246,7 @@ index f1fb28949367..598333df3e6d 100644
ret = wait_for_thread(thread, 100); ret = wait_for_thread(thread, 100);
EXPECT_EQ(0, ret); EXPECT_EQ(0, ret);
@@ -910,6 +1051,8 @@ TEST(wake_all) @@ -943,6 +1084,8 @@ TEST(wake_all)
close(sem_args.sem); close(sem_args.sem);
close(mutex_args.mutex); close(mutex_args.mutex);
@ -267,4 +257,3 @@ index f1fb28949367..598333df3e6d 100644
EXPECT_EQ(0, ret); EXPECT_EQ(0, ret);
-- --
2.43.0 2.43.0

View File

@ -1,13 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 26/29] selftests: ntsync: Add tests for alertable
waits.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:53 -0600
Message-Id: <20240131021356.10322-27-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Test the "alert" functionality of NTSYNC_IOC_WAIT_ALL and NTSYNC_IOC_WAIT_ANY, Test the "alert" functionality of NTSYNC_IOC_WAIT_ALL and NTSYNC_IOC_WAIT_ANY,
when a wait is woken with an alert and when it is woken by an object. when a wait is woken with an alert and when it is woken by an object.
@ -17,7 +7,7 @@ Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
1 file changed, 176 insertions(+), 3 deletions(-) 1 file changed, 176 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c
index 598333df3e6d..6c00a55909aa 100644 index 5d17eff6a370..5465a16d38b3 100644
--- a/tools/testing/selftests/drivers/ntsync/ntsync.c --- a/tools/testing/selftests/drivers/ntsync/ntsync.c
+++ b/tools/testing/selftests/drivers/ntsync/ntsync.c +++ b/tools/testing/selftests/drivers/ntsync/ntsync.c
@@ -95,7 +95,7 @@ static int read_event_state(int event, __u32 *signaled, __u32 *manual) @@ -95,7 +95,7 @@ static int read_event_state(int event, __u32 *signaled, __u32 *manual)
@ -66,7 +56,7 @@ index 598333df3e6d..6c00a55909aa 100644
} }
TEST(semaphore_state) TEST(semaphore_state)
@@ -1062,4 +1077,162 @@ TEST(wake_all) @@ -1095,4 +1110,162 @@ TEST(wake_all)
close(fd); close(fd);
} }
@ -231,4 +221,3 @@ index 598333df3e6d..6c00a55909aa 100644
TEST_HARNESS_MAIN TEST_HARNESS_MAIN
-- --
2.43.0 2.43.0

View File

@ -1,13 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 27/29] selftests: ntsync: Add some tests for wakeup
signaling via alerts.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:54 -0600
Message-Id: <20240131021356.10322-28-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Expand the alert tests to cover alerting a thread mid-wait, to test that the Expand the alert tests to cover alerting a thread mid-wait, to test that the
relevant scheduling logic works correctly. relevant scheduling logic works correctly.
@ -17,10 +7,10 @@ Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
1 file changed, 62 insertions(+) 1 file changed, 62 insertions(+)
diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c
index 6c00a55909aa..09153d0686ac 100644 index 5465a16d38b3..968874d7e325 100644
--- a/tools/testing/selftests/drivers/ntsync/ntsync.c --- a/tools/testing/selftests/drivers/ntsync/ntsync.c
+++ b/tools/testing/selftests/drivers/ntsync/ntsync.c +++ b/tools/testing/selftests/drivers/ntsync/ntsync.c
@@ -1080,9 +1080,12 @@ TEST(wake_all) @@ -1113,9 +1113,12 @@ TEST(wake_all)
TEST(alert_any) TEST(alert_any)
{ {
struct ntsync_event_args event_args = {0}; struct ntsync_event_args event_args = {0};
@ -33,7 +23,7 @@ index 6c00a55909aa..09153d0686ac 100644
fd = open("/dev/ntsync", O_CLOEXEC | O_RDONLY); fd = open("/dev/ntsync", O_CLOEXEC | O_RDONLY);
ASSERT_LE(0, fd); ASSERT_LE(0, fd);
@@ -1130,6 +1133,34 @@ TEST(alert_any) @@ -1163,6 +1166,34 @@ TEST(alert_any)
EXPECT_EQ(0, ret); EXPECT_EQ(0, ret);
EXPECT_EQ(2, index); EXPECT_EQ(2, index);
@ -68,7 +58,7 @@ index 6c00a55909aa..09153d0686ac 100644
close(event_args.event); close(event_args.event);
/* test with an auto-reset event */ /* test with an auto-reset event */
@@ -1166,9 +1197,12 @@ TEST(alert_any) @@ -1199,9 +1230,12 @@ TEST(alert_any)
TEST(alert_all) TEST(alert_all)
{ {
struct ntsync_event_args event_args = {0}; struct ntsync_event_args event_args = {0};
@ -81,7 +71,7 @@ index 6c00a55909aa..09153d0686ac 100644
fd = open("/dev/ntsync", O_CLOEXEC | O_RDONLY); fd = open("/dev/ntsync", O_CLOEXEC | O_RDONLY);
ASSERT_LE(0, fd); ASSERT_LE(0, fd);
@@ -1202,6 +1236,34 @@ TEST(alert_all) @@ -1235,6 +1269,34 @@ TEST(alert_all)
EXPECT_EQ(0, ret); EXPECT_EQ(0, ret);
EXPECT_EQ(2, index); EXPECT_EQ(2, index);
@ -118,4 +108,3 @@ index 6c00a55909aa..09153d0686ac 100644
/* test with an auto-reset event */ /* test with an auto-reset event */
-- --
2.43.0 2.43.0

View File

@ -0,0 +1,97 @@
Test a more realistic usage pattern, and one with heavy contention, in order to
actually exercise ntsync's internal synchronization.
This test has several threads in a tight loop acquiring a mutex, modifying some
shared data, and then releasing the mutex. At the end we check if the data is
consistent.
Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
---
.../testing/selftests/drivers/ntsync/ntsync.c | 74 +++++++++++++++++++
1 file changed, 74 insertions(+)
diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c
index 968874d7e325..5fa2c9a0768c 100644
--- a/tools/testing/selftests/drivers/ntsync/ntsync.c
+++ b/tools/testing/selftests/drivers/ntsync/ntsync.c
@@ -1330,4 +1330,78 @@ TEST(alert_all)
close(fd);
}
+#define STRESS_LOOPS 10000
+#define STRESS_THREADS 4
+
+static unsigned int stress_counter;
+static int stress_device, stress_start_event, stress_mutex;
+
+static void *stress_thread(void *arg)
+{
+ struct ntsync_wait_args wait_args = {0};
+ __u32 index, count, i;
+ int ret;
+
+ wait_args.timeout = UINT64_MAX;
+ wait_args.count = 1;
+ wait_args.objs = (uintptr_t)&stress_start_event;
+ wait_args.owner = gettid();
+ wait_args.index = 0xdeadbeef;
+
+ ioctl(stress_device, NTSYNC_IOC_WAIT_ANY, &wait_args);
+
+ wait_args.objs = (uintptr_t)&stress_mutex;
+
+ for (i = 0; i < STRESS_LOOPS; ++i) {
+ ioctl(stress_device, NTSYNC_IOC_WAIT_ANY, &wait_args);
+
+ ++stress_counter;
+
+ unlock_mutex(stress_mutex, wait_args.owner, &count);
+ }
+
+ return NULL;
+}
+
+TEST(stress_wait)
+{
+ struct ntsync_event_args event_args;
+ struct ntsync_mutex_args mutex_args;
+ pthread_t threads[STRESS_THREADS];
+ __u32 signaled, i;
+ int ret;
+
+ stress_device = open("/dev/ntsync", O_CLOEXEC | O_RDONLY);
+ ASSERT_LE(0, stress_device);
+
+ mutex_args.owner = 0;
+ mutex_args.count = 0;
+ ret = ioctl(stress_device, NTSYNC_IOC_CREATE_MUTEX, &mutex_args);
+ EXPECT_EQ(0, ret);
+ stress_mutex = mutex_args.mutex;
+
+ event_args.manual = 1;
+ event_args.signaled = 0;
+ ret = ioctl(stress_device, NTSYNC_IOC_CREATE_EVENT, &event_args);
+ EXPECT_EQ(0, ret);
+ stress_start_event = event_args.event;
+
+ for (i = 0; i < STRESS_THREADS; ++i)
+ pthread_create(&threads[i], NULL, stress_thread, NULL);
+
+ ret = ioctl(stress_start_event, NTSYNC_IOC_EVENT_SET, &signaled);
+ EXPECT_EQ(0, ret);
+
+ for (i = 0; i < STRESS_THREADS; ++i) {
+ ret = pthread_join(threads[i], NULL);
+ EXPECT_EQ(0, ret);
+ }
+
+ EXPECT_EQ(STRESS_LOOPS * STRESS_THREADS, stress_counter);
+
+ close(stress_start_event);
+ close(stress_mutex);
+ close(stress_device);
+}
+
TEST_HARNESS_MAIN
--
2.43.0

View File

@ -1,12 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 28/29] maintainers: Add an entry for ntsync.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:55 -0600
Message-Id: <20240131021356.10322-29-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Add myself as maintainer, supported by CodeWeavers. Add myself as maintainer, supported by CodeWeavers.
Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com> Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
@ -15,10 +6,10 @@ Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
1 file changed, 9 insertions(+) 1 file changed, 9 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS diff --git a/MAINTAINERS b/MAINTAINERS
index 8d1052fa6a69..7924127d351b 100644 index 9ed4d3868539..d83dd35d9f73 100644
--- a/MAINTAINERS --- a/MAINTAINERS
+++ b/MAINTAINERS +++ b/MAINTAINERS
@@ -15585,6 +15585,15 @@ T: git https://github.com/Paragon-Software-Group/linux-ntfs3.git @@ -15595,6 +15595,15 @@ T: git https://github.com/Paragon-Software-Group/linux-ntfs3.git
F: Documentation/filesystems/ntfs3.rst F: Documentation/filesystems/ntfs3.rst
F: fs/ntfs3/ F: fs/ntfs3/
@ -36,4 +27,3 @@ index 8d1052fa6a69..7924127d351b 100644
L: linux-m68k@lists.linux-m68k.org L: linux-m68k@lists.linux-m68k.org
-- --
2.43.0 2.43.0

View File

@ -1,5 +1,5 @@
pkgname=linux6.7-zen pkgname=linux6.7-zen
version=6.7.5 version=6.7.6
revision=1 revision=1
zen=1 zen=1
wrksrc="linux-${version}-zen${zen}" wrksrc="linux-${version}-zen${zen}"
@ -8,7 +8,7 @@ maintainer="Wizzard <retard@deadzone.lol>"
license="GPL-2.0-only" license="GPL-2.0-only"
homepage="http://www.zen-kernel.org/" homepage="http://www.zen-kernel.org/"
distfiles="https://github.com/zen-kernel/zen-kernel/archive/refs/tags/v${version}-zen${zen}.tar.gz" distfiles="https://github.com/zen-kernel/zen-kernel/archive/refs/tags/v${version}-zen${zen}.tar.gz"
checksum="6f4bb1b180880034269d539a47f3c120874f4923604976127f4ba9d8db0546dd" checksum="77cdaa148e8ff5660b7c0287f6f70a0c36e0355521456c6fc754948fbe101ceb"
python_version=3 python_version=3
patch_args="-Np1" patch_args="-Np1"

View File

@ -1,13 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 1/29] ntsync: Introduce the ntsync driver and
character device.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:28 -0600
Message-Id: <20240131021356.10322-2-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
ntsync uses a misc device as the simplest and least intrusive uAPI interface. ntsync uses a misc device as the simplest and least intrusive uAPI interface.
Each file description on the device represents an isolated NT instance, intended Each file description on the device represents an isolated NT instance, intended
@ -15,19 +5,19 @@ to correspond to a single NT virtual machine.
Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com> Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
--- ---
drivers/misc/Kconfig | 9 ++++++++ drivers/misc/Kconfig | 11 +++++++++
drivers/misc/Makefile | 1 + drivers/misc/Makefile | 1 +
drivers/misc/ntsync.c | 52 +++++++++++++++++++++++++++++++++++++++++++ drivers/misc/ntsync.c | 52 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 62 insertions(+) 3 files changed, 64 insertions(+)
create mode 100644 drivers/misc/ntsync.c create mode 100644 drivers/misc/ntsync.c
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 4fb291f0bf7c..bdd8a71bd853 100644 index 4fb291f0bf7c..801ed229ed7d 100644
--- a/drivers/misc/Kconfig --- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig
@@ -504,6 +504,15 @@ config OPEN_DICE @@ -506,6 +506,17 @@ config OPEN_DICE
measured boot flow. Userspace can use CDIs for remote attestation
and sealing. If unsure, say N.
+config NTSYNC +config NTSYNC
+ tristate "NT synchronization primitive emulation" + tristate "NT synchronization primitive emulation"
@ -38,9 +28,11 @@ index 4fb291f0bf7c..bdd8a71bd853 100644
+ To compile this driver as a module, choose M here: the + To compile this driver as a module, choose M here: the
+ module will be called ntsync. + module will be called ntsync.
+ +
If unsure, say N. + If unsure, say N.
+
config VCPU_STALL_DETECTOR config VCPU_STALL_DETECTOR
tristate "Guest vCPU stall detector"
depends on OF && HAS_IOMEM
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index ea6ea5bbbc9c..153a3f4837e8 100644 index ea6ea5bbbc9c..153a3f4837e8 100644
--- a/drivers/misc/Makefile --- a/drivers/misc/Makefile
@ -55,7 +47,7 @@ index ea6ea5bbbc9c..153a3f4837e8 100644
obj-$(CONFIG_GP_PCI1XXXX) += mchp_pci1xxxx/ obj-$(CONFIG_GP_PCI1XXXX) += mchp_pci1xxxx/
diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c
new file mode 100644 new file mode 100644
index 000000000000..e4969ef90722 index 000000000000..bd76e653d83e
--- /dev/null --- /dev/null
+++ b/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c
@@ -0,0 +1,52 @@ @@ -0,0 +1,52 @@
@ -63,7 +55,7 @@ index 000000000000..e4969ef90722
+/* +/*
+ * ntsync.c - Kernel driver for NT synchronization primitives + * ntsync.c - Kernel driver for NT synchronization primitives
+ * + *
+ * Copyright (C) 2024 Elizabeth Figura + * Copyright (C) 2024 Elizabeth Figura <zfigura@codeweavers.com>
+ */ + */
+ +
+#include <linux/fs.h> +#include <linux/fs.h>
@ -108,9 +100,8 @@ index 000000000000..e4969ef90722
+ +
+module_misc_device(ntsync_misc); +module_misc_device(ntsync_misc);
+ +
+MODULE_AUTHOR("Elizabeth Figura"); +MODULE_AUTHOR("Elizabeth Figura <zfigura@codeweavers.com>");
+MODULE_DESCRIPTION("Kernel driver for NT synchronization primitives"); +MODULE_DESCRIPTION("Kernel driver for NT synchronization primitives");
+MODULE_LICENSE("GPL"); +MODULE_LICENSE("GPL");
-- --
2.43.0 2.43.0

View File

@ -1,12 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 2/29] ntsync: Introduce NTSYNC_IOC_CREATE_SEM.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:29 -0600
Message-Id: <20240131021356.10322-3-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
This corresponds to the NT syscall NtCreateSemaphore(). This corresponds to the NT syscall NtCreateSemaphore().
Semaphores are one of three types of object to be implemented in this driver, Semaphores are one of three types of object to be implemented in this driver,
@ -20,12 +11,15 @@ creation time. There are no restrictions on the maximum and initial value.
Each object is exposed as an file, to which any number of fds may be opened. Each object is exposed as an file, to which any number of fds may be opened.
When all fds are closed, the object is deleted. When all fds are closed, the object is deleted.
Objects hold a pointer to the ntsync_device that created them. The device's
reference count is driven by struct file.
Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com> Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
--- ---
.../userspace-api/ioctl/ioctl-number.rst | 2 + .../userspace-api/ioctl/ioctl-number.rst | 2 +
drivers/misc/ntsync.c | 120 ++++++++++++++++++ drivers/misc/ntsync.c | 131 ++++++++++++++++++
include/uapi/linux/ntsync.h | 21 +++ include/uapi/linux/ntsync.h | 21 +++
3 files changed, 143 insertions(+) 3 files changed, 154 insertions(+)
create mode 100644 include/uapi/linux/ntsync.h create mode 100644 include/uapi/linux/ntsync.h
diff --git a/Documentation/userspace-api/ioctl/ioctl-number.rst b/Documentation/userspace-api/ioctl/ioctl-number.rst diff --git a/Documentation/userspace-api/ioctl/ioctl-number.rst b/Documentation/userspace-api/ioctl/ioctl-number.rst
@ -42,11 +36,11 @@ index 457e16f06e04..2f5c6994f042 100644
'P' all linux/soundcard.h conflict! 'P' all linux/soundcard.h conflict!
'P' 60-6F sound/sscape_ioctl.h conflict! 'P' 60-6F sound/sscape_ioctl.h conflict!
diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c
index e4969ef90722..3ad86d98b82d 100644 index bd76e653d83e..20158ec148bc 100644
--- a/drivers/misc/ntsync.c --- a/drivers/misc/ntsync.c
+++ b/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c
@@ -5,26 +5,146 @@ @@ -5,26 +5,157 @@
* Copyright (C) 2024 Elizabeth Figura * Copyright (C) 2024 Elizabeth Figura <zfigura@codeweavers.com>
*/ */
+#include <linux/anon_inodes.h> +#include <linux/anon_inodes.h>
@ -63,6 +57,17 @@ index e4969ef90722..3ad86d98b82d 100644
+ NTSYNC_TYPE_SEM, + NTSYNC_TYPE_SEM,
+}; +};
+ +
+/*
+ * Individual synchronization primitives are represented by
+ * struct ntsync_obj, and each primitive is backed by a file.
+ *
+ * The whole namespace is represented by a struct ntsync_device also
+ * backed by a file.
+ *
+ * Both rely on struct file for reference counting. Individual
+ * ntsync_obj objects take a reference to the device when created.
+ */
+
+struct ntsync_obj { +struct ntsync_obj {
+ enum ntsync_type type; + enum ntsync_type type;
+ +
@ -194,7 +199,7 @@ index e4969ef90722..3ad86d98b82d 100644
} }
diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h
new file mode 100644 new file mode 100644
index 000000000000..f38818e7759d index 000000000000..6a4867a6c97b
--- /dev/null --- /dev/null
+++ b/include/uapi/linux/ntsync.h +++ b/include/uapi/linux/ntsync.h
@@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
@ -202,7 +207,7 @@ index 000000000000..f38818e7759d
+/* +/*
+ * Kernel support for NT synchronization primitive emulation + * Kernel support for NT synchronization primitive emulation
+ * + *
+ * Copyright (C) 2021-2022 Elizabeth Figura + * Copyright (C) 2021-2022 Elizabeth Figura <zfigura@codeweavers.com>
+ */ + */
+ +
+#ifndef __LINUX_NTSYNC_H +#ifndef __LINUX_NTSYNC_H
@ -221,4 +226,3 @@ index 000000000000..f38818e7759d
+#endif +#endif
-- --
2.43.0 2.43.0

View File

@ -1,12 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 3/29] ntsync: Introduce NTSYNC_IOC_SEM_POST.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:30 -0600
Message-Id: <20240131021356.10322-4-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
This corresponds to the NT syscall NtReleaseSemaphore(). This corresponds to the NT syscall NtReleaseSemaphore().
This increases the semaphore's internal counter by the given value, and returns This increases the semaphore's internal counter by the given value, and returns
@ -15,16 +6,26 @@ function instead fails and returns -EOVERFLOW.
Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com> Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
--- ---
drivers/misc/ntsync.c | 68 +++++++++++++++++++++++++++++++++++-- drivers/misc/ntsync.c | 72 +++++++++++++++++++++++++++++++++++--
include/uapi/linux/ntsync.h | 2 ++ include/uapi/linux/ntsync.h | 2 ++
2 files changed, 67 insertions(+), 3 deletions(-) 2 files changed, 71 insertions(+), 3 deletions(-)
diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c
index 3ad86d98b82d..1af38969f9a2 100644 index 20158ec148bc..3c2f743c58b0 100644
--- a/drivers/misc/ntsync.c --- a/drivers/misc/ntsync.c
+++ b/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c
@@ -20,23 +20,68 @@ enum ntsync_type { @@ -10,7 +10,9 @@
}; #include <linux/fs.h>
#include <linux/miscdevice.h>
#include <linux/module.h>
+#include <linux/overflow.h>
#include <linux/slab.h>
+#include <linux/spinlock.h>
#include <uapi/linux/ntsync.h>
#define NTSYNC_NAME "ntsync"
@@ -31,23 +33,70 @@ enum ntsync_type {
*/
struct ntsync_obj { struct ntsync_obj {
+ spinlock_t lock; + spinlock_t lock;
@ -56,13 +57,15 @@ index 3ad86d98b82d..1af38969f9a2 100644
+ */ + */
+static int post_sem_state(struct ntsync_obj *sem, __u32 count) +static int post_sem_state(struct ntsync_obj *sem, __u32 count)
+{ +{
+ __u32 sum;
+
+ lockdep_assert_held(&sem->lock); + lockdep_assert_held(&sem->lock);
+ +
+ if (sem->u.sem.count + count < sem->u.sem.count || + if (check_add_overflow(sem->u.sem.count, count, &sum) ||
+ sem->u.sem.count + count > sem->u.sem.max) + sum > sem->u.sem.max)
+ return -EOVERFLOW; + return -EOVERFLOW;
+ +
+ sem->u.sem.count += count; + sem->u.sem.count = sum;
+ return 0; + return 0;
+} +}
+ +
@ -95,7 +98,7 @@ index 3ad86d98b82d..1af38969f9a2 100644
static int ntsync_obj_release(struct inode *inode, struct file *file) static int ntsync_obj_release(struct inode *inode, struct file *file)
{ {
struct ntsync_obj *obj = file->private_data; struct ntsync_obj *obj = file->private_data;
@@ -47,9 +92,25 @@ static int ntsync_obj_release(struct inode *inode, struct file *file) @@ -58,9 +107,25 @@ static int ntsync_obj_release(struct inode *inode, struct file *file)
return 0; return 0;
} }
@ -121,7 +124,7 @@ index 3ad86d98b82d..1af38969f9a2 100644
.llseek = no_llseek, .llseek = no_llseek,
}; };
@@ -64,6 +125,7 @@ static struct ntsync_obj *ntsync_alloc_obj(struct ntsync_device *dev, @@ -75,6 +140,7 @@ static struct ntsync_obj *ntsync_alloc_obj(struct ntsync_device *dev,
obj->type = type; obj->type = type;
obj->dev = dev; obj->dev = dev;
get_file(dev->file); get_file(dev->file);
@ -130,7 +133,7 @@ index 3ad86d98b82d..1af38969f9a2 100644
return obj; return obj;
} }
diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h
index f38818e7759d..878ec4f0f2e8 100644 index 6a4867a6c97b..dcfa38fdc93c 100644
--- a/include/uapi/linux/ntsync.h --- a/include/uapi/linux/ntsync.h
+++ b/include/uapi/linux/ntsync.h +++ b/include/uapi/linux/ntsync.h
@@ -18,4 +18,6 @@ struct ntsync_sem_args { @@ -18,4 +18,6 @@ struct ntsync_sem_args {
@ -142,4 +145,3 @@ index f38818e7759d..878ec4f0f2e8 100644
#endif #endif
-- --
2.43.0 2.43.0

View File

@ -1,12 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 4/29] ntsync: Introduce NTSYNC_IOC_WAIT_ANY.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:31 -0600
Message-Id: <20240131021356.10322-5-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
This corresponds to part of the functionality of the NT syscall This corresponds to part of the functionality of the NT syscall
NtWaitForMultipleObjects(). Specifically, it implements the behaviour where NtWaitForMultipleObjects(). Specifically, it implements the behaviour where
the third argument (wait_any) is TRUE, and it does not handle alertable waits. the third argument (wait_any) is TRUE, and it does not handle alertable waits.
@ -29,17 +20,46 @@ This ioctl validates that all objects belong to the relevant device. This is not
necessary for any technical reason related to NTSYNC_IOC_WAIT_ANY, but will be necessary for any technical reason related to NTSYNC_IOC_WAIT_ANY, but will be
necessary for NTSYNC_IOC_WAIT_ALL introduced in the following patch. necessary for NTSYNC_IOC_WAIT_ALL introduced in the following patch.
Wait ioctls need to take a temporary reference to each object being waited on.
As with the device, the reference count of struct file is used for ntsync_obj.
Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com> Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
--- ---
drivers/misc/ntsync.c | 232 ++++++++++++++++++++++++++++++++++++ drivers/misc/ntsync.c | 239 ++++++++++++++++++++++++++++++++++++
include/uapi/linux/ntsync.h | 12 ++ include/uapi/linux/ntsync.h | 12 ++
2 files changed, 244 insertions(+) 2 files changed, 251 insertions(+)
diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c
index 1af38969f9a2..0a0ab755d57f 100644 index 3c2f743c58b0..ad93ca0f8b84 100644
--- a/drivers/misc/ntsync.c --- a/drivers/misc/ntsync.c
+++ b/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c
@@ -34,12 +34,55 @@ struct ntsync_obj { @@ -6,11 +6,16 @@
*/
#include <linux/anon_inodes.h>
+#include <linux/atomic.h>
#include <linux/file.h>
#include <linux/fs.h>
+#include <linux/hrtimer.h>
+#include <linux/ktime.h>
#include <linux/miscdevice.h>
#include <linux/module.h>
#include <linux/overflow.h>
+#include <linux/sched.h>
+#include <linux/sched/signal.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <uapi/linux/ntsync.h>
@@ -30,6 +35,8 @@ enum ntsync_type {
*
* Both rely on struct file for reference counting. Individual
* ntsync_obj objects take a reference to the device when created.
+ * Wait operations take a reference to each object being waited on for
+ * the duration of the wait.
*/
struct ntsync_obj {
@@ -47,12 +54,55 @@ struct ntsync_obj {
__u32 max; __u32 max;
} sem; } sem;
} u; } u;
@ -95,7 +115,7 @@ index 1af38969f9a2..0a0ab755d57f 100644
/* /*
* Actually change the semaphore state, returning -EOVERFLOW if it is made * Actually change the semaphore state, returning -EOVERFLOW if it is made
* invalid. * invalid.
@@ -73,6 +116,8 @@ static int ntsync_sem_post(struct ntsync_obj *sem, void __user *argp) @@ -88,6 +138,8 @@ static int ntsync_sem_post(struct ntsync_obj *sem, void __user *argp)
prev_count = sem->u.sem.count; prev_count = sem->u.sem.count;
ret = post_sem_state(sem, args); ret = post_sem_state(sem, args);
@ -104,7 +124,7 @@ index 1af38969f9a2..0a0ab755d57f 100644
spin_unlock(&sem->lock); spin_unlock(&sem->lock);
@@ -126,6 +171,7 @@ static struct ntsync_obj *ntsync_alloc_obj(struct ntsync_device *dev, @@ -141,6 +193,7 @@ static struct ntsync_obj *ntsync_alloc_obj(struct ntsync_device *dev,
obj->dev = dev; obj->dev = dev;
get_file(dev->file); get_file(dev->file);
spin_lock_init(&obj->lock); spin_lock_init(&obj->lock);
@ -112,7 +132,7 @@ index 1af38969f9a2..0a0ab755d57f 100644
return obj; return obj;
} }
@@ -176,6 +222,190 @@ static int ntsync_create_sem(struct ntsync_device *dev, void __user *argp) @@ -191,6 +244,190 @@ static int ntsync_create_sem(struct ntsync_device *dev, void __user *argp)
return put_user(fd, &user_args->sem); return put_user(fd, &user_args->sem);
} }
@ -121,15 +141,13 @@ index 1af38969f9a2..0a0ab755d57f 100644
+ struct file *file = fget(fd); + struct file *file = fget(fd);
+ struct ntsync_obj *obj; + struct ntsync_obj *obj;
+ +
+ if (file->f_op != &ntsync_obj_fops) + if (file->f_op != &ntsync_obj_fops) {
+ {
+ fput(file); + fput(file);
+ return NULL; + return NULL;
+ } + }
+ +
+ obj = file->private_data; + obj = file->private_data;
+ if (obj->dev != dev) + if (obj->dev != dev) {
+ {
+ fput(file); + fput(file);
+ return NULL; + return NULL;
+ } + }
@ -142,10 +160,14 @@ index 1af38969f9a2..0a0ab755d57f 100644
+ fput(obj->file); + fput(obj->file);
+} +}
+ +
+static int ntsync_schedule(const struct ntsync_q *q, ktime_t *timeout) +static int ntsync_schedule(const struct ntsync_q *q, const struct ntsync_wait_args *args)
+{ +{
+ ktime_t timeout = ns_to_ktime(args->timeout);
+ ktime_t *timeout_ptr;
+ int ret = 0; + int ret = 0;
+ +
+ timeout_ptr = (args->timeout == U64_MAX ? NULL : &timeout);
+
+ do { + do {
+ if (signal_pending(current)) { + if (signal_pending(current)) {
+ ret = -ERESTARTSYS; + ret = -ERESTARTSYS;
@ -157,7 +179,7 @@ index 1af38969f9a2..0a0ab755d57f 100644
+ ret = 0; + ret = 0;
+ break; + break;
+ } + }
+ ret = schedule_hrtimeout(timeout, HRTIMER_MODE_ABS); + ret = schedule_hrtimeout(timeout_ptr, HRTIMER_MODE_ABS);
+ } while (ret < 0); + } while (ret < 0);
+ __set_current_state(TASK_RUNNING); + __set_current_state(TASK_RUNNING);
+ +
@ -229,7 +251,6 @@ index 1af38969f9a2..0a0ab755d57f 100644
+{ +{
+ struct ntsync_wait_args args; + struct ntsync_wait_args args;
+ struct ntsync_q *q; + struct ntsync_q *q;
+ ktime_t timeout;
+ int signaled; + int signaled;
+ __u32 i; + __u32 i;
+ int ret; + int ret;
@ -267,8 +288,7 @@ index 1af38969f9a2..0a0ab755d57f 100644
+ +
+ /* sleep */ + /* sleep */
+ +
+ timeout = ns_to_ktime(args.timeout); + ret = ntsync_schedule(q, &args);
+ ret = ntsync_schedule(q, args.timeout == U64_MAX ? NULL : &timeout);
+ +
+ /* and finally, unqueue */ + /* and finally, unqueue */
+ +
@ -303,7 +323,7 @@ index 1af38969f9a2..0a0ab755d57f 100644
static int ntsync_char_open(struct inode *inode, struct file *file) static int ntsync_char_open(struct inode *inode, struct file *file)
{ {
struct ntsync_device *dev; struct ntsync_device *dev;
@@ -207,6 +437,8 @@ static long ntsync_char_ioctl(struct file *file, unsigned int cmd, @@ -222,6 +459,8 @@ static long ntsync_char_ioctl(struct file *file, unsigned int cmd,
switch (cmd) { switch (cmd) {
case NTSYNC_IOC_CREATE_SEM: case NTSYNC_IOC_CREATE_SEM:
return ntsync_create_sem(dev, argp); return ntsync_create_sem(dev, argp);
@ -313,7 +333,7 @@ index 1af38969f9a2..0a0ab755d57f 100644
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
} }
diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h
index 878ec4f0f2e8..9cd1dd05d971 100644 index dcfa38fdc93c..56b643fab611 100644
--- a/include/uapi/linux/ntsync.h --- a/include/uapi/linux/ntsync.h
+++ b/include/uapi/linux/ntsync.h +++ b/include/uapi/linux/ntsync.h
@@ -16,7 +16,19 @@ struct ntsync_sem_args { @@ -16,7 +16,19 @@ struct ntsync_sem_args {
@ -338,4 +358,3 @@ index 878ec4f0f2e8..9cd1dd05d971 100644
-- --
2.43.0 2.43.0

View File

@ -1,27 +1,18 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 5/29] ntsync: Introduce NTSYNC_IOC_WAIT_ALL.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:32 -0600
Message-Id: <20240131021356.10322-6-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
This is similar to NTSYNC_IOC_WAIT_ANY, but waits until all of the objects are This is similar to NTSYNC_IOC_WAIT_ANY, but waits until all of the objects are
simultaneously signaled, and then acquires all of them as a single atomic simultaneously signaled, and then acquires all of them as a single atomic
operation. operation.
Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com> Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
--- ---
drivers/misc/ntsync.c | 244 ++++++++++++++++++++++++++++++++++-- drivers/misc/ntsync.c | 242 ++++++++++++++++++++++++++++++++++--
include/uapi/linux/ntsync.h | 1 + include/uapi/linux/ntsync.h | 1 +
2 files changed, 237 insertions(+), 8 deletions(-) 2 files changed, 235 insertions(+), 8 deletions(-)
diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c
index 0a0ab755d57f..b86d62094344 100644 index ad93ca0f8b84..d5759e9a3a8e 100644
--- a/drivers/misc/ntsync.c --- a/drivers/misc/ntsync.c
+++ b/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c
@@ -35,7 +35,34 @@ struct ntsync_obj { @@ -55,7 +55,34 @@ struct ntsync_obj {
} sem; } sem;
} u; } u;
@ -56,7 +47,7 @@ index 0a0ab755d57f..b86d62094344 100644
}; };
struct ntsync_q_entry { struct ntsync_q_entry {
@@ -56,14 +83,99 @@ struct ntsync_q { @@ -76,14 +103,99 @@ struct ntsync_q {
*/ */
atomic_t signaled; atomic_t signaled;
@ -156,7 +147,7 @@ index 0a0ab755d57f..b86d62094344 100644
static void try_wake_any_sem(struct ntsync_obj *sem) static void try_wake_any_sem(struct ntsync_obj *sem)
{ {
struct ntsync_q_entry *entry; struct ntsync_q_entry *entry;
@@ -101,6 +213,7 @@ static int post_sem_state(struct ntsync_obj *sem, __u32 count) @@ -123,6 +235,7 @@ static int post_sem_state(struct ntsync_obj *sem, __u32 count)
static int ntsync_sem_post(struct ntsync_obj *sem, void __user *argp) static int ntsync_sem_post(struct ntsync_obj *sem, void __user *argp)
{ {
@ -164,7 +155,7 @@ index 0a0ab755d57f..b86d62094344 100644
__u32 __user *user_args = argp; __u32 __user *user_args = argp;
__u32 prev_count; __u32 prev_count;
__u32 args; __u32 args;
@@ -112,14 +225,29 @@ static int ntsync_sem_post(struct ntsync_obj *sem, void __user *argp) @@ -134,14 +247,29 @@ static int ntsync_sem_post(struct ntsync_obj *sem, void __user *argp)
if (sem->type != NTSYNC_TYPE_SEM) if (sem->type != NTSYNC_TYPE_SEM)
return -EINVAL; return -EINVAL;
@ -200,7 +191,7 @@ index 0a0ab755d57f..b86d62094344 100644
if (!ret && put_user(prev_count, user_args)) if (!ret && put_user(prev_count, user_args))
ret = -EFAULT; ret = -EFAULT;
@@ -172,6 +300,8 @@ static struct ntsync_obj *ntsync_alloc_obj(struct ntsync_device *dev, @@ -194,6 +322,8 @@ static struct ntsync_obj *ntsync_alloc_obj(struct ntsync_device *dev,
get_file(dev->file); get_file(dev->file);
spin_lock_init(&obj->lock); spin_lock_init(&obj->lock);
INIT_LIST_HEAD(&obj->any_waiters); INIT_LIST_HEAD(&obj->any_waiters);
@ -209,7 +200,7 @@ index 0a0ab755d57f..b86d62094344 100644
return obj; return obj;
} }
@@ -274,7 +404,7 @@ static int ntsync_schedule(const struct ntsync_q *q, ktime_t *timeout) @@ -298,7 +428,7 @@ static int ntsync_schedule(const struct ntsync_q *q, const struct ntsync_wait_ar
* Allocate and initialize the ntsync_q structure, but do not queue us yet. * Allocate and initialize the ntsync_q structure, but do not queue us yet.
*/ */
static int setup_wait(struct ntsync_device *dev, static int setup_wait(struct ntsync_device *dev,
@ -218,7 +209,7 @@ index 0a0ab755d57f..b86d62094344 100644
struct ntsync_q **ret_q) struct ntsync_q **ret_q)
{ {
const __u32 count = args->count; const __u32 count = args->count;
@@ -298,6 +428,7 @@ static int setup_wait(struct ntsync_device *dev, @@ -322,6 +452,7 @@ static int setup_wait(struct ntsync_device *dev,
q->task = current; q->task = current;
q->owner = args->owner; q->owner = args->owner;
atomic_set(&q->signaled, -1); atomic_set(&q->signaled, -1);
@ -226,7 +217,7 @@ index 0a0ab755d57f..b86d62094344 100644
q->count = count; q->count = count;
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
@@ -307,6 +438,16 @@ static int setup_wait(struct ntsync_device *dev, @@ -331,6 +462,16 @@ static int setup_wait(struct ntsync_device *dev,
if (!obj) if (!obj)
goto err; goto err;
@ -243,7 +234,7 @@ index 0a0ab755d57f..b86d62094344 100644
entry->obj = obj; entry->obj = obj;
entry->q = q; entry->q = q;
entry->index = i; entry->index = i;
@@ -343,7 +484,7 @@ static int ntsync_wait_any(struct ntsync_device *dev, void __user *argp) @@ -366,7 +507,7 @@ static int ntsync_wait_any(struct ntsync_device *dev, void __user *argp)
if (copy_from_user(&args, argp, sizeof(args))) if (copy_from_user(&args, argp, sizeof(args)))
return -EFAULT; return -EFAULT;
@ -252,7 +243,7 @@ index 0a0ab755d57f..b86d62094344 100644
if (ret < 0) if (ret < 0)
return ret; return ret;
@@ -406,6 +547,89 @@ static int ntsync_wait_any(struct ntsync_device *dev, void __user *argp) @@ -428,6 +569,87 @@ static int ntsync_wait_any(struct ntsync_device *dev, void __user *argp)
return ret; return ret;
} }
@ -260,7 +251,6 @@ index 0a0ab755d57f..b86d62094344 100644
+{ +{
+ struct ntsync_wait_args args; + struct ntsync_wait_args args;
+ struct ntsync_q *q; + struct ntsync_q *q;
+ ktime_t timeout;
+ int signaled; + int signaled;
+ __u32 i; + __u32 i;
+ int ret; + int ret;
@ -298,8 +288,7 @@ index 0a0ab755d57f..b86d62094344 100644
+ +
+ /* sleep */ + /* sleep */
+ +
+ timeout = ns_to_ktime(args.timeout); + ret = ntsync_schedule(q, &args);
+ ret = ntsync_schedule(q, args.timeout == U64_MAX ? NULL : &timeout);
+ +
+ /* and finally, unqueue */ + /* and finally, unqueue */
+ +
@ -342,7 +331,7 @@ index 0a0ab755d57f..b86d62094344 100644
static int ntsync_char_open(struct inode *inode, struct file *file) static int ntsync_char_open(struct inode *inode, struct file *file)
{ {
struct ntsync_device *dev; struct ntsync_device *dev;
@@ -414,6 +638,8 @@ static int ntsync_char_open(struct inode *inode, struct file *file) @@ -436,6 +658,8 @@ static int ntsync_char_open(struct inode *inode, struct file *file)
if (!dev) if (!dev)
return -ENOMEM; return -ENOMEM;
@ -351,7 +340,7 @@ index 0a0ab755d57f..b86d62094344 100644
file->private_data = dev; file->private_data = dev;
dev->file = file; dev->file = file;
return nonseekable_open(inode, file); return nonseekable_open(inode, file);
@@ -437,6 +663,8 @@ static long ntsync_char_ioctl(struct file *file, unsigned int cmd, @@ -459,6 +683,8 @@ static long ntsync_char_ioctl(struct file *file, unsigned int cmd,
switch (cmd) { switch (cmd) {
case NTSYNC_IOC_CREATE_SEM: case NTSYNC_IOC_CREATE_SEM:
return ntsync_create_sem(dev, argp); return ntsync_create_sem(dev, argp);
@ -361,7 +350,7 @@ index 0a0ab755d57f..b86d62094344 100644
return ntsync_wait_any(dev, argp); return ntsync_wait_any(dev, argp);
default: default:
diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h
index 9cd1dd05d971..524404f6aceb 100644 index 56b643fab611..19c37e27a4f8 100644
--- a/include/uapi/linux/ntsync.h --- a/include/uapi/linux/ntsync.h
+++ b/include/uapi/linux/ntsync.h +++ b/include/uapi/linux/ntsync.h
@@ -29,6 +29,7 @@ struct ntsync_wait_args { @@ -29,6 +29,7 @@ struct ntsync_wait_args {
@ -374,4 +363,3 @@ index 9cd1dd05d971..524404f6aceb 100644
-- --
2.43.0 2.43.0

View File

@ -1,12 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 6/29] ntsync: Introduce NTSYNC_IOC_CREATE_MUTEX.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:33 -0600
Message-Id: <20240131021356.10322-7-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
This corresponds to the NT syscall NtCreateMutant(). This corresponds to the NT syscall NtCreateMutant().
An NT mutex is recursive, with a 32-bit recursion counter. When acquired via An NT mutex is recursive, with a 32-bit recursion counter. When acquired via
@ -26,18 +17,18 @@ Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
2 files changed, 74 insertions(+) 2 files changed, 74 insertions(+)
diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c
index b86d62094344..484219a266ae 100644 index d5759e9a3a8e..6f7086d0440a 100644
--- a/drivers/misc/ntsync.c --- a/drivers/misc/ntsync.c
+++ b/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c
@@ -17,6 +17,7 @@ @@ -24,6 +24,7 @@
enum ntsync_type { enum ntsync_type {
NTSYNC_TYPE_SEM, NTSYNC_TYPE_SEM,
+ NTSYNC_TYPE_MUTEX, + NTSYNC_TYPE_MUTEX,
}; };
struct ntsync_obj { /*
@@ -33,6 +34,10 @@ struct ntsync_obj { @@ -53,6 +54,10 @@ struct ntsync_obj {
__u32 count; __u32 count;
__u32 max; __u32 max;
} sem; } sem;
@ -48,7 +39,7 @@ index b86d62094344..484219a266ae 100644
} u; } u;
/* /*
@@ -112,6 +117,10 @@ static bool is_signaled(struct ntsync_obj *obj, __u32 owner) @@ -132,6 +137,10 @@ static bool is_signaled(struct ntsync_obj *obj, __u32 owner)
switch (obj->type) { switch (obj->type) {
case NTSYNC_TYPE_SEM: case NTSYNC_TYPE_SEM:
return !!obj->u.sem.count; return !!obj->u.sem.count;
@ -59,7 +50,7 @@ index b86d62094344..484219a266ae 100644
} }
WARN(1, "bad object type %#x\n", obj->type); WARN(1, "bad object type %#x\n", obj->type);
@@ -154,6 +163,10 @@ static void try_wake_all(struct ntsync_device *dev, struct ntsync_q *q, @@ -174,6 +183,10 @@ static void try_wake_all(struct ntsync_device *dev, struct ntsync_q *q,
case NTSYNC_TYPE_SEM: case NTSYNC_TYPE_SEM:
obj->u.sem.count--; obj->u.sem.count--;
break; break;
@ -70,7 +61,7 @@ index b86d62094344..484219a266ae 100644
} }
} }
wake_up_process(q->task); wake_up_process(q->task);
@@ -195,6 +208,28 @@ static void try_wake_any_sem(struct ntsync_obj *sem) @@ -215,6 +228,28 @@ static void try_wake_any_sem(struct ntsync_obj *sem)
} }
} }
@ -99,7 +90,7 @@ index b86d62094344..484219a266ae 100644
/* /*
* Actually change the semaphore state, returning -EOVERFLOW if it is made * Actually change the semaphore state, returning -EOVERFLOW if it is made
* invalid. * invalid.
@@ -352,6 +387,33 @@ static int ntsync_create_sem(struct ntsync_device *dev, void __user *argp) @@ -374,6 +409,33 @@ static int ntsync_create_sem(struct ntsync_device *dev, void __user *argp)
return put_user(fd, &user_args->sem); return put_user(fd, &user_args->sem);
} }
@ -133,7 +124,7 @@ index b86d62094344..484219a266ae 100644
static struct ntsync_obj *get_obj(struct ntsync_device *dev, int fd) static struct ntsync_obj *get_obj(struct ntsync_device *dev, int fd)
{ {
struct file *file = fget(fd); struct file *file = fget(fd);
@@ -469,6 +531,9 @@ static void try_wake_any_obj(struct ntsync_obj *obj) @@ -493,6 +555,9 @@ static void try_wake_any_obj(struct ntsync_obj *obj)
case NTSYNC_TYPE_SEM: case NTSYNC_TYPE_SEM:
try_wake_any_sem(obj); try_wake_any_sem(obj);
break; break;
@ -143,7 +134,7 @@ index b86d62094344..484219a266ae 100644
} }
} }
@@ -661,6 +726,8 @@ static long ntsync_char_ioctl(struct file *file, unsigned int cmd, @@ -681,6 +746,8 @@ static long ntsync_char_ioctl(struct file *file, unsigned int cmd,
void __user *argp = (void __user *)parm; void __user *argp = (void __user *)parm;
switch (cmd) { switch (cmd) {
@ -153,7 +144,7 @@ index b86d62094344..484219a266ae 100644
return ntsync_create_sem(dev, argp); return ntsync_create_sem(dev, argp);
case NTSYNC_IOC_WAIT_ALL: case NTSYNC_IOC_WAIT_ALL:
diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h
index 524404f6aceb..d68f24fd75a2 100644 index 19c37e27a4f8..8ac9d419c360 100644
--- a/include/uapi/linux/ntsync.h --- a/include/uapi/linux/ntsync.h
+++ b/include/uapi/linux/ntsync.h +++ b/include/uapi/linux/ntsync.h
@@ -16,6 +16,12 @@ struct ntsync_sem_args { @@ -16,6 +16,12 @@ struct ntsync_sem_args {
@ -179,4 +170,3 @@ index 524404f6aceb..d68f24fd75a2 100644
-- --
2.43.0 2.43.0

View File

@ -1,12 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 7/29] ntsync: Introduce NTSYNC_IOC_MUTEX_UNLOCK.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:34 -0600
Message-Id: <20240131021356.10322-8-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
This corresponds to the NT syscall NtReleaseMutant(). This corresponds to the NT syscall NtReleaseMutant().
This syscall decrements the mutex's recursion count by one, and returns the This syscall decrements the mutex's recursion count by one, and returns the
@ -20,10 +11,10 @@ Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
2 files changed, 65 insertions(+) 2 files changed, 65 insertions(+)
diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c
index 484219a266ae..1770ec4008af 100644 index 6f7086d0440a..222ebead8eba 100644
--- a/drivers/misc/ntsync.c --- a/drivers/misc/ntsync.c
+++ b/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c
@@ -290,6 +290,68 @@ static int ntsync_sem_post(struct ntsync_obj *sem, void __user *argp) @@ -312,6 +312,68 @@ static int ntsync_sem_post(struct ntsync_obj *sem, void __user *argp)
return ret; return ret;
} }
@ -92,7 +83,7 @@ index 484219a266ae..1770ec4008af 100644
static int ntsync_obj_release(struct inode *inode, struct file *file) static int ntsync_obj_release(struct inode *inode, struct file *file)
{ {
struct ntsync_obj *obj = file->private_data; struct ntsync_obj *obj = file->private_data;
@@ -309,6 +371,8 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd, @@ -331,6 +393,8 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd,
switch (cmd) { switch (cmd) {
case NTSYNC_IOC_SEM_POST: case NTSYNC_IOC_SEM_POST:
return ntsync_sem_post(obj, argp); return ntsync_sem_post(obj, argp);
@ -102,7 +93,7 @@ index 484219a266ae..1770ec4008af 100644
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
} }
diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h
index d68f24fd75a2..a3f5f4f13798 100644 index 8ac9d419c360..265503d441b1 100644
--- a/include/uapi/linux/ntsync.h --- a/include/uapi/linux/ntsync.h
+++ b/include/uapi/linux/ntsync.h +++ b/include/uapi/linux/ntsync.h
@@ -39,5 +39,6 @@ struct ntsync_wait_args { @@ -39,5 +39,6 @@ struct ntsync_wait_args {
@ -114,4 +105,3 @@ index d68f24fd75a2..a3f5f4f13798 100644
#endif #endif
-- --
2.43.0 2.43.0

View File

@ -1,12 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 8/29] ntsync: Introduce NTSYNC_IOC_MUTEX_KILL.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:35 -0600
Message-Id: <20240131021356.10322-9-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
This does not correspond to any NT syscall. Rather, when a thread dies, it This does not correspond to any NT syscall. Rather, when a thread dies, it
should be called by the NT emulator for each mutex. should be called by the NT emulator for each mutex.
@ -23,10 +14,10 @@ Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
2 files changed, 70 insertions(+), 2 deletions(-) 2 files changed, 70 insertions(+), 2 deletions(-)
diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c
index 1770ec4008af..aadf01c65ca0 100644 index 222ebead8eba..a3466be50c45 100644
--- a/drivers/misc/ntsync.c --- a/drivers/misc/ntsync.c
+++ b/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c
@@ -37,6 +37,7 @@ struct ntsync_obj { @@ -57,6 +57,7 @@ struct ntsync_obj {
struct { struct {
__u32 count; __u32 count;
__u32 owner; __u32 owner;
@ -34,7 +25,7 @@ index 1770ec4008af..aadf01c65ca0 100644
} mutex; } mutex;
} u; } u;
@@ -89,6 +90,7 @@ struct ntsync_q { @@ -109,6 +110,7 @@ struct ntsync_q {
atomic_t signaled; atomic_t signaled;
bool all; bool all;
@ -42,7 +33,7 @@ index 1770ec4008af..aadf01c65ca0 100644
__u32 count; __u32 count;
struct ntsync_q_entry entries[]; struct ntsync_q_entry entries[];
}; };
@@ -164,6 +166,9 @@ static void try_wake_all(struct ntsync_device *dev, struct ntsync_q *q, @@ -184,6 +186,9 @@ static void try_wake_all(struct ntsync_device *dev, struct ntsync_q *q,
obj->u.sem.count--; obj->u.sem.count--;
break; break;
case NTSYNC_TYPE_MUTEX: case NTSYNC_TYPE_MUTEX:
@ -52,7 +43,7 @@ index 1770ec4008af..aadf01c65ca0 100644
obj->u.mutex.count++; obj->u.mutex.count++;
obj->u.mutex.owner = q->owner; obj->u.mutex.owner = q->owner;
break; break;
@@ -223,6 +228,9 @@ static void try_wake_any_mutex(struct ntsync_obj *mutex) @@ -243,6 +248,9 @@ static void try_wake_any_mutex(struct ntsync_obj *mutex)
continue; continue;
if (atomic_cmpxchg(&q->signaled, -1, entry->index) == -1) { if (atomic_cmpxchg(&q->signaled, -1, entry->index) == -1) {
@ -62,7 +53,7 @@ index 1770ec4008af..aadf01c65ca0 100644
mutex->u.mutex.count++; mutex->u.mutex.count++;
mutex->u.mutex.owner = q->owner; mutex->u.mutex.owner = q->owner;
wake_up_process(q->task); wake_up_process(q->task);
@@ -352,6 +360,62 @@ static int ntsync_mutex_unlock(struct ntsync_obj *mutex, void __user *argp) @@ -374,6 +382,62 @@ static int ntsync_mutex_unlock(struct ntsync_obj *mutex, void __user *argp)
return ret; return ret;
} }
@ -125,7 +116,7 @@ index 1770ec4008af..aadf01c65ca0 100644
static int ntsync_obj_release(struct inode *inode, struct file *file) static int ntsync_obj_release(struct inode *inode, struct file *file)
{ {
struct ntsync_obj *obj = file->private_data; struct ntsync_obj *obj = file->private_data;
@@ -373,6 +437,8 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd, @@ -395,6 +459,8 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd,
return ntsync_sem_post(obj, argp); return ntsync_sem_post(obj, argp);
case NTSYNC_IOC_MUTEX_UNLOCK: case NTSYNC_IOC_MUTEX_UNLOCK:
return ntsync_mutex_unlock(obj, argp); return ntsync_mutex_unlock(obj, argp);
@ -134,7 +125,7 @@ index 1770ec4008af..aadf01c65ca0 100644
default: default:
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
} }
@@ -555,6 +621,7 @@ static int setup_wait(struct ntsync_device *dev, @@ -579,6 +645,7 @@ static int setup_wait(struct ntsync_device *dev,
q->owner = args->owner; q->owner = args->owner;
atomic_set(&q->signaled, -1); atomic_set(&q->signaled, -1);
q->all = all; q->all = all;
@ -142,7 +133,7 @@ index 1770ec4008af..aadf01c65ca0 100644
q->count = count; q->count = count;
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
@@ -664,7 +731,7 @@ static int ntsync_wait_any(struct ntsync_device *dev, void __user *argp) @@ -686,7 +753,7 @@ static int ntsync_wait_any(struct ntsync_device *dev, void __user *argp)
struct ntsync_wait_args __user *user_args = argp; struct ntsync_wait_args __user *user_args = argp;
/* even if we caught a signal, we need to communicate success */ /* even if we caught a signal, we need to communicate success */
@ -151,7 +142,7 @@ index 1770ec4008af..aadf01c65ca0 100644
if (put_user(signaled, &user_args->index)) if (put_user(signaled, &user_args->index))
ret = -EFAULT; ret = -EFAULT;
@@ -747,7 +814,7 @@ static int ntsync_wait_all(struct ntsync_device *dev, void __user *argp) @@ -767,7 +834,7 @@ static int ntsync_wait_all(struct ntsync_device *dev, void __user *argp)
struct ntsync_wait_args __user *user_args = argp; struct ntsync_wait_args __user *user_args = argp;
/* even if we caught a signal, we need to communicate success */ /* even if we caught a signal, we need to communicate success */
@ -161,7 +152,7 @@ index 1770ec4008af..aadf01c65ca0 100644
if (put_user(signaled, &user_args->index)) if (put_user(signaled, &user_args->index))
ret = -EFAULT; ret = -EFAULT;
diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h
index a3f5f4f13798..3861397c6c2f 100644 index 265503d441b1..4800941fcbda 100644
--- a/include/uapi/linux/ntsync.h --- a/include/uapi/linux/ntsync.h
+++ b/include/uapi/linux/ntsync.h +++ b/include/uapi/linux/ntsync.h
@@ -40,5 +40,6 @@ struct ntsync_wait_args { @@ -40,5 +40,6 @@ struct ntsync_wait_args {
@ -173,4 +164,3 @@ index a3f5f4f13798..3861397c6c2f 100644
#endif #endif
-- --
2.43.0 2.43.0

View File

@ -1,12 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 9/29] ntsync: Introduce NTSYNC_IOC_CREATE_EVENT.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:36 -0600
Message-Id: <20240131021356.10322-10-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
This correspond to the NT syscall NtCreateEvent(). This correspond to the NT syscall NtCreateEvent().
An NT event holds a single bit of state denoting whether it is signaled or An NT event holds a single bit of state denoting whether it is signaled or
@ -26,18 +17,18 @@ Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
2 files changed, 67 insertions(+) 2 files changed, 67 insertions(+)
diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c
index aadf01c65ca0..c719ddd9f6d7 100644 index a3466be50c45..17dd47d06e0a 100644
--- a/drivers/misc/ntsync.c --- a/drivers/misc/ntsync.c
+++ b/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c
@@ -18,6 +18,7 @@ @@ -25,6 +25,7 @@
enum ntsync_type { enum ntsync_type {
NTSYNC_TYPE_SEM, NTSYNC_TYPE_SEM,
NTSYNC_TYPE_MUTEX, NTSYNC_TYPE_MUTEX,
+ NTSYNC_TYPE_EVENT, + NTSYNC_TYPE_EVENT,
}; };
struct ntsync_obj { /*
@@ -39,6 +40,10 @@ struct ntsync_obj { @@ -59,6 +60,10 @@ struct ntsync_obj {
__u32 owner; __u32 owner;
bool ownerdead; bool ownerdead;
} mutex; } mutex;
@ -48,7 +39,7 @@ index aadf01c65ca0..c719ddd9f6d7 100644
} u; } u;
/* /*
@@ -123,6 +128,8 @@ static bool is_signaled(struct ntsync_obj *obj, __u32 owner) @@ -143,6 +148,8 @@ static bool is_signaled(struct ntsync_obj *obj, __u32 owner)
if (obj->u.mutex.owner && obj->u.mutex.owner != owner) if (obj->u.mutex.owner && obj->u.mutex.owner != owner)
return false; return false;
return obj->u.mutex.count < UINT_MAX; return obj->u.mutex.count < UINT_MAX;
@ -57,7 +48,7 @@ index aadf01c65ca0..c719ddd9f6d7 100644
} }
WARN(1, "bad object type %#x\n", obj->type); WARN(1, "bad object type %#x\n", obj->type);
@@ -172,6 +179,10 @@ static void try_wake_all(struct ntsync_device *dev, struct ntsync_q *q, @@ -192,6 +199,10 @@ static void try_wake_all(struct ntsync_device *dev, struct ntsync_q *q,
obj->u.mutex.count++; obj->u.mutex.count++;
obj->u.mutex.owner = q->owner; obj->u.mutex.owner = q->owner;
break; break;
@ -68,7 +59,7 @@ index aadf01c65ca0..c719ddd9f6d7 100644
} }
} }
wake_up_process(q->task); wake_up_process(q->task);
@@ -238,6 +249,26 @@ static void try_wake_any_mutex(struct ntsync_obj *mutex) @@ -258,6 +269,26 @@ static void try_wake_any_mutex(struct ntsync_obj *mutex)
} }
} }
@ -95,7 +86,7 @@ index aadf01c65ca0..c719ddd9f6d7 100644
/* /*
* Actually change the semaphore state, returning -EOVERFLOW if it is made * Actually change the semaphore state, returning -EOVERFLOW if it is made
* invalid. * invalid.
@@ -544,6 +575,30 @@ static int ntsync_create_mutex(struct ntsync_device *dev, void __user *argp) @@ -566,6 +597,30 @@ static int ntsync_create_mutex(struct ntsync_device *dev, void __user *argp)
return put_user(fd, &user_args->mutex); return put_user(fd, &user_args->mutex);
} }
@ -126,7 +117,7 @@ index aadf01c65ca0..c719ddd9f6d7 100644
static struct ntsync_obj *get_obj(struct ntsync_device *dev, int fd) static struct ntsync_obj *get_obj(struct ntsync_device *dev, int fd)
{ {
struct file *file = fget(fd); struct file *file = fget(fd);
@@ -665,6 +720,9 @@ static void try_wake_any_obj(struct ntsync_obj *obj) @@ -689,6 +744,9 @@ static void try_wake_any_obj(struct ntsync_obj *obj)
case NTSYNC_TYPE_MUTEX: case NTSYNC_TYPE_MUTEX:
try_wake_any_mutex(obj); try_wake_any_mutex(obj);
break; break;
@ -136,7 +127,7 @@ index aadf01c65ca0..c719ddd9f6d7 100644
} }
} }
@@ -857,6 +915,8 @@ static long ntsync_char_ioctl(struct file *file, unsigned int cmd, @@ -877,6 +935,8 @@ static long ntsync_char_ioctl(struct file *file, unsigned int cmd,
void __user *argp = (void __user *)parm; void __user *argp = (void __user *)parm;
switch (cmd) { switch (cmd) {
@ -146,7 +137,7 @@ index aadf01c65ca0..c719ddd9f6d7 100644
return ntsync_create_mutex(dev, argp); return ntsync_create_mutex(dev, argp);
case NTSYNC_IOC_CREATE_SEM: case NTSYNC_IOC_CREATE_SEM:
diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h
index 3861397c6c2f..b8cf503365ef 100644 index 4800941fcbda..040cbdb39033 100644
--- a/include/uapi/linux/ntsync.h --- a/include/uapi/linux/ntsync.h
+++ b/include/uapi/linux/ntsync.h +++ b/include/uapi/linux/ntsync.h
@@ -22,6 +22,12 @@ struct ntsync_mutex_args { @@ -22,6 +22,12 @@ struct ntsync_mutex_args {
@ -172,4 +163,3 @@ index 3861397c6c2f..b8cf503365ef 100644
#define NTSYNC_IOC_MUTEX_UNLOCK _IOWR('N', 0x85, struct ntsync_mutex_args) #define NTSYNC_IOC_MUTEX_UNLOCK _IOWR('N', 0x85, struct ntsync_mutex_args)
-- --
2.43.0 2.43.0

View File

@ -1,12 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 10/29] ntsync: Introduce NTSYNC_IOC_EVENT_SET.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:37 -0600
Message-Id: <20240131021356.10322-11-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
This corresponds to the NT syscall NtSetEvent(). This corresponds to the NT syscall NtSetEvent().
This sets the event to the signaled state, and returns its previous state. This sets the event to the signaled state, and returns its previous state.
@ -18,10 +9,10 @@ Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
2 files changed, 38 insertions(+) 2 files changed, 38 insertions(+)
diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c
index c719ddd9f6d7..b2da50989953 100644 index 17dd47d06e0a..edfbf11cafe0 100644
--- a/drivers/misc/ntsync.c --- a/drivers/misc/ntsync.c
+++ b/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c
@@ -447,6 +447,41 @@ static int ntsync_mutex_kill(struct ntsync_obj *mutex, void __user *argp) @@ -469,6 +469,41 @@ static int ntsync_mutex_kill(struct ntsync_obj *mutex, void __user *argp)
return ret; return ret;
} }
@ -63,7 +54,7 @@ index c719ddd9f6d7..b2da50989953 100644
static int ntsync_obj_release(struct inode *inode, struct file *file) static int ntsync_obj_release(struct inode *inode, struct file *file)
{ {
struct ntsync_obj *obj = file->private_data; struct ntsync_obj *obj = file->private_data;
@@ -470,6 +505,8 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd, @@ -492,6 +527,8 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd,
return ntsync_mutex_unlock(obj, argp); return ntsync_mutex_unlock(obj, argp);
case NTSYNC_IOC_MUTEX_KILL: case NTSYNC_IOC_MUTEX_KILL:
return ntsync_mutex_kill(obj, argp); return ntsync_mutex_kill(obj, argp);
@ -73,7 +64,7 @@ index c719ddd9f6d7..b2da50989953 100644
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
} }
diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h
index b8cf503365ef..782057552483 100644 index 040cbdb39033..af518530bffd 100644
--- a/include/uapi/linux/ntsync.h --- a/include/uapi/linux/ntsync.h
+++ b/include/uapi/linux/ntsync.h +++ b/include/uapi/linux/ntsync.h
@@ -48,5 +48,6 @@ struct ntsync_wait_args { @@ -48,5 +48,6 @@ struct ntsync_wait_args {
@ -85,4 +76,3 @@ index b8cf503365ef..782057552483 100644
#endif #endif
-- --
2.43.0 2.43.0

View File

@ -1,12 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 11/29] ntsync: Introduce NTSYNC_IOC_EVENT_RESET.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:38 -0600
Message-Id: <20240131021356.10322-12-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
This corresponds to the NT syscall NtResetEvent(). This corresponds to the NT syscall NtResetEvent().
This sets the event to the unsignaled state, and returns its previous state. This sets the event to the unsignaled state, and returns its previous state.
@ -18,10 +9,10 @@ Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
2 files changed, 23 insertions(+) 2 files changed, 23 insertions(+)
diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c
index b2da50989953..009d927739b8 100644 index edfbf11cafe0..fa4c3fa1e496 100644
--- a/drivers/misc/ntsync.c --- a/drivers/misc/ntsync.c
+++ b/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c
@@ -482,6 +482,26 @@ static int ntsync_event_set(struct ntsync_obj *event, void __user *argp) @@ -504,6 +504,26 @@ static int ntsync_event_set(struct ntsync_obj *event, void __user *argp)
return 0; return 0;
} }
@ -48,7 +39,7 @@ index b2da50989953..009d927739b8 100644
static int ntsync_obj_release(struct inode *inode, struct file *file) static int ntsync_obj_release(struct inode *inode, struct file *file)
{ {
struct ntsync_obj *obj = file->private_data; struct ntsync_obj *obj = file->private_data;
@@ -507,6 +527,8 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd, @@ -529,6 +549,8 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd,
return ntsync_mutex_kill(obj, argp); return ntsync_mutex_kill(obj, argp);
case NTSYNC_IOC_EVENT_SET: case NTSYNC_IOC_EVENT_SET:
return ntsync_event_set(obj, argp); return ntsync_event_set(obj, argp);
@ -58,7 +49,7 @@ index b2da50989953..009d927739b8 100644
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
} }
diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h
index 782057552483..f2d7507d8438 100644 index af518530bffd..6963356ee3f7 100644
--- a/include/uapi/linux/ntsync.h --- a/include/uapi/linux/ntsync.h
+++ b/include/uapi/linux/ntsync.h +++ b/include/uapi/linux/ntsync.h
@@ -49,5 +49,6 @@ struct ntsync_wait_args { @@ -49,5 +49,6 @@ struct ntsync_wait_args {
@ -70,4 +61,3 @@ index 782057552483..f2d7507d8438 100644
#endif #endif
-- --
2.43.0 2.43.0

View File

@ -1,12 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 12/29] ntsync: Introduce NTSYNC_IOC_EVENT_PULSE.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:39 -0600
Message-Id: <20240131021356.10322-13-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
This corresponds to the NT syscall NtPulseEvent(). This corresponds to the NT syscall NtPulseEvent().
This wakes up any waiters as if the event had been set, but does not set the This wakes up any waiters as if the event had been set, but does not set the
@ -21,10 +12,10 @@ Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
2 files changed, 9 insertions(+), 2 deletions(-) 2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c
index 009d927739b8..240ae858fa96 100644 index fa4c3fa1e496..b9b4127a6c9f 100644
--- a/drivers/misc/ntsync.c --- a/drivers/misc/ntsync.c
+++ b/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c
@@ -447,7 +447,7 @@ static int ntsync_mutex_kill(struct ntsync_obj *mutex, void __user *argp) @@ -469,7 +469,7 @@ static int ntsync_mutex_kill(struct ntsync_obj *mutex, void __user *argp)
return ret; return ret;
} }
@ -33,7 +24,7 @@ index 009d927739b8..240ae858fa96 100644
{ {
struct ntsync_device *dev = event->dev; struct ntsync_device *dev = event->dev;
__u32 prev_state; __u32 prev_state;
@@ -463,6 +463,8 @@ static int ntsync_event_set(struct ntsync_obj *event, void __user *argp) @@ -485,6 +485,8 @@ static int ntsync_event_set(struct ntsync_obj *event, void __user *argp)
event->u.event.signaled = true; event->u.event.signaled = true;
try_wake_all_obj(dev, event); try_wake_all_obj(dev, event);
try_wake_any_event(event); try_wake_any_event(event);
@ -42,7 +33,7 @@ index 009d927739b8..240ae858fa96 100644
spin_unlock(&event->lock); spin_unlock(&event->lock);
spin_unlock(&dev->wait_all_lock); spin_unlock(&dev->wait_all_lock);
@@ -472,6 +474,8 @@ static int ntsync_event_set(struct ntsync_obj *event, void __user *argp) @@ -494,6 +496,8 @@ static int ntsync_event_set(struct ntsync_obj *event, void __user *argp)
prev_state = event->u.event.signaled; prev_state = event->u.event.signaled;
event->u.event.signaled = true; event->u.event.signaled = true;
try_wake_any_event(event); try_wake_any_event(event);
@ -51,7 +42,7 @@ index 009d927739b8..240ae858fa96 100644
spin_unlock(&event->lock); spin_unlock(&event->lock);
} }
@@ -526,9 +530,11 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd, @@ -548,9 +552,11 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd,
case NTSYNC_IOC_MUTEX_KILL: case NTSYNC_IOC_MUTEX_KILL:
return ntsync_mutex_kill(obj, argp); return ntsync_mutex_kill(obj, argp);
case NTSYNC_IOC_EVENT_SET: case NTSYNC_IOC_EVENT_SET:
@ -65,7 +56,7 @@ index 009d927739b8..240ae858fa96 100644
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
} }
diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h
index f2d7507d8438..598f894f868d 100644 index 6963356ee3f7..72047f36c45d 100644
--- a/include/uapi/linux/ntsync.h --- a/include/uapi/linux/ntsync.h
+++ b/include/uapi/linux/ntsync.h +++ b/include/uapi/linux/ntsync.h
@@ -50,5 +50,6 @@ struct ntsync_wait_args { @@ -50,5 +50,6 @@ struct ntsync_wait_args {
@ -77,4 +68,3 @@ index f2d7507d8438..598f894f868d 100644
#endif #endif
-- --
2.43.0 2.43.0

View File

@ -1,12 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 13/29] ntsync: Introduce NTSYNC_IOC_SEM_READ.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:40 -0600
Message-Id: <20240131021356.10322-14-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
This corresponds to the NT syscall NtQuerySemaphore(). This corresponds to the NT syscall NtQuerySemaphore().
This returns the current count and maximum count of the semaphore. This returns the current count and maximum count of the semaphore.
@ -18,10 +9,10 @@ Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
2 files changed, 22 insertions(+) 2 files changed, 22 insertions(+)
diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c
index 240ae858fa96..6dccfbfb2512 100644 index b9b4127a6c9f..0daaeeeba051 100644
--- a/drivers/misc/ntsync.c --- a/drivers/misc/ntsync.c
+++ b/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c
@@ -506,6 +506,25 @@ static int ntsync_event_reset(struct ntsync_obj *event, void __user *argp) @@ -528,6 +528,25 @@ static int ntsync_event_reset(struct ntsync_obj *event, void __user *argp)
return 0; return 0;
} }
@ -47,7 +38,7 @@ index 240ae858fa96..6dccfbfb2512 100644
static int ntsync_obj_release(struct inode *inode, struct file *file) static int ntsync_obj_release(struct inode *inode, struct file *file)
{ {
struct ntsync_obj *obj = file->private_data; struct ntsync_obj *obj = file->private_data;
@@ -525,6 +544,8 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd, @@ -547,6 +566,8 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd,
switch (cmd) { switch (cmd) {
case NTSYNC_IOC_SEM_POST: case NTSYNC_IOC_SEM_POST:
return ntsync_sem_post(obj, argp); return ntsync_sem_post(obj, argp);
@ -57,7 +48,7 @@ index 240ae858fa96..6dccfbfb2512 100644
return ntsync_mutex_unlock(obj, argp); return ntsync_mutex_unlock(obj, argp);
case NTSYNC_IOC_MUTEX_KILL: case NTSYNC_IOC_MUTEX_KILL:
diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h
index 598f894f868d..6017f621687e 100644 index 72047f36c45d..42f51dc4e57e 100644
--- a/include/uapi/linux/ntsync.h --- a/include/uapi/linux/ntsync.h
+++ b/include/uapi/linux/ntsync.h +++ b/include/uapi/linux/ntsync.h
@@ -51,5 +51,6 @@ struct ntsync_wait_args { @@ -51,5 +51,6 @@ struct ntsync_wait_args {
@ -69,4 +60,3 @@ index 598f894f868d..6017f621687e 100644
#endif #endif
-- --
2.43.0 2.43.0

View File

@ -1,12 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 14/29] ntsync: Introduce NTSYNC_IOC_MUTEX_READ.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:41 -0600
Message-Id: <20240131021356.10322-15-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
This corresponds to the NT syscall NtQueryMutant(). This corresponds to the NT syscall NtQueryMutant().
This returns the recursion count, owner, and abandoned state of the mutex. This returns the recursion count, owner, and abandoned state of the mutex.
@ -18,10 +9,10 @@ Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
2 files changed, 24 insertions(+) 2 files changed, 24 insertions(+)
diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c
index 6dccfbfb2512..7f5f96ec7c69 100644 index 0daaeeeba051..b07510035c1f 100644
--- a/drivers/misc/ntsync.c --- a/drivers/misc/ntsync.c
+++ b/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c
@@ -525,6 +525,27 @@ static int ntsync_sem_read(struct ntsync_obj *sem, void __user *argp) @@ -547,6 +547,27 @@ static int ntsync_sem_read(struct ntsync_obj *sem, void __user *argp)
return 0; return 0;
} }
@ -49,7 +40,7 @@ index 6dccfbfb2512..7f5f96ec7c69 100644
static int ntsync_obj_release(struct inode *inode, struct file *file) static int ntsync_obj_release(struct inode *inode, struct file *file)
{ {
struct ntsync_obj *obj = file->private_data; struct ntsync_obj *obj = file->private_data;
@@ -550,6 +571,8 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd, @@ -572,6 +593,8 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd,
return ntsync_mutex_unlock(obj, argp); return ntsync_mutex_unlock(obj, argp);
case NTSYNC_IOC_MUTEX_KILL: case NTSYNC_IOC_MUTEX_KILL:
return ntsync_mutex_kill(obj, argp); return ntsync_mutex_kill(obj, argp);
@ -59,7 +50,7 @@ index 6dccfbfb2512..7f5f96ec7c69 100644
return ntsync_event_set(obj, argp, false); return ntsync_event_set(obj, argp, false);
case NTSYNC_IOC_EVENT_RESET: case NTSYNC_IOC_EVENT_RESET:
diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h
index 6017f621687e..a1d0ef581212 100644 index 42f51dc4e57e..25f3296cfabf 100644
--- a/include/uapi/linux/ntsync.h --- a/include/uapi/linux/ntsync.h
+++ b/include/uapi/linux/ntsync.h +++ b/include/uapi/linux/ntsync.h
@@ -52,5 +52,6 @@ struct ntsync_wait_args { @@ -52,5 +52,6 @@ struct ntsync_wait_args {
@ -71,4 +62,3 @@ index 6017f621687e..a1d0ef581212 100644
#endif #endif
-- --
2.43.0 2.43.0

View File

@ -1,12 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 15/29] ntsync: Introduce NTSYNC_IOC_EVENT_READ.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:42 -0600
Message-Id: <20240131021356.10322-16-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
This corresponds to the NT syscall NtQueryEvent(). This corresponds to the NT syscall NtQueryEvent().
This returns the signaled state of the event and whether it is manual-reset. This returns the signaled state of the event and whether it is manual-reset.
@ -18,10 +9,10 @@ Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
2 files changed, 22 insertions(+) 2 files changed, 22 insertions(+)
diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c
index 7f5f96ec7c69..5439c1c9e90f 100644 index b07510035c1f..981a1545192c 100644
--- a/drivers/misc/ntsync.c --- a/drivers/misc/ntsync.c
+++ b/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c
@@ -546,6 +546,25 @@ static int ntsync_mutex_read(struct ntsync_obj *mutex, void __user *argp) @@ -568,6 +568,25 @@ static int ntsync_mutex_read(struct ntsync_obj *mutex, void __user *argp)
return ret; return ret;
} }
@ -47,7 +38,7 @@ index 7f5f96ec7c69..5439c1c9e90f 100644
static int ntsync_obj_release(struct inode *inode, struct file *file) static int ntsync_obj_release(struct inode *inode, struct file *file)
{ {
struct ntsync_obj *obj = file->private_data; struct ntsync_obj *obj = file->private_data;
@@ -579,6 +598,8 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd, @@ -601,6 +620,8 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd,
return ntsync_event_reset(obj, argp); return ntsync_event_reset(obj, argp);
case NTSYNC_IOC_EVENT_PULSE: case NTSYNC_IOC_EVENT_PULSE:
return ntsync_event_set(obj, argp, true); return ntsync_event_set(obj, argp, true);
@ -57,7 +48,7 @@ index 7f5f96ec7c69..5439c1c9e90f 100644
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
} }
diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h
index a1d0ef581212..582d33b0dcac 100644 index 25f3296cfabf..03c95e5a398f 100644
--- a/include/uapi/linux/ntsync.h --- a/include/uapi/linux/ntsync.h
+++ b/include/uapi/linux/ntsync.h +++ b/include/uapi/linux/ntsync.h
@@ -53,5 +53,6 @@ struct ntsync_wait_args { @@ -53,5 +53,6 @@ struct ntsync_wait_args {
@ -69,4 +60,3 @@ index a1d0ef581212..582d33b0dcac 100644
#endif #endif
-- --
2.43.0 2.43.0

View File

@ -1,12 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 16/29] ntsync: Introduce alertable waits.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:43 -0600
Message-Id: <20240131021356.10322-17-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
NT waits can optionally be made "alertable". This is a special channel for NT waits can optionally be made "alertable". This is a special channel for
thread wakeup that is mildly similar to SIGIO. A thread has an internal single thread wakeup that is mildly similar to SIGIO. A thread has an internal single
bit of "alerted" state, and if a thread is made alerted while an alertable wait, bit of "alerted" state, and if a thread is made alerted while an alertable wait,
@ -24,10 +15,10 @@ Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
2 files changed, 60 insertions(+), 10 deletions(-) 2 files changed, 60 insertions(+), 10 deletions(-)
diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c
index 5439c1c9e90f..1e619e1ce6a6 100644 index 981a1545192c..0055b4671808 100644
--- a/drivers/misc/ntsync.c --- a/drivers/misc/ntsync.c
+++ b/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c
@@ -784,22 +784,29 @@ static int setup_wait(struct ntsync_device *dev, @@ -808,22 +808,29 @@ static int setup_wait(struct ntsync_device *dev,
const struct ntsync_wait_args *args, bool all, const struct ntsync_wait_args *args, bool all,
struct ntsync_q **ret_q) struct ntsync_q **ret_q)
{ {
@ -60,7 +51,7 @@ index 5439c1c9e90f..1e619e1ce6a6 100644
if (!q) if (!q)
return -ENOMEM; return -ENOMEM;
q->task = current; q->task = current;
@@ -809,7 +816,7 @@ static int setup_wait(struct ntsync_device *dev, @@ -833,7 +840,7 @@ static int setup_wait(struct ntsync_device *dev,
q->ownerdead = false; q->ownerdead = false;
q->count = count; q->count = count;
@ -69,18 +60,18 @@ index 5439c1c9e90f..1e619e1ce6a6 100644
struct ntsync_q_entry *entry = &q->entries[i]; struct ntsync_q_entry *entry = &q->entries[i];
struct ntsync_obj *obj = get_obj(dev, fds[i]); struct ntsync_obj *obj = get_obj(dev, fds[i]);
@@ -860,9 +867,9 @@ static int ntsync_wait_any(struct ntsync_device *dev, void __user *argp) @@ -883,9 +890,9 @@ static void try_wake_any_obj(struct ntsync_obj *obj)
static int ntsync_wait_any(struct ntsync_device *dev, void __user *argp)
{ {
struct ntsync_wait_args args; struct ntsync_wait_args args;
struct ntsync_q *q;
+ __u32 i, total_count; + __u32 i, total_count;
ktime_t timeout; struct ntsync_q *q;
int signaled; int signaled;
- __u32 i; - __u32 i;
int ret; int ret;
if (copy_from_user(&args, argp, sizeof(args))) if (copy_from_user(&args, argp, sizeof(args)))
@@ -872,9 +879,13 @@ static int ntsync_wait_any(struct ntsync_device *dev, void __user *argp) @@ -895,9 +902,13 @@ static int ntsync_wait_any(struct ntsync_device *dev, void __user *argp)
if (ret < 0) if (ret < 0)
return ret; return ret;
@ -95,7 +86,7 @@ index 5439c1c9e90f..1e619e1ce6a6 100644
struct ntsync_q_entry *entry = &q->entries[i]; struct ntsync_q_entry *entry = &q->entries[i];
struct ntsync_obj *obj = entry->obj; struct ntsync_obj *obj = entry->obj;
@@ -883,9 +894,15 @@ static int ntsync_wait_any(struct ntsync_device *dev, void __user *argp) @@ -906,9 +917,15 @@ static int ntsync_wait_any(struct ntsync_device *dev, void __user *argp)
spin_unlock(&obj->lock); spin_unlock(&obj->lock);
} }
@ -113,7 +104,7 @@ index 5439c1c9e90f..1e619e1ce6a6 100644
struct ntsync_obj *obj = q->entries[i].obj; struct ntsync_obj *obj = q->entries[i].obj;
if (atomic_read(&q->signaled) != -1) if (atomic_read(&q->signaled) != -1)
@@ -903,7 +920,7 @@ static int ntsync_wait_any(struct ntsync_device *dev, void __user *argp) @@ -925,7 +942,7 @@ static int ntsync_wait_any(struct ntsync_device *dev, void __user *argp)
/* and finally, unqueue */ /* and finally, unqueue */
@ -122,7 +113,7 @@ index 5439c1c9e90f..1e619e1ce6a6 100644
struct ntsync_q_entry *entry = &q->entries[i]; struct ntsync_q_entry *entry = &q->entries[i];
struct ntsync_obj *obj = entry->obj; struct ntsync_obj *obj = entry->obj;
@@ -964,6 +981,14 @@ static int ntsync_wait_all(struct ntsync_device *dev, void __user *argp) @@ -985,6 +1002,14 @@ static int ntsync_wait_all(struct ntsync_device *dev, void __user *argp)
*/ */
list_add_tail(&entry->node, &obj->all_waiters); list_add_tail(&entry->node, &obj->all_waiters);
} }
@ -137,7 +128,7 @@ index 5439c1c9e90f..1e619e1ce6a6 100644
/* check if we are already signaled */ /* check if we are already signaled */
@@ -971,6 +996,21 @@ static int ntsync_wait_all(struct ntsync_device *dev, void __user *argp) @@ -992,6 +1017,21 @@ static int ntsync_wait_all(struct ntsync_device *dev, void __user *argp)
spin_unlock(&dev->wait_all_lock); spin_unlock(&dev->wait_all_lock);
@ -158,8 +149,8 @@ index 5439c1c9e90f..1e619e1ce6a6 100644
+ +
/* sleep */ /* sleep */
timeout = ns_to_ktime(args.timeout); ret = ntsync_schedule(q, &args);
@@ -994,6 +1034,16 @@ static int ntsync_wait_all(struct ntsync_device *dev, void __user *argp) @@ -1014,6 +1054,16 @@ static int ntsync_wait_all(struct ntsync_device *dev, void __user *argp)
put_obj(obj); put_obj(obj);
} }
@ -177,7 +168,7 @@ index 5439c1c9e90f..1e619e1ce6a6 100644
spin_unlock(&dev->wait_all_lock); spin_unlock(&dev->wait_all_lock);
diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h
index 582d33b0dcac..7c91af7011e4 100644 index 03c95e5a398f..555ae81b479a 100644
--- a/include/uapi/linux/ntsync.h --- a/include/uapi/linux/ntsync.h
+++ b/include/uapi/linux/ntsync.h +++ b/include/uapi/linux/ntsync.h
@@ -34,7 +34,7 @@ struct ntsync_wait_args { @@ -34,7 +34,7 @@ struct ntsync_wait_args {
@ -191,4 +182,3 @@ index 582d33b0dcac..7c91af7011e4 100644
#define NTSYNC_MAX_WAIT_COUNT 64 #define NTSYNC_MAX_WAIT_COUNT 64
-- --
2.43.0 2.43.0

View File

@ -0,0 +1,79 @@
NtWaitForMultipleObjects() can receive a timeout in two forms, relative or
absolute. Relative timeouts are unaffected by changes to the system time and do
not count down while the system suspends; for absolute timeouts the opposite is
true.
In order to make the interface and implementation simpler, the ntsync driver
only deals in absolute timeouts. However, we need to be able to emulate both
behaviours apropos suspension and time adjustment, which is achieved by allowing
either the MONOTONIC or REALTIME clock to be used.
Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
---
drivers/misc/ntsync.c | 9 ++++++++-
include/uapi/linux/ntsync.h | 4 ++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c
index 0055b4671808..f54c81dada3d 100644
--- a/drivers/misc/ntsync.c
+++ b/drivers/misc/ntsync.c
@@ -778,11 +778,15 @@ static void put_obj(struct ntsync_obj *obj)
static int ntsync_schedule(const struct ntsync_q *q, const struct ntsync_wait_args *args)
{
ktime_t timeout = ns_to_ktime(args->timeout);
+ clockid_t clock = CLOCK_MONOTONIC;
ktime_t *timeout_ptr;
int ret = 0;
timeout_ptr = (args->timeout == U64_MAX ? NULL : &timeout);
+ if (args->flags & NTSYNC_WAIT_REALTIME)
+ clock = CLOCK_REALTIME;
+
do {
if (signal_pending(current)) {
ret = -ERESTARTSYS;
@@ -794,7 +798,7 @@ static int ntsync_schedule(const struct ntsync_q *q, const struct ntsync_wait_ar
ret = 0;
break;
}
- ret = schedule_hrtimeout(timeout_ptr, HRTIMER_MODE_ABS);
+ ret = schedule_hrtimeout_range_clock(timeout_ptr, 0, HRTIMER_MODE_ABS, clock);
} while (ret < 0);
__set_current_state(TASK_RUNNING);
@@ -817,6 +821,9 @@ static int setup_wait(struct ntsync_device *dev,
if (!args->owner)
return -EINVAL;
+ if (args->pad || (args->flags & ~NTSYNC_WAIT_REALTIME))
+ return -EINVAL;
+
if (args->count > NTSYNC_MAX_WAIT_COUNT)
return -EINVAL;
diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h
index 555ae81b479a..b5e835d8dba8 100644
--- a/include/uapi/linux/ntsync.h
+++ b/include/uapi/linux/ntsync.h
@@ -28,6 +28,8 @@ struct ntsync_event_args {
__u32 signaled;
};
+#define NTSYNC_WAIT_REALTIME 0x1
+
struct ntsync_wait_args {
__u64 timeout;
__u64 objs;
@@ -35,6 +37,8 @@ struct ntsync_wait_args {
__u32 owner;
__u32 index;
__u32 alert;
+ __u32 flags;
+ __u32 pad;
};
#define NTSYNC_MAX_WAIT_COUNT 64
--
2.43.0

View File

@ -1,13 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 17/29] selftests: ntsync: Add some tests for
semaphore state.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:44 -0600
Message-Id: <20240131021356.10322-18-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Wine has tests for its synchronization primitives, but these are more accessible Wine has tests for its synchronization primitives, but these are more accessible
to kernel developers, and also allow us to test some edge cases that Wine does to kernel developers, and also allow us to test some edge cases that Wine does
not care about. not care about.
@ -20,8 +10,8 @@ Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
tools/testing/selftests/Makefile | 1 + tools/testing/selftests/Makefile | 1 +
.../testing/selftests/drivers/ntsync/Makefile | 8 + .../testing/selftests/drivers/ntsync/Makefile | 8 +
tools/testing/selftests/drivers/ntsync/config | 1 + tools/testing/selftests/drivers/ntsync/config | 1 +
.../testing/selftests/drivers/ntsync/ntsync.c | 143 ++++++++++++++++++ .../testing/selftests/drivers/ntsync/ntsync.c | 149 ++++++++++++++++++
4 files changed, 153 insertions(+) 4 files changed, 159 insertions(+)
create mode 100644 tools/testing/selftests/drivers/ntsync/Makefile create mode 100644 tools/testing/selftests/drivers/ntsync/Makefile
create mode 100644 tools/testing/selftests/drivers/ntsync/config create mode 100644 tools/testing/selftests/drivers/ntsync/config
create mode 100644 tools/testing/selftests/drivers/ntsync/ntsync.c create mode 100644 tools/testing/selftests/drivers/ntsync/ntsync.c
@ -61,15 +51,15 @@ index 000000000000..60539c826d06
+CONFIG_WINESYNC=y +CONFIG_WINESYNC=y
diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c
new file mode 100644 new file mode 100644
index 000000000000..6ceb48fb42e3 index 000000000000..1e145c6dfded
--- /dev/null --- /dev/null
+++ b/tools/testing/selftests/drivers/ntsync/ntsync.c +++ b/tools/testing/selftests/drivers/ntsync/ntsync.c
@@ -0,0 +1,143 @@ @@ -0,0 +1,149 @@
+// SPDX-License-Identifier: GPL-2.0-or-later +// SPDX-License-Identifier: GPL-2.0-or-later
+/* +/*
+ * Various unit tests for the "ntsync" synchronization primitive driver. + * Various unit tests for the "ntsync" synchronization primitive driver.
+ * + *
+ * Copyright (C) 2021-2022 Elizabeth Figura + * Copyright (C) 2021-2022 Elizabeth Figura <zfigura@codeweavers.com>
+ */ + */
+ +
+#define _GNU_SOURCE +#define _GNU_SOURCE
@ -202,6 +192,12 @@ index 000000000000..6ceb48fb42e3
+ EXPECT_EQ(0, count); + EXPECT_EQ(0, count);
+ check_sem_state(sem, 1, 2); + check_sem_state(sem, 1, 2);
+ +
+ count = ~0u;
+ ret = post_sem(sem, &count);
+ EXPECT_EQ(-1, ret);
+ EXPECT_EQ(EOVERFLOW, errno);
+ check_sem_state(sem, 1, 2);
+
+ close(sem); + close(sem);
+ +
+ close(fd); + close(fd);
@ -210,4 +206,3 @@ index 000000000000..6ceb48fb42e3
+TEST_HARNESS_MAIN +TEST_HARNESS_MAIN
-- --
2.43.0 2.43.0

View File

@ -1,23 +1,13 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 18/29] selftests: ntsync: Add some tests for mutex
state.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:45 -0600
Message-Id: <20240131021356.10322-19-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Test mutex-specific ioctls NTSYNC_IOC_MUTEX_UNLOCK and NTSYNC_IOC_MUTEX_READ, Test mutex-specific ioctls NTSYNC_IOC_MUTEX_UNLOCK and NTSYNC_IOC_MUTEX_READ,
and waiting on mutexes. and waiting on mutexes.
Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com> Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
--- ---
.../testing/selftests/drivers/ntsync/ntsync.c | 181 ++++++++++++++++++ .../testing/selftests/drivers/ntsync/ntsync.c | 196 ++++++++++++++++++
1 file changed, 181 insertions(+) 1 file changed, 196 insertions(+)
diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c
index 6ceb48fb42e3..80c8bd409d68 100644 index 1e145c6dfded..7cd0f40594fd 100644
--- a/tools/testing/selftests/drivers/ntsync/ntsync.c --- a/tools/testing/selftests/drivers/ntsync/ntsync.c
+++ b/tools/testing/selftests/drivers/ntsync/ntsync.c +++ b/tools/testing/selftests/drivers/ntsync/ntsync.c
@@ -40,6 +40,39 @@ static int post_sem(int sem, __u32 *count) @@ -40,6 +40,39 @@ static int post_sem(int sem, __u32 *count)
@ -60,7 +50,7 @@ index 6ceb48fb42e3..80c8bd409d68 100644
static int wait_any(int fd, __u32 count, const int *objs, __u32 owner, __u32 *index) static int wait_any(int fd, __u32 count, const int *objs, __u32 owner, __u32 *index)
{ {
struct ntsync_wait_args args = {0}; struct ntsync_wait_args args = {0};
@@ -140,4 +173,152 @@ TEST(semaphore_state) @@ -146,4 +179,167 @@ TEST(semaphore_state)
close(fd); close(fd);
} }
@ -209,10 +199,24 @@ index 6ceb48fb42e3..80c8bd409d68 100644
+ +
+ close(mutex); + close(mutex);
+ +
+ mutex_args.owner = 123;
+ mutex_args.count = ~0u;
+ mutex_args.mutex = 0xdeadbeef;
+ ret = ioctl(fd, NTSYNC_IOC_CREATE_MUTEX, &mutex_args);
+ EXPECT_EQ(0, ret);
+ EXPECT_NE(0xdeadbeef, mutex_args.mutex);
+ mutex = mutex_args.mutex;
+ check_mutex_state(mutex, ~0u, 123);
+
+ ret = wait_any(fd, 1, &mutex, 123, &index);
+ EXPECT_EQ(-1, ret);
+ EXPECT_EQ(ETIMEDOUT, errno);
+
+ close(mutex);
+
+ close(fd); + close(fd);
+} +}
+ +
TEST_HARNESS_MAIN TEST_HARNESS_MAIN
-- --
2.43.0 2.43.0

View File

@ -1,38 +1,27 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 19/29] selftests: ntsync: Add some tests for
NTSYNC_IOC_WAIT_ANY.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:46 -0600
Message-Id: <20240131021356.10322-20-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Test basic synchronous functionality of NTSYNC_IOC_WAIT_ANY, when objects are Test basic synchronous functionality of NTSYNC_IOC_WAIT_ANY, when objects are
considered signaled or not signaled, and how they are affected by a successful considered signaled or not signaled, and how they are affected by a successful
wait. wait.
Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com> Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
--- ---
.../testing/selftests/drivers/ntsync/ntsync.c | 105 ++++++++++++++++++ .../testing/selftests/drivers/ntsync/ntsync.c | 119 ++++++++++++++++++
1 file changed, 105 insertions(+) 1 file changed, 119 insertions(+)
diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c
index 80c8bd409d68..13e7c9d7441e 100644 index 7cd0f40594fd..40ad8cbd3138 100644
--- a/tools/testing/selftests/drivers/ntsync/ntsync.c --- a/tools/testing/selftests/drivers/ntsync/ntsync.c
+++ b/tools/testing/selftests/drivers/ntsync/ntsync.c +++ b/tools/testing/selftests/drivers/ntsync/ntsync.c
@@ -321,4 +321,109 @@ TEST(mutex_state) @@ -342,4 +342,123 @@ TEST(mutex_state)
close(fd); close(fd);
} }
+TEST(test_wait_any) +TEST(test_wait_any)
+{ +{
+ int objs[NTSYNC_MAX_WAIT_COUNT + 1], fd, ret;
+ struct ntsync_mutex_args mutex_args = {0}; + struct ntsync_mutex_args mutex_args = {0};
+ struct ntsync_wait_args wait_args = {0};
+ struct ntsync_sem_args sem_args = {0}; + struct ntsync_sem_args sem_args = {0};
+ __u32 owner, index, count; + __u32 owner, index, count, i;
+ struct timespec timeout; + struct timespec timeout;
+ int objs[2], fd, ret;
+ +
+ clock_gettime(CLOCK_MONOTONIC, &timeout); + clock_gettime(CLOCK_MONOTONIC, &timeout);
+ +
@ -117,13 +106,28 @@ index 80c8bd409d68..13e7c9d7441e 100644
+ objs[0] = objs[1] = sem_args.sem; + objs[0] = objs[1] = sem_args.sem;
+ ret = wait_any(fd, 2, objs, 456, &index); + ret = wait_any(fd, 2, objs, 456, &index);
+ EXPECT_EQ(0, ret); + EXPECT_EQ(0, ret);
+ EXPECT_EQ(0, wait_args.index); + EXPECT_EQ(0, index);
+ check_sem_state(sem_args.sem, 1, 3); + check_sem_state(sem_args.sem, 1, 3);
+ +
+ ret = wait_any(fd, 0, NULL, 456, &index); + ret = wait_any(fd, 0, NULL, 456, &index);
+ EXPECT_EQ(-1, ret); + EXPECT_EQ(-1, ret);
+ EXPECT_EQ(ETIMEDOUT, errno); + EXPECT_EQ(ETIMEDOUT, errno);
+ +
+ for (i = 0; i < NTSYNC_MAX_WAIT_COUNT + 1; ++i)
+ objs[i] = sem_args.sem;
+
+ ret = wait_any(fd, NTSYNC_MAX_WAIT_COUNT, objs, 123, &index);
+ EXPECT_EQ(0, ret);
+ EXPECT_EQ(0, index);
+
+ ret = wait_any(fd, NTSYNC_MAX_WAIT_COUNT + 1, objs, 123, &index);
+ EXPECT_EQ(-1, ret);
+ EXPECT_EQ(EINVAL, errno);
+
+ ret = wait_any(fd, -1, objs, 123, &index);
+ EXPECT_EQ(-1, ret);
+ EXPECT_EQ(EINVAL, errno);
+
+ close(sem_args.sem); + close(sem_args.sem);
+ close(mutex_args.mutex); + close(mutex_args.mutex);
+ +
@ -133,4 +137,3 @@ index 80c8bd409d68..13e7c9d7441e 100644
TEST_HARNESS_MAIN TEST_HARNESS_MAIN
-- --
2.43.0 2.43.0

View File

@ -1,13 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 20/29] selftests: ntsync: Add some tests for
NTSYNC_IOC_WAIT_ALL.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:47 -0600
Message-Id: <20240131021356.10322-21-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Test basic synchronous functionality of NTSYNC_IOC_WAIT_ALL, and when objects Test basic synchronous functionality of NTSYNC_IOC_WAIT_ALL, and when objects
are considered simultaneously signaled. are considered simultaneously signaled.
@ -17,7 +7,7 @@ Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
1 file changed, 97 insertions(+), 2 deletions(-) 1 file changed, 97 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c
index 13e7c9d7441e..77f1b7e42d76 100644 index 40ad8cbd3138..c0f372167557 100644
--- a/tools/testing/selftests/drivers/ntsync/ntsync.c --- a/tools/testing/selftests/drivers/ntsync/ntsync.c
+++ b/tools/testing/selftests/drivers/ntsync/ntsync.c +++ b/tools/testing/selftests/drivers/ntsync/ntsync.c
@@ -73,7 +73,8 @@ static int unlock_mutex(int mutex, __u32 owner, __u32 *count) @@ -73,7 +73,8 @@ static int unlock_mutex(int mutex, __u32 owner, __u32 *count)
@ -53,7 +43,7 @@ index 13e7c9d7441e..77f1b7e42d76 100644
TEST(semaphore_state) TEST(semaphore_state)
{ {
struct ntsync_sem_args sem_args; struct ntsync_sem_args sem_args;
@@ -426,4 +437,88 @@ TEST(test_wait_any) @@ -461,4 +472,88 @@ TEST(test_wait_any)
close(fd); close(fd);
} }
@ -144,4 +134,3 @@ index 13e7c9d7441e..77f1b7e42d76 100644
TEST_HARNESS_MAIN TEST_HARNESS_MAIN
-- --
2.43.0 2.43.0

View File

@ -1,37 +1,25 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 21/29] selftests: ntsync: Add some tests for wakeup
signaling with WINESYNC_IOC_WAIT_ANY.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:48 -0600
Message-Id: <20240131021356.10322-22-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Test contended "wait-for-any" waits, to make sure that scheduling and wakeup Test contended "wait-for-any" waits, to make sure that scheduling and wakeup
logic works correctly. logic works correctly.
Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com> Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
--- ---
.../testing/selftests/drivers/ntsync/ntsync.c | 152 ++++++++++++++++++ .../testing/selftests/drivers/ntsync/ntsync.c | 150 ++++++++++++++++++
1 file changed, 152 insertions(+) 1 file changed, 150 insertions(+)
diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c
index 77f1b7e42d76..96a866ef235f 100644 index c0f372167557..993f5db23768 100644
--- a/tools/testing/selftests/drivers/ntsync/ntsync.c --- a/tools/testing/selftests/drivers/ntsync/ntsync.c
+++ b/tools/testing/selftests/drivers/ntsync/ntsync.c +++ b/tools/testing/selftests/drivers/ntsync/ntsync.c
@@ -521,4 +521,156 @@ TEST(test_wait_all) @@ -556,4 +556,154 @@ TEST(test_wait_all)
close(fd); close(fd);
} }
+struct wake_args +struct wake_args {
+{
+ int fd; + int fd;
+ int obj; + int obj;
+}; +};
+ +
+struct wait_args +struct wait_args {
+{
+ int fd; + int fd;
+ unsigned long request; + unsigned long request;
+ struct ntsync_wait_args *args; + struct ntsync_wait_args *args;
@ -179,4 +167,3 @@ index 77f1b7e42d76..96a866ef235f 100644
TEST_HARNESS_MAIN TEST_HARNESS_MAIN
-- --
2.43.0 2.43.0

View File

@ -1,13 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 22/29] selftests: ntsync: Add some tests for wakeup
signaling with WINESYNC_IOC_WAIT_ALL.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:49 -0600
Message-Id: <20240131021356.10322-23-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Test contended "wait-for-all" waits, to make sure that scheduling and wakeup Test contended "wait-for-all" waits, to make sure that scheduling and wakeup
logic works correctly, and that the wait only exits once objects are all logic works correctly, and that the wait only exits once objects are all
simultaneously signaled. simultaneously signaled.
@ -18,10 +8,10 @@ Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
1 file changed, 98 insertions(+) 1 file changed, 98 insertions(+)
diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c
index 96a866ef235f..7776fe71b8ef 100644 index 993f5db23768..b77fb0b2c4b1 100644
--- a/tools/testing/selftests/drivers/ntsync/ntsync.c --- a/tools/testing/selftests/drivers/ntsync/ntsync.c
+++ b/tools/testing/selftests/drivers/ntsync/ntsync.c +++ b/tools/testing/selftests/drivers/ntsync/ntsync.c
@@ -673,4 +673,102 @@ TEST(wake_any) @@ -706,4 +706,102 @@ TEST(wake_any)
close(fd); close(fd);
} }
@ -126,4 +116,3 @@ index 96a866ef235f..7776fe71b8ef 100644
TEST_HARNESS_MAIN TEST_HARNESS_MAIN
-- --
2.43.0 2.43.0

View File

@ -1,13 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 23/29] selftests: ntsync: Add some tests for
manual-reset event state.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:50 -0600
Message-Id: <20240131021356.10322-24-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Test event-specific ioctls NTSYNC_IOC_EVENT_SET, NTSYNC_IOC_EVENT_RESET, Test event-specific ioctls NTSYNC_IOC_EVENT_SET, NTSYNC_IOC_EVENT_RESET,
NTSYNC_IOC_EVENT_PULSE, NTSYNC_IOC_EVENT_READ for manual-reset events, and NTSYNC_IOC_EVENT_PULSE, NTSYNC_IOC_EVENT_READ for manual-reset events, and
waiting on manual-reset events. waiting on manual-reset events.
@ -18,7 +8,7 @@ Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
1 file changed, 89 insertions(+) 1 file changed, 89 insertions(+)
diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c
index 7776fe71b8ef..98fc70a9a58b 100644 index b77fb0b2c4b1..b6481c2b85cc 100644
--- a/tools/testing/selftests/drivers/ntsync/ntsync.c --- a/tools/testing/selftests/drivers/ntsync/ntsync.c
+++ b/tools/testing/selftests/drivers/ntsync/ntsync.c +++ b/tools/testing/selftests/drivers/ntsync/ntsync.c
@@ -73,6 +73,27 @@ static int unlock_mutex(int mutex, __u32 owner, __u32 *count) @@ -73,6 +73,27 @@ static int unlock_mutex(int mutex, __u32 owner, __u32 *count)
@ -49,7 +39,7 @@ index 7776fe71b8ef..98fc70a9a58b 100644
static int wait_objs(int fd, unsigned long request, __u32 count, static int wait_objs(int fd, unsigned long request, __u32 count,
const int *objs, __u32 owner, __u32 *index) const int *objs, __u32 owner, __u32 *index)
{ {
@@ -332,6 +353,74 @@ TEST(mutex_state) @@ -353,6 +374,74 @@ TEST(mutex_state)
close(fd); close(fd);
} }
@ -123,7 +113,6 @@ index 7776fe71b8ef..98fc70a9a58b 100644
+ +
TEST(test_wait_any) TEST(test_wait_any)
{ {
struct ntsync_mutex_args mutex_args = {0}; int objs[NTSYNC_MAX_WAIT_COUNT + 1], fd, ret;
-- --
2.43.0 2.43.0

View File

@ -1,13 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 24/29] selftests: ntsync: Add some tests for
auto-reset event state.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:51 -0600
Message-Id: <20240131021356.10322-25-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Test event-specific ioctls NTSYNC_IOC_EVENT_SET, NTSYNC_IOC_EVENT_RESET, Test event-specific ioctls NTSYNC_IOC_EVENT_SET, NTSYNC_IOC_EVENT_RESET,
NTSYNC_IOC_EVENT_PULSE, NTSYNC_IOC_EVENT_READ for auto-reset events, and NTSYNC_IOC_EVENT_PULSE, NTSYNC_IOC_EVENT_READ for auto-reset events, and
waiting on auto-reset events. waiting on auto-reset events.
@ -18,10 +8,10 @@ Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
1 file changed, 59 insertions(+) 1 file changed, 59 insertions(+)
diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c
index 98fc70a9a58b..f1fb28949367 100644 index b6481c2b85cc..12ccb4ec28e4 100644
--- a/tools/testing/selftests/drivers/ntsync/ntsync.c --- a/tools/testing/selftests/drivers/ntsync/ntsync.c
+++ b/tools/testing/selftests/drivers/ntsync/ntsync.c +++ b/tools/testing/selftests/drivers/ntsync/ntsync.c
@@ -421,6 +421,65 @@ TEST(manual_event_state) @@ -442,6 +442,65 @@ TEST(manual_event_state)
close(fd); close(fd);
} }
@ -86,7 +76,6 @@ index 98fc70a9a58b..f1fb28949367 100644
+ +
TEST(test_wait_any) TEST(test_wait_any)
{ {
struct ntsync_mutex_args mutex_args = {0}; int objs[NTSYNC_MAX_WAIT_COUNT + 1], fd, ret;
-- --
2.43.0 2.43.0

View File

@ -1,13 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 25/29] selftests: ntsync: Add some tests for wakeup
signaling with events.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:52 -0600
Message-Id: <20240131021356.10322-26-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Expand the contended wait tests, which previously only covered events and Expand the contended wait tests, which previously only covered events and
semaphores, to cover events as well. semaphores, to cover events as well.
@ -17,10 +7,10 @@ Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
1 file changed, 147 insertions(+), 4 deletions(-) 1 file changed, 147 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c
index f1fb28949367..598333df3e6d 100644 index 12ccb4ec28e4..5d17eff6a370 100644
--- a/tools/testing/selftests/drivers/ntsync/ntsync.c --- a/tools/testing/selftests/drivers/ntsync/ntsync.c
+++ b/tools/testing/selftests/drivers/ntsync/ntsync.c +++ b/tools/testing/selftests/drivers/ntsync/ntsync.c
@@ -587,6 +587,7 @@ TEST(test_wait_any) @@ -622,6 +622,7 @@ TEST(test_wait_any)
TEST(test_wait_all) TEST(test_wait_all)
{ {
@ -28,7 +18,7 @@ index f1fb28949367..598333df3e6d 100644
struct ntsync_mutex_args mutex_args = {0}; struct ntsync_mutex_args mutex_args = {0};
struct ntsync_sem_args sem_args = {0}; struct ntsync_sem_args sem_args = {0};
__u32 owner, index, count; __u32 owner, index, count;
@@ -609,6 +610,11 @@ TEST(test_wait_all) @@ -644,6 +645,11 @@ TEST(test_wait_all)
EXPECT_EQ(0, ret); EXPECT_EQ(0, ret);
EXPECT_NE(0xdeadbeef, mutex_args.mutex); EXPECT_NE(0xdeadbeef, mutex_args.mutex);
@ -40,7 +30,7 @@ index f1fb28949367..598333df3e6d 100644
objs[0] = sem_args.sem; objs[0] = sem_args.sem;
objs[1] = mutex_args.mutex; objs[1] = mutex_args.mutex;
@@ -657,6 +663,14 @@ TEST(test_wait_all) @@ -692,6 +698,14 @@ TEST(test_wait_all)
check_sem_state(sem_args.sem, 1, 3); check_sem_state(sem_args.sem, 1, 3);
check_mutex_state(mutex_args.mutex, 1, 123); check_mutex_state(mutex_args.mutex, 1, 123);
@ -55,7 +45,7 @@ index f1fb28949367..598333df3e6d 100644
/* test waiting on the same object twice */ /* test waiting on the same object twice */
objs[0] = objs[1] = sem_args.sem; objs[0] = objs[1] = sem_args.sem;
ret = wait_all(fd, 2, objs, 123, &index); ret = wait_all(fd, 2, objs, 123, &index);
@@ -665,6 +679,7 @@ TEST(test_wait_all) @@ -700,6 +714,7 @@ TEST(test_wait_all)
close(sem_args.sem); close(sem_args.sem);
close(mutex_args.mutex); close(mutex_args.mutex);
@ -63,7 +53,7 @@ index f1fb28949367..598333df3e6d 100644
close(fd); close(fd);
} }
@@ -713,12 +728,13 @@ static int wait_for_thread(pthread_t thread, unsigned int ms) @@ -746,12 +761,13 @@ static int wait_for_thread(pthread_t thread, unsigned int ms)
TEST(wake_any) TEST(wake_any)
{ {
@ -78,7 +68,7 @@ index f1fb28949367..598333df3e6d 100644
pthread_t thread; pthread_t thread;
fd = open("/dev/ntsync", O_CLOEXEC | O_RDONLY); fd = open("/dev/ntsync", O_CLOEXEC | O_RDONLY);
@@ -800,10 +816,101 @@ TEST(wake_any) @@ -833,10 +849,101 @@ TEST(wake_any)
EXPECT_EQ(0, thread_args.ret); EXPECT_EQ(0, thread_args.ret);
EXPECT_EQ(1, wait_args.index); EXPECT_EQ(1, wait_args.index);
@ -180,7 +170,7 @@ index f1fb28949367..598333df3e6d 100644
ret = pthread_create(&thread, NULL, wait_thread, &thread_args); ret = pthread_create(&thread, NULL, wait_thread, &thread_args);
EXPECT_EQ(0, ret); EXPECT_EQ(0, ret);
@@ -823,12 +930,14 @@ TEST(wake_any) @@ -856,12 +963,14 @@ TEST(wake_any)
TEST(wake_all) TEST(wake_all)
{ {
@ -197,7 +187,7 @@ index f1fb28949367..598333df3e6d 100644
pthread_t thread; pthread_t thread;
fd = open("/dev/ntsync", O_CLOEXEC | O_RDONLY); fd = open("/dev/ntsync", O_CLOEXEC | O_RDONLY);
@@ -848,12 +957,24 @@ TEST(wake_all) @@ -881,12 +990,24 @@ TEST(wake_all)
EXPECT_EQ(0, ret); EXPECT_EQ(0, ret);
EXPECT_NE(0xdeadbeef, mutex_args.mutex); EXPECT_NE(0xdeadbeef, mutex_args.mutex);
@ -223,7 +213,7 @@ index f1fb28949367..598333df3e6d 100644
wait_args.owner = 456; wait_args.owner = 456;
thread_args.fd = fd; thread_args.fd = fd;
thread_args.args = &wait_args; thread_args.args = &wait_args;
@@ -887,12 +1008,32 @@ TEST(wake_all) @@ -920,12 +1041,32 @@ TEST(wake_all)
check_mutex_state(mutex_args.mutex, 0, 0); check_mutex_state(mutex_args.mutex, 0, 0);
@ -256,7 +246,7 @@ index f1fb28949367..598333df3e6d 100644
ret = wait_for_thread(thread, 100); ret = wait_for_thread(thread, 100);
EXPECT_EQ(0, ret); EXPECT_EQ(0, ret);
@@ -910,6 +1051,8 @@ TEST(wake_all) @@ -943,6 +1084,8 @@ TEST(wake_all)
close(sem_args.sem); close(sem_args.sem);
close(mutex_args.mutex); close(mutex_args.mutex);
@ -267,4 +257,3 @@ index f1fb28949367..598333df3e6d 100644
EXPECT_EQ(0, ret); EXPECT_EQ(0, ret);
-- --
2.43.0 2.43.0

View File

@ -1,13 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 26/29] selftests: ntsync: Add tests for alertable
waits.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:53 -0600
Message-Id: <20240131021356.10322-27-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Test the "alert" functionality of NTSYNC_IOC_WAIT_ALL and NTSYNC_IOC_WAIT_ANY, Test the "alert" functionality of NTSYNC_IOC_WAIT_ALL and NTSYNC_IOC_WAIT_ANY,
when a wait is woken with an alert and when it is woken by an object. when a wait is woken with an alert and when it is woken by an object.
@ -17,7 +7,7 @@ Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
1 file changed, 176 insertions(+), 3 deletions(-) 1 file changed, 176 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c
index 598333df3e6d..6c00a55909aa 100644 index 5d17eff6a370..5465a16d38b3 100644
--- a/tools/testing/selftests/drivers/ntsync/ntsync.c --- a/tools/testing/selftests/drivers/ntsync/ntsync.c
+++ b/tools/testing/selftests/drivers/ntsync/ntsync.c +++ b/tools/testing/selftests/drivers/ntsync/ntsync.c
@@ -95,7 +95,7 @@ static int read_event_state(int event, __u32 *signaled, __u32 *manual) @@ -95,7 +95,7 @@ static int read_event_state(int event, __u32 *signaled, __u32 *manual)
@ -66,7 +56,7 @@ index 598333df3e6d..6c00a55909aa 100644
} }
TEST(semaphore_state) TEST(semaphore_state)
@@ -1062,4 +1077,162 @@ TEST(wake_all) @@ -1095,4 +1110,162 @@ TEST(wake_all)
close(fd); close(fd);
} }
@ -231,4 +221,3 @@ index 598333df3e6d..6c00a55909aa 100644
TEST_HARNESS_MAIN TEST_HARNESS_MAIN
-- --
2.43.0 2.43.0

View File

@ -1,13 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 27/29] selftests: ntsync: Add some tests for wakeup
signaling via alerts.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:54 -0600
Message-Id: <20240131021356.10322-28-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Expand the alert tests to cover alerting a thread mid-wait, to test that the Expand the alert tests to cover alerting a thread mid-wait, to test that the
relevant scheduling logic works correctly. relevant scheduling logic works correctly.
@ -17,10 +7,10 @@ Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
1 file changed, 62 insertions(+) 1 file changed, 62 insertions(+)
diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c
index 6c00a55909aa..09153d0686ac 100644 index 5465a16d38b3..968874d7e325 100644
--- a/tools/testing/selftests/drivers/ntsync/ntsync.c --- a/tools/testing/selftests/drivers/ntsync/ntsync.c
+++ b/tools/testing/selftests/drivers/ntsync/ntsync.c +++ b/tools/testing/selftests/drivers/ntsync/ntsync.c
@@ -1080,9 +1080,12 @@ TEST(wake_all) @@ -1113,9 +1113,12 @@ TEST(wake_all)
TEST(alert_any) TEST(alert_any)
{ {
struct ntsync_event_args event_args = {0}; struct ntsync_event_args event_args = {0};
@ -33,7 +23,7 @@ index 6c00a55909aa..09153d0686ac 100644
fd = open("/dev/ntsync", O_CLOEXEC | O_RDONLY); fd = open("/dev/ntsync", O_CLOEXEC | O_RDONLY);
ASSERT_LE(0, fd); ASSERT_LE(0, fd);
@@ -1130,6 +1133,34 @@ TEST(alert_any) @@ -1163,6 +1166,34 @@ TEST(alert_any)
EXPECT_EQ(0, ret); EXPECT_EQ(0, ret);
EXPECT_EQ(2, index); EXPECT_EQ(2, index);
@ -68,7 +58,7 @@ index 6c00a55909aa..09153d0686ac 100644
close(event_args.event); close(event_args.event);
/* test with an auto-reset event */ /* test with an auto-reset event */
@@ -1166,9 +1197,12 @@ TEST(alert_any) @@ -1199,9 +1230,12 @@ TEST(alert_any)
TEST(alert_all) TEST(alert_all)
{ {
struct ntsync_event_args event_args = {0}; struct ntsync_event_args event_args = {0};
@ -81,7 +71,7 @@ index 6c00a55909aa..09153d0686ac 100644
fd = open("/dev/ntsync", O_CLOEXEC | O_RDONLY); fd = open("/dev/ntsync", O_CLOEXEC | O_RDONLY);
ASSERT_LE(0, fd); ASSERT_LE(0, fd);
@@ -1202,6 +1236,34 @@ TEST(alert_all) @@ -1235,6 +1269,34 @@ TEST(alert_all)
EXPECT_EQ(0, ret); EXPECT_EQ(0, ret);
EXPECT_EQ(2, index); EXPECT_EQ(2, index);
@ -118,4 +108,3 @@ index 6c00a55909aa..09153d0686ac 100644
/* test with an auto-reset event */ /* test with an auto-reset event */
-- --
2.43.0 2.43.0

View File

@ -0,0 +1,97 @@
Test a more realistic usage pattern, and one with heavy contention, in order to
actually exercise ntsync's internal synchronization.
This test has several threads in a tight loop acquiring a mutex, modifying some
shared data, and then releasing the mutex. At the end we check if the data is
consistent.
Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
---
.../testing/selftests/drivers/ntsync/ntsync.c | 74 +++++++++++++++++++
1 file changed, 74 insertions(+)
diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c
index 968874d7e325..5fa2c9a0768c 100644
--- a/tools/testing/selftests/drivers/ntsync/ntsync.c
+++ b/tools/testing/selftests/drivers/ntsync/ntsync.c
@@ -1330,4 +1330,78 @@ TEST(alert_all)
close(fd);
}
+#define STRESS_LOOPS 10000
+#define STRESS_THREADS 4
+
+static unsigned int stress_counter;
+static int stress_device, stress_start_event, stress_mutex;
+
+static void *stress_thread(void *arg)
+{
+ struct ntsync_wait_args wait_args = {0};
+ __u32 index, count, i;
+ int ret;
+
+ wait_args.timeout = UINT64_MAX;
+ wait_args.count = 1;
+ wait_args.objs = (uintptr_t)&stress_start_event;
+ wait_args.owner = gettid();
+ wait_args.index = 0xdeadbeef;
+
+ ioctl(stress_device, NTSYNC_IOC_WAIT_ANY, &wait_args);
+
+ wait_args.objs = (uintptr_t)&stress_mutex;
+
+ for (i = 0; i < STRESS_LOOPS; ++i) {
+ ioctl(stress_device, NTSYNC_IOC_WAIT_ANY, &wait_args);
+
+ ++stress_counter;
+
+ unlock_mutex(stress_mutex, wait_args.owner, &count);
+ }
+
+ return NULL;
+}
+
+TEST(stress_wait)
+{
+ struct ntsync_event_args event_args;
+ struct ntsync_mutex_args mutex_args;
+ pthread_t threads[STRESS_THREADS];
+ __u32 signaled, i;
+ int ret;
+
+ stress_device = open("/dev/ntsync", O_CLOEXEC | O_RDONLY);
+ ASSERT_LE(0, stress_device);
+
+ mutex_args.owner = 0;
+ mutex_args.count = 0;
+ ret = ioctl(stress_device, NTSYNC_IOC_CREATE_MUTEX, &mutex_args);
+ EXPECT_EQ(0, ret);
+ stress_mutex = mutex_args.mutex;
+
+ event_args.manual = 1;
+ event_args.signaled = 0;
+ ret = ioctl(stress_device, NTSYNC_IOC_CREATE_EVENT, &event_args);
+ EXPECT_EQ(0, ret);
+ stress_start_event = event_args.event;
+
+ for (i = 0; i < STRESS_THREADS; ++i)
+ pthread_create(&threads[i], NULL, stress_thread, NULL);
+
+ ret = ioctl(stress_start_event, NTSYNC_IOC_EVENT_SET, &signaled);
+ EXPECT_EQ(0, ret);
+
+ for (i = 0; i < STRESS_THREADS; ++i) {
+ ret = pthread_join(threads[i], NULL);
+ EXPECT_EQ(0, ret);
+ }
+
+ EXPECT_EQ(STRESS_LOOPS * STRESS_THREADS, stress_counter);
+
+ close(stress_start_event);
+ close(stress_mutex);
+ close(stress_device);
+}
+
TEST_HARNESS_MAIN
--
2.43.0

View File

@ -1,12 +1,3 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH RFC v2 28/29] maintainers: Add an entry for ntsync.
From: Elizabeth Figura <zfigura@codeweavers.com>
Date: Tue, 30 Jan 2024 20:13:55 -0600
Message-Id: <20240131021356.10322-29-zfigura@codeweavers.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Add myself as maintainer, supported by CodeWeavers. Add myself as maintainer, supported by CodeWeavers.
Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com> Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
@ -15,10 +6,10 @@ Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
1 file changed, 9 insertions(+) 1 file changed, 9 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS diff --git a/MAINTAINERS b/MAINTAINERS
index 8d1052fa6a69..7924127d351b 100644 index 9ed4d3868539..d83dd35d9f73 100644
--- a/MAINTAINERS --- a/MAINTAINERS
+++ b/MAINTAINERS +++ b/MAINTAINERS
@@ -15585,6 +15585,15 @@ T: git https://github.com/Paragon-Software-Group/linux-ntfs3.git @@ -15595,6 +15595,15 @@ T: git https://github.com/Paragon-Software-Group/linux-ntfs3.git
F: Documentation/filesystems/ntfs3.rst F: Documentation/filesystems/ntfs3.rst
F: fs/ntfs3/ F: fs/ntfs3/
@ -36,4 +27,3 @@ index 8d1052fa6a69..7924127d351b 100644
L: linux-m68k@lists.linux-m68k.org L: linux-m68k@lists.linux-m68k.org
-- --
2.43.0 2.43.0

View File

@ -1,5 +1,5 @@
pkgname=linux6.7-zen pkgname=linux6.7-zen
version=6.7.5 version=6.7.6
revision=1 revision=1
zen=1 zen=1
python_version=3 python_version=3
@ -8,7 +8,7 @@ maintainer="Wizzard <retard@deadzone.lol>"
license="GPL-2.0-only" license="GPL-2.0-only"
homepage="https://github.com/zen-kernel/zen-kernel" homepage="https://github.com/zen-kernel/zen-kernel"
distfiles="https://github.com/zen-kernel/zen-kernel/archive/refs/tags/v${version}-zen${zen}.tar.gz" distfiles="https://github.com/zen-kernel/zen-kernel/archive/refs/tags/v${version}-zen${zen}.tar.gz"
checksum="6f4bb1b180880034269d539a47f3c120874f4923604976127f4ba9d8db0546dd" checksum="77cdaa148e8ff5660b7c0287f6f70a0c36e0355521456c6fc754948fbe101ceb"
archs="x86_64* i686* ppc* aarch64*" archs="x86_64* i686* ppc* aarch64*"
patch_args="-Np1" patch_args="-Np1"