From patchwork Wed Aug 7 08:21:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 265395 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C71832C00DC for ; Wed, 7 Aug 2013 18:24:35 +1000 (EST) Received: from localhost ([::1]:34712 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V6z2n-0005Js-2h for incoming@patchwork.ozlabs.org; Wed, 07 Aug 2013 04:24:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59277) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V6z0w-0002zi-5m for qemu-devel@nongnu.org; Wed, 07 Aug 2013 04:22:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V6z0m-0007WX-38 for qemu-devel@nongnu.org; Wed, 07 Aug 2013 04:22:38 -0400 Received: from mail-pd0-f180.google.com ([209.85.192.180]:65509) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V6z0l-0007WF-TA for qemu-devel@nongnu.org; Wed, 07 Aug 2013 04:22:28 -0400 Received: by mail-pd0-f180.google.com with SMTP id 15so1133408pdi.11 for ; Wed, 07 Aug 2013 01:22:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AFOjjMAukEP61q2+Q/yXGb/d3uZsXYWcXIXRClXlRlg=; b=Fh4ExyidWnwXGRJsJY7Bdvtvlu6KfOEBR/oUchxMkqF0kAjKMrzP+1KhXls55386aO ItToRiBgXNcNdDtUFfdG+U/KHnzk8ogQQAOjGwY5raOk/QzqVUj1pUdbQpxB+xnWM7Xn 6gj6GnLyXQIjSpU8RoUJgpUNKzAKHK9A408OcnNRx656Yl0/0dnFsd7K55Jf7d5xv/VM uCbC5Xk+pSxqoR3VBx+TJCC1w5HhBkE12EhmWcjHSDA5gRVWsX1wlFxtCkn/vLUJuNmg B6WeWM1b5QkcNydTpIuIDvYsicgxKvP5oLLZ6iXPq7fUp8rim4dqXWxApn2teepmX7Mc jSmQ== X-Gm-Message-State: ALoCoQl/j1UcqU8r2eHWJUM8IsaHSAYELsHwgmzL9LBjtgpt2mC8E/XC6Yx+4qsfH0f1s1Fh3VLn X-Received: by 10.68.254.73 with SMTP id ag9mr2403063pbd.54.1375863747169; Wed, 07 Aug 2013 01:22:27 -0700 (PDT) Received: from ka1.ozlabs.ibm.com (ibmaus65.lnk.telstra.net. [165.228.126.9]) by mx.google.com with ESMTPSA id 7sm8957160paf.22.2013.08.07.01.22.22 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 07 Aug 2013 01:22:25 -0700 (PDT) From: Alexey Kardashevskiy To: qemu-devel@nongnu.org Date: Wed, 7 Aug 2013 18:21:30 +1000 Message-Id: <1375863692-12207-7-git-send-email-aik@ozlabs.ru> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1375863692-12207-1-git-send-email-aik@ozlabs.ru> References: <1375863692-12207-1-git-send-email-aik@ozlabs.ru> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.192.180 Cc: Anthony Liguori , "Michael S . Tsirkin" , Alexey Kardashevskiy , Alexander Graf , Alex Williamson , qemu-ppc@nongnu.org, Paolo Bonzini , Paul Mackerras , David Gibson Subject: [Qemu-devel] [PATCH 6/8] spapr vfio: add vfio_container_spapr_get_info() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org As sPAPR platform supports DMA windows on a PCI bus, the information about their location and size should be passed into the guest via the device tree. The patch adds a helper to read this info from the container fd. Signed-off-by: Alexey Kardashevskiy --- hw/misc/vfio.c | 37 +++++++++++++++++++++++++++++++++++++ include/hw/misc/vfio.h | 11 +++++++++++ 2 files changed, 48 insertions(+) create mode 100644 include/hw/misc/vfio.h diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c index 3855efe..4571f64 100644 --- a/hw/misc/vfio.c +++ b/hw/misc/vfio.c @@ -39,6 +39,7 @@ #include "qemu/range.h" #include "sysemu/kvm.h" #include "sysemu/sysemu.h" +#include "hw/misc/vfio.h" /* #define DEBUG_VFIO */ #ifdef DEBUG_VFIO @@ -3488,3 +3489,39 @@ static void register_vfio_pci_dev_type(void) } type_init(register_vfio_pci_dev_type) + +int vfio_container_spapr_get_info(AddressSpace *as, int32_t groupid, + struct vfio_iommu_spapr_tce_info *info, + int *group_fd) +{ + VFIOAddressSpace *space; + VFIOGroup *group; + VFIOContainer *container; + int ret, fd; + + space = vfio_get_address_space(as); + if (!space) { + return -1; + } + group = vfio_get_group(groupid, space); + if (!group) { + return -1; + } + container = group->container; + if (!group->container) { + return -1; + } + fd = container->fd; + if (!ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_SPAPR_TCE_IOMMU)) { + return -1; + } + ret = ioctl(fd, VFIO_IOMMU_SPAPR_TCE_GET_INFO, info); + if (ret) { + error_report("vfio: failed to get iommu info for container: %s", + strerror(errno)); + return -1; + } + *group_fd = group->fd; + + return 0; +} diff --git a/include/hw/misc/vfio.h b/include/hw/misc/vfio.h new file mode 100644 index 0000000..ac9a971 --- /dev/null +++ b/include/hw/misc/vfio.h @@ -0,0 +1,11 @@ +#ifndef VFIO_API_H +#define VFIO_API_H + +#include "qemu/typedefs.h" +#include + +extern int vfio_container_spapr_get_info(AddressSpace *as, int32_t groupid, + struct vfio_iommu_spapr_tce_info *info, + int *group_fd); + +#endif