diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2018-02-07 14:38:53 +0000 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2018-02-07 14:38:53 +0000 |
commit | ea62da0913d20338b8a47bbfaef2e8f2763ee13f (patch) | |
tree | 916e3f25f4bf7799c77a9045e8097ccb59ecb6a1 /hw/vfio/common.c | |
parent | 0833df03f4206a6cf416fbb3d380fa95c8e61fba (diff) | |
parent | db32d0f43839627f54a1a7f8eee17baa770f52d2 (diff) | |
download | qemu-ea62da0913d20338b8a47bbfaef2e8f2763ee13f.zip qemu-ea62da0913d20338b8a47bbfaef2e8f2763ee13f.tar.gz qemu-ea62da0913d20338b8a47bbfaef2e8f2763ee13f.tar.bz2 |
Merge remote-tracking branch 'remotes/awilliam/tags/vfio-update-20180206.0' into staging
VFIO updates 2018-02-06
- SPAPR in-kernel TCE accleration (Alexey Kardashevskiy)
- MSI-X relocation (Alex Williamson)
- Add missing platform mutex init (Eric Auger)
- Redundant variable cleanup (Alexey Kardashevskiy)
- Option to disable GeForce quirks (Alex Williamson)
# gpg: Signature made Tue 06 Feb 2018 18:21:22 GMT
# gpg: using RSA key 239B9B6E3BB08B22
# gpg: Good signature from "Alex Williamson <alex.williamson@redhat.com>"
# gpg: aka "Alex Williamson <alex@shazbot.org>"
# gpg: aka "Alex Williamson <alwillia@redhat.com>"
# gpg: aka "Alex Williamson <alex.l.williamson@gmail.com>"
# Primary key fingerprint: 42F6 C04E 540B D1A9 9E7B 8A90 239B 9B6E 3BB0 8B22
* remotes/awilliam/tags/vfio-update-20180206.0:
vfio/pci: Add option to disable GeForce quirks
vfio/common: Remove redundant copy of local variable
hw/vfio/platform: Init the interrupt mutex
vfio/pci: Allow relocating MSI-X MMIO
qapi: Create DEFINE_PROP_OFF_AUTO_PCIBAR
vfio/pci: Emulate BARs
vfio/pci: Add base BAR MemoryRegion
vfio/pci: Fixup VFIOMSIXInfo comment
spapr/iommu: Enable in-kernel TCE acceleration via VFIO KVM device
vfio/spapr: Use iommu memory region's get_attr()
memory/iommu: Add get_attr()
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/vfio/common.c')
-rw-r--r-- | hw/vfio/common.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/hw/vfio/common.c b/hw/vfio/common.c index b77be3a..ee9240d 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -435,7 +435,6 @@ static void vfio_listener_region_add(MemoryListener *listener, end = int128_get64(int128_sub(llend, int128_one())); if (container->iommu_type == VFIO_SPAPR_TCE_v2_IOMMU) { - VFIOHostDMAWindow *hostwin; hwaddr pgsize = 0; /* For now intersections are not allowed, we may relax this later */ @@ -457,6 +456,33 @@ static void vfio_listener_region_add(MemoryListener *listener, vfio_host_win_add(container, section->offset_within_address_space, section->offset_within_address_space + int128_get64(section->size) - 1, pgsize); +#ifdef CONFIG_KVM + if (kvm_enabled()) { + VFIOGroup *group; + IOMMUMemoryRegion *iommu_mr = IOMMU_MEMORY_REGION(section->mr); + struct kvm_vfio_spapr_tce param; + struct kvm_device_attr attr = { + .group = KVM_DEV_VFIO_GROUP, + .attr = KVM_DEV_VFIO_GROUP_SET_SPAPR_TCE, + .addr = (uint64_t)(unsigned long)¶m, + }; + + if (!memory_region_iommu_get_attr(iommu_mr, IOMMU_ATTR_SPAPR_TCE_FD, + ¶m.tablefd)) { + QLIST_FOREACH(group, &container->group_list, container_next) { + param.groupfd = group->fd; + if (ioctl(vfio_kvm_device_fd, KVM_SET_DEVICE_ATTR, &attr)) { + error_report("vfio: failed to setup fd %d " + "for a group with fd %d: %s", + param.tablefd, param.groupfd, + strerror(errno)); + return; + } + trace_vfio_spapr_group_attach(param.groupfd, param.tablefd); + } + } + } +#endif } hostwin_found = false; |