From patchwork Mon Mar 2 16:59:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baptiste Reynal X-Patchwork-Id: 5915691 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 D4D15BF440 for ; Mon, 2 Mar 2015 17:08:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0C8C6201EC for ; Mon, 2 Mar 2015 17:08:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 31955200B4 for ; Mon, 2 Mar 2015 17:08:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755975AbbCBRBX (ORCPT ); Mon, 2 Mar 2015 12:01:23 -0500 Received: from mail-we0-f177.google.com ([74.125.82.177]:34967 "EHLO mail-we0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755966AbbCBRBV (ORCPT ); Mon, 2 Mar 2015 12:01:21 -0500 Received: by wevl61 with SMTP id l61so34665333wev.2 for ; Mon, 02 Mar 2015 09:01:19 -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=ZLo0T9yEJ2ckJMqjNXiBstHy3MLd8xdrRLwZJ8GmAII=; b=jBz2i3so51b5/Qr1OdAxXQX81+m+9FgTn4ONfrf5XbkPq7sQ+PelLgOIBPcMK7Krkx GBcvPo5ZAWTPkItYPCTSXmwch8zvQcFKTqfJCiZClXssIQJDOt5vNrRuYMLi7kzTps84 VXjvFN+lnqDvjGeVCgryUrov/HTgd0DJwybToCGOLdC8jgH3qzCunrelCWHW5w1ySGjh d86RSHOCqiIx/n7Gq1gLaAufKnNKhzJ55A57XeX+p9l23QkRaITM2K+6OgsQpowG4bmT 3ho/gi1DQaMORqxZK2ZambQ3+4f3yI7ibvC7v+Oratn37FaFiFUY2blrbO1t9AmAFYgY OR/A== X-Gm-Message-State: ALoCoQkq+4ChiwF6SmE+La2K1IpHAFzDRBRh6FG31XUdTMH9h1IjBmBn0Do8JuP9tO5g2Ya+yieK X-Received: by 10.180.91.43 with SMTP id cb11mr37404900wib.16.1425315679932; Mon, 02 Mar 2015 09:01:19 -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 hs7sm16860113wib.4.2015.03.02.09.01.18 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Mar 2015 09:01:19 -0800 (PST) From: Baptiste Reynal To: iommu@lists.linux-foundation.org, kvmarm@lists.cs.columbia.edu Cc: tech@virtualopensystems.com, Antonios Motakis , Baptiste Reynal , Alex Williamson , kvm@vger.kernel.org (open list:VFIO DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v14 06/20] vfio/platform: return info for bound device Date: Mon, 2 Mar 2015 17:59:46 +0100 Message-Id: <1425315600-29761-7-git-send-email-b.reynal@virtualopensystems.com> X-Mailer: git-send-email 2.3.1 In-Reply-To: <1425315600-29761-1-git-send-email-b.reynal@virtualopensystems.com> References: <1425315600-29761-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=unavailable 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 [Baptiste Reynal: added include in vfio_platform_common.c] Signed-off-by: Baptiste Reynal --- drivers/vfio/platform/vfio_platform_common.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/drivers/vfio/platform/vfio_platform_common.c b/drivers/vfio/platform/vfio_platform_common.c index 34d023b..c2f853a 100644 --- a/drivers/vfio/platform/vfio_platform_common.c +++ b/drivers/vfio/platform/vfio_platform_common.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include "vfio_platform_private.h" @@ -38,10 +39,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)