Message ID | 20240219223833.95710-2-zfigura@codeweavers.com |
---|---|
State | Superseded |
Headers | show |
Series | NT synchronization primitive driver | expand |
Hi Elizabeth, On Mon, Feb 19, 2024 at 11:42 PM Elizabeth Figura <zfigura@codeweavers.com> wrote: > 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 > to correspond to a single NT virtual machine. > > Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com> Thanks for your patch! > --- a/drivers/misc/Kconfig > +++ b/drivers/misc/Kconfig > @@ -506,6 +506,17 @@ config OPEN_DICE > > If unsure, say N. > > +config NTSYNC > + tristate "NT synchronization primitive emulation" > + help > + This module provides kernel support for emulation of Windows NT > + synchronization primitives. It is not a hardware driver. > + > + To compile this driver as a module, choose M here: the > + module will be called ntsync. > + > + If unsure, say N. Is it useful to have this feature on systems or architectures that are not supported by Windows NT? If not, this should depend on <something> || COMPILE_TEST. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
On Thursday, 22 February 2024 04:56:21 CST Geert Uytterhoeven wrote: > > --- a/drivers/misc/Kconfig > > +++ b/drivers/misc/Kconfig > > @@ -506,6 +506,17 @@ config OPEN_DICE > > > > If unsure, say N. > > > > +config NTSYNC > > + tristate "NT synchronization primitive emulation" > > + help > > + This module provides kernel support for emulation of Windows NT > > + synchronization primitives. It is not a hardware driver. > > + > > + To compile this driver as a module, choose M here: the > > + module will be called ntsync. > > + > > + If unsure, say N. > > Is it useful to have this feature on systems or architectures that > are not supported by Windows NT? > > If not, this should depend on <something> || COMPILE_TEST. Hmm, that's an interesting question. Currently only Wine supports x86 and ARM, as the only architectures supported by modern Windows. On the other hand, that hasn't always been the case, and there's been some desire to use Wine (as a porting tool) on architectures that Windows doesn't support, and out-of-tree ports to e.g. PowerPC to that end. Perhaps more saliently, there's no reason I'm aware of that this code *can't* run on any architecture, and Wine (or another NT emulator) may grow support for more architectures in the future. I (with my limited experience) don't see a reason to artificially limit ourselves, especially if the driver is disabled by default. --Zeb
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 4fb291f0bf7c..801ed229ed7d 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -506,6 +506,17 @@ config OPEN_DICE If unsure, say N. +config NTSYNC + tristate "NT synchronization primitive emulation" + help + This module provides kernel support for emulation of Windows NT + synchronization primitives. It is not a hardware driver. + + To compile this driver as a module, choose M here: the + module will be called ntsync. + + If unsure, say N. + config VCPU_STALL_DETECTOR tristate "Guest vCPU stall detector" depends on OF && HAS_IOMEM diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index ea6ea5bbbc9c..153a3f4837e8 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -59,6 +59,7 @@ obj-$(CONFIG_PVPANIC) += pvpanic/ obj-$(CONFIG_UACCE) += uacce/ obj-$(CONFIG_XILINX_SDFEC) += xilinx_sdfec.o obj-$(CONFIG_HISI_HIKEY_USB) += hisi_hikey_usb.o +obj-$(CONFIG_NTSYNC) += ntsync.o obj-$(CONFIG_HI6421V600_IRQ) += hi6421v600-irq.o obj-$(CONFIG_OPEN_DICE) += open-dice.o obj-$(CONFIG_GP_PCI1XXXX) += mchp_pci1xxxx/ diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c new file mode 100644 index 000000000000..bd76e653d83e --- /dev/null +++ b/drivers/misc/ntsync.c @@ -0,0 +1,52 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * ntsync.c - Kernel driver for NT synchronization primitives + * + * Copyright (C) 2024 Elizabeth Figura <zfigura@codeweavers.com> + */ + +#include <linux/fs.h> +#include <linux/miscdevice.h> +#include <linux/module.h> + +#define NTSYNC_NAME "ntsync" + +static int ntsync_char_open(struct inode *inode, struct file *file) +{ + return nonseekable_open(inode, file); +} + +static int ntsync_char_release(struct inode *inode, struct file *file) +{ + return 0; +} + +static long ntsync_char_ioctl(struct file *file, unsigned int cmd, + unsigned long parm) +{ + switch (cmd) { + default: + return -ENOIOCTLCMD; + } +} + +static const struct file_operations ntsync_fops = { + .owner = THIS_MODULE, + .open = ntsync_char_open, + .release = ntsync_char_release, + .unlocked_ioctl = ntsync_char_ioctl, + .compat_ioctl = compat_ptr_ioctl, + .llseek = no_llseek, +}; + +static struct miscdevice ntsync_misc = { + .minor = MISC_DYNAMIC_MINOR, + .name = NTSYNC_NAME, + .fops = &ntsync_fops, +}; + +module_misc_device(ntsync_misc); + +MODULE_AUTHOR("Elizabeth Figura <zfigura@codeweavers.com>"); +MODULE_DESCRIPTION("Kernel driver for NT synchronization primitives"); +MODULE_LICENSE("GPL");
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 to correspond to a single NT virtual machine. Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com> --- drivers/misc/Kconfig | 11 +++++++++ drivers/misc/Makefile | 1 + drivers/misc/ntsync.c | 52 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 drivers/misc/ntsync.c