Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3523377pxa; Wed, 26 Aug 2020 02:45:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQsjv+13N7l+Z65uLVz6w+jb5c821oobQdF/Q1/dzETPfgD+AUSbl2iiP/FA9waJt76SNv X-Received: by 2002:a17:906:68d:: with SMTP id u13mr5898508ejb.184.1598435127441; Wed, 26 Aug 2020 02:45:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598435127; cv=none; d=google.com; s=arc-20160816; b=UG7xbnpYuw32D3Bq/NBkzHgvWJXgi1atafTcqNRO1dqcC2U+Vi14BQGkYKjxFGO10s owk67dNdf0yfy/4GDs5SZTc0vetWtu8FGRKeea0U9q9SjSPyVtzFZ1AEhE6OjxO1z+d0 omlqVcjVSALlP1Br31z2rqEtWM5/90lTYgS5AM4+zq4dvUxf3/SHgonLC8VBbdVzdSLI NtpNvNyUp8CBWPgUC3W/vx8k7iTRmb9OVk1cA6Bdah4NdmNCqqMuaJV6hN4ln8rbKqjt YCznYrD8m74+A4IYZEnWe9hxXHJ58KmqI6HOwQUeGvMErA8d9RZTYJhfjTzQv7tZuAuM YSPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=PsVyVgD+uoSWOWAGfZEQiCkMEyLsI3lyNDfzgb6X+Aw=; b=BQ3F+RHPUfvaI1hk2f36r171YY+LFBKjFBNCtBdsIz1vQg4x3BXYz3ITwV6qvll9Kp f4Rp6A1NDAPxcQbdrg+xt4QD1O5juYUNJroP2UnxnLKQYT//osNBkB3ZDplwgGh2aaH2 FGo0RIsRDCB0SAI138PoTgJrTBFy6JsjHZp9t9P1HGD6x1kmgkCL5vxvyTPAfxz9CxVG TIGZx90Mv+Js0u14B8k/lgKYJnL8Vh1Khu1MYYxb/9ilOh8a5aZWlWYRxPkAL4BtKCJ0 jxq5H6SeVKtvjE99KlP4iCxlu2WneHMsyyh7N63AiEq9Hj/rBW/hrh/OJVWOpQrlvKIP tZMw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dg15si1211956edb.524.2020.08.26.02.45.04; Wed, 26 Aug 2020 02:45:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728079AbgHZJld (ORCPT + 99 others); Wed, 26 Aug 2020 05:41:33 -0400 Received: from inva020.nxp.com ([92.121.34.13]:42104 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728002AbgHZJdy (ORCPT ); Wed, 26 Aug 2020 05:33:54 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id EC9E21A090E; Wed, 26 Aug 2020 11:33:52 +0200 (CEST) Received: from inva024.eu-rdc02.nxp.com (inva024.eu-rdc02.nxp.com [134.27.226.22]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id DFDE91A08FF; Wed, 26 Aug 2020 11:33:52 +0200 (CEST) Received: from fsr-ub1864-111.ea.freescale.net (fsr-ub1864-111.ea.freescale.net [10.171.82.141]) by inva024.eu-rdc02.nxp.com (Postfix) with ESMTP id 8B01C202CA; Wed, 26 Aug 2020 11:33:52 +0200 (CEST) From: Diana Craciun To: alex.williamson@redhat.com, kvm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, bharatb.linux@gmail.com, laurentiu.tudor@nxp.com, Diana Craciun , Bharat Bhushan Subject: [PATCH v4 03/10] vfio/fsl-mc: Implement VFIO_DEVICE_GET_INFO ioctl Date: Wed, 26 Aug 2020 12:33:08 +0300 Message-Id: <20200826093315.5279-4-diana.craciun@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200826093315.5279-1-diana.craciun@oss.nxp.com> References: <20200826093315.5279-1-diana.craciun@oss.nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Allow userspace to get fsl-mc device info (number of regions and irqs). Signed-off-by: Bharat Bhushan Signed-off-by: Diana Craciun --- drivers/vfio/fsl-mc/vfio_fsl_mc.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/vfio/fsl-mc/vfio_fsl_mc.c b/drivers/vfio/fsl-mc/vfio_fsl_mc.c index 85e007be3a5d..5a5460d01f00 100644 --- a/drivers/vfio/fsl-mc/vfio_fsl_mc.c +++ b/drivers/vfio/fsl-mc/vfio_fsl_mc.c @@ -33,10 +33,29 @@ static void vfio_fsl_mc_release(void *device_data) static long vfio_fsl_mc_ioctl(void *device_data, unsigned int cmd, unsigned long arg) { + unsigned long minsz; + struct vfio_fsl_mc_device *vdev = device_data; + struct fsl_mc_device *mc_dev = vdev->mc_dev; + switch (cmd) { case VFIO_DEVICE_GET_INFO: { - return -ENOTTY; + struct vfio_device_info info; + + minsz = offsetofend(struct vfio_device_info, num_irqs); + + if (copy_from_user(&info, (void __user *)arg, minsz)) + return -EFAULT; + + if (info.argsz < minsz) + return -EINVAL; + + info.flags = VFIO_DEVICE_FLAGS_FSL_MC; + info.num_regions = mc_dev->obj_desc.region_count; + info.num_irqs = mc_dev->obj_desc.irq_count; + + return copy_to_user((void __user *)arg, &info, minsz) ? + -EFAULT : 0; } case VFIO_DEVICE_GET_REGION_INFO: { -- 2.17.1