diff mbox

[qemu,2/5] vfio: Skip PCI BARs in memory listener

Message ID 1436525028-23963-3-git-send-email-aik@ozlabs.ru
State New
Headers show

Commit Message

Alexey Kardashevskiy July 10, 2015, 10:43 a.m. UTC
In some cases PCI BARs are registered as RAM via
memory_region_init_ram_ptr() and the vfio_memory_listener will be called
on them too. However DMA will not be performed to/from these regions so
just skip them.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
 hw/vfio/common.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Alex Williamson July 13, 2015, 5:08 p.m. UTC | #1
On Fri, 2015-07-10 at 20:43 +1000, Alexey Kardashevskiy wrote:
> In some cases PCI BARs are registered as RAM via
> memory_region_init_ram_ptr() and the vfio_memory_listener will be called
> on them too. However DMA will not be performed to/from these regions so
> just skip them.


Who says?  What about peer-to-peer DMA?  We have all sorts of FUD about
whether the hardware handles this correctly, but mapping PCI MMIO BARs
into the IOMMU allows the possibility of supporting p2p DMA between
devices in the guest.  Thanks,

Alex


> 
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
>  hw/vfio/common.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/vfio/common.c b/hw/vfio/common.c
> index d115ec9..225cdc7 100644
> --- a/hw/vfio/common.c
> +++ b/hw/vfio/common.c
> @@ -248,7 +248,8 @@ static bool vfio_listener_skipped_section(MemoryRegionSection *section)
>              * are never accessed by the CPU and beyond the address width of
>              * some IOMMU hardware.  TODO: VFIO should tell us the IOMMU width.
>              */
> -           section->offset_within_address_space & (1ULL << 63);
> +           section->offset_within_address_space & (1ULL << 63) ||
> +           memory_region_is_skip_dump(section->mr);
>  }
>  
>  static void vfio_iommu_map_notify(Notifier *n, void *data)
diff mbox

Patch

diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index d115ec9..225cdc7 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -248,7 +248,8 @@  static bool vfio_listener_skipped_section(MemoryRegionSection *section)
             * are never accessed by the CPU and beyond the address width of
             * some IOMMU hardware.  TODO: VFIO should tell us the IOMMU width.
             */
-           section->offset_within_address_space & (1ULL << 63);
+           section->offset_within_address_space & (1ULL << 63) ||
+           memory_region_is_skip_dump(section->mr);
 }
 
 static void vfio_iommu_map_notify(Notifier *n, void *data)