From patchwork Mon Feb 19 22:38:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elizabeth Figura X-Patchwork-Id: 203306 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp75950dyc; Mon, 19 Feb 2024 14:44:04 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVotY2JR6Wh0Dm32tMT+OLr8AVl4hmi+rvEykOxVEFrZoNtCNv51nInL+jSoWvYrCvjkptGYiwEKam/GGtwGZNA+xJ2OQ== X-Google-Smtp-Source: AGHT+IFlhMIVOInxXN9Iuxdi7OYQ8z7BUfShqadhrDe2JBEG/n/rh8/66jX+Ziw5oi1O4LjP68S4 X-Received: by 2002:a19:5e42:0:b0:512:aa57:f38b with SMTP id z2-20020a195e42000000b00512aa57f38bmr4557216lfi.53.1708382644055; Mon, 19 Feb 2024 14:44:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708382644; cv=pass; d=google.com; s=arc-20160816; b=O9uYHQDXt8kxvID4scFMAWSH616r/OYYKWuWa5bUqady1HSh4NViVfYcA8I1ikkPJc 0ubkBNG3rba35xHM5CJBc5wLtOtvqdwazLswbhQIFf88HERqI5lxx6VUli4k4y4h8usD eRZsKP/RtfUqAe8G6sjYoDOs7hQ9zzWGuC54n64Ez8iK0KNxJiJdjMEVaIFYZI4PovPW on6/8dBE1JlcWFUy9nA9bkay8m11VpFdvmTIEnu5C4SH98xRARy+/GyHUkZBh8KE+UTJ z+xEnCbDQhu5Vi8qOTxOzuzdjdgCKMA11LjSqRGGWnMCFfCG+9s7a3nwAxKvFngnu2yQ BNIw== 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=/i5nF4410gEXNHjyrEQSUz30K2sNvrn0R5ExzpIN3gw=; fh=hR3Xqo6s6FufP5gEw1XgbtLHrluZu7hd5XGp+hLIfiM=; b=J/W02zDieWmNKX6Ahbzj80qgPOtuqtCHm16La3u4uVkalwugTTg867L11sI6EoQxR+ rxtOQDHLElECXnFVjum+owF3plzcwOErZr3NJPQwE0vV2Pfn3BDTFdQxbsUV8c6lMn5p OCDEwyi/Plx1B6VsMgftNEU/yzIMTUVefGOgTe/2aag/5MsSrl4gB8RkUfxknX4xqYHZ hlMffMLbAM+5FoWp3hFOT6gi0v4U2/X1kqeh85XVi32K65IIZONvwHhBIFFze5Jr1Xgr gUp3t6VfNR47YjP+EPDhYbBtQhOc8LHRO0x8bAl07sAp13wt20wNCcfhQ6JtUIHvsQzO BNSg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@codeweavers.com header.s=s1 header.b=Nzl9mkeE; 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-72088-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72088-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=codeweavers.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id lv12-20020a170906bc8c00b00a3ea1663592si1090431ejb.218.2024.02.19.14.44.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 14:44:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-72088-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@codeweavers.com header.s=s1 header.b=Nzl9mkeE; 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-72088-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72088-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 A5A981F21A03 for ; Mon, 19 Feb 2024 22:44:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E1EE460DF8; Mon, 19 Feb 2024 22:39:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=codeweavers.com header.i=@codeweavers.com header.b="Nzl9mkeE" 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 EF59656450; Mon, 19 Feb 2024 22:39:35 +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=1708382381; cv=none; b=lTbtiVhou1C9mxQ0Rtl4a/pEndvwDs8FFfHZfkGGjThU3tnHgunsuVC4BojROv6Q0nEyuZocl1ZYbS/MkEeZFQpMt5voHzXW7b3u+3u1svpllactR+iaUuiUeVeOT6fS14fmjvyNsU8sUxuxQnsoe7e3iPmX351rcygowVCn7fk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708382381; c=relaxed/simple; bh=UXKmd/tB5MoVcAQ9w02fckyfMxcSHRdyv+iPNlCu+YA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TeGsBgsCnZ9mgWPf1BQuaYYZsTuu6A11zKeO0WLPhHQyoTqx3jgxX8qed5K6zc+0JjmDZjM4NqRGddsKHI2l5i2LkmgoPEQKvWnuwevAhWo59LU0O6SlMW869+PWl69TZwl2hHgZfmFprUkF11LRj4UZ3LNn6Lk08SKn6txJjBM= 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=Nzl9mkeE; 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=/i5nF4410gEXNHjyrEQSUz30K2sNvrn0R5ExzpIN3gw=; b=Nzl9mkeEdLjpiWMozXAeBxqXcx booeuTmy8P+BAM62cOGJmwYrp31pyikkXa+EIddqiW7qc6ehbIfsXJq+8H7vBZblgM9ZO6MRD+tGd cfR1NXNF2HG2fBb9T8tNrm762bO+lAf8qulGd72g32mVfzVHbtzoPOZC3AVsXBqQC1hts2lAb+JV3 xFgN/EFRgcyG27VOEsbr+sAbUgx0cEyqTMtWiQda5Fl+7QCIayMyiac5kUwlsxlIZFE/D0VAfhJSc WrYr0NM2OwvS8V2vpoVFYnsajqGKYpn6Z02EdfzZws25t1etmzWsFJBMDt3EcVNi3WbkLDFgqppeN 6aeKp1nw==; 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 1rcCIK-0037Oz-0l; Mon, 19 Feb 2024 16:39:28 -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, Randy Dunlap , Elizabeth Figura Subject: [PATCH v2 01/31] ntsync: Introduce the ntsync driver and character device. Date: Mon, 19 Feb 2024 16:38:03 -0600 Message-ID: <20240219223833.95710-2-zfigura@codeweavers.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240219223833.95710-1-zfigura@codeweavers.com> References: <20240219223833.95710-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: 1791369039549566697 X-GMAIL-MSGID: 1791369039549566697 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 | 11 +++++++++ drivers/misc/Makefile | 1 + drivers/misc/ntsync.c | 52 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 drivers/misc/ntsync.c 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 + */ + +#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");