From patchwork Wed Jan 31 02:13:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elizabeth Figura X-Patchwork-Id: 194433 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1625547dyb; Tue, 30 Jan 2024 18:18:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IG75nYvipBe6h+8B0munfTpBB8CpN81SxtK0GG+7X7L1U2kGI/p2ZyG0e0+1o4yMuMKJyCq X-Received: by 2002:a05:6512:3e05:b0:50f:5e2:d50 with SMTP id i5-20020a0565123e0500b0050f05e20d50mr318170lfv.51.1706667482766; Tue, 30 Jan 2024 18:18:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706667482; cv=pass; d=google.com; s=arc-20160816; b=ePXibWVXyjkfcHjMqof0MHQ3bdKAyv1KJenxpfuGU1okj6t7v8hzQWtYySgSbqmmfy 1yrIOU89Xs1FBRlWiqQP8nVV+n6FcUkMSmCb08w+hVvbklIuCcX51jF/ovlLuz3IIslM tGnAMLnYr2u5NojqD+I/aXWXqaGjKYDTxs/UJacRmgaswXiFF3F0RHStGTZapzJTOZBM kKK5Y/38tV1MxfPUKBZhHHGmvJyKhdjy5x39kJVYfbYXnHBmRRV9xN6m/9Zli3+50Txg T8niFaLNkALsmBhS4oJwomMroUlObgNTSFED5dgZipsLNyVJvgfuzRl4yKQ44mIK8yRf N3cA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=X/IZwfYWP9znQfddabnSoi+xBA9zWsqNxvzC3bQDVaM=; fh=aUQKu1atq2V6oCm/Uj3cXs9I+NsJT8/AIWmtjlLMkjI=; b=o/SOFdNGQJjtC5C78Iv3dtXG1MFwiehsfhRPXpxnbJR4QNHK2m1nix6RvC0aDJK162 k+/7Hg8u3yF9uwySAXz3DHJKOfgbWPXf341ZiwkjJzTDnMzYjlqM5yaRDgy9eU9qUFCV dZe/vlAXOMblqsjWe9NpY7Yg59xM9mG3NmK/NODJ7Stc5tmZsTU+6VaskOBKCxqO2X9c s3+woL633ModYBEKIbaWxFUMokVQaMjN8iSQ3flxD7pCBp83+ZbyoknXVJQL6r1czud/ 6ILWlYR68SLT316ZCVegMu2QGti3tAvab2K8OSHGevvnlnqUGBweXuPYjB40XbXPJ0DK BxhA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@codeweavers.com header.s=s1 header.b=cqzL2BqK; arc=pass (i=1 spf=pass spfdomain=codeweavers.com dkim=pass dkdomain=codeweavers.com dmarc=pass fromdomain=codeweavers.com); spf=pass (google.com: domain of linux-kernel+bounces-45633-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45633-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=codeweavers.com X-Forwarded-Encrypted: i=1; AJvYcCVHtGaMO7CBEpdWh9mi6j2jZEYo1rIOgspu55u0i5vv5IQTDD9Qk7Nii/r1lOBHt18qa2cLEOo4butI1QdTkR6vX41eHQ== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id l10-20020a056402124a00b0055f0078ad56si2534546edw.397.2024.01.30.18.18.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 18:18:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45633-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@codeweavers.com header.s=s1 header.b=cqzL2BqK; arc=pass (i=1 spf=pass spfdomain=codeweavers.com dkim=pass dkdomain=codeweavers.com dmarc=pass fromdomain=codeweavers.com); spf=pass (google.com: domain of linux-kernel+bounces-45633-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45633-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=codeweavers.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 5D5E61F21FD3 for ; Wed, 31 Jan 2024 02:18:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 41B4A5240; Wed, 31 Jan 2024 02:16:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=codeweavers.com header.i=@codeweavers.com header.b="cqzL2BqK" Received: from mail.codeweavers.com (mail.codeweavers.com [4.36.192.163]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 962C45667; Wed, 31 Jan 2024 02:16:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=4.36.192.163 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706667366; cv=none; b=Us8U/eDC+yWj5D1BZFsXAiEmgQ0MvDn8XX/DApZAbDDBg3uEPf8s+XwI//gXhNc/qh3wMryGnTFDCS4jnDPC+fY0LuxRGarECEulJWylmrbuuiNAKQu23HPiHT8gx3sz6CkZp3+y2DkRnRJq+SucZHOgTZ1XekuZKff7jiQEw7Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706667366; c=relaxed/simple; bh=I4trA2JfrK9wBwFoc8bTAUMVwA5tJ+kKV0vPGN6dfHk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kOyewLxdo/BDuCfFhGd+V7gFjBHFRUN4kBLft/jiTPvSbmZhsVeK+vF1+acGUFMX+XoZjPOz94W7Fz0TA4zDRBp44RlAbJRjehZ4n17+EMe5V/Yp39xa9FI7lv39K8ElAUUK2vUf00UHtNX7qa74f+5vaa2AQGqO6bH3R8rt9OY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=codeweavers.com; spf=pass smtp.mailfrom=codeweavers.com; dkim=pass (2048-bit key) header.d=codeweavers.com header.i=@codeweavers.com header.b=cqzL2BqK; arc=none smtp.client-ip=4.36.192.163 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=codeweavers.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=codeweavers.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=codeweavers.com; s=s1; h=Message-ID:Date:Subject:Cc:To:From:Sender; bh=X/IZwfYWP9znQfddabnSoi+xBA9zWsqNxvzC3bQDVaM=; b=cqzL2BqKLT0kOzyVTWLpHtAvEn CokxLS83003PLTeKCseYL0B7nzWKw6waJ3UDbNRaafYfrc//BhVcx9Zao0981tSm2EeiA0ClrXoxG UzExgMJCWcy0ZaNjSWr1qAfxZmiDXDgYfv1vc/X8YPSUqgZALKygghsULFRunHTqpIqrINlJCIGXe JvWULanxOUx5Bp0g3zBrhSv640BZBjXxcJcasU4nFf3834DQREf/vub1O67GI9deb+4itk44+5c16 +C+2O4gpet496MFsBKnzh8i/g2R3KR5WLRE7QdGkJNMFu0scFE8vsRUcnKl5TKmNhRWvEqxeMfr4d boR1AvqA==; Received: from cw137ip160.mn.codeweavers.com ([10.69.137.160] helo=camazotz.mn.codeweavers.com) by mail.codeweavers.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rV08m-0038Kv-0L; Tue, 30 Jan 2024 20:15:52 -0600 From: Elizabeth Figura To: Arnd Bergmann , Greg Kroah-Hartman , Jonathan Corbet , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, wine-devel@winehq.org, =?utf-8?q?Andr=C3=A9_Almeida?= , Wolfram Sang , Arkadiusz Hiler , Peter Zijlstra , Andy Lutomirski , linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Elizabeth Figura Subject: [RFC PATCH v2 01/29] ntsync: Introduce the ntsync driver and character device. Date: Tue, 30 Jan 2024 20:13:28 -0600 Message-ID: <20240131021356.10322-2-zfigura@codeweavers.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240131021356.10322-1-zfigura@codeweavers.com> References: <20240131021356.10322-1-zfigura@codeweavers.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789570562793355132 X-GMAIL-MSGID: 1789570562793355132 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 --- drivers/misc/Kconfig | 9 ++++++++ drivers/misc/Makefile | 1 + drivers/misc/ntsync.c | 52 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 drivers/misc/ntsync.c diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 4fb291f0bf7c..bdd8a71bd853 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -504,6 +504,15 @@ config OPEN_DICE measured boot flow. Userspace can use CDIs for remote attestation and sealing. +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 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..e4969ef90722 --- /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 + */ + +#include +#include +#include + +#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"); +MODULE_DESCRIPTION("Kernel driver for NT synchronization primitives"); +MODULE_LICENSE("GPL");