[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-ppc] [PULL 07/14] vfio/spapr: Create DMA window dynamically (S
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-ppc] [PULL 07/14] vfio/spapr: Create DMA window dynamically (SPAPR IOMMU v2) |
Date: |
Mon, 11 Jul 2016 15:51:44 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 |
On 05/07/2016 07:31, David Gibson wrote:
> + ret = ioctl(container->fd, VFIO_IOMMU_SPAPR_TCE_CREATE, &create);
> + if (ret) {
> + error_report("Failed to create a window, ret = %d (%m)", ret);
> + return -errno;
> + }
> +
> + if (create.start_addr != section->offset_within_address_space) {
> + vfio_spapr_remove_window(container, create.start_addr);
> +
> + error_report("Host doesn't support DMA window at %"HWADDR_PRIx",
> must be %"PRIx64,
> + section->offset_within_address_space,
> + (uint64_t)create.start_addr);
> + ioctl(container->fd, VFIO_IOMMU_SPAPR_TCE_REMOVE, &remove);
Was this ioctl left there by mistake? It passes the address of the
remove *function* to VFIO_IOMMU_SPAPR_TCE_REMOVE.
Thanks,
Paolo
> + return -EINVAL;
> + }
> + trace_vfio_spapr_create_window(create.page_shift,
> + create.window_size,
> + create.start_addr);
> + *pgsize = pagesize;
> +
> + return 0;
> +}
> +
> +int vfio_spapr_remove_window(VFIOContainer *container,
> + hwaddr offset_within_address_space)
> +{
> + struct vfio_iommu_spapr_tce_remove remove = {
> + .argsz = sizeof(remove),
> + .start_addr = offset_within_address_space,
> + };
> + int ret;
> +
> + ret = ioctl(container->fd, VFIO_IOMMU_SPAPR_TCE_REMOVE, &remove);
> + if (ret) {
> + error_report("Failed to remove window at %"PRIx64,
> + (uint64_t)remove.start_addr);
> + return -errno;
> + }
> +
> + trace_vfio_spapr_remove_window(offset_within_address_space);
> +
> + return 0;
> +}
> diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events
> index 0b02a3b..4bb7690 100644
> --- a/hw/vfio/trace-events
> +++ b/hw/vfio/trace-events
> @@ -121,3 +121,5 @@ vfio_prereg_listener_region_add_skip(uint64_t start,
> uint64_t end) "%"PRIx64" -
> vfio_prereg_listener_region_del_skip(uint64_t start, uint64_t end)
> "%"PRIx64" - %"PRIx64
> vfio_prereg_register(uint64_t va, uint64_t size, int ret) "va=%"PRIx64"
> size=%"PRIx64" ret=%d"
> vfio_prereg_unregister(uint64_t va, uint64_t size, int ret) "va=%"PRIx64"
> size=%"PRIx64" ret=%d"
> +vfio_spapr_create_window(int ps, uint64_t ws, uint64_t off) "pageshift=0x%x
> winsize=0x%"PRIx64" offset=0x%"PRIx64
> +vfio_spapr_remove_window(uint64_t off) "offset=%"PRIx64
> diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h
> index b1f3e92..07f7188 100644
> --- a/include/hw/vfio/vfio-common.h
> +++ b/include/hw/vfio/vfio-common.h
> @@ -168,4 +168,10 @@ int vfio_get_dev_region_info(VFIODevice *vbasedev,
> uint32_t type,
> #endif
> extern const MemoryListener vfio_prereg_listener;
>
> +int vfio_spapr_create_window(VFIOContainer *container,
> + MemoryRegionSection *section,
> + hwaddr *pgsize);
> +int vfio_spapr_remove_window(VFIOContainer *container,
> + hwaddr offset_within_address_space);
> +
> #endif /* !HW_VFIO_VFIO_COMMON_H */
>
- [Qemu-ppc] [PULL 12/14] target-ppc: Return page shift from PTEG search, (continued)
- [Qemu-ppc] [PULL 12/14] target-ppc: Return page shift from PTEG search, David Gibson, 2016/07/05
- [Qemu-ppc] [PULL 11/14] target-ppc: Simplify HPTE matching, David Gibson, 2016/07/05
- [Qemu-ppc] [PULL 06/14] vfio: Add host side DMA window capabilities, David Gibson, 2016/07/05
- [Qemu-ppc] [PULL 14/14] ppc/hash64: Fix support for LPCR:ISL, David Gibson, 2016/07/05
- [Qemu-ppc] [PULL 02/14] spapr: Ensure thread0 of CPU core is always realized first, David Gibson, 2016/07/05
- [Qemu-ppc] [PULL 01/14] ppc: Fix xsrdpi, xvrdpi and xvrspi rounding, David Gibson, 2016/07/05
- [Qemu-ppc] [PULL 09/14] ppc: simplify ppc_hash64_hpte_page_shift_noslb(), David Gibson, 2016/07/05
- [Qemu-ppc] [PULL 10/14] target-ppc: Correct page size decoding in ppc_hash64_pteg_search(), David Gibson, 2016/07/05
- [Qemu-ppc] [PULL 04/14] spapr_iommu: Realloc guest visible TCE table when starting/stopping listening, David Gibson, 2016/07/05
- [Qemu-ppc] [PULL 07/14] vfio/spapr: Create DMA window dynamically (SPAPR IOMMU v2), David Gibson, 2016/07/05
- Re: [Qemu-ppc] [PULL 07/14] vfio/spapr: Create DMA window dynamically (SPAPR IOMMU v2),
Paolo Bonzini <=
- [Qemu-ppc] [PULL 13/14] ppc/hash64: Add proper real mode translation support, David Gibson, 2016/07/05
- [Qemu-ppc] [PULL 05/14] vfio: spapr: Add DMA memory preregistering (SPAPR IOMMU v2), David Gibson, 2016/07/05
- [Qemu-ppc] [PULL 08/14] spapr_pci/spapr_pci_vfio: Support Dynamic DMA Windows (DDW), David Gibson, 2016/07/05
- Re: [Qemu-ppc] [PULL 00/14] ppc-for-2.7 queue 20160705 (v2), Peter Maydell, 2016/07/05