From patchwork Wed Jan 31 02:13:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elizabeth Figura X-Patchwork-Id: 194468 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1633314dyb; Tue, 30 Jan 2024 18:42:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IHGCZWcGtos8f4ZC1j6l5CjAIzR1p1/UIf4/uf+zsl1vfvbGryYlOPBfzTyOSaXbc1g8TOK X-Received: by 2002:a9d:5a10:0:b0:6e1:1437:8a45 with SMTP id v16-20020a9d5a10000000b006e114378a45mr248321oth.16.1706668954566; Tue, 30 Jan 2024 18:42:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706668954; cv=pass; d=google.com; s=arc-20160816; b=zmjeMdbkOJakd+mb6XFTXdRsbKYh1n5jswxC4Uy1Hl8xvP3gQnp02ucFB8MsZ2G611 aJUQCQSRaKHPgN/ZdlXJPpRcBkvE+S/Vr2GGTY/ag9jN2P5DBGHJALhFdrLD0nW7UgPL n3Mm7sUkfpyEVocqRVKzNcmMqwyfqTuIdkZ0AvdYM2riUOjey5pkNQAXIK09/X6/Uq+X v5Sj96Pa+ttvlj/+9zv+l0epnxeDDal9Ck8FK2Puj4lwn44S85xq8Z54pUPzOJnolUay fP/m8vRls3zTBbDkCa6mYrjtdpHSezuZCYKspWqy5JWsWlF7WeRtZHPK8Grt6MVYYg/O pMsQ== 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=R39lGOqTNBMRXbRmwXOtAWXBwOD9NggROFCJWXViCO4=; fh=cY3Nfsrebs1N4FR0DlyBcN9JkrW7iKKwgXjcfVfirQM=; b=EyoBpb5ORFhng+i2E6j/pGf8daP5N0OFEPMMwUZ9RGYxUZl/7O0Kcp1lf9U4FIurtq n0Jw7vzi9NFfeyHs2oWTducNxbJVuGawXyKyO/CSqJpyoyfBydY6Fk3PyE2+Tj1hph8c 24pVZkFkBmUwmuUE5+m2Bp9U2EiTKrjakWc3dRtA6E29Qv2BK6VV0mQTmfoEsU7ohlRe tbyG9t5UXbK4WngwqklmdxSnOtCt4ZmI3zJsp3jY7t3IIxR28Va0QFF8nI4kpOG9nNwv oS+CHUnrWzdpsht5qXaOmypDr0WftwxK39vM7790e5cfkdjKq+LQl6gdiCBwd82i+NeU Zc1w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@codeweavers.com header.s=s1 header.b="b/wDzQH6"; 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-45648-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45648-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=codeweavers.com X-Forwarded-Encrypted: i=1; AJvYcCWph/i3FwXpXX7mwuIwMXTYbadalyiWk/nLoqXw/rTQ54cFKh+jJInZfp139djQaJf0LlRx0kYrLRfPDGtQ8hFVRCtAlQ== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id j186-20020a638bc3000000b005b96af23fe6si8533031pge.284.2024.01.30.18.42.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 18:42:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45648-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@codeweavers.com header.s=s1 header.b="b/wDzQH6"; 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-45648-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45648-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id B44A428C774 for ; Wed, 31 Jan 2024 02:22:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 867843D3A5; Wed, 31 Jan 2024 02:16:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=codeweavers.com header.i=@codeweavers.com header.b="b/wDzQH6" 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 961D05394; 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=1706667368; cv=none; b=SKS+kiLgsNDXrMECF40owruN6ivU3pJIOnYkR4Ii0Mv36xnEjtOLBA5Yw49nfW1SWVIP89lwAmmIC3IPCGMydUIqKPO2M7UcRH3e8fVUSoukRzIVR503HMZsiMs4FThBrLGJQo8Rl89Ek8jwhykn4sa0Ws1tRnN5YEoIjFufWG8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706667368; c=relaxed/simple; bh=HCJDXrbbClLe54itl4O3me4eGm27hgSAHGhToE6sjJA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TMSkGJpPyqfaY/LD//lwg5hjR3/Fey7Y5sXE18a171cBns6MNjzJbAXONZ+7LEmtf8TXQn9QNpNsPInEa7TRbD4MX/sbixe1AViKA9fg6Q5YNvfA51/639O5hAl4bzlb9q59FDAiOuEe3o5OdIFV8Y4LUAB92VPWnXmfljOUN0E= 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=b/wDzQH6; 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=R39lGOqTNBMRXbRmwXOtAWXBwOD9NggROFCJWXViCO4=; b=b/wDzQH6Mzut/tAITEPLUTaKVE k9IamG8XOeeE3ntHS0bXtYmBvDn97GUEB/LVGXkFeCg0/6Rzb2j+YrUrg1+RUD2pskQOLaGMKA775 hjqKMmHp/Z15IzDSmXc9Hd16oW8zqJxgwF3fS7cVoeppiyvFvclwsfBUo2IykJkzjoxmVchrLxyaM Ds3s6WMIULYiGME82YQS/MHw/rqV236Z/EhhefrGN63zbwnhhtN+kllp/K1EZh8RXU+5Fo19E+W7+ jXAbN2VLiPjFRxpwvHjMccMdMbO/iVZrsND7y3hWzSDk+iP9Wiz2bXQRhyRheboNYWLmI2SRMdJfp yRew08zw==; 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-0p; Tue, 30 Jan 2024 20:15:54 -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 13/29] ntsync: Introduce NTSYNC_IOC_SEM_READ. Date: Tue, 30 Jan 2024 20:13:40 -0600 Message-ID: <20240131021356.10322-14-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: 1789572105311063863 X-GMAIL-MSGID: 1789572105311063863 This corresponds to the NT syscall NtQuerySemaphore(). This returns the current count and maximum count of the semaphore. 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 240ae858fa96..6dccfbfb2512 100644 --- a/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c @@ -506,6 +506,25 @@ static int ntsync_event_reset(struct ntsync_obj *event, void __user *argp) return 0; } +static int ntsync_sem_read(struct ntsync_obj *sem, void __user *argp) +{ + struct ntsync_sem_args __user *user_args = argp; + struct ntsync_sem_args args; + + if (sem->type != NTSYNC_TYPE_SEM) + return -EINVAL; + + args.sem = 0; + spin_lock(&sem->lock); + args.count = sem->u.sem.count; + args.max = sem->u.sem.max; + spin_unlock(&sem->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; @@ -525,6 +544,8 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd, switch (cmd) { case NTSYNC_IOC_SEM_POST: return ntsync_sem_post(obj, argp); + case NTSYNC_IOC_SEM_READ: + return ntsync_sem_read(obj, argp); case NTSYNC_IOC_MUTEX_UNLOCK: return ntsync_mutex_unlock(obj, argp); case NTSYNC_IOC_MUTEX_KILL: diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h index 598f894f868d..6017f621687e 100644 --- a/include/uapi/linux/ntsync.h +++ b/include/uapi/linux/ntsync.h @@ -51,5 +51,6 @@ struct ntsync_wait_args { #define NTSYNC_IOC_EVENT_SET _IOR ('N', 0x88, __u32) #define NTSYNC_IOC_EVENT_RESET _IOR ('N', 0x89, __u32) #define NTSYNC_IOC_EVENT_PULSE _IOR ('N', 0x8a, __u32) +#define NTSYNC_IOC_SEM_READ _IOR ('N', 0x8b, struct ntsync_sem_args) #endif