Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3478105pxk; Mon, 5 Oct 2020 10:38:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKfeeNmuAuz/nR6MTq0g0dlEZm0BD4JrrCOeKAGm1JaG1EXZIq3gSbky9iOc8ThFXDuiUE X-Received: by 2002:a05:6402:1b9a:: with SMTP id cc26mr824024edb.30.1601919535849; Mon, 05 Oct 2020 10:38:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601919535; cv=none; d=google.com; s=arc-20160816; b=vybv3VvbLI9XIPfm4zR6kMh+tYGthoyxpDLJIabzA5V28lSjufd8+KaZUq/NG/A+42 xo49vcCmDW4D6KCSYForBrxn3vxDQ/wFCjOTCB95IKTl3siEyzdEaaI4BCwC77eoms+P j/LmVD+Ojd1vsFYESyyJRiWhE/fA00hLQ58XejlJjo00phNvTKa/qZj1kYo7eErGNlaB gQt+h+zkFTRcUrVerospHI51xl4OLheYYyHLdKF7EQkV6ULPM63KK7K8KptVLMpdLAy7 Fr14qvfJdq0KSopxqVoT51W02eRCU0Tr/0urKUoXTd0GKtGmrylWn61cnQnNa5AbJsLd qa/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=1DNc7hz0k202iGMoko1hhaweojn1Jm8PeOntOxsEtYQ=; b=VObRM5Yuh1PKYeR9wheq/pjLRHwr/jArIOdX3iZGRss9dw1QmYmlC+VTVbZVqNghmi Crd2G4O+5Wux1uIRAMrc/VW76e+uZ5FbCIFGfs83VrNW2AJZ+MEm6Vv3SZGMhM00NKJN Fyfqv3ELadULWSKUNY5n0HTdra9sYjZ0dPIzoCdovQZt2W1biRg8aRDaFBObNBQYhz9g psGzue+7fyR+ulOzak9qNJbbyHpPrOMyTThRsZ3pcEQVCPTlRR7QIx2FRBApPJapOa+H KtTRRalrsRkIn0DxBLvRS5JO6rsZyQtApfOYDJf+g6P1v5Kk9R6rJVKD7n7j4ovnQtl8 T7dQ== 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 zo20si186497ejb.554.2020.10.05.10.38.31; Mon, 05 Oct 2020 10:38:55 -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 S1728621AbgJERhB (ORCPT + 99 others); Mon, 5 Oct 2020 13:37:01 -0400 Received: from inva020.nxp.com ([92.121.34.13]:52106 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728479AbgJERhA (ORCPT ); Mon, 5 Oct 2020 13:37:00 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id EA8A11A0953; Mon, 5 Oct 2020 19:36:58 +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 DC95B1A091E; Mon, 5 Oct 2020 19:36:58 +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 8B0852032B; Mon, 5 Oct 2020 19:36:58 +0200 (CEST) From: Diana Craciun To: Alex Williamson , kvm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, bharatb.linux@gmail.com, laurentiu.tudor@nxp.com, Diana Craciun , Bharat Bhushan Subject: [PATCH v6 03/10] vfio/fsl-mc: Implement VFIO_DEVICE_GET_INFO ioctl Date: Mon, 5 Oct 2020 20:36:47 +0300 Message-Id: <20201005173654.31773-4-diana.craciun@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201005173654.31773-1-diana.craciun@oss.nxp.com> References: <20201005173654.31773-1-diana.craciun@oss.nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Eric Auger --- 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 594760203268..161c2cbe07dc 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