Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3933747ybb; Mon, 23 Mar 2020 10:20:04 -0700 (PDT) X-Google-Smtp-Source: ADFU+vu97aW2tJJ/+t2cs9t/P+mZe/dp8uNvbvXiE6yw07wJY1M9DKOcAmG18ERoqlvbBiIo/c/H X-Received: by 2002:aca:3ad7:: with SMTP id h206mr243977oia.169.1584984003963; Mon, 23 Mar 2020 10:20:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584984003; cv=none; d=google.com; s=arc-20160816; b=mETttSKqPsEK8hIooSW52G5ZkMw5MoYmHi4a5g6AJeoOgjT2SpXMDjgGazskuiDwOc rYjb8xTvtC0t2yYD+Uce8RFdErQc5Bo0dWQUoYpbEaLXOcbEG433R14L6sjZl7ViyIy6 i/p6BWLFwqYZuAUWPXeaIgdCxxBcQ8/n/vSQrS4zK477MmDUQSQkJZfkTGNhTYd8uaEn 7DwoBN/G5r21xLufpUnbjM1isPWyo4kJ8SLsaLDRWOATpuvcBN50P5isMkXGNP8ri0bY xsHRpjg+EVvtVtfAF34w8F32brWuo6nl9eXu7PL8hGZcU0qbvu3XWkk41jbBV8SKwZid +VKA== 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=RZ68QlVVMEoWKqBl/s81FtvxpZ5iF7cWrP0JlOHDH38=; b=m5DOyZVTaRoTp/3Z2E0mfQZSW1Sy9Tvg2pmxnAZmXN+JHFUEAYaqsoAReKD/DZ1rDh oxS1eaa7KL+P4ei8Z63B+X5QCsGqC5sLmaihe7cMfMVfFksGNbqZ1nemHL9JwkxhSWi2 z24Njc4DjTz0KW+owb/uc68NLsnu9TynZR83xo/xUv1tANUDkKzvXlTE41yjiVfhHzXY ixLIY9XBoiyPF3oisdYRoEybPVazD3gcrbSH1bTyuXtkXyb6BcznGdEbDZ8x4hmO1/FI UDf1ERXRKrk6vIJ/RVocTi1IEdU+OjkBuWdoec3/cLSaNnCDQKN0bDFHOwET6CJaCyUA g3uQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id d1si669418otq.225.2020.03.23.10.19.50; Mon, 23 Mar 2020 10:20:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727890AbgCWRTb (ORCPT + 99 others); Mon, 23 Mar 2020 13:19:31 -0400 Received: from inva021.nxp.com ([92.121.34.21]:57090 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725844AbgCWRTa (ORCPT ); Mon, 23 Mar 2020 13:19:30 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 9B313201848; Mon, 23 Mar 2020 18:19:28 +0100 (CET) Received: from inva024.eu-rdc02.nxp.com (inva024.eu-rdc02.nxp.com [134.27.226.22]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 8E2A52012E7; Mon, 23 Mar 2020 18:19:28 +0100 (CET) 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 F12E62035C; Mon, 23 Mar 2020 18:19:27 +0100 (CET) From: Diana Craciun To: kvm@vger.kernel.org, alex.williamson@redhat.com, laurentiu.tudor@nxp.com, linux-arm-kernel@lists.infradead.org, bharatb.yadav@gmail.com Cc: linux-kernel@vger.kernel.org, Diana Craciun , Bharat Bhushan Subject: [PATCH 3/9] vfio/fsl-mc: Implement VFIO_DEVICE_GET_INFO ioctl Date: Mon, 23 Mar 2020 19:19:05 +0200 Message-Id: <20200323171911.27178-4-diana.craciun@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200323171911.27178-1-diana.craciun@oss.nxp.com> References: <20200323171911.27178-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 | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/drivers/vfio/fsl-mc/vfio_fsl_mc.c b/drivers/vfio/fsl-mc/vfio_fsl_mc.c index 5cc533808bc1..ab1cde375fc6 100644 --- a/drivers/vfio/fsl-mc/vfio_fsl_mc.c +++ b/drivers/vfio/fsl-mc/vfio_fsl_mc.c @@ -31,10 +31,30 @@ 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 -EINVAL; + 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