From patchwork Fri Jan 30 13:46:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baptiste Reynal X-Patchwork-Id: 5750461 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5426B9F358 for ; Fri, 30 Jan 2015 13:53:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 828A72027D for ; Fri, 30 Jan 2015 13:53:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9DEA12025B for ; Fri, 30 Jan 2015 13:53:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932723AbbA3Nrr (ORCPT ); Fri, 30 Jan 2015 08:47:47 -0500 Received: from mail-wg0-f53.google.com ([74.125.82.53]:37878 "EHLO mail-wg0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932702AbbA3Nrp (ORCPT ); Fri, 30 Jan 2015 08:47:45 -0500 Received: by mail-wg0-f53.google.com with SMTP id a1so26880987wgh.12 for ; Fri, 30 Jan 2015 05:47:44 -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=b/yZ0GF3BKwchcOTIAJoYyfkW91R0H/zUpYxB25os8Y=; b=ADgF/lorlM7Us5asbkL78cyz+hFo4Pn5v7h0p4nwhrXdHJIagSG/fpIb3NgyD26Rkp 5FaSrCzDsyLuCylAsNkejTaK5mtafiGhX2wP64zEwOLVQnLO4/K7Hzia3O1CPGVOCxbX p3mFBYT9INTuAe198v3JcI++KqFqN2ZlQbE24/6tBrRifx76w62ApfbtgO2PKMF+f4JV lGHujRkTd2TTziXkWm7T7o61riJ7Qs80SnLjLTf+xtDNgGDf55fO3N781UVoI5SceDJr lQ4127FdNVQs7Csm9V84AsrEBs/q1VwORPNBW2SH4QjKrLPBVZfxoBCsYe+k0QwZvXpM AeJQ== X-Gm-Message-State: ALoCoQkSZhfpVGnpMV/6SA02xDvtyI/7CArHQLAAcTNNAlHaT0Medg4zTBJT1WQeEee7T9fw3zqQ X-Received: by 10.194.77.75 with SMTP id q11mr12661532wjw.116.1422625664327; Fri, 30 Jan 2015 05:47:44 -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 mz10sm7014002wic.9.2015.01.30.05.47.43 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Jan 2015 05:47:43 -0800 (PST) From: Baptiste Reynal To: kvmarm@lists.cs.columbia.edu, iommu@lists.linux-foundation.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 v13 04/18] vfio/platform: return info for bound device Date: Fri, 30 Jan 2015 14:46:10 +0100 Message-Id: <1422625584-3741-5-git-send-email-b.reynal@virtualopensystems.com> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1422625584-3741-1-git-send-email-b.reynal@virtualopensystems.com> References: <1422625584-3741-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)