From patchwork Wed Jan 21 12:49:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baptiste Reynal X-Patchwork-Id: 5677171 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BCC0CC058D for ; Wed, 21 Jan 2015 12:56:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 04A2F204D6 for ; Wed, 21 Jan 2015 12:56:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3535020513 for ; Wed, 21 Jan 2015 12:56:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753320AbbAUMvm (ORCPT ); Wed, 21 Jan 2015 07:51:42 -0500 Received: from mail-wg0-f51.google.com ([74.125.82.51]:45264 "EHLO mail-wg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753309AbbAUMvf (ORCPT ); Wed, 21 Jan 2015 07:51:35 -0500 Received: by mail-wg0-f51.google.com with SMTP id l18so17499541wgh.10 for ; Wed, 21 Jan 2015 04:51:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/nM57VVk0vPOJtow0OYDw3HAmtYNfNu3phXtop7J80A=; b=c/jgZvZh1b8KODm+xe8c26X7FTIxvs2yzhJxFz5UNbQRmpwbSkFF0zZGe/CgsNhEe3 d9asNMa15qoH+IaWA0o2UJYUOEzi2nYJbUFD/zop6xF4vbTIESWY3StUYqfbVb/H8Q7L tV18LCZh7+NuqJQUU7mSqmgAsyeRLAWnHVGimElkfkWK8zNLim6+0W15VN7KrbhkjWJe SRpdHBBxnv15sQ2FVLuzH7dEV8IS08dBLWG4wZkdLTLpn+Mqt0rsqzuOXlpz9jDzbifX 7DS4pSgTV2BTl9R52udqm4LmTJJ7X0ZKuSVJzjrNh8K+cPqZu7MNBb/gxeA73FfMZsjX oKqg== X-Gm-Message-State: ALoCoQmOyxeUw5QRcmFi9USiEUgQwuACLOW9AAjv7Bd/SmByR0sQBtUTheSE+IntlfUBjdnUuHqL X-Received: by 10.180.208.74 with SMTP id mc10mr47834087wic.51.1421844693638; Wed, 21 Jan 2015 04:51:33 -0800 (PST) Received: from localhost (LPuteaux-656-1-278-113.w80-15.abo.wanadoo.fr. [80.15.154.113]) by mx.google.com with ESMTPSA id gl11sm25412098wjc.40.2015.01.21.04.51.32 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Jan 2015 04:51:33 -0800 (PST) From: Baptiste Reynal To: kvmarm@lists.cs.columbia.edu, iommu@lists.linux-fundation.org, alex.williamson@redhat.com Cc: will.deacon@arm.com, tech@virtualopensystems.com, christoffer.dall@linaro.org, eric.auger@linaro.org, kim.phillips@freescale.com, marc.zyngier@arm.com, Antonios Motakis , Baptiste Reynal , kvm@vger.kernel.org (open list:VFIO DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v12 04/18] vfio/platform: return info for bound device Date: Wed, 21 Jan 2015 13:49:52 +0100 Message-Id: <1421844606-24751-5-git-send-email-b.reynal@virtualopensystems.com> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1421844606-24751-1-git-send-email-b.reynal@virtualopensystems.com> References: <1421844606-24751-1-git-send-email-b.reynal@virtualopensystems.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Antonios Motakis A VFIO userspace driver will start by opening the VFIO device that corresponds to an IOMMU group, and will use the ioctl interface to get the basic device info, such as number of memory regions and interrupts, and their properties. This patch enables the VFIO_DEVICE_GET_INFO ioctl call. Signed-off-by: Antonios Motakis --- drivers/vfio/platform/vfio_platform_common.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/vfio/platform/vfio_platform_common.c b/drivers/vfio/platform/vfio_platform_common.c index 34d023b..862b43b 100644 --- a/drivers/vfio/platform/vfio_platform_common.c +++ b/drivers/vfio/platform/vfio_platform_common.c @@ -38,10 +38,27 @@ static int vfio_platform_open(void *device_data) static long vfio_platform_ioctl(void *device_data, unsigned int cmd, unsigned long arg) { - if (cmd == VFIO_DEVICE_GET_INFO) - return -EINVAL; + struct vfio_platform_device *vdev = device_data; + unsigned long minsz; + + if (cmd == VFIO_DEVICE_GET_INFO) { + 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 = vdev->flags; + info.num_regions = 0; + info.num_irqs = 0; + + return copy_to_user((void __user *)arg, &info, minsz); - else if (cmd == VFIO_DEVICE_GET_REGION_INFO) + } else if (cmd == VFIO_DEVICE_GET_REGION_INFO) return -EINVAL; else if (cmd == VFIO_DEVICE_GET_IRQ_INFO)