From patchwork Wed Jan 31 02:13:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elizabeth Figura X-Patchwork-Id: 194463 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1632858dyb; Tue, 30 Jan 2024 18:41:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IGp5AG800MIllT9oenkpuYGTx+/AfI+t+vB75HIUVpkmjbu0EDViDv1vR0rOhjvfKA0me0s X-Received: by 2002:a17:906:1691:b0:a36:5dc3:ca2b with SMTP id s17-20020a170906169100b00a365dc3ca2bmr118133ejd.29.1706668873407; Tue, 30 Jan 2024 18:41:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706668873; cv=pass; d=google.com; s=arc-20160816; b=MCSNYH9NOUupEm3OT7S0FzG6KY4N6sNHjsMgfsMBvwE27LOptrGhFIMP6WbKuh23vP 4dp9HpaZX4BNqtG5LLMjCNK2OKgaQGMUbdjNPAk65yBB3T0w1dQHK9njPk318+7t/XH6 XydYysSZTIFhh55r4MU0e6Y4G/nyJlWCZXgqwxZfLiNBm2zR1VSd5XJT3qgzV3SuWM4V Inspf3U0Ljm/1AG1MFdzvcR0BvnihLByJ8zbD7N2e3blBZwY5X15JbgTNhcST2YHnlks 1viUzXx4FATTjtw9grvif0t2w0xQ8Z7Tw5/zbfmWZRSjGFOGVL5bRroK8ajZNYXKA8wU 2TCw== 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=3BWgowJmtieQMddj1G2RVM2nAQyW8FCsxXFT7QNUe/k=; fh=zcXf/R86H7gRcNuU7Jg2SXr0F3e3mYjKjP2pbQdTKfw=; b=RjBBB/+iFS32BIIu2YTVmts7rb8Z/ld9l/dI7jYdEB7lM3yksOPpDLJ+tHgx6YGG1/ cIrMnu8Ju4p7C0D6URIvO7nKjNc+GBqcMrSiDWysBaIgcQC42ztpBcy5qnHvTdQknFEJ lPog29yJRUxawJpNdwXPrtNNl2MTx2fa01DyHMOjyDcijB9bWnUOPcZjZySCnt0B0/TR jyYWVq/nHxJk0TJFvyY1sKbAxeO1Cr6ClNMp06TSYoVEtBg4JuRkGLD/Ifq4wSoY8O+P 8b6DquCUw0+XCId1l23BwY2Ea7mUfxNzCcPFenmcidJX/a/7l0bYMPdv4ZPe0xXuQETo oncQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@codeweavers.com header.s=s1 header.b=XWTVmhZd; 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-45654-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45654-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=codeweavers.com X-Forwarded-Encrypted: i=1; AJvYcCXHiekWQcPNYRnaP2rds3AHk/wJ5bDJmLVaMmCLx2H8wmoKJ0RDPPiZC7PNZQowJpv99KsGMbSLBjkuLGcJDr76ypysXg== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id dx22-20020a170906a85600b00a3554a6b921si3582383ejb.107.2024.01.30.18.41.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 18:41:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45654-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=XWTVmhZd; 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-45654-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45654-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 D024D1F2A0B1 for ; Wed, 31 Jan 2024 02:23:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3ED0E3D57C; Wed, 31 Jan 2024 02:16:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=codeweavers.com header.i=@codeweavers.com header.b="XWTVmhZd" 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 A85A75C99; 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=1706667369; cv=none; b=vGaTMFwfqFGM7U6X/oOXTJIhxs2Jnj6e9e9HGwq5b6uxdU5g1NNoaSCLLEOLTOgTs2n9/fa7o5BX03RxNwmQJiQyH5xRN6y1tPiDQD2EMd364UIaWgnmJh5JNpsDL90+Y4aNt6+Y+9aWMFT37v8xmwQSsAMi61q3a/fGxquZ9qI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706667369; c=relaxed/simple; bh=LDrNxlhtoCwJ7k+stDb9MlrDauz5jYqNXZ6Ztjqd6Wo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jORs4zSx4g7j5X2qX2iJ3n6avJCAyn0VWzp8bTIyE6e2p9sRmoY92tnjiPJF1COxR9CDkHGigeur0ypGTqx2lGxw3DMLPGbs25/Uab23hEyK3pwE4mYyd4Uk9iSFsyB5rZjbKHU4BQJPYnFMgBzcYPqp62xCIY21PleadUxOkLQ= 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=XWTVmhZd; 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=3BWgowJmtieQMddj1G2RVM2nAQyW8FCsxXFT7QNUe/k=; b=XWTVmhZds9SBkupWGR2zjPEjm6 W/lB98xH7Yzw76o1iyii7Bj75H1drp0bxTBD6AUoMIFHhf6TWFckjaUa695+xcaacvBkMxNIW5xfh Wp0R71zR1JuOrNBt1PgNAcyYtcytCR6zzIElZTaCrMmtCOPE+R6EkpvMQhD1tC/JenRkTe+kZmCM+ 3lcJ4OfJflbcjihV4gz5TSF66HcqMxKppf5jxQMwyMHJtA4G6Nd0hL3GG1xLG1eT0GqfG1aAW5nUG 4a4d/BoJQTy8sqZbxMaXIa69zHjktHldBE4YknXHVeCSmBnNalHdIz3iA56aA3PEAeqFg0J8V4wAA meAeF57w==; 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 1rV08o-0038Kv-34; Tue, 30 Jan 2024 20:15:55 -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 15/29] ntsync: Introduce NTSYNC_IOC_EVENT_READ. Date: Tue, 30 Jan 2024 20:13:42 -0600 Message-ID: <20240131021356.10322-16-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: 1789572020907138670 X-GMAIL-MSGID: 1789572020907138670 This corresponds to the NT syscall NtQueryEvent(). This returns the signaled state of the event and whether it is manual-reset. Signed-off-by: Elizabeth Figura --- drivers/misc/ntsync.c | 21 +++++++++++++++++++++ include/uapi/linux/ntsync.h | 1 + 2 files changed, 22 insertions(+) diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c index 7f5f96ec7c69..5439c1c9e90f 100644 --- a/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) return ret; } +static int ntsync_event_read(struct ntsync_obj *event, void __user *argp) +{ + struct ntsync_event_args __user *user_args = argp; + struct ntsync_event_args args; + + if (event->type != NTSYNC_TYPE_EVENT) + return -EINVAL; + + args.event = 0; + spin_lock(&event->lock); + args.manual = event->u.event.manual; + args.signaled = event->u.event.signaled; + spin_unlock(&event->lock); + + if (copy_to_user(user_args, &args, sizeof(args))) + return -EFAULT; + return 0; +} + static int ntsync_obj_release(struct inode *inode, struct file *file) { struct ntsync_obj *obj = file->private_data; @@ -579,6 +598,8 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd, return ntsync_event_reset(obj, argp); case NTSYNC_IOC_EVENT_PULSE: return ntsync_event_set(obj, argp, true); + case NTSYNC_IOC_EVENT_READ: + return ntsync_event_read(obj, argp); default: return -ENOIOCTLCMD; } diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h index a1d0ef581212..582d33b0dcac 100644 --- a/include/uapi/linux/ntsync.h +++ b/include/uapi/linux/ntsync.h @@ -53,5 +53,6 @@ struct ntsync_wait_args { #define NTSYNC_IOC_EVENT_PULSE _IOR ('N', 0x8a, __u32) #define NTSYNC_IOC_SEM_READ _IOR ('N', 0x8b, struct ntsync_sem_args) #define NTSYNC_IOC_MUTEX_READ _IOR ('N', 0x8c, struct ntsync_mutex_args) +#define NTSYNC_IOC_EVENT_READ _IOR ('N', 0x8d, struct ntsync_event_args) #endif