From patchwork Wed Feb 14 23:52:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elizabeth Figura X-Patchwork-Id: 201209 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp74255dyb; Wed, 14 Feb 2024 16:22:38 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWwrvbcU7Uy7uR2f4KDEU9LxW0RMnXPuXULb2RUF9THGhyccJ9qEvGm+luLiIUecRa1/Qh1CV6CjioFe5sKNSLZEXPA3Q== X-Google-Smtp-Source: AGHT+IG+mgEGIhYiqPfmThwDjWEYyQeEWrXcrxfXTFigOgN5F/r1MW7AO8vPw8+1L8OzkyRN8laG X-Received: by 2002:a17:902:7888:b0:1d9:5cfc:ac6a with SMTP id q8-20020a170902788800b001d95cfcac6amr215979pll.69.1707956558799; Wed, 14 Feb 2024 16:22:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707956558; cv=pass; d=google.com; s=arc-20160816; b=yzfJB8aY90nU8SrJ2XQsdWTkLZNA/yYMj0eczkn5sDt1JrpUaLfysbXYFXd2QdXzmY X9TrxBZFCXdTZk+a6zLxol8yI9s/2u6mUNjl4e+UrV4hyqWMvRlmn0gK9FYC1reXlLXC UDrwpw+9q1M6NaSRClITRYw9J6PbEeL68b8xYA4IjYfYKyVFs6lTGOScZGshQDmJw8K8 jdNvplHLfpZStY01WFHMw023K7E+jLp6UqYNDFPXw54ok1IWrF0Bzp/GSm2K060/TTqk syYbqq6+e3VHJHW0WoudB6rjGZjpdg2R51iqsX/IvS1TFb+DgyKRE4+S18wTRHiNRlmK S0nQ== 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=AL5zjVdXuExjwQk+undZ6ylI2OzNOm8lFsQUivBQ0kE=; fh=sOAzP1IXJnllEbSCBRlwdfT0MN3UiaRLwzx1Tpw7GJA=; b=sKxonMBkQ/y0C8T8qBQKd9lWwARh2GDLCmZRZ+a36RqsvIZUjts9GA8QzcZ5I9MIIm 2l2luqfjlXTZ6953xf0ASJTtpssh9kxBFxbWabl5VGRyWv5FQDWrhvcikoTybjXuNw77 Yj5pNvl6Gr0efS/5L2TdbcMwWTTzIN36hFXO91LuNtWOohSqbhQehOfGaftVeyo4X6Hn tZmLr6HJFzl6xorW4dZ1AvGg0vekCxNxD3JJKH6PbJvriLxrdSUxw1CVTghURn3xJMi2 D6/XQ6j3QVPWB/fc56npCSSLPbsZN3Ivug1pi3zrmXwzBK/MdeSoyDAe4xylHzoRk9ly JeGA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@codeweavers.com header.s=s1 header.b=Ljdg3gM1; 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-66149-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66149-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=codeweavers.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id z2-20020a170902d54200b001d92e40f68asi72644plf.69.2024.02.14.16.22.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 16:22:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66149-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@codeweavers.com header.s=s1 header.b=Ljdg3gM1; 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-66149-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66149-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 9D6E4B2AB35 for ; Wed, 14 Feb 2024 23:57:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C272014A082; Wed, 14 Feb 2024 23:53:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=codeweavers.com header.i=@codeweavers.com header.b="Ljdg3gM1" 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 6134C1482ED; Wed, 14 Feb 2024 23:53: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=1707954817; cv=none; b=lK6SjNYvT1CtuVmg8o8XP/sUFgu+pme2UgTcH36P1qjynD/fEL8z9k/TCZ42k+zSSvv/KBDA8ur+/PEtvoClc2SWawfcFOnUwjFrch6XiBAuJmeU2CgwRJyosyNkrSa/kRwJawfSuAXxo9ADSPwBUBzCuqQN7KVavpjTNBtrFIo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707954817; c=relaxed/simple; bh=hOO6pI/Zoh0v+lz+RmYsAAK/7RhFCidMqxtVLgR3VjA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QtmjpATGVxJo5sFr1UwqJsEDOYOwHs0Ln52Hywi9zHepwIbTxNevtRiy2KJyu6wu7lnS0UMZL/5Q1jkEkMrsXaRzWIzpowYwU/wAZGtgCjci6v5OlJjgA9nqzFRtVLrNG021fYpVcIBXa7ud/oxlt7uvuJp0aNVICSePb6F8qms= 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=Ljdg3gM1; 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=AL5zjVdXuExjwQk+undZ6ylI2OzNOm8lFsQUivBQ0kE=; b=Ljdg3gM16KAUQBJlZaKxtXg4YC n/A78hCG0YEzPgZNxZNq+D16bsJlnZYbeS6f17ft+EA1gkRl2zwEe0huj/cs46OV4b7Nc3fc5eRAr 3EVfdXp82cPmg+vKYThuWCzaC/1+n/9Msqy8BwG5Mdg9lMRIVian7bnLDfn4anuOrdn0n0mIsF2Jw raKdln/TeymreuERliUcb0+WQa2ny45mnOhq0gAJQLfCaXWJoEpSdzYAMIHmRdJoRXNO4+gHtEIRc O3DpdgRfg3vmRVj6TNVDxEBFrJU+ve/WC1qc370YccoR8/Fby8zh02ZcVqHnMaQ2+l5tudE/VDs8k OzkEUxzg==; 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 1raP4F-00GcSK-0d; Wed, 14 Feb 2024 17:53:31 -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: [PATCH 15/31] ntsync: Introduce NTSYNC_IOC_EVENT_READ. Date: Wed, 14 Feb 2024 17:52:50 -0600 Message-ID: <20240214235307.10494-6-zfigura@codeweavers.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240214235307.10494-1-zfigura@codeweavers.com> References: <20240214233645.9273-1-zfigura@codeweavers.com> <20240214235307.10494-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: 1790922256210199429 X-GMAIL-MSGID: 1790922256210199429 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 73f40ea1c8f8..5bf7af8095e6 100644 --- a/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c @@ -555,6 +555,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; @@ -588,6 +607,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