[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PATCH 6/8] spapr vfio: add vfio_container_spapr_get_info()
From: |
Alexey Kardashevskiy |
Subject: |
[Qemu-ppc] [PATCH 6/8] spapr vfio: add vfio_container_spapr_get_info() |
Date: |
Wed, 7 Aug 2013 18:21:30 +1000 |
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 <address@hidden>
---
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 <linux/vfio.h>
+
+extern int vfio_container_spapr_get_info(AddressSpace *as, int32_t groupid,
+ struct vfio_iommu_spapr_tce_info
*info,
+ int *group_fd);
+
+#endif
--
1.8.3.2
- [Qemu-ppc] [PATCH 3/8] vfio: Introduce VFIO address spaces, (continued)
[Qemu-ppc] [PATCH 6/8] spapr vfio: add vfio_container_spapr_get_info(),
Alexey Kardashevskiy <=
[Qemu-ppc] [PATCH 7/8] spapr vfio: add spapr-pci-vfio-host-bridge to support vfio, Alexey Kardashevskiy, 2013/08/07
[Qemu-ppc] [PATCH 8/8] spapr vfio: enable for spapr, Alexey Kardashevskiy, 2013/08/07