virtio-iommu: VFIO integration
v9 cover virtio-iommu: VFIO integration
This patch series integrates VFIO with virtio-iommu. This is only applicable for PCI pass-through with virtio-iommu.
This series is available at:
https://github.com/bharat-bhushan-devel/qemu.git virtio-iommu-vfio-integration-v8
This is tested with assigning more than one pci devices to Virtual Machine.
v8-v9:
- Have page size mask per endpint
- Add PROBE interface, return page size mask
v7->v8:
- Set page size mask as per host
This fixes issue with 64K host/guest
- Device list from IOMMUDevice directly removed VirtioIOMMUNotifierNode
- Add missing iep->viommu init on post-load
v6->v7:
- corrected email-address
v5->v6:
- Rebase to v16 version from Eric
- Tested with upstream Linux
- Added a patch from Eric/Myself on removing mmio-region error print in vfio
v4->v5:
- Rebase to v9 version from Eric
- PCIe device hotplug fix
- Added Patch 1/5 from Eric previous series (Eric somehow dropped in last version.
- Patch "Translate the MSI doorbell in kvm_arch_fixup_msi_route" already integrated with vsmmu3
v3->v4:
- Rebase to v4 version from Eric
- Fixes from Eric with DPDK in VM
- Logical division in multiple patches
v2->v3:
- This series is based on "[RFC v3 0/8] VIRTIO-IOMMU device" Which is based on top of v2.10-rc0 that
- Fixed issue with two PCI devices
- Addressed review comments
v1->v2:
- Added trace events
- removed vSMMU3 link in patch description
Bharat Bhushan (9):
hw/vfio/common: Remove error print on mmio region translation by
viommu
memory: Add interface to set iommu page size mask
vfio: set iommu page size as per host supported page size
virtio-iommu: set supported page size mask
virtio-iommu: Add iommu notifier for map/unmap
virtio-iommu: Call iommu notifier for attach/detach
virtio-iommu: add iommu replay
virtio-iommu: Implement probe request
virtio-iommu: add iommu notifier memory-region
include/exec/memory.h | 20 + include/hw/virtio/virtio-iommu.h | 3 + include/standard-headers/linux/virtio_iommu.h | 6 + hw/vfio/common.c | 5 +- hw/virtio/virtio-iommu.c | 352 +++++++++++++++++- memory.c | 10 + hw/virtio/trace-events | 7 + 7 files changed, 397 insertions(+), 6 deletions(-)
Signature · 1 line
2.17.1
PATCH v9 1/9 hw/vfio/common: Remove error print on mmio region translation by viommu
On ARM, the MSI doorbell is translated by the virtual IOMMU. As such address_space_translate() returns the MSI controller MMIO region and we get an "iommu map to non memory area" message. Let's remove this latter.
--- hw/vfio/common.c | 2 -- 1 file changed, 2 deletions(-)
hw/vfio/common.c +0 -2
@@ -426,8 +426,6 @@ static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb, void **vaddr, &xlat, &len, writable, MEMTXATTRS_UNSPECIFIED);if (!memory_region_is_ram (mr)) { -error_report ("iommu map to non memory area %" HWADDR_PRIx"" , - xlat);return false; }
Signature · 1 line
2.17.1
Re: [PATCH v9 1/9] hw/vfio/common: Remove error print on mmio region translation by viommu
[Cc +dwg who originated this warning]
Quoted 16 lines · On Mon, 23 Mar 2020 14:16:09 +0530 Bharat Bhushan <[email protected]> wrote:
On ARM, the MSI doorbell is translated by the virtual IOMMU. As such
address_space_translate()returns the MSI controller MMIO region and we get an "iommu map to non memory area" message. Let's remove this latter.Signed-off-by Eric Auger <[email protected]>Signed-off-by Bharat Bhushan <[email protected]>--- hw/vfio/common.c | 2 -- 1 file changed, 2 deletions(-)hw/vfio/common.c +0
-0
hw/vfio/common.c static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb, void **vaddr, · line 431
Quoted 8 lines
hw/vfio/common.c +0
-2@@ -426,8 +426,6 @@ static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb, void **vaddr, &xlat, &len, writable, MEMTXATTRS_UNSPECIFIED);if (!memory_region_is_ram (mr)) { -error_report ("iommu map to non memory area %" HWADDR_PRIx"" , - xlat);return false; }
I'm a bit confused here, I think we need more justification beyond "we hit this warning and we don't want to because it's ok in this one special case, therefore remove it". I assume the special case is that the device MSI address is managed via the SET_IRQS ioctl and therefore we won't actually get DMAs to this range. But I imagine the case that was in mind when adding this warning was general peer-to-peer between and assigned and emulated device. Maybe there's an argument to be made that such a p2p mapping might also be used in a non-vIOMMU case. We skip creating those mappings and drivers continue to work, maybe because nobody attempts to do p2p DMA with the types of devices we emulate, maybe because p2p DMA is not absolutely reliable on bare metal and drivers test it before using it. Anyway, I need a better argument why this is ok. Thanks,
Alex
Re: [PATCH v9 1/9] hw/vfio/common: Remove error print on mmio region translation by viommu
Hi Alex,
Quoted 27 lines · Alex Williamson
[Cc +dwg who originated this warning]
Quoted 22 lines · On Mon, 23 Mar 2020 14:16:09 +0530 Bharat Bhushan <[email protected]> wrote:
On ARM, the MSI doorbell is translated by the virtual IOMMU. As such
address_space_translate()returns the MSI controller MMIO region and we get an "iommu map to non memory area" message. Let's remove this latter.Signed-off-by Eric Auger <[email protected]>Signed-off-by Bharat Bhushan <[email protected]>--- hw/vfio/common.c | 2 -- 1 file changed, 2 deletions(-)hw/vfio/common.c +0
-2@@ -426,8 +426,6 @@ static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb, void **vaddr, &xlat, &len, writable, MEMTXATTRS_UNSPECIFIED);if (!memory_region_is_ram (mr)) { -error_report ("iommu map to non memory area %" HWADDR_PRIx"" , - xlat);return false;
Quoted 8 lines
hw/vfio/common.c static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb, void **vaddr, · line 431
Quoted 2 lines
hw/vfio/common.c +0
-0}I'm a bit confused here, I think we need more justification beyond "we hit this warning and we don't want to because it's ok in this one special case, therefore remove it". I assume the special case is that the device MSI address is managed via the
SET_IRQSioctl and therefore we won't actually get DMAs to this range.
Yes exactly. The guest creates a mapping between one giova and this gpa (corresponding to the MSI controller doorbell) because MSIs are mapped on ARM. But practically the physical device is programmed with an host chosen iova that maps onto the physical MSI controller's doorbell. so the device never performs DMA accesses to this range.
But I imagine the case that
Quoted 2 lines
was in mind when adding this warning was general peer-to-peer between and assigned and emulated device.
yes makes sense.
Maybe there's an argument to be made
Quoted 5 lines
that such a p2p mapping might also be used in a non-vIOMMU case. We skip creating those mappings and drivers continue to work, maybe because nobody attempts to do p2p DMA with the types of devices we emulate, maybe because p2p DMA is not absolutely reliable on bare metal and drivers test it before using it.
MSI doorbells are mapped using the IOMMU_MMIO flag (dma-iommu.c iommu_dma_get_msi_page).
One idea could be to pass that flag through the IOMMU Notifier mechanism into the iotlb->perm. Eventually when we get this in vfio_get_vaddr() we would not print the warning. Could that make sense?
Thanks
Eric
Anyway, I need a better argument
Quoted 4 lines
why this is ok. Thanks,
Alex
Re: [PATCH v9 1/9] hw/vfio/common: Remove error print on mmio region translation by viommu
Quoted 55 lines · On Thu, 26 Mar 2020 18:35:48 +0100 Auger Eric <[email protected]> wrote:
Hi Alex,
Quoted 27 lines · Alex Williamson
[Cc +dwg who originated this warning]
Quoted 22 lines · On Mon, 23 Mar 2020 14:16:09 +0530 Bharat Bhushan <[email protected]> wrote:
On ARM, the MSI doorbell is translated by the virtual IOMMU. As such
address_space_translate()returns the MSI controller MMIO region and we get an "iommu map to non memory area" message. Let's remove this latter.Signed-off-by Eric Auger <[email protected]>Signed-off-by Bharat Bhushan <[email protected]>--- hw/vfio/common.c | 2 -- 1 file changed, 2 deletions(-)hw/vfio/common.c +0
-2@@ -426,8 +426,6 @@ static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb, void **vaddr, &xlat, &len, writable, MEMTXATTRS_UNSPECIFIED);if (!memory_region_is_ram (mr)) { -error_report ("iommu map to non memory area %" HWADDR_PRIx"" , - xlat);return false;Quoted 8 lines
hw/vfio/common.c static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb, void **vaddr, · line 431
Quoted 2 lines
hw/vfio/common.c +0
-0}I'm a bit confused here, I think we need more justification beyond "we hit this warning and we don't want to because it's ok in this one special case, therefore remove it". I assume the special case is that the device MSI address is managed via the
SET_IRQSioctl and therefore we won't actually get DMAs to this range.Yes exactly. The guest creates a mapping between one giova and this gpa (corresponding to the MSI controller doorbell) because MSIs are mapped on ARM. But practically the physical device is programmed with an host chosen iova that maps onto the physical MSI controller's doorbell. so the device never performs DMA accesses to this range.
But I imagine the case that
Quoted 2 lines
was in mind when adding this warning was general peer-to-peer between and assigned and emulated device.
yes makes sense.
Maybe there's an argument to be made
Quoted 5 lines
that such a p2p mapping might also be used in a non-vIOMMU case. We skip creating those mappings and drivers continue to work, maybe because nobody attempts to do p2p DMA with the types of devices we emulate, maybe because p2p DMA is not absolutely reliable on bare metal and drivers test it before using it.
Quoted 5 lines
MSI doorbells are mapped using the
IOMMU_MMIOflag (dma-iommu.ciommu_dma_get_msi_page).
One idea could be to pass that flag through the IOMMU Notifier mechanism into theiotlb->perm. Eventually when we get this invfio_get_vaddr()we would not print the warning. Could that make sense?
Yeah, if we can identify a valid case that doesn't need a warning, that's fine by me. Thanks,
Alex
RE: [EXT] Re: [PATCH v9 1/9] hw/vfio/common: Remove error print on mmio region translation by viommu
Hi Alex, Eric,
Quoted 75 lines
-----Original Message-----
From: Alex Williamson <[email protected]>
Sent: Thursday, March 26, 2020 11:23 PM
To: Auger Eric <[email protected]>
Cc: Bharat Bhushan <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Tomasz Nowicki [C] <[email protected]>; [email protected]; [email protected]; [email protected]; qemu- [email protected]; [email protected]; [email protected]; [email protected]; David Gibson <[email protected]>
Subject: [EXT] Re: [PATCH v9 1/9] hw/vfio/common: Remove error print on mmio region translation by viommuExternal Email
----------------------------------------------------------------------
Quoted 19 lines · On Thu, 26 Mar 2020 18:35:48 +0100 Auger Eric <[email protected]> wrote:
Hi Alex,
Quoted 16 lines · Alex Williamson
[Cc +dwg who originated this warning]
Quoted 11 lines · On Mon, 23 Mar 2020 14:16:09 +0530 Bharat Bhushan <[email protected]> wrote:
On ARM, the MSI doorbell is translated by the virtual IOMMU. As such
address_space_translate()returns the MSI controller MMIO region and we get an "iommu map to non memory area" message. Let's remove this latter.Signed-off-by Eric Auger <[email protected]>Signed-off-by Bharat Bhushan <[email protected]>--- hw/vfio/common.c | 2 -- 1 file changed, 2 deletions(-)Quoted 5 lines
Quoted 5 lines
hw/vfio/common.c static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb,
Quoted 5 lines
hw/vfio/common.c index renamed from hw/vfio/common.c +0
-0
5ca11488d6..c586edf47a100644hw/vfio/common.c +0
-0@@ -426,8 +426,6 @@ static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb,void **vaddr,
Quoted 31 lines
Quoted 9 lines
hw/vfio/common.c static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb, void **vaddr, · line 431
Quoted 8 lines
hw/vfio/common.c +0
-2&xlat, &len, writable, MEMTXATTRS_UNSPECIFIED);if (!memory_region_is_ram (mr)) { -error_report ("iommu map to non memory area %" HWADDR_PRIx"" , - xlat);return false; }Quoted 5 lines
I'm a bit confused here, I think we need more justification beyond "we hit this warning and we don't want to because it's ok in this one special case, therefore remove it". I assume the special case is that the device MSI address is managed via the
SET_IRQSioctl and therefore we won't actually get DMAs to this range.Yes exactly. The guest creates a mapping between one giova and this gpa (corresponding to the MSI controller doorbell) because MSIs are mapped on ARM. But practically the physical device is programmed with an host chosen iova that maps onto the physical MSI controller's doorbell. so the device never performs DMA accesses to this range.
But I imagine the case that
Quoted 2 lines
was in mind when adding this warning was general peer-to-peer between and assigned and emulated device.
yes makes sense.
Maybe there's an argument to be made
Quoted 5 lines
that such a p2p mapping might also be used in a non-vIOMMU case. We skip creating those mappings and drivers continue to work, maybe because nobody attempts to do p2p DMA with the types of devices we emulate, maybe because p2p DMA is not absolutely reliable on bare metal and drivers test it before using it.
Quoted 8 lines
Quoted 5 lines
MSI doorbells are mapped using the
IOMMU_MMIOflag (dma-iommu.ciommu_dma_get_msi_page).
One idea could be to pass that flag through the IOMMU Notifier mechanism into theiotlb->perm. Eventually when we get this invfio_get_vaddr()we would not print the warning. Could that make sense?Yeah, if we can identify a valid case that doesn't need a warning, that's fine by me. Thanks,
Will change as per above suggestion by Eric.
Thanks
-Bharat
Quoted 2 lines
Alex
RE: [EXT] Re: [PATCH v9 1/9] hw/vfio/common: Remove error print on mmio region translation by viommu
In reply to Alex WilliamsonHi Eric/Alex,
Quoted 75 lines
-----Original Message-----
From: Alex Williamson <[email protected]>
Sent: Thursday, March 26, 2020 11:23 PM
To: Auger Eric <[email protected]>
Cc: Bharat Bhushan <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Tomasz Nowicki [C] <[email protected]>; [email protected]; [email protected]; [email protected]; qemu- [email protected]; [email protected]; [email protected]; [email protected]; David Gibson <[email protected]>
Subject: [EXT] Re: [PATCH v9 1/9] hw/vfio/common: Remove error print on mmio region translation by viommuExternal Email
----------------------------------------------------------------------
Quoted 19 lines · On Thu, 26 Mar 2020 18:35:48 +0100 Auger Eric <[email protected]> wrote:
Hi Alex,
Quoted 16 lines · Alex Williamson
[Cc +dwg who originated this warning]
Quoted 11 lines · On Mon, 23 Mar 2020 14:16:09 +0530 Bharat Bhushan <[email protected]> wrote:
On ARM, the MSI doorbell is translated by the virtual IOMMU. As such
address_space_translate()returns the MSI controller MMIO region and we get an "iommu map to non memory area" message. Let's remove this latter.Signed-off-by Eric Auger <[email protected]>Signed-off-by Bharat Bhushan <[email protected]>--- hw/vfio/common.c | 2 -- 1 file changed, 2 deletions(-)Quoted 5 lines
Quoted 5 lines
hw/vfio/common.c static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb,
Quoted 5 lines
hw/vfio/common.c index renamed from hw/vfio/common.c +0
-0
5ca11488d6..c586edf47a100644hw/vfio/common.c +0
-0@@ -426,8 +426,6 @@ static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb,void **vaddr,
Quoted 31 lines
Quoted 9 lines
hw/vfio/common.c static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb, void **vaddr, · line 431
Quoted 8 lines
hw/vfio/common.c +0
-2&xlat, &len, writable, MEMTXATTRS_UNSPECIFIED);if (!memory_region_is_ram (mr)) { -error_report ("iommu map to non memory area %" HWADDR_PRIx"" , - xlat);return false; }Quoted 5 lines
I'm a bit confused here, I think we need more justification beyond "we hit this warning and we don't want to because it's ok in this one special case, therefore remove it". I assume the special case is that the device MSI address is managed via the
SET_IRQSioctl and therefore we won't actually get DMAs to this range.Yes exactly. The guest creates a mapping between one giova and this gpa (corresponding to the MSI controller doorbell) because MSIs are mapped on ARM. But practically the physical device is programmed with an host chosen iova that maps onto the physical MSI controller's doorbell. so the device never performs DMA accesses to this range.
But I imagine the case that
Quoted 2 lines
was in mind when adding this warning was general peer-to-peer between and assigned and emulated device.
yes makes sense.
Maybe there's an argument to be made
Quoted 5 lines
that such a p2p mapping might also be used in a non-vIOMMU case. We skip creating those mappings and drivers continue to work, maybe because nobody attempts to do p2p DMA with the types of devices we emulate, maybe because p2p DMA is not absolutely reliable on bare metal and drivers test it before using it.
Quoted 8 lines
Quoted 5 lines
MSI doorbells are mapped using the
IOMMU_MMIOflag (dma-iommu.ciommu_dma_get_msi_page).
One idea could be to pass that flag through the IOMMU Notifier mechanism into theiotlb->perm. Eventually when we get this invfio_get_vaddr()we would not print the warning. Could that make sense?Yeah, if we can identify a valid case that doesn't need a warning, that's fine by me. Thanks,
Let me know if I understood the proposal correctly:
virtio-iommu driver in guest will make map (VIRTIO_IOMMU_T_MAP) with VIRTIO_IOMMU_MAP_F_MMIO flag for MSI mapping.
In qemu, virtio-iommu device will set a new defined flag (say IOMMU_MMIO) in iotlb->perm in memory_region_notify_iommu(). vfio_get_vaddr() will check same flag and will not print the warning.
Is above correct?
Thanks
-Bharat
Quoted 2 lines
Alex
Re: [EXT] Re: [PATCH v9 1/9] hw/vfio/common: Remove error print on mmio region translation by viommu
Hi Bharat,
Quoted 83 lines · Bharat Bhushan
Hi Eric/Alex,
Quoted 81 lines
-----Original Message-----
From: Alex Williamson <[email protected]>
Sent: Thursday, March 26, 2020 11:23 PM
To: Auger Eric <[email protected]>
Cc: Bharat Bhushan <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Tomasz Nowicki [C] <[email protected]>; [email protected]; [email protected]; [email protected]; qemu- [email protected]; [email protected]; [email protected]; [email protected]; David Gibson <[email protected]>
Subject: [EXT] Re: [PATCH v9 1/9] hw/vfio/common: Remove error print on mmio region translation by viommuExternal Email
----------------------------------------------------------------------
Quoted 19 lines · On Thu, 26 Mar 2020 18:35:48 +0100 Auger Eric <[email protected]> wrote:
Hi Alex,
Quoted 16 lines · Alex Williamson
[Cc +dwg who originated this warning]
Quoted 11 lines · On Mon, 23 Mar 2020 14:16:09 +0530 Bharat Bhushan <[email protected]> wrote:
On ARM, the MSI doorbell is translated by the virtual IOMMU. As such
address_space_translate()returns the MSI controller MMIO region and we get an "iommu map to non memory area" message. Let's remove this latter.Signed-off-by Eric Auger <[email protected]>Signed-off-by Bharat Bhushan <[email protected]>--- hw/vfio/common.c | 2 -- 1 file changed, 2 deletions(-)Quoted 5 lines
Quoted 5 lines
hw/vfio/common.c static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb,
Quoted 5 lines
hw/vfio/common.c index renamed from hw/vfio/common.c +0
-0
5ca11488d6..c586edf47a100644hw/vfio/common.c +0
-0@@ -426,8 +426,6 @@ static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb,void **vaddr,
Quoted 36 lines
Quoted 9 lines
hw/vfio/common.c static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb, void **vaddr, · line 431
Quoted 8 lines
hw/vfio/common.c +0
-2&xlat, &len, writable, MEMTXATTRS_UNSPECIFIED);if (!memory_region_is_ram (mr)) { -error_report ("iommu map to non memory area %" HWADDR_PRIx"" , - xlat);return false; }Quoted 5 lines
I'm a bit confused here, I think we need more justification beyond "we hit this warning and we don't want to because it's ok in this one special case, therefore remove it". I assume the special case is that the device MSI address is managed via the
SET_IRQSioctl and therefore we won't actually get DMAs to this range.Yes exactly. The guest creates a mapping between one giova and this gpa (corresponding to the MSI controller doorbell) because MSIs are mapped on ARM. But practically the physical device is programmed with an host chosen iova that maps onto the physical MSI controller's doorbell. so the device never performs DMA accesses to this range.
But I imagine the case that
Quoted 2 lines
was in mind when adding this warning was general peer-to-peer between and assigned and emulated device.
yes makes sense.
Maybe there's an argument to be made
Quoted 5 lines
that such a p2p mapping might also be used in a non-vIOMMU case. We skip creating those mappings and drivers continue to work, maybe because nobody attempts to do p2p DMA with the types of devices we emulate, maybe because p2p DMA is not absolutely reliable on bare metal and drivers test it before using it.
MSI doorbells are mapped using the
IOMMU_MMIOflag (dma-iommu.ciommu_dma_get_msi_page).
One idea could be to pass that flag through the IOMMU Notifier mechanism into theiotlb->perm. Eventually when we get this invfio_get_vaddr()we would not print the warning. Could that make sense?
Quoted 8 lines
Quoted 2 lines
Yeah, if we can identify a valid case that doesn't need a warning, that's fine by me. Thanks,
Let me know if I understood the proposal correctly:
virtio-iommu driver in guest will make map (
VIRTIO_IOMMU_T_MAP) withVIRTIO_IOMMU_MAP_F_MMIOflag for MSI mapping.
In qemu, virtio-iommu device will set a new defined flag (sayIOMMU_MMIO) iniotlb->perminmemory_region_notify_iommu().vfio_get_vaddr()will check same flag and will not print the warning.> Is above correct?
Yes that's what I had in mind.
Thanks
Eric
Quoted 8 lines
Thanks
-BharatQuoted 2 lines
Alex
Re: [EXT] Re: [PATCH v9 1/9] hw/vfio/common: Remove error print on mmio region translation by viommu
Hi Eric,
Quoted 90 lines · Auger Eric
Hi Bharat,
Quoted 86 lines · Bharat Bhushan
Hi Eric/Alex,
Quoted 83 lines
-----Original Message-----
From: Alex Williamson <[email protected]>
Sent: Thursday, March 26, 2020 11:23 PM
To: Auger Eric <[email protected]>
Cc: Bharat Bhushan <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Tomasz Nowicki [C] <[email protected]>; [email protected]; [email protected]; [email protected]; qemu- [email protected]; [email protected]; [email protected]; [email protected]; David Gibson <[email protected]>
Subject: [EXT] Re: [PATCH v9 1/9] hw/vfio/common: Remove error print on mmio region translation by viommuExternal Email
----------------------------------------------------------------------
Quoted 19 lines · On Thu, 26 Mar 2020 18:35:48 +0100 Auger Eric <[email protected]> wrote:
Hi Alex,
Quoted 16 lines · Alex Williamson
[Cc +dwg who originated this warning]
Quoted 11 lines · On Mon, 23 Mar 2020 14:16:09 +0530 Bharat Bhushan <[email protected]> wrote:
On ARM, the MSI doorbell is translated by the virtual IOMMU. As such
address_space_translate()returns the MSI controller MMIO region and we get an "iommu map to non memory area" message. Let's remove this latter.Signed-off-by Eric Auger <[email protected]>Signed-off-by Bharat Bhushan <[email protected]>--- hw/vfio/common.c | 2 -- 1 file changed, 2 deletions(-)Quoted 5 lines
Quoted 5 lines
hw/vfio/common.c static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb,
Quoted 5 lines
hw/vfio/common.c index renamed from hw/vfio/common.c +0
-0
5ca11488d6..c586edf47a100644hw/vfio/common.c +0
-0@@ -426,8 +426,6 @@ static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb,void **vaddr,
Quoted 31 lines
Quoted 9 lines
hw/vfio/common.c static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb, void **vaddr, · line 431
Quoted 8 lines
hw/vfio/common.c +0
-2&xlat, &len, writable, MEMTXATTRS_UNSPECIFIED);if (!memory_region_is_ram (mr)) { -error_report ("iommu map to non memory area %" HWADDR_PRIx"" , - xlat);return false; }Quoted 5 lines
I'm a bit confused here, I think we need more justification beyond "we hit this warning and we don't want to because it's ok in this one special case, therefore remove it". I assume the special case is that the device MSI address is managed via the
SET_IRQSioctl and therefore we won't actually get DMAs to this range.Yes exactly. The guest creates a mapping between one giova and this gpa (corresponding to the MSI controller doorbell) because MSIs are mapped on ARM. But practically the physical device is programmed with an host chosen iova that maps onto the physical MSI controller's doorbell. so the device never performs DMA accesses to this range.
But I imagine the case that
Quoted 2 lines
was in mind when adding this warning was general peer-to-peer between and assigned and emulated device.
yes makes sense.
Maybe there's an argument to be made
Quoted 5 lines
that such a p2p mapping might also be used in a non-vIOMMU case. We skip creating those mappings and drivers continue to work, maybe because nobody attempts to do p2p DMA with the types of devices we emulate, maybe because p2p DMA is not absolutely reliable on bare metal and drivers test it before using it.
Quoted 5 lines
MSI doorbells are mapped using the
IOMMU_MMIOflag (dma-iommu.ciommu_dma_get_msi_page).
One idea could be to pass that flag through the IOMMU Notifier mechanism into theiotlb->perm. Eventually when we get this invfio_get_vaddr()we would not print the warning. Could that make sense?Yeah, if we can identify a valid case that doesn't need a warning, that's fine by me. Thanks,
Quoted 6 lines
Quoted 5 lines
Let me know if I understood the proposal correctly:
virtio-iommu driver in guest will make map (
VIRTIO_IOMMU_T_MAP) withVIRTIO_IOMMU_MAP_F_MMIOflag for MSI mapping.
In qemu, virtio-iommu device will set a new defined flag (sayIOMMU_MMIO) iniotlb->perminmemory_region_notify_iommu().vfio_get_vaddr()will check same flag and will not print the warning.> Is above correct?Yes that's what I had in mind.
In that case virtio-iommu driver in guest should not make map (VIRTIO_IOMMU_T_MAP) call as it known nothing to be mapped.
Stay Safe
Thanks
-Bharat
Quoted 13 lines
Thanks
Eric
Quoted 8 lines
Thanks
-BharatQuoted 2 lines
Alex
Re: [EXT] Re: [PATCH v9 1/9] hw/vfio/common: Remove error print on mmio region translation by viommu
Hi Bharat,
Quoted 95 lines · Bharat Bhushan
Hi Eric,
Quoted 92 lines · Auger Eric
Hi Bharat,
Quoted 88 lines · Bharat Bhushan
Hi Eric/Alex,
Quoted 75 lines
-----Original Message-----
From: Alex Williamson <[email protected]>
Sent: Thursday, March 26, 2020 11:23 PM
To: Auger Eric <[email protected]>
Cc: Bharat Bhushan <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Tomasz Nowicki [C] <[email protected]>; [email protected]; [email protected]; [email protected]; qemu- [email protected]; [email protected]; [email protected]; [email protected]; David Gibson <[email protected]>
Subject: [EXT] Re: [PATCH v9 1/9] hw/vfio/common: Remove error print on mmio region translation by viommuExternal Email
----------------------------------------------------------------------
Quoted 19 lines · On Thu, 26 Mar 2020 18:35:48 +0100 Auger Eric <[email protected]> wrote:
Hi Alex,
Quoted 16 lines · Alex Williamson
[Cc +dwg who originated this warning]
Quoted 11 lines · On Mon, 23 Mar 2020 14:16:09 +0530 Bharat Bhushan <[email protected]> wrote:
On ARM, the MSI doorbell is translated by the virtual IOMMU. As such
address_space_translate()returns the MSI controller MMIO region and we get an "iommu map to non memory area" message. Let's remove this latter.Signed-off-by Eric Auger <[email protected]>Signed-off-by Bharat Bhushan <[email protected]>--- hw/vfio/common.c | 2 -- 1 file changed, 2 deletions(-)Quoted 5 lines
Quoted 5 lines
hw/vfio/common.c static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb,
Quoted 5 lines
hw/vfio/common.c index renamed from hw/vfio/common.c +0
-0
5ca11488d6..c586edf47a100644hw/vfio/common.c +0
-0@@ -426,8 +426,6 @@ static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb,void **vaddr,
Quoted 31 lines
Quoted 9 lines
hw/vfio/common.c static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb, · line 431
Quoted 8 lines
hw/vfio/common.c +0
-2&xlat, &len, writable, MEMTXATTRS_UNSPECIFIED);if (!memory_region_is_ram (mr)) { -error_report ("iommu map to non memory area %" HWADDR_PRIx"" , - xlat);return false; }Quoted 5 lines
I'm a bit confused here, I think we need more justification beyond "we hit this warning and we don't want to because it's ok in this one special case, therefore remove it". I assume the special case is that the device MSI address is managed via the
SET_IRQSioctl and therefore we won't actually get DMAs to this range.Yes exactly. The guest creates a mapping between one giova and this gpa (corresponding to the MSI controller doorbell) because MSIs are mapped on ARM. But practically the physical device is programmed with an host chosen iova that maps onto the physical MSI controller's doorbell. so the device never performs DMA accesses to this range.
But I imagine the case that
Quoted 2 lines
was in mind when adding this warning was general peer-to-peer between and assigned and emulated device.
yes makes sense.
Maybe there's an argument to be made
Quoted 5 lines
that such a p2p mapping might also be used in a non-vIOMMU case. We skip creating those mappings and drivers continue to work, maybe because nobody attempts to do p2p DMA with the types of devices we emulate, maybe because p2p DMA is not absolutely reliable on bare metal and drivers test it before using it.
Quoted 8 lines
Quoted 5 lines
MSI doorbells are mapped using the
IOMMU_MMIOflag (dma-iommu.ciommu_dma_get_msi_page).
One idea could be to pass that flag through the IOMMU Notifier mechanism into theiotlb->perm. Eventually when we get this invfio_get_vaddr()we would not print the warning. Could that make sense?Yeah, if we can identify a valid case that doesn't need a warning, that's fine by me. Thanks,
Let me know if I understood the proposal correctly:
Quoted 7 lines
Quoted 4 lines
Quoted 3 lines
virtio-iommu driver in guest will make map (
VIRTIO_IOMMU_T_MAP) withVIRTIO_IOMMU_MAP_F_MMIOflag for MSI mapping.
In qemu, virtio-iommu device will set a new defined flag (sayIOMMU_MMIO) iniotlb->perminmemory_region_notify_iommu().vfio_get_vaddr()will check same flag and will not print the warning.> Is above correct?Yes that's what I had in mind.
In that case virtio-iommu driver in guest should not make map (
VIRTIO_IOMMU_T_MAP) call as it known nothing to be mapped.
sorry I don't catch what you meant. Please can you elaborate?
Thanks
Eric
Quoted 20 lines
Stay Safe
Thanks
-BharatQuoted 13 lines
Thanks
Eric
Quoted 8 lines
Thanks
-BharatQuoted 2 lines
Alex
Re: [EXT] Re: [PATCH v9 1/9] hw/vfio/common: Remove error print on mmio region translation by viommu
hi Eric,
Quoted 99 lines · Auger Eric
Hi Bharat,
Quoted 95 lines · Bharat Bhushan
Hi Eric,
Quoted 92 lines · Auger Eric
Hi Bharat,
Quoted 88 lines · Bharat Bhushan
Hi Eric/Alex,
Quoted 75 lines
-----Original Message-----
From: Alex Williamson <[email protected]>
Sent: Thursday, March 26, 2020 11:23 PM
To: Auger Eric <[email protected]>
Cc: Bharat Bhushan <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Tomasz Nowicki [C] <[email protected]>; [email protected]; [email protected]; [email protected]; qemu- [email protected]; [email protected]; [email protected]; [email protected]; David Gibson <[email protected]>
Subject: [EXT] Re: [PATCH v9 1/9] hw/vfio/common: Remove error print on mmio region translation by viommuExternal Email
----------------------------------------------------------------------
Quoted 19 lines · On Thu, 26 Mar 2020 18:35:48 +0100 Auger Eric <[email protected]> wrote:
Hi Alex,
Quoted 16 lines · Alex Williamson
[Cc +dwg who originated this warning]
Quoted 11 lines · On Mon, 23 Mar 2020 14:16:09 +0530 Bharat Bhushan <[email protected]> wrote:
On ARM, the MSI doorbell is translated by the virtual IOMMU. As such
address_space_translate()returns the MSI controller MMIO region and we get an "iommu map to non memory area" message. Let's remove this latter.Signed-off-by Eric Auger <[email protected]>Signed-off-by Bharat Bhushan <[email protected]>--- hw/vfio/common.c | 2 -- 1 file changed, 2 deletions(-)Quoted 5 lines
Quoted 5 lines
hw/vfio/common.c static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb,
Quoted 5 lines
hw/vfio/common.c index renamed from hw/vfio/common.c +0
-0
5ca11488d6..c586edf47a100644hw/vfio/common.c +0
-0@@ -426,8 +426,6 @@ static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb,void **vaddr,
Quoted 31 lines
Quoted 9 lines
hw/vfio/common.c static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb, · line 431
Quoted 8 lines
hw/vfio/common.c +0
-2&xlat, &len, writable, MEMTXATTRS_UNSPECIFIED);if (!memory_region_is_ram (mr)) { -error_report ("iommu map to non memory area %" HWADDR_PRIx"" , - xlat);return false; }Quoted 5 lines
I'm a bit confused here, I think we need more justification beyond "we hit this warning and we don't want to because it's ok in this one special case, therefore remove it". I assume the special case is that the device MSI address is managed via the
SET_IRQSioctl and therefore we won't actually get DMAs to this range.Yes exactly. The guest creates a mapping between one giova and this gpa (corresponding to the MSI controller doorbell) because MSIs are mapped on ARM. But practically the physical device is programmed with an host chosen iova that maps onto the physical MSI controller's doorbell. so the device never performs DMA accesses to this range.
But I imagine the case that
Quoted 2 lines
was in mind when adding this warning was general peer-to-peer between and assigned and emulated device.
yes makes sense.
Maybe there's an argument to be made
Quoted 5 lines
that such a p2p mapping might also be used in a non-vIOMMU case. We skip creating those mappings and drivers continue to work, maybe because nobody attempts to do p2p DMA with the types of devices we emulate, maybe because p2p DMA is not absolutely reliable on bare metal and drivers test it before using it.
Quoted 8 lines
Quoted 5 lines
MSI doorbells are mapped using the
IOMMU_MMIOflag (dma-iommu.ciommu_dma_get_msi_page).
One idea could be to pass that flag through the IOMMU Notifier mechanism into theiotlb->perm. Eventually when we get this invfio_get_vaddr()we would not print the warning. Could that make sense?Yeah, if we can identify a valid case that doesn't need a warning, that's fine by me. Thanks,
Let me know if I understood the proposal correctly:
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
Quoted 3 lines
virtio-iommu driver in guest will make map (
VIRTIO_IOMMU_T_MAP) withVIRTIO_IOMMU_MAP_F_MMIOflag for MSI mapping.
In qemu, virtio-iommu device will set a new defined flag (sayIOMMU_MMIO) iniotlb->perminmemory_region_notify_iommu().vfio_get_vaddr()will check same flag and will not print the warning.> Is above correct?Yes that's what I had in mind.
In that case virtio-iommu driver in guest should not make map (
VIRTIO_IOMMU_T_MAP) call as it known nothing to be mapped.sorry I don't catch what you meant. Please can you elaborate?
What I understood of the proposal is:
Linux:
1) MSI doorbells are mapped using the IOMMU_MMIO flag (dma-iommu.ciommu_dma_get_msi_page)
2) virtio-iommu driver in guest will make map (VIRTIO_IOMMU_T_MAP)
with VIRTIO_IOMMU_MAP_F_MMIO flag for MSI mapping.
GEMU:
3) virtio-iommu device - If VIRTIO_IOMMU_MAP_F_MMIO flag set then will set a new defined flag (say IOMMU_MMIO) in iotlb->perm in memory_region_notify_iommu()
4. vfio_get_vaddr() will check same flag and will not print the warning. Also vfio_iommu_map_notify() will not do anything.
So, rather than going down to step 3 and 4, can we avoid maling map() calling in step-2 itself?
Thanks
-Bharat
Quoted 25 lines
Thanks
Eric
Quoted 20 lines
Stay Safe
Thanks
-BharatQuoted 13 lines
Thanks
Eric
Quoted 8 lines
Thanks
-BharatQuoted 2 lines
Alex
Re: [EXT] Re: [PATCH v9 1/9] hw/vfio/common: Remove error print on mmio region translation by viommu
Hi Eric,
Quoted 126 lines · Bharat Bhushan
hi Eric,
Quoted 99 lines · Auger Eric
Hi Bharat,
Quoted 95 lines · Bharat Bhushan
Hi Eric,
Quoted 92 lines · Auger Eric
Hi Bharat,
Quoted 88 lines · Bharat Bhushan
Hi Eric/Alex,
Quoted 75 lines
-----Original Message-----
From: Alex Williamson <[email protected]>
Sent: Thursday, March 26, 2020 11:23 PM
To: Auger Eric <[email protected]>
Cc: Bharat Bhushan <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Tomasz Nowicki [C] <[email protected]>; [email protected]; [email protected]; [email protected]; qemu- [email protected]; [email protected]; [email protected]; [email protected]; David Gibson <[email protected]>
Subject: [EXT] Re: [PATCH v9 1/9] hw/vfio/common: Remove error print on mmio region translation by viommuExternal Email
----------------------------------------------------------------------
Quoted 19 lines · On Thu, 26 Mar 2020 18:35:48 +0100 Auger Eric <[email protected]> wrote:
Hi Alex,
Quoted 16 lines · Alex Williamson
[Cc +dwg who originated this warning]
Quoted 11 lines · On Mon, 23 Mar 2020 14:16:09 +0530 Bharat Bhushan <[email protected]> wrote:
On ARM, the MSI doorbell is translated by the virtual IOMMU. As such
address_space_translate()returns the MSI controller MMIO region and we get an "iommu map to non memory area" message. Let's remove this latter.Signed-off-by Eric Auger <[email protected]>Signed-off-by Bharat Bhushan <[email protected]>--- hw/vfio/common.c | 2 -- 1 file changed, 2 deletions(-)Quoted 5 lines
Quoted 5 lines
hw/vfio/common.c static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb,
Quoted 5 lines
hw/vfio/common.c index renamed from hw/vfio/common.c +0
-0
5ca11488d6..c586edf47a100644hw/vfio/common.c +0
-0@@ -426,8 +426,6 @@ static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb,void **vaddr,
Quoted 31 lines
Quoted 9 lines
hw/vfio/common.c static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb, · line 431
Quoted 8 lines
hw/vfio/common.c +0
-2&xlat, &len, writable, MEMTXATTRS_UNSPECIFIED);if (!memory_region_is_ram (mr)) { -error_report ("iommu map to non memory area %" HWADDR_PRIx"" , - xlat);return false; }Quoted 5 lines
I'm a bit confused here, I think we need more justification beyond "we hit this warning and we don't want to because it's ok in this one special case, therefore remove it". I assume the special case is that the device MSI address is managed via the
SET_IRQSioctl and therefore we won't actually get DMAs to this range.Yes exactly. The guest creates a mapping between one giova and this gpa (corresponding to the MSI controller doorbell) because MSIs are mapped on ARM. But practically the physical device is programmed with an host chosen iova that maps onto the physical MSI controller's doorbell. so the device never performs DMA accesses to this range.
But I imagine the case that
Quoted 2 lines
was in mind when adding this warning was general peer-to-peer between and assigned and emulated device.
yes makes sense.
Maybe there's an argument to be made
Quoted 5 lines
that such a p2p mapping might also be used in a non-vIOMMU case. We skip creating those mappings and drivers continue to work, maybe because nobody attempts to do p2p DMA with the types of devices we emulate, maybe because p2p DMA is not absolutely reliable on bare metal and drivers test it before using it.
Quoted 8 lines
Quoted 5 lines
MSI doorbells are mapped using the
IOMMU_MMIOflag (dma-iommu.ciommu_dma_get_msi_page).
One idea could be to pass that flag through the IOMMU Notifier mechanism into theiotlb->perm. Eventually when we get this invfio_get_vaddr()we would not print the warning. Could that make sense?Yeah, if we can identify a valid case that doesn't need a warning, that's fine by me. Thanks,
Let me know if I understood the proposal correctly:
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
Quoted 3 lines
virtio-iommu driver in guest will make map (
VIRTIO_IOMMU_T_MAP) withVIRTIO_IOMMU_MAP_F_MMIOflag for MSI mapping.
In qemu, virtio-iommu device will set a new defined flag (sayIOMMU_MMIO) iniotlb->perminmemory_region_notify_iommu().vfio_get_vaddr()will check same flag and will not print the warning.> Is above correct?Yes that's what I had in mind.
In that case virtio-iommu driver in guest should not make map (
VIRTIO_IOMMU_T_MAP) call as it known nothing to be mapped.sorry I don't catch what you meant. Please can you elaborate?
What I understood of the proposal is:
Linux:
1) MSI doorbells are mapped using theIOMMU_MMIOflag (dma-iommu.ciommu_dma_get_msi_page)
2) virtio-iommu driver in guest will make map (VIRTIO_IOMMU_T_MAP)
withVIRTIO_IOMMU_MAP_F_MMIOflag for MSI mapping.GEMU:
3) virtio-iommu device - IfVIRTIO_IOMMU_MAP_F_MMIOflag set then will set a new defined flag (sayIOMMU_MMIO) iniotlb->perminmemory_region_notify_iommu()
4.vfio_get_vaddr()will check same flag and will not print the warning. Alsovfio_iommu_map_notify()will not do anything.
Quoted 2 lines
So, rather than going down to step 3 and 4, can we avoid maling
map()calling in step-2 itself?
ohh, We need to setup msi translation mapping, correct.
Thanks
-Bharat
Quoted 29 lines
Thanks
-BharatQuoted 25 lines
Thanks
Eric
Quoted 20 lines
Stay Safe
Thanks
-BharatQuoted 13 lines
Thanks
Eric
Quoted 8 lines
Thanks
-BharatQuoted 2 lines
Alex
Re: [EXT] Re: [PATCH v9 1/9] hw/vfio/common: Remove error print on mmio region translation by viommu
Hi Bharat,
Quoted 129 lines · Bharat Bhushan
Hi Eric,
Quoted 126 lines · Bharat Bhushan
hi Eric,
Quoted 99 lines · Auger Eric
Hi Bharat,
Quoted 95 lines · Bharat Bhushan
Hi Eric,
Quoted 92 lines · Auger Eric
Hi Bharat,
Quoted 88 lines · Bharat Bhushan
Hi Eric/Alex,
Quoted 75 lines
-----Original Message-----
From: Alex Williamson <[email protected]>
Sent: Thursday, March 26, 2020 11:23 PM
To: Auger Eric <[email protected]>
Cc: Bharat Bhushan <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Tomasz Nowicki [C] <[email protected]>; [email protected]; [email protected]; [email protected]; qemu- [email protected]; [email protected]; [email protected]; [email protected]; David Gibson <[email protected]>
Subject: [EXT] Re: [PATCH v9 1/9] hw/vfio/common: Remove error print on mmio region translation by viommuExternal Email
----------------------------------------------------------------------
Quoted 19 lines · On Thu, 26 Mar 2020 18:35:48 +0100 Auger Eric <[email protected]> wrote:
Hi Alex,
Quoted 16 lines · Alex Williamson
[Cc +dwg who originated this warning]
Quoted 11 lines · On Mon, 23 Mar 2020 14:16:09 +0530 Bharat Bhushan <[email protected]> wrote:
On ARM, the MSI doorbell is translated by the virtual IOMMU. As such
address_space_translate()returns the MSI controller MMIO region and we get an "iommu map to non memory area" message. Let's remove this latter.Signed-off-by Eric Auger <[email protected]>Signed-off-by Bharat Bhushan <[email protected]>--- hw/vfio/common.c | 2 -- 1 file changed, 2 deletions(-)Quoted 5 lines
Quoted 5 lines
hw/vfio/common.c static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb,
Quoted 5 lines
hw/vfio/common.c index renamed from hw/vfio/common.c +0
-0
5ca11488d6..c586edf47a100644hw/vfio/common.c +0
-0@@ -426,8 +426,6 @@ static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb,void **vaddr,
Quoted 31 lines
Quoted 9 lines
hw/vfio/common.c static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb, · line 431
Quoted 8 lines
hw/vfio/common.c +0
-2&xlat, &len, writable, MEMTXATTRS_UNSPECIFIED);if (!memory_region_is_ram (mr)) { -error_report ("iommu map to non memory area %" HWADDR_PRIx"" , - xlat);return false; }Quoted 5 lines
I'm a bit confused here, I think we need more justification beyond "we hit this warning and we don't want to because it's ok in this one special case, therefore remove it". I assume the special case is that the device MSI address is managed via the
SET_IRQSioctl and therefore we won't actually get DMAs to this range.Yes exactly. The guest creates a mapping between one giova and this gpa (corresponding to the MSI controller doorbell) because MSIs are mapped on ARM. But practically the physical device is programmed with an host chosen iova that maps onto the physical MSI controller's doorbell. so the device never performs DMA accesses to this range.
But I imagine the case that
Quoted 2 lines
was in mind when adding this warning was general peer-to-peer between and assigned and emulated device.
yes makes sense.
Maybe there's an argument to be made
Quoted 5 lines
that such a p2p mapping might also be used in a non-vIOMMU case. We skip creating those mappings and drivers continue to work, maybe because nobody attempts to do p2p DMA with the types of devices we emulate, maybe because p2p DMA is not absolutely reliable on bare metal and drivers test it before using it.
Quoted 8 lines
Quoted 5 lines
MSI doorbells are mapped using the
IOMMU_MMIOflag (dma-iommu.ciommu_dma_get_msi_page).
One idea could be to pass that flag through the IOMMU Notifier mechanism into theiotlb->perm. Eventually when we get this invfio_get_vaddr()we would not print the warning. Could that make sense?Yeah, if we can identify a valid case that doesn't need a warning, that's fine by me. Thanks,
Let me know if I understood the proposal correctly:
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
Quoted 3 lines
virtio-iommu driver in guest will make map (
VIRTIO_IOMMU_T_MAP) withVIRTIO_IOMMU_MAP_F_MMIOflag for MSI mapping.
In qemu, virtio-iommu device will set a new defined flag (sayIOMMU_MMIO) iniotlb->perminmemory_region_notify_iommu().vfio_get_vaddr()will check same flag and will not print the warning.> Is above correct?Yes that's what I had in mind.
In that case virtio-iommu driver in guest should not make map (
VIRTIO_IOMMU_T_MAP) call as it known nothing to be mapped.sorry I don't catch what you meant. Please can you elaborate?
What I understood of the proposal is:
Linux:
1) MSI doorbells are mapped using theIOMMU_MMIOflag (dma-iommu.ciommu_dma_get_msi_page)
2) virtio-iommu driver in guest will make map (VIRTIO_IOMMU_T_MAP)
withVIRTIO_IOMMU_MAP_F_MMIOflag for MSI mapping.GEMU:
3) virtio-iommu device - IfVIRTIO_IOMMU_MAP_F_MMIOflag set then will set a new defined flag (sayIOMMU_MMIO) iniotlb->perminmemory_region_notify_iommu()
4.vfio_get_vaddr()will check same flag and will not print the warning. Alsovfio_iommu_map_notify()will not do anything.
Quoted 4 lines
Quoted 2 lines
So, rather than going down to step 3 and 4, can we avoid maling
map()calling in step-2 itself?ohh, We need to setup msi translation mapping, correct.
The virtio-iommu driver is supposed to obey the map() operation argument and cascade this to the device. I don't see why it would filter this out.
Now we should have means to declare the vITS GPA as an HW MSI reserved region and avoid calling the map(). I will try this out.
Thanks
Eric
Quoted 34 lines
Thanks
-BharatQuoted 29 lines
Thanks
-BharatQuoted 25 lines
Thanks
Eric
Quoted 20 lines
Stay Safe
Thanks
-BharatQuoted 13 lines
Thanks
Eric
Quoted 8 lines
Thanks
-BharatQuoted 2 lines
Alex
Re: [EXT] Re: [PATCH v9 1/9] hw/vfio/common: Remove error print on mmio region translation by viommu
In reply to Bharat BhushanHi Bharat,
Quoted 129 lines · Bharat Bhushan
Hi Eric,
Quoted 126 lines · Bharat Bhushan
hi Eric,
Quoted 99 lines · Auger Eric
Hi Bharat,
Quoted 95 lines · Bharat Bhushan
Hi Eric,
Quoted 92 lines · Auger Eric
Hi Bharat,
Quoted 88 lines · Bharat Bhushan
Hi Eric/Alex,
Quoted 75 lines
-----Original Message-----
From: Alex Williamson <[email protected]>
Sent: Thursday, March 26, 2020 11:23 PM
To: Auger Eric <[email protected]>
Cc: Bharat Bhushan <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Tomasz Nowicki [C] <[email protected]>; [email protected]; [email protected]; [email protected]; qemu- [email protected]; [email protected]; [email protected]; [email protected]; David Gibson <[email protected]>
Subject: [EXT] Re: [PATCH v9 1/9] hw/vfio/common: Remove error print on mmio region translation by viommuExternal Email
----------------------------------------------------------------------
Quoted 19 lines · On Thu, 26 Mar 2020 18:35:48 +0100 Auger Eric <[email protected]> wrote:
Hi Alex,
Quoted 16 lines · Alex Williamson
[Cc +dwg who originated this warning]
Quoted 11 lines · On Mon, 23 Mar 2020 14:16:09 +0530 Bharat Bhushan <[email protected]> wrote:
On ARM, the MSI doorbell is translated by the virtual IOMMU. As such
address_space_translate()returns the MSI controller MMIO region and we get an "iommu map to non memory area" message. Let's remove this latter.Signed-off-by Eric Auger <[email protected]>Signed-off-by Bharat Bhushan <[email protected]>--- hw/vfio/common.c | 2 -- 1 file changed, 2 deletions(-)Quoted 5 lines
Quoted 5 lines
hw/vfio/common.c static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb,
Quoted 5 lines
hw/vfio/common.c index renamed from hw/vfio/common.c +0
-0
5ca11488d6..c586edf47a100644hw/vfio/common.c +0
-0@@ -426,8 +426,6 @@ static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb,void **vaddr,
Quoted 31 lines
Quoted 9 lines
hw/vfio/common.c static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb, · line 431
Quoted 8 lines
hw/vfio/common.c +0
-2&xlat, &len, writable, MEMTXATTRS_UNSPECIFIED);if (!memory_region_is_ram (mr)) { -error_report ("iommu map to non memory area %" HWADDR_PRIx"" , - xlat);return false; }Quoted 5 lines
I'm a bit confused here, I think we need more justification beyond "we hit this warning and we don't want to because it's ok in this one special case, therefore remove it". I assume the special case is that the device MSI address is managed via the
SET_IRQSioctl and therefore we won't actually get DMAs to this range.Yes exactly. The guest creates a mapping between one giova and this gpa (corresponding to the MSI controller doorbell) because MSIs are mapped on ARM. But practically the physical device is programmed with an host chosen iova that maps onto the physical MSI controller's doorbell. so the device never performs DMA accesses to this range.
But I imagine the case that
Quoted 2 lines
was in mind when adding this warning was general peer-to-peer between and assigned and emulated device.
yes makes sense.
Maybe there's an argument to be made
Quoted 5 lines
that such a p2p mapping might also be used in a non-vIOMMU case. We skip creating those mappings and drivers continue to work, maybe because nobody attempts to do p2p DMA with the types of devices we emulate, maybe because p2p DMA is not absolutely reliable on bare metal and drivers test it before using it.
Quoted 8 lines
Quoted 5 lines
MSI doorbells are mapped using the
IOMMU_MMIOflag (dma-iommu.ciommu_dma_get_msi_page).
One idea could be to pass that flag through the IOMMU Notifier mechanism into theiotlb->perm. Eventually when we get this invfio_get_vaddr()we would not print the warning. Could that make sense?Yeah, if we can identify a valid case that doesn't need a warning, that's fine by me. Thanks,
Let me know if I understood the proposal correctly:
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
Quoted 3 lines
virtio-iommu driver in guest will make map (
VIRTIO_IOMMU_T_MAP) withVIRTIO_IOMMU_MAP_F_MMIOflag for MSI mapping.
In qemu, virtio-iommu device will set a new defined flag (sayIOMMU_MMIO) iniotlb->perminmemory_region_notify_iommu().vfio_get_vaddr()will check same flag and will not print the warning.> Is above correct?Yes that's what I had in mind.
In that case virtio-iommu driver in guest should not make map (
VIRTIO_IOMMU_T_MAP) call as it known nothing to be mapped.sorry I don't catch what you meant. Please can you elaborate?
What I understood of the proposal is:
Linux:
1) MSI doorbells are mapped using theIOMMU_MMIOflag (dma-iommu.ciommu_dma_get_msi_page)
2) virtio-iommu driver in guest will make map (VIRTIO_IOMMU_T_MAP)
withVIRTIO_IOMMU_MAP_F_MMIOflag for MSI mapping.GEMU:
3) virtio-iommu device - IfVIRTIO_IOMMU_MAP_F_MMIOflag set then will set a new defined flag (sayIOMMU_MMIO) iniotlb->perminmemory_region_notify_iommu()
4.vfio_get_vaddr()will check same flag and will not print the warning. Alsovfio_iommu_map_notify()will not do anything.
Quoted 4 lines
Quoted 2 lines
So, rather than going down to step 3 and 4, can we avoid maling
map()calling in step-2 itself?ohh, We need to setup msi translation mapping, correct.
I sent
[PATCH 0/5] VIRTIO-IOMMU probe request support and MSI bypass on ARM
With this series, the guest does not attempt to map the ITS MSI doorbell anymore. So you shouldn't get "iommu map to non memory area" anymore if you rebase on it and remove this patch.
At the moment I only bypass the ITS doorbell but I think it is safe to do the same with GICv2M doorbell as well. Anyway all assigned devices will be able to access this latter.
Thanks
Eric
Quoted 34 lines
Thanks
-BharatQuoted 29 lines
Thanks
-BharatQuoted 25 lines
Thanks
Eric
Quoted 20 lines
Stay Safe
Thanks
-BharatQuoted 13 lines
Thanks
Eric
Quoted 8 lines
Thanks
-BharatQuoted 2 lines
Alex
PATCH v9 2/9 memory: Add interface to set iommu page size mask
In reply to Bharat BhushanAllow to set page size mask to be supported by iommu. This is required to expose page size mask compatible with host with virtio-iommu.
--- include/exec/memory.h | 20 ++++++++++++++++++++ memory.c | 10 ++++++++++ 2 files changed, 30 insertions(+)
include/exec/memory.h +20 -0
@@ -355,6 +355,16 @@ typedef struct IOMMUMemoryRegionClass {* @iommu: the IOMMUMemoryRegion */ int (*num_indexes)(IOMMUMemoryRegion *iommu); + +/* +* Set supported IOMMU page size +* +* Optional method: if this is supported then set page size that +* can be supported by IOMMU. This is called to set supported page +* size as per host Linux. +*/ +void (*iommu_set_page_size_mask)(IOMMUMemoryRegion *iommu, +uint64_t page_size_mask); } IOMMUMemoryRegionClass;typedef struct CoalescedMemoryRange CoalescedMemoryRange ;
@@ -1363,6 +1373,16 @@ int memory_region_iommu_attrs_to_index(IOMMUMemoryRegion *iommu_mr,*/ int memory_region_iommu_num_indexes (IOMMUMemoryRegion *iommu_mr); +/** +* memory_region_iommu_set_page_size_mask: set the supported pages +* size by iommu. +* +* @iommu_mr: the memory region +* @page_size_mask: supported page size mask +*/ +void memory_region_iommu_set_page_size_mask (IOMMUMemoryRegion *iommu_mr, +uint64_t page_size_mask); +/** * memory_region_name: get a memory region's name *
memory.c +10 -0
@@ -1833,6 +1833,16 @@ static int memory_region_update_iommu_notify_flags(IOMMUMemoryRegion *iommu_mr,return ret; } +void memory_region_iommu_set_page_size_mask (IOMMUMemoryRegion *iommu_mr, +uint64_t page_size_mask) +{ +IOMMUMemoryRegionClass *imrc =IOMMU_MEMORY_REGION_GET_CLASS (iommu_mr); + +if (imrc->iommu_set_page_size_mask) { + imrc->iommu_set_page_size_mask (iommu_mr, page_size_mask); + } +} +int memory_region_register_iommu_notifier (MemoryRegion *mr,IOMMUNotifier *n,Error **errp) {
Signature · 1 line
2.17.1
Re: [PATCH v9 2/9] memory: Add interface to set iommu page size mask
Hi Bharat,
Quoted 1 line · Bharat Bhushan
Allow to set page size mask to be supported by iommu.
by iommu memory region. I mean this is not global to the IOMMU.
Quoted 14 lines
This is required to expose page size mask compatible with host with virtio-iommu.
Signed-off-by Bharat Bhushan <[email protected]>--- include/exec/memory.h | 20 ++++++++++++++++++++ memory.c | 10 ++++++++++ 2 files changed, 30 insertions(+)include/exec/memory.h +0
-0
include/exec/memory.h typedef struct IOMMUMemoryRegionClass { · line 364
Quoted 10 lines
include/exec/memory.h +7
-0@@ -355,6 +355,16 @@ typedef struct IOMMUMemoryRegionClass {* @iommu: the IOMMUMemoryRegion */ int (*num_indexes)(IOMMUMemoryRegion *iommu); + +/* +* Set supported IOMMU page size +* +* Optional method: if this is supported then set page size that +* can be supported by IOMMU. This is called to set supported page +* size as per host Linux.
What about: If supported, allows to restrict the page size mask that can be supported with a given IOMMU memory region. For example, this allows to propagate host physical IOMMU page size mask limitations to the virtual IOMMU (vfio assignment with virtual iommu).
include/exec/memory.h int memory_region_iommu_attrs_to_index(IOMMUMemoryRegion *iommu_mr, · line 1378
Quoted 13 lines
include/exec/memory.h +6
-0+*/ +void (*iommu_set_page_size_mask)(IOMMUMemoryRegion *iommu, +uint64_t page_size_mask); } IOMMUMemoryRegionClass;typedef struct CoalescedMemoryRange CoalescedMemoryRange ;@@ -1363,6 +1373,16 @@ int memory_region_iommu_attrs_to_index(IOMMUMemoryRegion *iommu_mr,*/ int memory_region_iommu_num_indexes (IOMMUMemoryRegion *iommu_mr); +/** +* memory_region_iommu_set_page_size_mask: set the supported pages +* size by iommu.
supported page sizes for a given IOMMU memory region
include/exec/memory.h int memory_region_iommu_attrs_to_index(IOMMUMemoryRegion *iommu_mr, · line 1380
Quoted 2 lines
include/exec/memory.h +2
-0+* +* @iommu_mr: the memory region
IOMMU memory region
Quoted 13 lines
include/exec/memory.h +5
-0+* @page_size_mask: supported page size mask +*/ +void memory_region_iommu_set_page_size_mask (IOMMUMemoryRegion *iommu_mr, +uint64_t page_size_mask); +/** * memory_region_name: get a memory region's name * memory.c +0
-0
memory.c static int memory_region_update_iommu_notify_flags(IOMMUMemoryRegion *iommu_mr, · line 1842
Quoted 10 lines
memory.c +7
-0@@ -1833,6 +1833,16 @@ static int memory_region_update_iommu_notify_flags(IOMMUMemoryRegion *iommu_mr,return ret; } +void memory_region_iommu_set_page_size_mask (IOMMUMemoryRegion *iommu_mr, +uint64_t page_size_mask) +{ +IOMMUMemoryRegionClass *imrc =IOMMU_MEMORY_REGION_GET_CLASS (iommu_mr); + +if (imrc->iommu_set_page_size_mask) { + imrc->iommu_set_page_size_mask (iommu_mr, page_size_mask);
Shouldn't it return an int in case the setting cannot be applied?
memory.c static int memory_region_update_iommu_notify_flags(IOMMUMemoryRegion *iommu_mr, · line 1848
Quoted 7 lines
memory.c +3
-0+ } +} +int memory_region_register_iommu_notifier (MemoryRegion *mr,IOMMUNotifier *n,Error **errp) {
Thanks
Eric
RE: [EXT] Re: [PATCH v9 2/9] memory: Add interface to set iommu page size mask
Hi Eric,
Quoted 12 lines
-----Original Message-----
From: Auger Eric <[email protected]>
Sent: Thursday, March 26, 2020 9:36 PM
To: Bharat Bhushan <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Tomasz Nowicki [C] <[email protected]>; [email protected]; [email protected]; qemu- [email protected]; [email protected]; [email protected]; jean- [email protected]; [email protected]
Subject: [EXT] Re: [PATCH v9 2/9] memory: Add interface to set iommu page size mask
Quoted 7 lines
External Email
----------------------------------------------------------------------
Hi Bharat,Quoted 1 line · Bharat Bhushan
Allow to set page size mask to be supported by iommu.
by iommu memory region. I mean this is not global to the IOMMU.
Yes.
Quoted 20 lines
Quoted 20 lines
This is required to expose page size mask compatible with host with virtio-iommu.
Signed-off-by Bharat Bhushan <[email protected]>--- include/exec/memory.h | 20 ++++++++++++++++++++ memory.c | 10 ++++++++++ 2 files changed, 30 insertions(+)include/exec/memory.h index renamed from include/exec/memory.h +0
-0
e85b7de99a..063c424854100644include/exec/memory.h +3
-0@@ -355,6 +355,16 @@ typedef struct IOMMUMemoryRegionClass {* @iommu: the IOMMUMemoryRegion */ int (*num_indexes)(IOMMUMemoryRegion *iommu); + +/* +* Set supported IOMMU page size
Quoted 8 lines
include/exec/memory.h typedef struct IOMMUMemoryRegionClass { · line 364
Quoted 4 lines
include/exec/memory.h +4
-0+* +* Optional method: if this is supported then set page size that +* can be supported by IOMMU. This is called to set supported page +* size as per host Linux. What about: If supported, allows to restrict the page size mask that can be supported with a given IOMMU memory region. For example, this allows to propagate host physical IOMMU page size mask limitations to the virtual IOMMU (vfio assignment with virtual iommu).
Much better
Quoted 38 lines
include/exec/memory.h typedef struct IOMMUMemoryRegionClass {
Quoted 7 lines
include/exec/memory.h +4
-0+*/ +void (*iommu_set_page_size_mask)(IOMMUMemoryRegion *iommu, +uint64_t page_size_mask); } IOMMUMemoryRegionClass; typedef struct CoalescedMemoryRange CoalescedMemoryRange; @@ -1363,6 +1373,16 @@ intmemory_region_iommu_attrs_to_index(IOMMUMemoryRegion
*iommu_mr,Quoted 6 lines
*/
intmemory_region_iommu_num_indexes(IOMMUMemoryRegion *iommu_mr);+/**
+ *memory_region_iommu_set_page_size_mask: set the supported pages
+ * size by iommu.supported page sizes for a given IOMMU memory region
Quoted 2 lines
+ *
+ * @iommu_mr: the memory regionIOMMU memory region
Quoted 2 lines
+ * @page_size_mask: supported page size mask */ void +memory_region_iommu_set_page_size_mask(IOMMUMemoryRegion
*iommu_mr,memory.c static int
Quoted 10 lines
include/exec/memory.h +2
-0+ uint64_t page_size_mask); +/** * memory_region_name: get a memory region's name * memory.c +0
-0@@ -1833,6 +1833,16 @@ static intmemory_region_update_iommu_notify_flags(IOMMUMemoryRegion
*iommu_mr,memory.c static int memory_region_update_iommu_notify_flags(IOMMUMemoryRegion *iommu_mr,
Quoted 4 lines
memory.c +1
-0return ret; } +void memory_region_iommu_set_page_size_mask(IOMMUMemoryRegion
*iommu_mr,
Quoted 8 lines
memory.c static int memory_region_update_iommu_notify_flags(IOMMUMemoryRegion *iommu_mr, · line 1842
Quoted 7 lines
memory.c +7
-0+ uint64_t page_size_mask) +{ +IOMMUMemoryRegionClass *imrc = +IOMMU_MEMORY_REGION_GET_CLASS (iommu_mr); + +if (imrc->iommu_set_page_size_mask) { + imrc->iommu_set_page_size_mask (iommu_mr, page_size_mask);Shouldn't it return an int in case the setting cannot be applied?
iommu_set_page_size_mask() is setting page-size-mask for endpoint. Below function from code
static void virtio_iommu_set_page_size_mask(IOMMUMemoryRegion *mr,
uint64_t page_size_mask)
{
IOMMUDevice *sdev = container_of(mr, IOMMUDevice, iommu_mr);
sdev->page_size_mask = page_size_mask;
}Do you see any reason it cannot be applied, am I missing something?
Thanks
-Bharat
Quoted 9 lines
Quoted 7 lines
memory.c +3
-0+ } +} +int memory_region_register_iommu_notifier (MemoryRegion *mr, IOMMUNotifier *n, Error**errp) {
Thanks
Eric
Re: [EXT] Re: [PATCH v9 2/9] memory: Add interface to set iommu page size mask
Hi Bharat,
Quoted 112 lines · Bharat Bhushan
Hi Eric,
Quoted 12 lines
-----Original Message-----
From: Auger Eric <[email protected]>
Sent: Thursday, March 26, 2020 9:36 PM
To: Bharat Bhushan <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Tomasz Nowicki [C] <[email protected]>; [email protected]; [email protected]; qemu- [email protected]; [email protected]; [email protected]; jean- [email protected]; [email protected]
Subject: [EXT] Re: [PATCH v9 2/9] memory: Add interface to set iommu page size maskQuoted 7 lines
External Email
----------------------------------------------------------------------
Hi Bharat,Quoted 1 line · Bharat Bhushan
Allow to set page size mask to be supported by iommu.
by iommu memory region. I mean this is not global to the IOMMU.
Yes.
Quoted 20 lines
Quoted 20 lines
This is required to expose page size mask compatible with host with virtio-iommu.
Signed-off-by Bharat Bhushan <[email protected]>--- include/exec/memory.h | 20 ++++++++++++++++++++ memory.c | 10 ++++++++++ 2 files changed, 30 insertions(+)include/exec/memory.h index renamed from include/exec/memory.h +0
-0
e85b7de99a..063c424854100644include/exec/memory.h +3
-0@@ -355,6 +355,16 @@ typedef struct IOMMUMemoryRegionClass {* @iommu: the IOMMUMemoryRegion */ int (*num_indexes)(IOMMUMemoryRegion *iommu); + +/* +* Set supported IOMMU page size Quoted 8 lines
include/exec/memory.h typedef struct IOMMUMemoryRegionClass { · line 364
Quoted 4 lines
include/exec/memory.h +4
-0+* +* Optional method: if this is supported then set page size that +* can be supported by IOMMU. This is called to set supported page +* size as per host Linux. What about: If supported, allows to restrict the page size mask that can be supported with a given IOMMU memory region. For example, this allows to propagate host physical IOMMU page size mask limitations to the virtual IOMMU (vfio assignment with virtual iommu).
Much better
Quoted 38 lines
include/exec/memory.h typedef struct IOMMUMemoryRegionClass {
Quoted 7 lines
include/exec/memory.h +4
-0+*/ +void (*iommu_set_page_size_mask)(IOMMUMemoryRegion *iommu, +uint64_t page_size_mask); } IOMMUMemoryRegionClass; typedef struct CoalescedMemoryRange CoalescedMemoryRange; @@ -1363,6 +1373,16 @@ intmemory_region_iommu_attrs_to_index(IOMMUMemoryRegion
*iommu_mr,Quoted 6 lines
*/
intmemory_region_iommu_num_indexes(IOMMUMemoryRegion *iommu_mr);+/**
+ *memory_region_iommu_set_page_size_mask: set the supported pages
+ * size by iommu.supported page sizes for a given IOMMU memory region
Quoted 2 lines
+ *
+ * @iommu_mr: the memory regionIOMMU memory region
Quoted 2 lines
+ * @page_size_mask: supported page size mask */ void +memory_region_iommu_set_page_size_mask(IOMMUMemoryRegion
*iommu_mr,memory.c static int
Quoted 10 lines
include/exec/memory.h +2
-0+ uint64_t page_size_mask); +/** * memory_region_name: get a memory region's name * memory.c +0
-0@@ -1833,6 +1833,16 @@ static intmemory_region_update_iommu_notify_flags(IOMMUMemoryRegion
*iommu_mr,memory.c static int memory_region_update_iommu_notify_flags(IOMMUMemoryRegion *iommu_mr,
Quoted 4 lines
memory.c +1
-0return ret; } +void memory_region_iommu_set_page_size_mask(IOMMUMemoryRegion
*iommu_mr,Quoted 8 lines
memory.c static int memory_region_update_iommu_notify_flags(IOMMUMemoryRegion *iommu_mr, · line 1842
Quoted 7 lines
memory.c +7
-0+ uint64_t page_size_mask) +{ +IOMMUMemoryRegionClass *imrc = +IOMMU_MEMORY_REGION_GET_CLASS (iommu_mr); + +if (imrc->iommu_set_page_size_mask) { + imrc->iommu_set_page_size_mask (iommu_mr, page_size_mask);Shouldn't it return an int in case the setting cannot be applied?
iommu_set_page_size_mask()is setting page-size-mask for endpoint. Below function from codestatic void virtio_iommu_set_page_size_mask(IOMMUMemoryRegion *mr, uint64_t page_size_mask) { IOMMUDevice *sdev = container_of(mr, IOMMUDevice, iommu_mr); sdev->page_size_mask = page_size_mask; }
Quoted 1 line
Do you see any reason it cannot be applied, am I missing something?
maybe the function can be called several times and one setting is already in place. In other contexts, maybe the setting we try to apply is not compatible with other settings enforced?
Thanks
Eric
Quoted 14 lines
Thanks
-BharatQuoted 9 lines
Quoted 7 lines
memory.c +3
-0+ } +} +int memory_region_register_iommu_notifier (MemoryRegion *mr, IOMMUNotifier *n, Error**errp) {
Thanks
Eric
PATCH v9 3/9 vfio: set iommu page size as per host supported page size
In reply to Bharat BhushanSet iommu supported page size mask same as host Linux supported page size mask.
--- hw/vfio/common.c | 3 +++ 1 file changed, 3 insertions(+)
hw/vfio/common.c +3 -0
@@ -635,6 +635,9 @@ static void vfio_listener_region_add(MemoryListener *listener,int128_get64 (llend), iommu_idx); +memory_region_iommu_set_page_size_mask (giommu->iommu, + container->pgsizes); + ret =memory_region_register_iommu_notifier (section->mr, &giommu->n, &err);if (ret) {
Signature · 1 line
2.17.1
PATCH v9 4/9 virtio-iommu: set supported page size mask
In reply to Bharat BhushanAdd optional interface to set page size mask. Currently this is set global configuration and not per endpoint.
--- include/hw/virtio/virtio-iommu.h | 1 + hw/virtio/virtio-iommu.c | 9 +++++++++ 2 files changed, 10 insertions(+)
include/hw/virtio/virtio-iommu.h +1 -0
@@ -35,6 +35,7 @@ typedef struct IOMMUDevice {void *viommu;PCIBus *bus;int devfn; +uint64_t page_size_mask;IOMMUMemoryRegion iommu_mr;AddressSpace as; } IOMMUDevice;
hw/virtio/virtio-iommu.c +9 -0
@@ -650,6 +650,14 @@ static gint int_cmp(gconstpointer a, gconstpointer b, gpointer user_data)return (ua > ub) - (ua < ub); } +static void virtio_iommu_set_page_size_mask (IOMMUMemoryRegion *mr, +uint64_t page_size_mask) +{ +IOMMUDevice *sdev =container_of (mr, IOMMUDevice, iommu_mr); + + sdev->page_size_mask = page_size_mask; +} +static void virtio_iommu_device_realize (DeviceState *dev,Error **errp) {VirtIODevice *vdev =VIRTIO_DEVICE (dev);
@@ -865,6 +873,7 @@ static void virtio_iommu_memory_region_class_init(ObjectClass *klass,IOMMUMemoryRegionClass *imrc =IOMMU_MEMORY_REGION_CLASS (klass); imrc->translate = virtio_iommu_translate; + imrc->iommu_set_page_size_mask = virtio_iommu_set_page_size_mask; }static const TypeInfo virtio_iommu_info = {
Signature · 1 line
2.17.1
Re: [PATCH v9 4/9] virtio-iommu: set supported page size mask
Hi Bharat,
Quoted 3 lines · Bharat Bhushan
Add optional interface to set page size mask. Currently this is set global configuration and not per endpoint.
This allows to override the page size mask per end-point?
Quoted 40 lines
Signed-off-by Bharat Bhushan <[email protected]>--- include/hw/virtio/virtio-iommu.h | 1 + hw/virtio/virtio-iommu.c | 9 +++++++++ 2 files changed, 10 insertions(+)include/hw/virtio/virtio-iommu.h +1
-0@@ -35,6 +35,7 @@ typedef struct IOMMUDevice {void *viommu;PCIBus *bus;int devfn; +uint64_t page_size_mask;IOMMUMemoryRegion iommu_mr;AddressSpace as; } IOMMUDevice;hw/virtio/virtio-iommu.c +8
-0@@ -650,6 +650,14 @@ static gint int_cmp(gconstpointer a, gconstpointer b, gpointer user_data)return (ua > ub) - (ua < ub); } +static void virtio_iommu_set_page_size_mask (IOMMUMemoryRegion *mr, +uint64_t page_size_mask) +{ +IOMMUDevice *sdev =container_of (mr, IOMMUDevice, iommu_mr); + + sdev->page_size_mask = page_size_mask; +} +static void virtio_iommu_device_realize (DeviceState *dev,Error **errp) {VirtIODevice *vdev =VIRTIO_DEVICE (dev);
hw/virtio/virtio-iommu.c static void virtio_iommu_memory_region_class_init(ObjectClass *klass, · line 879
Quoted 7 lines
hw/virtio/virtio-iommu.c +1
-0@@ -865,6 +873,7 @@ static void virtio_iommu_memory_region_class_init(ObjectClass *klass,IOMMUMemoryRegionClass *imrc =IOMMU_MEMORY_REGION_CLASS (klass); imrc->translate = virtio_iommu_translate; + imrc->iommu_set_page_size_mask = virtio_iommu_set_page_size_mask; }static const TypeInfo virtio_iommu_info = {
Thanks
Eric
RE: [EXT] Re: [PATCH v9 4/9] virtio-iommu: set supported page size mask
Hi Eric,
Quoted 13 lines
-----Original Message-----
From: Auger Eric <[email protected]>
Sent: Thursday, March 26, 2020 9:22 PM
To: Bharat Bhushan <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Tomasz Nowicki [C] <[email protected]>; [email protected]; [email protected]; qemu- [email protected]; [email protected]; [email protected]; jean- [email protected]; [email protected]
Subject: [EXT] Re: [PATCH v9 4/9] virtio-iommu: set supported page size maskExternal Email
Quoted 7 lines
----------------------------------------------------------------------
Hi Bharat,Quoted 2 lines · Bharat Bhushan
Add optional interface to set page size mask. Currently this is set global configuration and not per endpoint.
This allows to override the page size mask per end-point?
This patch adds per endpoint page-size-mask configuration in addition to global page-size-mask. endpoint page-size-mask will override global page-size-mask configuration for that endpoint.
Thanks
-Bharat
Quoted 52 lines
hw/virtio/virtio-iommu.c static gint int_cmp(gconstpointer a, gconstpointer b,
Quoted 25 lines
Signed-off-by Bharat Bhushan <[email protected]>--- include/hw/virtio/virtio-iommu.h | 1 + hw/virtio/virtio-iommu.c | 9 +++++++++ 2 files changed, 10 insertions(+)include/hw/virtio/virtio-iommu.h +1
-0@@ -35,6 +35,7 @@ typedef struct IOMMUDevice {void *viommu;PCIBus *bus;int devfn; +uint64_t page_size_mask;IOMMUMemoryRegion iommu_mr;AddressSpace as; } IOMMUDevice;hw/virtio/virtio-iommu.c index renamed from hw/virtio/virtio-iommu.c +0
-0
4cee8083bc..a28818202c100644hw/virtio/virtio-iommu.c +0
-0@@ -650,6 +650,14 @@ static gint int_cmp(gconstpointer a, gconstpointer b,gpointer
user_data)Quoted 13 lines
hw/virtio/virtio-iommu.c +7
-0return (ua > ub) - (ua < ub); } +static void virtio_iommu_set_page_size_mask (IOMMUMemoryRegion *mr, +uint64_t page_size_mask) +{ +IOMMUDevice *sdev =container_of (mr, IOMMUDevice, iommu_mr); + + sdev->page_size_mask = page_size_mask; } +static void virtio_iommu_device_realize (DeviceState *dev,Error **errp) { VirtIODevice *vdev = VIRTIO_DEVICE(dev); @@ -865,6 +873,7 @@Quoted 2 lines
static void virtio_iommu_memory_region_class_init(ObjectClass *klass,
IOMMUMemoryRegionClass *imrc =
IOMMU_MEMORY_REGION_CLASS(klass);Quoted 7 lines
imrc->translate = virtio_iommu_translate;+
imrc->iommu_set_page_size_mask=virtio_iommu_set_page_size_mask;
}static const TypeInfo
virtio_iommu_info= {Thanks
Eric
Re: [EXT] Re: [PATCH v9 4/9] virtio-iommu: set supported page size mask
Hi Bharat,
Quoted 18 lines · Bharat Bhushan
Hi Eric,
Quoted 16 lines
-----Original Message-----
From: Auger Eric <[email protected]>
Sent: Thursday, March 26, 2020 9:22 PM
To: Bharat Bhushan <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Tomasz Nowicki [C] <[email protected]>; [email protected]; [email protected]; qemu- [email protected]; [email protected]; [email protected]; jean- [email protected]; [email protected]
Subject: [EXT] Re: [PATCH v9 4/9] virtio-iommu: set supported page size maskExternal Email
----------------------------------------------------------------------
Hi Bharat,
Quoted 7 lines
Quoted 4 lines · Bharat Bhushan
Quoted 2 lines
Add optional interface to set page size mask. Currently this is set global configuration and not per endpoint.
This allows to override the page size mask per end-point?
This patch adds per endpoint page-size-mask configuration in addition to global page-size-mask. endpoint page-size-mask will override global page-size-mask configuration for that endpoint.
Yes my comment was a suggestion for commit msg rephrasing. Sorry if it was unclear. The above text sounds clearer.
thanks
Eric
Quoted 58 lines
Thanks
-BharatQuoted 52 lines
hw/virtio/virtio-iommu.c static gint int_cmp(gconstpointer a, gconstpointer b,
Quoted 25 lines
Signed-off-by Bharat Bhushan <[email protected]>--- include/hw/virtio/virtio-iommu.h | 1 + hw/virtio/virtio-iommu.c | 9 +++++++++ 2 files changed, 10 insertions(+)include/hw/virtio/virtio-iommu.h +1
-0@@ -35,6 +35,7 @@ typedef struct IOMMUDevice {void *viommu;PCIBus *bus;int devfn; +uint64_t page_size_mask;IOMMUMemoryRegion iommu_mr;AddressSpace as; } IOMMUDevice;hw/virtio/virtio-iommu.c index renamed from hw/virtio/virtio-iommu.c +0
-0
4cee8083bc..a28818202c100644hw/virtio/virtio-iommu.c +0
-0@@ -650,6 +650,14 @@ static gint int_cmp(gconstpointer a, gconstpointer b,gpointer
user_data)Quoted 13 lines
hw/virtio/virtio-iommu.c +7
-0return (ua > ub) - (ua < ub); } +static void virtio_iommu_set_page_size_mask (IOMMUMemoryRegion *mr, +uint64_t page_size_mask) +{ +IOMMUDevice *sdev =container_of (mr, IOMMUDevice, iommu_mr); + + sdev->page_size_mask = page_size_mask; } +static void virtio_iommu_device_realize (DeviceState *dev,Error **errp) { VirtIODevice *vdev = VIRTIO_DEVICE(dev); @@ -865,6 +873,7 @@Quoted 2 lines
static void virtio_iommu_memory_region_class_init(ObjectClass *klass,
IOMMUMemoryRegionClass *imrc =
IOMMU_MEMORY_REGION_CLASS(klass);Quoted 7 lines
imrc->translate = virtio_iommu_translate;+
imrc->iommu_set_page_size_mask=virtio_iommu_set_page_size_mask;
}static const TypeInfo
virtio_iommu_info= {Thanks
Eric
PATCH v9 5/9 virtio-iommu: Add iommu notifier for map/unmap
In reply to Bharat BhushanThis patch extends VIRTIO_IOMMU_T_MAP/UNMAP request to notify registered iommu-notifier. Which will call vfio notifier to map/unmap region in iommu.
--- include/hw/virtio/virtio-iommu.h | 2 + hw/virtio/virtio-iommu.c | 67 +++++++++++++++++++++++++++++++- hw/virtio/trace-events | 2 + 3 files changed, 70 insertions(+), 1 deletion(-)
include/hw/virtio/virtio-iommu.h +2 -0
@@ -38,6 +38,7 @@ typedef struct IOMMUDevice {uint64_t page_size_mask;IOMMUMemoryRegion iommu_mr;AddressSpace as; +QLIST_ENTRY (IOMMUDevice) next; } IOMMUDevice; typedef struct IOMMUPciBus {
@@ -57,6 +58,7 @@ typedef struct VirtIOIOMMU {GTree *domains;QemuMutex mutex;GTree *endpoints; + QLIST_HEAD(, IOMMUDevice) notifiers_list; } VirtIOIOMMU;#endif
hw/virtio/virtio-iommu.c +66 -1
103 lines not on this page · raw message
hw/virtio/trace-events +2 -0
@@ -73,3 +73,5 @@ virtio_iommu_get_domain(uint32_t domain_id) "Alloc domain=%d" virtio_iommu_put_domain(uint32_t domain_id) "Free domain=%d" virtio_iommu_translate_out(uint64_t virt_addr, uint64_t phys_addr, uint32_t sid) "0x%"PRIx64" -> 0x%"PRIx64 " for sid=%d" virtio_iommu_report_fault(uint8_t reason, uint32_t flags, uint32_t endpoint, uint64_t addr) "FAULT reason=%d flags=%d endpoint=%d address =0x%"PRIx64 +virtio_iommu_notify_map(const char *name, uint64_t iova, uint64_t paddr, uint64_t map_size) "mr=%s iova=0x%"PRIx64" pa=0x%" PRIx64" size=0x%"PRIx64 +virtio_iommu_notify_unmap(const char *name, uint64_t iova, uint64_t map_size) "mr=%s iova=0x%"PRIx64" size=0x%"PRIx64
Signature · 1 line
2.17.1
PATCH v9 6/9 virtio-iommu: Call iommu notifier for attach/detach
In reply to Bharat Bhushaniommu-notifier are called when a device is attached or detached to as address-space.
This is needed for VFIO.
--- hw/virtio/virtio-iommu.c | 49 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)
hw/virtio/virtio-iommu.c +49 -0
@@ -49,6 +49,7 @@ typedef struct VirtIOIOMMUEndpoint {uint32_t id;VirtIOIOMMUDomain *domain;QLIST_ENTRY (VirtIOIOMMUEndpoint) next; +VirtIOIOMMU *viommu; } VirtIOIOMMUEndpoint; typedef struct VirtIOIOMMUInterval {
@@ -155,11 +156,48 @@ static void virtio_iommu_notify_unmap(IOMMUMemoryRegion *mr, hwaddr iova,memory_region_notify_iommu (mr,0 , entry); } +static gboolean virtio_iommu_mapping_unmap (gpointer key,gpointer value, +gpointer data) +{ +VirtIOIOMMUInterval *interval = (VirtIOIOMMUInterval *) key; +IOMMUMemoryRegion *mr = (IOMMUMemoryRegion *) data; + +virtio_iommu_notify_unmap (mr, interval->low, + interval->high - interval->low +1 ); + +return false; +} + +static gboolean virtio_iommu_mapping_map (gpointer key,gpointer value, +gpointer data) +{ +VirtIOIOMMUMapping *mapping = (VirtIOIOMMUMapping *) value; +VirtIOIOMMUInterval *interval = (VirtIOIOMMUInterval *) key; +IOMMUMemoryRegion *mr = (IOMMUMemoryRegion *) data; + +virtio_iommu_notify_map (mr, interval->low, mapping->phys_addr, + interval->high - interval->low +1 ); + +return false; +} +static void virtio_iommu_detach_endpoint_from_domain (VirtIOIOMMUEndpoint *ep) { +VirtIOIOMMU *s = ep->viommu; +VirtIOIOMMUDomain *domain = ep->domain; +IOMMUDevice *sdev; +if (!ep->domain) {return ; } + + QLIST_FOREACH(sdev, &s->notifiers_list, next) { +if (ep->id == sdev->devfn) { +g_tree_foreach (domain->mappings, virtio_iommu_mapping_unmap, + &sdev->iommu_mr); + } + } +QLIST_REMOVE (ep, next); ep->domain =NULL ; }
@@ -178,6 +216,7 @@ static VirtIOIOMMUEndpoint *virtio_iommu_get_endpoint(VirtIOIOMMU *s, } ep =g_malloc0 (sizeof (*ep)); ep->id = ep_id; + ep->viommu = s;trace_virtio_iommu_get_endpoint (ep_id);g_tree_insert (s->endpoints,GUINT_TO_POINTER (ep_id), ep);return ep;
@@ -274,6 +313,7 @@ static int virtio_iommu_attach(VirtIOIOMMU *s,uint32_t ep_id =le32_to_cpu (req->endpoint);VirtIOIOMMUDomain *domain;VirtIOIOMMUEndpoint *ep; +IOMMUDevice *sdev;trace_virtio_iommu_attach (domain_id, ep_id);
@@ -299,6 +339,14 @@ static int virtio_iommu_attach(VirtIOIOMMU *s, ep->domain = domain; +/* Replay domain mappings on the associated memory region */ + QLIST_FOREACH(sdev, &s->notifiers_list, next) { +if (ep_id == sdev->devfn) { +g_tree_foreach (domain->mappings, virtio_iommu_mapping_map, + &sdev->iommu_mr); + } + } +return VIRTIO_IOMMU_S_OK ; }
@@ -872,6 +920,7 @@ static gboolean reconstruct_endpoints(gpointer key, gpointer value, QLIST_FOREACH(iter, &d->endpoint_list, next) { iter->domain = d; + iter->viommu = s;g_tree_insert (s->endpoints,GUINT_TO_POINTER (iter->id), iter); }return false;/* continue the domain traversal */
Signature · 1 line
2.17.1
PATCH v9 7/9 virtio-iommu: add iommu replay
In reply to Bharat BhushanDefault replay does not work with virtio-iommu, so this patch provide virtio-iommu replay functionality.
--- hw/virtio/virtio-iommu.c | 44 ++++++++++++++++++++++++++++++++++++++++ hw/virtio/trace-events | 1 + 2 files changed, 45 insertions(+)
hw/virtio/virtio-iommu.c +44 -0
@@ -770,6 +770,49 @@ static void virtio_iommu_set_page_size_mask(IOMMUMemoryRegion *mr, sdev->page_size_mask = page_size_mask; } +static gboolean virtio_iommu_remap (gpointer key,gpointer value,gpointer data) +{ +VirtIOIOMMUMapping *mapping = (VirtIOIOMMUMapping *) value; +VirtIOIOMMUInterval *interval = (VirtIOIOMMUInterval *) key; +IOMMUMemoryRegion *mr = (IOMMUMemoryRegion *) data; + +trace_virtio_iommu_remap (interval->low, mapping->phys_addr, + interval->high - interval->low +1 ); +/* unmap previous entry and map again */ +virtio_iommu_notify_unmap (mr, interval->low, + interval->high - interval->low +1 ); + +virtio_iommu_notify_map (mr, interval->low, mapping->phys_addr, + interval->high - interval->low +1 ); +return false; +} + +static void virtio_iommu_replay (IOMMUMemoryRegion *mr,IOMMUNotifier *n) +{ +IOMMUDevice *sdev =container_of (mr, IOMMUDevice, iommu_mr); +VirtIOIOMMU *s = sdev->viommu; +uint32_t sid; +VirtIOIOMMUEndpoint *ep; + + sid =virtio_iommu_get_bdf (sdev); + +qemu_mutex_lock (&s->mutex); + +if (!s->endpoints) { + goto unlock; + } + + ep =g_tree_lookup (s->endpoints,GUINT_TO_POINTER (sid)); +if (!ep || !ep->domain) { + goto unlock; + } + +g_tree_foreach (ep->domain->mappings, virtio_iommu_remap, mr); + +unlock: +qemu_mutex_unlock (&s->mutex); +} +static void virtio_iommu_device_realize (DeviceState *dev,Error **errp) {VirtIODevice *vdev =VIRTIO_DEVICE (dev);
@@ -988,6 +1031,7 @@ static void virtio_iommu_memory_region_class_init(ObjectClass *klass, imrc->translate = virtio_iommu_translate; imrc->iommu_set_page_size_mask = virtio_iommu_set_page_size_mask; + imrc->replay = virtio_iommu_replay; }static const TypeInfo virtio_iommu_info = {
hw/virtio/trace-events +1 -0
@@ -75,3 +75,4 @@ virtio_iommu_translate_out(uint64_t virt_addr, uint64_t phys_addr, uint32_t sid) virtio_iommu_report_fault(uint8_t reason, uint32_t flags, uint32_t endpoint, uint64_t addr) "FAULT reason=%d flags=%d endpoint=%d address =0x%"PRIx64 virtio_iommu_notify_map(const char *name, uint64_t iova, uint64_t paddr, uint64_t map_size) "mr=%s iova=0x%"PRIx64" pa=0x%" PRIx64" size=0x%"PRIx64 virtio_iommu_notify_unmap(const char *name, uint64_t iova, uint64_t map_size) "mr=%s iova=0x%"PRIx64" size=0x%"PRIx64 +virtio_iommu_remap(uint64_t iova, uint64_t pa, uint64_t size) "iova=0x%"PRIx64" pa=0x%" PRIx64" size=0x%"PRIx64""
Signature · 1 line
2.17.1
PATCH v9 8/9 virtio-iommu: Implement probe request
In reply to Bharat BhushanThis patch implements the PROBE request. Currently supported page size mask per endpoint is returned. Also append a NONE property in the end.
--- include/standard-headers/linux/virtio_iommu.h | 6 + hw/virtio/virtio-iommu.c | 161 +++++++++++++++++- hw/virtio/trace-events | 2 + 3 files changed, 166 insertions(+), 3 deletions(-)
include/standard-headers/linux/virtio_iommu.h +6 -0
@@ -111,6 +111,7 @@ struct virtio_iommu_req_unmap {#define VIRTIO_IOMMU_PROBE_T_NONE 0#define VIRTIO_IOMMU_PROBE_T_RESV_MEM 1 +#define VIRTIO_IOMMU_PROBE_T_PAGE_SIZE_MASK 2#define VIRTIO_IOMMU_PROBE_T_MASK 0xfff
@@ -130,6 +131,11 @@ struct virtio_iommu_probe_resv_mem {uint64_t end; }; +struct virtio_iommu_probe_pgsize_mask { +struct virtio_iommu_probe_property head; +uint64_t pgsize_bitmap; +}; +struct virtio_iommu_req_probe {struct virtio_iommu_req_head head;uint32_t endpoint;
hw/virtio/virtio-iommu.c +158 -3
227 lines not on this page · raw message
hw/virtio/trace-events +2 -0
@@ -76,3 +76,5 @@ virtio_iommu_report_fault(uint8_t reason, uint32_t flags, uint32_t endpoint, uin virtio_iommu_notify_map(const char *name, uint64_t iova, uint64_t paddr, uint64_t map_size) "mr=%s iova=0x%"PRIx64" pa=0x%" PRIx64" size=0x%"PRIx64 virtio_iommu_notify_unmap(const char *name, uint64_t iova, uint64_t map_size) "mr=%s iova=0x%"PRIx64" size=0x%"PRIx64 virtio_iommu_remap(uint64_t iova, uint64_t pa, uint64_t size) "iova=0x%"PRIx64" pa=0x%" PRIx64" size=0x%"PRIx64"" +virtio_iommu_fill_none_property(uint32_t devid) "devid=%d" +virtio_iommu_fill_pgsize_mask_property(uint32_t devid, uint64_t pgsize_mask, size_t filled) "dev= %d, pgsize_mask=0x%"PRIx64" filled=0x%lx"
Signature · 1 line
2.17.1
Re: [PATCH v9 8/9] virtio-iommu: Implement probe request
Hi Bharat
Quoted 8 lines · Bharat Bhushan
This patch implements the PROBE request. Currently supported page size mask per endpoint is returned. Also append a NONE property in the end.
Signed-off-by Bharat Bhushan <[email protected]>Signed-off-by Eric Auger <[email protected]>--- include/standard-headers/linux/virtio_iommu.h | 6 +
Changes to virtio_iommu.h should be in a separate patch
you should use ./scripts/update-linux-headers.sh
See for instance:ddda37483d linux-headers: update
until the uapi updates are not upstream you can link to your kernel branch and mention this is a temporary linux header update or partial if you just want to pick up the iommu.h changes.
Quoted 115 lines
hw/virtio/virtio-iommu.c | 161 +++++++++++++++++- hw/virtio/trace-events | 2 + 3 files changed, 166 insertions(+), 3 deletions(-)include/standard-headers/linux/virtio_iommu.h +6
-0@@ -111,6 +111,7 @@ struct virtio_iommu_req_unmap {#define VIRTIO_IOMMU_PROBE_T_NONE 0#define VIRTIO_IOMMU_PROBE_T_RESV_MEM 1 +#define VIRTIO_IOMMU_PROBE_T_PAGE_SIZE_MASK 2#define VIRTIO_IOMMU_PROBE_T_MASK 0xfff@@ -130,6 +131,11 @@ struct virtio_iommu_probe_resv_mem {uint64_t end; }; +struct virtio_iommu_probe_pgsize_mask { +struct virtio_iommu_probe_property head; +uint64_t pgsize_bitmap; +}; +struct virtio_iommu_req_probe {struct virtio_iommu_req_head head;uint32_t endpoint;hw/virtio/virtio-iommu.c +65
-0@@ -38,6 +38,10 @@/* Max size */ #define VIOMMU_DEFAULT_QUEUE_SIZE 256 +#define VIOMMU_PROBE_SIZE 512 + +#define SUPPORTED_PROBE_PROPERTIES (\ + 1 << VIRTIO_IOMMU_PROBE_T_PAGE_SIZE_MASK) typedef struct VirtIOIOMMUDomain { uint32_t id;@@ -62,6 +66,13 @@ typedef struct VirtIOIOMMUMapping {uint32_t flags; } VirtIOIOMMUMapping; +typedef struct VirtIOIOMMUPropBuffer { +VirtIOIOMMUEndpoint *endpoint; +size_t filled; +uint8_t *start; +bool error; +}VirtIOIOMMUPropBuffer ; +static inline uint16_t virtio_iommu_get_bdf (IOMMUDevice *dev) {return PCI_BUILD_BDF (pci_bus_num (dev->bus), dev->devfn);@@ -490,6 +501,114 @@ static int virtio_iommu_unmap(VirtIOIOMMU *s,return ret; } +static int virtio_iommu_fill_none_prop (VirtIOIOMMUPropBuffer *bufstate) +{ +struct virtio_iommu_probe_property *prop; + + prop = (struct virtio_iommu_probe_property *) + (bufstate->start + bufstate->filled); + prop->type =0 ; + prop->length =0 ; + bufstate->filled +=sizeof (*prop); +trace_virtio_iommu_fill_none_property (bufstate->endpoint->id); +return 0 ; +} + +static int virtio_iommu_fill_page_size_mask (VirtIOIOMMUPropBuffer *bufstate) +{ +struct virtio_iommu_probe_pgsize_mask *page_size_mask; +size_t prop_size =sizeof (*page_size_mask); +VirtIOIOMMUEndpoint *ep = bufstate->endpoint; +VirtIOIOMMU *s = ep->viommu; +IOMMUDevice *sdev; + +if (bufstate->filled + prop_size >=VIOMMU_PROBE_SIZE ) { + bufstate->error = true; +/* get the traversal stopped by returning true */ +return true; + } + + page_size_mask = (struct virtio_iommu_probe_pgsize_mask *) + (bufstate->start + bufstate->filled); + + page_size_mask->head.type =VIRTIO_IOMMU_PROBE_T_PAGE_SIZE_MASK ; + page_size_mask->head.length = prop_size; + QLIST_FOREACH(sdev, &s->notifiers_list, next) { +if (ep->id == sdev->devfn) { + page_size_mask->pgsize_bitmap = sdev->page_size_mask; + } + } + bufstate->filled +=sizeof (*page_size_mask); +trace_virtio_iommu_fill_pgsize_mask_property (bufstate->endpoint->id, + page_size_mask->pgsize_bitmap, + bufstate->filled); +return false; +} + +/* Fill the properties[] buffer with properties of type @type */ +static int virtio_iommu_fill_property (int type, +VirtIOIOMMUPropBuffer *bufstate) +{ +int ret = -ENOSPC ; + +if (bufstate->filled +sizeof (struct virtio_iommu_probe_property ) + >=VIOMMU_PROBE_SIZE ) { +/* no space left for the header */ + bufstate->error = true;
hw/virtio/virtio-iommu.c static int virtio_iommu_unmap(VirtIOIOMMU *s, · line 567
Quoted 10 lines
hw/virtio/virtio-iommu.c +10
-0+ goto out; + } + +switch (type) { +case VIRTIO_IOMMU_PROBE_T_NONE : + ret =virtio_iommu_fill_none_prop (bufstate); +break ; +case VIRTIO_IOMMU_PROBE_T_PAGE_SIZE_MASK : + { + ret =virtio_iommu_fill_page_size_mask (bufstate);
I don't think you want to fill the property of each EP. Only for those whose sdev->page_size_mask was properly set. For instance if you mix virtio and vfio devices, virtio ones won't have this field set.
Quoted 106 lines
hw/virtio/virtio-iommu.c +74
-2+break ; + } +default : + ret = -ENOENT ; +break ; + } +out: +if (ret) { +error_report ("%s property of type=%d could not be filled (%d)," +" remaining size = 0x%lx" , + __func__, type, ret, bufstate->filled); + } +return ret; +} + +/** +* virtio_iommu_probe - Fill the probe request buffer with all +* the properties the device is able to return and add a NONE +* property at the end. @buf points to properties[]. +*/ +static int virtio_iommu_probe (VirtIOIOMMU *s, +struct virtio_iommu_req_probe *req, +uint8_t *buf) +{ +uint32_t ep_id =le32_to_cpu (req->endpoint); +VirtIOIOMMUEndpoint *ep =virtio_iommu_get_endpoint (s, ep_id); +int16_t prop_types =SUPPORTED_PROBE_PROPERTIES , type; +VirtIOIOMMUPropBuffer bufstate = {.start = buf, .filled =0 , + .error = false, .endpoint = ep}; + +while ((type =ctz32 (prop_types)) !=32 ) { +if (virtio_iommu_fill_property (type, &bufstate)) { + goto failure; + } + prop_types &= ~(1 << type); + } +if (virtio_iommu_fill_property (VIRTIO_IOMMU_PROBE_T_NONE , &bufstate)) { + goto failure; + } +return VIRTIO_IOMMU_S_OK ; +failure: +return VIRTIO_IOMMU_S_INVAL ; +} +static int virtio_iommu_iov_to_req (struct iovec *iov,unsigned int iov_cnt,void *req,size_t req_sz)@@ -519,6 +638,17 @@ virtio_iommu_handle_req(detach)virtio_iommu_handle_req (map)virtio_iommu_handle_req (unmap) +static int virtio_iommu_handle_probe(VirtIOIOMMU *s, + struct iovec *iov, + unsigned int iov_cnt, + uint8_t *buf) +{ +struct virtio_iommu_req_probe req; +int ret =virtio_iommu_iov_to_req (iov, iov_cnt, &req,sizeof (req)); + + return ret ? ret : virtio_iommu_probe(s, &req, buf); +} + static void virtio_iommu_handle_command(VirtIODevice *vdev, VirtQueue *vq) {VirtIOIOMMU *s =VIRTIO_IOMMU (vdev);@@ -564,17 +694,33 @@ static void virtio_iommu_handle_command(VirtIODevice *vdev, VirtQueue *vq)case VIRTIO_IOMMU_T_UNMAP : tail.status =virtio_iommu_handle_unmap (s, iov, iov_cnt);break ; +case VIRTIO_IOMMU_T_PROBE : + { +struct virtio_iommu_req_tail *ptail; +uint8_t *buf =g_malloc0 (s->config.probe_size +sizeof (tail)); + + ptail = (struct virtio_iommu_req_tail *) + (buf + s->config.probe_size); + ptail->status =virtio_iommu_handle_probe (s, iov, iov_cnt, buf); + + sz =iov_from_buf (elem->in_sg, elem->in_num,0 , + buf, s->config.probe_size +sizeof (tail)); +g_free (buf); +assert (sz == s->config.probe_size +sizeof (tail)); + goto push; + }default : tail.status =VIRTIO_IOMMU_S_UNSUPP ; } -qemu_mutex_unlock (&s->mutex); out: sz =iov_from_buf (elem->in_sg, elem->in_num,0 , &tail,sizeof (tail));assert (sz ==sizeof (tail)); -virtqueue_push (vq, elem,sizeof (tail)); +push: +qemu_mutex_unlock (&s->mutex); +virtqueue_push (vq, elem, sz);virtio_notify (vdev, vq);g_free (elem); }@@ -634,16 +780,23 @@ static IOMMUTLBEntry virtio_iommu_translate(IOMMUMemoryRegion *mr, hwaddr addr,VirtIOIOMMUEndpoint *ep;uint32_t sid, flags;bool bypass_allowed; +hwaddr addr_mask;
hw/virtio/virtio-iommu.c static IOMMUTLBEntry virtio_iommu_translate(IOMMUMemoryRegion *mr, hwaddr addr, · line 793
Quoted 10 lines
hw/virtio/virtio-iommu.c +5
-0bool found; interval.low = addr; interval.high = addr +1 ; +if (sdev->page_size_mask) { + addr_mask = (1 <<ctz32 (sdev->page_size_mask)) -1 ; + }else { + addr_mask = (1 <<ctz32 (s->config.page_size_mask)) -1 ; + }
This change does not belong ot this patch. Rather belongs to "virtio-iommu: set supported page size mask"
Quoted 32 lines
hw/virtio/virtio-iommu.c +4
-1+IOMMUTLBEntry entry = { .target_as = &address_space_memory, .iova = addr, .translated_addr = addr, - .addr_mask = (1 <<ctz32 (s->config.page_size_mask)) -1 , + .addr_mask = addr_mask, .perm =IOMMU_NONE , };@@ -831,6 +984,7 @@ static void virtio_iommu_device_realize(DeviceState *dev, Error **errp) s->config.page_size_mask =TARGET_PAGE_MASK ; s->config.input_range.end =-1UL ; s->config.domain_range.end =32 ; + s->config.probe_size =VIOMMU_PROBE_SIZE ;virtio_add_feature (&s->features,VIRTIO_RING_F_EVENT_IDX );virtio_add_feature (&s->features,VIRTIO_RING_F_INDIRECT_DESC );@@ -840,6 +994,7 @@ static void virtio_iommu_device_realize(DeviceState *dev, Error **errp)virtio_add_feature (&s->features,VIRTIO_IOMMU_F_MAP_UNMAP );virtio_add_feature (&s->features,VIRTIO_IOMMU_F_BYPASS );virtio_add_feature (&s->features,VIRTIO_IOMMU_F_MMIO ); +virtio_add_feature (&s->features,VIRTIO_IOMMU_F_PROBE );qemu_mutex_init (&s->mutex);hw/virtio/trace-events +0
-0
hw/virtio/trace-events virtio_iommu_report_fault(uint8_t reason, uint32_t flags, uint32_t endpoint, uin · line 80
Quoted 5 lines
hw/virtio/trace-events +2
-0@@ -76,3 +76,5 @@ virtio_iommu_report_fault(uint8_t reason, uint32_t flags, uint32_t endpoint, uin virtio_iommu_notify_map(const char *name, uint64_t iova, uint64_t paddr, uint64_t map_size) "mr=%s iova=0x%"PRIx64" pa=0x%" PRIx64" size=0x%"PRIx64 virtio_iommu_notify_unmap(const char *name, uint64_t iova, uint64_t map_size) "mr=%s iova=0x%"PRIx64" size=0x%"PRIx64 virtio_iommu_remap(uint64_t iova, uint64_t pa, uint64_t size) "iova=0x%"PRIx64" pa=0x%" PRIx64" size=0x%"PRIx64"" +virtio_iommu_fill_none_property(uint32_t devid) "devid=%d" +virtio_iommu_fill_pgsize_mask_property(uint32_t devid, uint64_t pgsize_mask, size_t filled) "dev= %d, pgsize_mask=0x%"PRIx64" filled=0x%lx"
Thanks
Eric
RE: [EXT] Re: [PATCH v9 8/9] virtio-iommu: Implement probe request
Hi Eric,
Quoted 24 lines
-----Original Message-----
From: Auger Eric <[email protected]>
Sent: Thursday, March 26, 2020 9:18 PM
To: Bharat Bhushan <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Tomasz Nowicki [C] <[email protected]>; [email protected]; [email protected]; qemu- [email protected]; [email protected]; [email protected]; jean- [email protected]; [email protected]
Subject: [EXT] Re: [PATCH v9 8/9] virtio-iommu: Implement probe requestExternal Email
----------------------------------------------------------------------
Hi BharatQuoted 7 lines · Bharat Bhushan
This patch implements the PROBE request. Currently supported page size mask per endpoint is returned. Also append a NONE property in the end.
Signed-off-by Bharat Bhushan <[email protected]>Signed-off-by Eric Auger <[email protected]>--- include/standard-headers/linux/virtio_iommu.h | 6 +
Quoted 6 lines
Changes to
virtio_iommu.hshould be in a separate patch you should use./scripts/update-linux-headers.shSee for instance:ddda37483dlinux-headers: update
until the uapi updates are not upstream you can link to your kernel branch and mention this is a temporary linux header update or partial if you just want to pick up theiommu.hchanges.
yes, I am sorry.
Quoted 127 lines
Quoted 116 lines
hw/virtio/virtio-iommu.c | 161 +++++++++++++++++- hw/virtio/trace-events | 2 + 3 files changed, 166 insertions(+), 3 deletions(-)include/standard-headers/linux/virtio_iommu.h +6
-0@@ -111,6 +111,7 @@ struct virtio_iommu_req_unmap {#define VIRTIO_IOMMU_PROBE_T_NONE 0#define VIRTIO_IOMMU_PROBE_T_RESV_MEM 1 +#define VIRTIO_IOMMU_PROBE_T_PAGE_SIZE_MASK 2#define VIRTIO_IOMMU_PROBE_T_MASK 0xfff@@ -130,6 +131,11 @@ struct virtio_iommu_probe_resv_mem {uint64_t end; }; +struct virtio_iommu_probe_pgsize_mask { +struct virtio_iommu_probe_property head; +uint64_t pgsize_bitmap; +}; +struct virtio_iommu_req_probe {struct virtio_iommu_req_head head;uint32_t endpoint;hw/virtio/virtio-iommu.c index renamed from hw/virtio/virtio-iommu.c +0
-0
747e3cf1da..63fbacdcdc100644hw/virtio/virtio-iommu.c +65
-1@@ -38,6 +38,10 @@/* Max size */ #define VIOMMU_DEFAULT_QUEUE_SIZE 256 +#define VIOMMU_PROBE_SIZE 512 + +#define SUPPORTED_PROBE_PROPERTIES (\ + 1 << VIRTIO_IOMMU_PROBE_T_PAGE_SIZE_MASK) typedef struct VirtIOIOMMUDomain { uint32_t id;@@ -62,6 +66,13 @@ typedef struct VirtIOIOMMUMapping {uint32_t flags; } VirtIOIOMMUMapping; +typedef struct VirtIOIOMMUPropBuffer { +VirtIOIOMMUEndpoint *endpoint; +size_t filled; +uint8_t *start; +bool error; +}VirtIOIOMMUPropBuffer ; +static inline uint16_t virtio_iommu_get_bdf (IOMMUDevice *dev) { return PCI_BUILD_BDF(pci_bus_num(dev->bus), dev->devfn); @@ -490,6 +501,114 @@ static int virtio_iommu_unmap(VirtIOIOMMU *s,return ret; } +static int virtio_iommu_fill_none_prop (VirtIOIOMMUPropBuffer +*bufstate) { +struct virtio_iommu_probe_property *prop; + + prop = (struct virtio_iommu_probe_property *) + (bufstate->start + bufstate->filled); + prop->type =0 ; + prop->length =0 ; + bufstate->filled +=sizeof (*prop); +trace_virtio_iommu_fill_none_property (bufstate->endpoint->id); +return 0 ; +} + +static int virtio_iommu_fill_page_size_mask (VirtIOIOMMUPropBuffer +*bufstate) { +struct virtio_iommu_probe_pgsize_mask *page_size_mask; +size_t prop_size =sizeof (*page_size_mask); +VirtIOIOMMUEndpoint *ep = bufstate->endpoint; +VirtIOIOMMU *s = ep->viommu; +IOMMUDevice *sdev; + +if (bufstate->filled + prop_size >=VIOMMU_PROBE_SIZE ) { + bufstate->error = true; +/* get the traversal stopped by returning true */ +return true; + } + + page_size_mask = (struct virtio_iommu_probe_pgsize_mask *) + (bufstate->start + bufstate->filled); + + page_size_mask->head.type =VIRTIO_IOMMU_PROBE_T_PAGE_SIZE_MASK ; + page_size_mask->head.length = prop_size; + QLIST_FOREACH(sdev, &s->notifiers_list, next) { +if (ep->id == sdev->devfn) { + page_size_mask->pgsize_bitmap = sdev->page_size_mask; + } + } + bufstate->filled +=sizeof (*page_size_mask); +trace_virtio_iommu_fill_pgsize_mask_property (bufstate->endpoint->id, + page_size_mask->pgsize_bitmap, + bufstate->filled); +return false; +} + +/* Fill the properties[] buffer with properties of type @type */ +static int virtio_iommu_fill_property (int type, +VirtIOIOMMUPropBuffer +*bufstate) { +int ret = -ENOSPC ; + +if (bufstate->filled +sizeof (struct virtio_iommu_probe_property ) + >=VIOMMU_PROBE_SIZE ) { +/* no space left for the header */ + bufstate->error = true;hw/virtio/virtio-iommu.c typedef struct VirtIOIOMMUMapping {
Quoted 10 lines
hw/virtio/virtio-iommu.c +10
-0+ goto out; + } + +switch (type) { +case VIRTIO_IOMMU_PROBE_T_NONE : + ret =virtio_iommu_fill_none_prop (bufstate); +break ; +case VIRTIO_IOMMU_PROBE_T_PAGE_SIZE_MASK : + { + ret =virtio_iommu_fill_page_size_mask (bufstate);I don't think you want to fill the property of each EP. Only for those whose sdev-
Quoted 2 lines
Quoted 1 line
page_size_maskwas properly set. For instance if you mix virtio and vfio devices,virtio ones won't have this field set.
This something I am looking for clarification ( asked in spec document patch). Copy pasting same here:
What some clarification about two page-size-mask configurations available.
- Global configuration for page-size-mask
- per endpoint page-size-mask configuration
PAGE_SIZE_MASK probe for and endpoint can return zero or non-zero value.
If it returns non-zero value than it will override the global configuration.
If PAGE_SIZE_MASK probe for and endpoint return zero value than global page-size-mask configuration will be used.
Is that correct?
Thanks
-Bharat
Quoted 114 lines
Quoted 27 lines
hw/virtio/virtio-iommu.c +27
-0+break ; + } +default : + ret = -ENOENT ; +break ; + } +out: +if (ret) { +error_report ("%s property of type=%d could not be filled (%d)," +" remaining size = 0x%lx" , + __func__, type, ret, bufstate->filled); + } +return ret; +} + +/** +* virtio_iommu_probe - Fill the probe request buffer with all +* the properties the device is able to return and add a NONE +* property at the end. @buf points to properties[]. +*/ +static int virtio_iommu_probe (VirtIOIOMMU *s, +struct virtio_iommu_req_probe *req, +uint8_t *buf) { +uint32_t ep_id =le32_to_cpu (req->endpoint); +VirtIOIOMMUEndpoint *ep =virtio_iommu_get_endpoint (s, ep_id); +int16_t prop_types =SUPPORTED_PROBE_PROPERTIES , type; +VirtIOIOMMUPropBuffer bufstate = {.start = buf, .filled =0 ,hw/virtio/virtio-iommu.c static int virtio_iommu_unmap(VirtIOIOMMU *s,
Quoted 10 lines
hw/virtio/virtio-iommu.c +10
-0+ .error = false, .endpoint = +ep}; + +while ((type =ctz32 (prop_types)) !=32 ) { +if (virtio_iommu_fill_property (type, &bufstate)) { + goto failure; + } + prop_types &= ~(1 << type); + } +if (virtio_iommu_fill_property (VIRTIO_IOMMU_PROBE_T_NONE , &bufstate)){
hw/virtio/virtio-iommu.c static IOMMUTLBEntry
Quoted 66 lines
hw/virtio/virtio-iommu.c +17
-1+ goto failure; + } +return VIRTIO_IOMMU_S_OK ; +failure: +return VIRTIO_IOMMU_S_INVAL ; +} +static int virtio_iommu_iov_to_req (struct iovec *iov,unsigned int iov_cnt, void *req, size_t req_sz) @@ -519,6 +638,17 @@ virtio_iommu_handle_req(detach)virtio_iommu_handle_req (map)virtio_iommu_handle_req (unmap) +static intvirtio_iommu_handle_probe (VirtIOIOMMU *s, + struct iovec *iov, + unsigned int iov_cnt, + uint8_t *buf) { +struct virtio_iommu_req_probe req; +int ret =virtio_iommu_iov_to_req (iov, iov_cnt, &req, +sizeof (req)); + +return ret ? ret :virtio_iommu_probe (s, &req, buf); } + static void virtio_iommu_handle_command(VirtIODevice *vdev, VirtQueue*vq) { VirtIOIOMMU *s = VIRTIO_IOMMU(vdev); @@ -564,17 +694,33 @@ static void virtio_iommu_handle_command(VirtIODevice *vdev, VirtQueue *vq) case VIRTIO_IOMMU_T_UNMAP: tail.status = virtio_iommu_handle_unmap(s, iov, iov_cnt); break;hw/virtio/virtio-iommu.c +20
-2+case VIRTIO_IOMMU_T_PROBE : + { +struct virtio_iommu_req_tail *ptail; +uint8_t *buf =g_malloc0 (s->config.probe_size + +sizeof (tail)); + + ptail = (struct virtio_iommu_req_tail *) + (buf + s->config.probe_size); + ptail->status =virtio_iommu_handle_probe (s, iov, + iov_cnt, buf); + + sz =iov_from_buf (elem->in_sg, elem->in_num,0 , + buf, s->config.probe_size +sizeof (tail)); +g_free (buf); +assert (sz == s->config.probe_size +sizeof (tail)); + goto push; + }default : tail.status =VIRTIO_IOMMU_S_UNSUPP ; } -qemu_mutex_unlock (&s->mutex); out: sz =iov_from_buf (elem->in_sg, elem->in_num,0 , &tail,sizeof (tail));assert (sz ==sizeof (tail)); -virtqueue_push (vq, elem,sizeof (tail)); +push: +qemu_mutex_unlock (&s->mutex); +virtqueue_push (vq, elem, sz);virtio_notify (vdev, vq);g_free (elem); }@@ -634,16 +780,23 @@ static IOMMUTLBEntryvirtio_iommu_translate(IOMMUMemoryRegion *mr, hwaddr addr,
Quoted 9 lines
hw/virtio/virtio-iommu.c +1
-0VirtIOIOMMUEndpoint *ep;uint32_t sid, flags;bool bypass_allowed; +hwaddr addr_mask;bool found; interval.low = addr; interval.high = addr +1 ;
Quoted 7 lines
hw/virtio/virtio-iommu.c static IOMMUTLBEntry virtio_iommu_translate(IOMMUMemoryRegion *mr, hwaddr addr, · line 793
Quoted 5 lines
hw/virtio/virtio-iommu.c +5
-0+if (sdev->page_size_mask) { + addr_mask = (1 <<ctz32 (sdev->page_size_mask)) -1 ; + }else { + addr_mask = (1 <<ctz32 (s->config.page_size_mask)) -1 ; + }This change does not belong ot this patch. Rather belongs to "virtio-iommu: set supported page size mask"
Thanks for pointing, will change.
Thanks
-Bharat
Quoted 46 lines
hw/virtio/virtio-iommu.c static void virtio_iommu_device_realize(DeviceState
Quoted 11 lines
hw/virtio/virtio-iommu.c +2
-1+IOMMUTLBEntry entry = { .target_as = &address_space_memory, .iova = addr, .translated_addr = addr, - .addr_mask = (1 <<ctz32 (s->config.page_size_mask)) -1 , + .addr_mask = addr_mask, .perm =IOMMU_NONE , };@@ -831,6 +984,7 @@ static void virtio_iommu_device_realize(DeviceState*dev, Error **errp)
hw/virtio/virtio-iommu.c static void virtio_iommu_device_realize(DeviceState *dev, Error **errp)
Quoted 8 lines
hw/virtio/virtio-iommu.c +1
-1s->config.page_size_mask =TARGET_PAGE_MASK ; s->config.input_range.end =-1UL ; s->config.domain_range.end =32 ; + s->config.probe_size =VIOMMU_PROBE_SIZE ;virtio_add_feature (&s->features,VIRTIO_RING_F_EVENT_IDX ); virtio_add_feature(&s->features, VIRTIO_RING_F_INDIRECT_DESC); @@ -840,6 +994,7 @@ static void virtio_iommu_device_realize(DeviceState *dev,Error **errp)
Quoted 12 lines
virtio_add_feature(&s->features, VIRTIO_IOMMU_F_MAP_UNMAP); virtio_add_feature(&s->features, VIRTIO_IOMMU_F_BYPASS); virtio_add_feature(&s->features, VIRTIO_IOMMU_F_MMIO);hw/virtio/virtio-iommu.c +1
-0+virtio_add_feature (&s->features,VIRTIO_IOMMU_F_PROBE );qemu_mutex_init (&s->mutex);hw/virtio/trace-events index renamed from hw/virtio/trace-events +0
-0
8bae651191..b0a6e4bda3100644hw/virtio/trace-events +0
-0@@ -76,3 +76,5 @@ virtio_iommu_report_fault(uint8_t reason, uint32_tQuoted 3 lines
flags,
uint32_tendpoint, uinvirtio_iommu_notify_map(const char *name, uint64_t iova, uint64_t paddr, uint64_t map_size)"mr=%s iova=0x%"PRIx64" pa=0x%" PRIx64" size=0x%"PRIx64
virtio_iommu_notify_unmap(const char *name, uint64_t iova, uint64_t map_size)"mr=%s iova=0x%"PRIx64" size=0x%"PRIx64virtio_iommu_remap(uint64_t iova, uint64_t pa, uint64_t size)"iova=0x%"PRIx64" pa=0x%" PRIx64" size=0x%"PRIx64""hw/virtio/trace-events
Quoted 2 lines
hw/virtio/trace-events +2
-0+virtio_iommu_fill_none_property(uint32_t devid) "devid=%d" +virtio_iommu_fill_pgsize_mask_property(uint32_t devid, uint64_t pgsize_mask,
size_tfilled) "dev= %d, pgsize_mask=0x%"PRIx64" filled=0x%lx"Quoted 1 line
Thanks
Eric
Re: [EXT] Re: [PATCH v9 8/9] virtio-iommu: Implement probe request
Hi Bharat,
Quoted 26 lines · Bharat Bhushan
Hi Eric,
Quoted 24 lines
-----Original Message-----
From: Auger Eric <[email protected]>
Sent: Thursday, March 26, 2020 9:18 PM
To: Bharat Bhushan <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Tomasz Nowicki [C] <[email protected]>; [email protected]; [email protected]; qemu- [email protected]; [email protected]; [email protected]; jean- [email protected]; [email protected]
Subject: [EXT] Re: [PATCH v9 8/9] virtio-iommu: Implement probe requestExternal Email
----------------------------------------------------------------------
Hi BharatQuoted 7 lines · Bharat Bhushan
This patch implements the PROBE request. Currently supported page size mask per endpoint is returned. Also append a NONE property in the end.
Signed-off-by Bharat Bhushan <[email protected]>Signed-off-by Eric Auger <[email protected]>--- include/standard-headers/linux/virtio_iommu.h | 6 +
Quoted 8 lines
Quoted 6 lines
Changes to
virtio_iommu.hshould be in a separate patch you should use./scripts/update-linux-headers.shSee for instance:ddda37483dlinux-headers: update
until the uapi updates are not upstream you can link to your kernel branch and mention this is a temporary linux header update or partial if you just want to pick up theiommu.hchanges.yes, I am sorry.
no problem
Quoted 133 lines
Quoted 128 lines
Quoted 117 lines
hw/virtio/virtio-iommu.c | 161 +++++++++++++++++- hw/virtio/trace-events | 2 + 3 files changed, 166 insertions(+), 3 deletions(-)include/standard-headers/linux/virtio_iommu.h +6
-0@@ -111,6 +111,7 @@ struct virtio_iommu_req_unmap {#define VIRTIO_IOMMU_PROBE_T_NONE 0#define VIRTIO_IOMMU_PROBE_T_RESV_MEM 1 +#define VIRTIO_IOMMU_PROBE_T_PAGE_SIZE_MASK 2#define VIRTIO_IOMMU_PROBE_T_MASK 0xfff@@ -130,6 +131,11 @@ struct virtio_iommu_probe_resv_mem {uint64_t end; }; +struct virtio_iommu_probe_pgsize_mask { +struct virtio_iommu_probe_property head; +uint64_t pgsize_bitmap; +}; +struct virtio_iommu_req_probe {struct virtio_iommu_req_head head;uint32_t endpoint;hw/virtio/virtio-iommu.c index renamed from hw/virtio/virtio-iommu.c +0
-0
747e3cf1da..63fbacdcdc100644hw/virtio/virtio-iommu.c +65
-1@@ -38,6 +38,10 @@/* Max size */ #define VIOMMU_DEFAULT_QUEUE_SIZE 256 +#define VIOMMU_PROBE_SIZE 512 + +#define SUPPORTED_PROBE_PROPERTIES (\ + 1 << VIRTIO_IOMMU_PROBE_T_PAGE_SIZE_MASK) typedef struct VirtIOIOMMUDomain { uint32_t id;@@ -62,6 +66,13 @@ typedef struct VirtIOIOMMUMapping {uint32_t flags; } VirtIOIOMMUMapping; +typedef struct VirtIOIOMMUPropBuffer { +VirtIOIOMMUEndpoint *endpoint; +size_t filled; +uint8_t *start; +bool error; +}VirtIOIOMMUPropBuffer ; +static inline uint16_t virtio_iommu_get_bdf (IOMMUDevice *dev) { return PCI_BUILD_BDF(pci_bus_num(dev->bus), dev->devfn); @@ -490,6 +501,114 @@ static int virtio_iommu_unmap(VirtIOIOMMU *s,return ret; } +static int virtio_iommu_fill_none_prop (VirtIOIOMMUPropBuffer +*bufstate) { +struct virtio_iommu_probe_property *prop; + + prop = (struct virtio_iommu_probe_property *) + (bufstate->start + bufstate->filled); + prop->type =0 ; + prop->length =0 ; + bufstate->filled +=sizeof (*prop); +trace_virtio_iommu_fill_none_property (bufstate->endpoint->id); +return 0 ; +} + +static int virtio_iommu_fill_page_size_mask (VirtIOIOMMUPropBuffer +*bufstate) { +struct virtio_iommu_probe_pgsize_mask *page_size_mask; +size_t prop_size =sizeof (*page_size_mask); +VirtIOIOMMUEndpoint *ep = bufstate->endpoint; +VirtIOIOMMU *s = ep->viommu; +IOMMUDevice *sdev; + +if (bufstate->filled + prop_size >=VIOMMU_PROBE_SIZE ) { + bufstate->error = true; +/* get the traversal stopped by returning true */ +return true; + } + + page_size_mask = (struct virtio_iommu_probe_pgsize_mask *) + (bufstate->start + bufstate->filled); + + page_size_mask->head.type =VIRTIO_IOMMU_PROBE_T_PAGE_SIZE_MASK ; + page_size_mask->head.length = prop_size; + QLIST_FOREACH(sdev, &s->notifiers_list, next) { +if (ep->id == sdev->devfn) { + page_size_mask->pgsize_bitmap = sdev->page_size_mask; + } + } + bufstate->filled +=sizeof (*page_size_mask); +trace_virtio_iommu_fill_pgsize_mask_property (bufstate->endpoint->id, + page_size_mask->pgsize_bitmap, + bufstate->filled); +return false; +} + +/* Fill the properties[] buffer with properties of type @type */ +static int virtio_iommu_fill_property (int type, +VirtIOIOMMUPropBuffer +*bufstate) { +int ret = -ENOSPC ; + +if (bufstate->filled +sizeof (struct virtio_iommu_probe_property ) + >=VIOMMU_PROBE_SIZE ) { +/* no space left for the header */ + bufstate->error = true;hw/virtio/virtio-iommu.c typedef struct VirtIOIOMMUMapping {
Quoted 10 lines
hw/virtio/virtio-iommu.c +10
-0+ goto out; + } + +switch (type) { +case VIRTIO_IOMMU_PROBE_T_NONE : + ret =virtio_iommu_fill_none_prop (bufstate); +break ; +case VIRTIO_IOMMU_PROBE_T_PAGE_SIZE_MASK : + { + ret =virtio_iommu_fill_page_size_mask (bufstate);I don't think you want to fill the property of each EP. Only for those whose sdev-
Quoted 2 lines
Quoted 1 line
page_size_maskwas properly set. For instance if you mix virtio and vfio devices,virtio ones won't have this field set.
This something I am looking for clarification ( asked in spec document patch). Copy pasting same here:
Quoted 7 lines
What some clarification about two page-size-mask configurations available.
- Global configuration for page-size-mask
- per endpoint page-size-mask configuration
PAGE_SIZE_MASKprobe for and endpoint can return zero or non-zero value.
If it returns non-zero value than it will override the global configuration.
IfPAGE_SIZE_MASKprobe for and endpoint return zero value than global page-size-mask configuration will be used.
Hum, that's not my current understanding. I understand it would also override the global page size mask with 0. Hence my suggestion to *not* return the property in that case.
Thanks
Eric
Quoted 180 lines
Is that correct?
Thanks
-BharatQuoted 114 lines
Quoted 27 lines
hw/virtio/virtio-iommu.c +27
-0+break ; + } +default : + ret = -ENOENT ; +break ; + } +out: +if (ret) { +error_report ("%s property of type=%d could not be filled (%d)," +" remaining size = 0x%lx" , + __func__, type, ret, bufstate->filled); + } +return ret; +} + +/** +* virtio_iommu_probe - Fill the probe request buffer with all +* the properties the device is able to return and add a NONE +* property at the end. @buf points to properties[]. +*/ +static int virtio_iommu_probe (VirtIOIOMMU *s, +struct virtio_iommu_req_probe *req, +uint8_t *buf) { +uint32_t ep_id =le32_to_cpu (req->endpoint); +VirtIOIOMMUEndpoint *ep =virtio_iommu_get_endpoint (s, ep_id); +int16_t prop_types =SUPPORTED_PROBE_PROPERTIES , type; +VirtIOIOMMUPropBuffer bufstate = {.start = buf, .filled =0 ,hw/virtio/virtio-iommu.c static int virtio_iommu_unmap(VirtIOIOMMU *s,
Quoted 10 lines
hw/virtio/virtio-iommu.c +10
-0+ .error = false, .endpoint = +ep}; + +while ((type =ctz32 (prop_types)) !=32 ) { +if (virtio_iommu_fill_property (type, &bufstate)) { + goto failure; + } + prop_types &= ~(1 << type); + } +if (virtio_iommu_fill_property (VIRTIO_IOMMU_PROBE_T_NONE , &bufstate)){
hw/virtio/virtio-iommu.c static IOMMUTLBEntry
Quoted 66 lines
hw/virtio/virtio-iommu.c +17
-1+ goto failure; + } +return VIRTIO_IOMMU_S_OK ; +failure: +return VIRTIO_IOMMU_S_INVAL ; +} +static int virtio_iommu_iov_to_req (struct iovec *iov,unsigned int iov_cnt, void *req, size_t req_sz) @@ -519,6 +638,17 @@ virtio_iommu_handle_req(detach)virtio_iommu_handle_req (map)virtio_iommu_handle_req (unmap) +static intvirtio_iommu_handle_probe (VirtIOIOMMU *s, + struct iovec *iov, + unsigned int iov_cnt, + uint8_t *buf) { +struct virtio_iommu_req_probe req; +int ret =virtio_iommu_iov_to_req (iov, iov_cnt, &req, +sizeof (req)); + +return ret ? ret :virtio_iommu_probe (s, &req, buf); } + static void virtio_iommu_handle_command(VirtIODevice *vdev, VirtQueue*vq) { VirtIOIOMMU *s = VIRTIO_IOMMU(vdev); @@ -564,17 +694,33 @@ static void virtio_iommu_handle_command(VirtIODevice *vdev, VirtQueue *vq) case VIRTIO_IOMMU_T_UNMAP: tail.status = virtio_iommu_handle_unmap(s, iov, iov_cnt); break;hw/virtio/virtio-iommu.c +20
-2+case VIRTIO_IOMMU_T_PROBE : + { +struct virtio_iommu_req_tail *ptail; +uint8_t *buf =g_malloc0 (s->config.probe_size + +sizeof (tail)); + + ptail = (struct virtio_iommu_req_tail *) + (buf + s->config.probe_size); + ptail->status =virtio_iommu_handle_probe (s, iov, + iov_cnt, buf); + + sz =iov_from_buf (elem->in_sg, elem->in_num,0 , + buf, s->config.probe_size +sizeof (tail)); +g_free (buf); +assert (sz == s->config.probe_size +sizeof (tail)); + goto push; + }default : tail.status =VIRTIO_IOMMU_S_UNSUPP ; } -qemu_mutex_unlock (&s->mutex); out: sz =iov_from_buf (elem->in_sg, elem->in_num,0 , &tail,sizeof (tail));assert (sz ==sizeof (tail)); -virtqueue_push (vq, elem,sizeof (tail)); +push: +qemu_mutex_unlock (&s->mutex); +virtqueue_push (vq, elem, sz);virtio_notify (vdev, vq);g_free (elem); }@@ -634,16 +780,23 @@ static IOMMUTLBEntryvirtio_iommu_translate(IOMMUMemoryRegion *mr, hwaddr addr,
Quoted 9 lines
hw/virtio/virtio-iommu.c +1
-0VirtIOIOMMUEndpoint *ep;uint32_t sid, flags;bool bypass_allowed; +hwaddr addr_mask;bool found; interval.low = addr; interval.high = addr +1 ;Quoted 7 lines
hw/virtio/virtio-iommu.c static IOMMUTLBEntry virtio_iommu_translate(IOMMUMemoryRegion *mr, hwaddr addr, · line 793
Quoted 5 lines
hw/virtio/virtio-iommu.c +5
-0+if (sdev->page_size_mask) { + addr_mask = (1 <<ctz32 (sdev->page_size_mask)) -1 ; + }else { + addr_mask = (1 <<ctz32 (s->config.page_size_mask)) -1 ; + }This change does not belong ot this patch. Rather belongs to "virtio-iommu: set supported page size mask"
Thanks for pointing, will change.
Thanks
-BharatQuoted 46 lines
hw/virtio/virtio-iommu.c static void virtio_iommu_device_realize(DeviceState
Quoted 11 lines
hw/virtio/virtio-iommu.c +2
-1+IOMMUTLBEntry entry = { .target_as = &address_space_memory, .iova = addr, .translated_addr = addr, - .addr_mask = (1 <<ctz32 (s->config.page_size_mask)) -1 , + .addr_mask = addr_mask, .perm =IOMMU_NONE , };@@ -831,6 +984,7 @@ static void virtio_iommu_device_realize(DeviceState*dev, Error **errp)
hw/virtio/virtio-iommu.c static void virtio_iommu_device_realize(DeviceState *dev, Error **errp)
Quoted 8 lines
hw/virtio/virtio-iommu.c +1
-1s->config.page_size_mask =TARGET_PAGE_MASK ; s->config.input_range.end =-1UL ; s->config.domain_range.end =32 ; + s->config.probe_size =VIOMMU_PROBE_SIZE ;virtio_add_feature (&s->features,VIRTIO_RING_F_EVENT_IDX ); virtio_add_feature(&s->features, VIRTIO_RING_F_INDIRECT_DESC); @@ -840,6 +994,7 @@ static void virtio_iommu_device_realize(DeviceState *dev,Error **errp)
Quoted 12 lines
virtio_add_feature(&s->features, VIRTIO_IOMMU_F_MAP_UNMAP); virtio_add_feature(&s->features, VIRTIO_IOMMU_F_BYPASS); virtio_add_feature(&s->features, VIRTIO_IOMMU_F_MMIO);hw/virtio/virtio-iommu.c +1
-0+virtio_add_feature (&s->features,VIRTIO_IOMMU_F_PROBE );qemu_mutex_init (&s->mutex);hw/virtio/trace-events index renamed from hw/virtio/trace-events +0
-0
8bae651191..b0a6e4bda3100644hw/virtio/trace-events +0
-0@@ -76,3 +76,5 @@ virtio_iommu_report_fault(uint8_t reason, uint32_tQuoted 3 lines
flags,
uint32_tendpoint, uinvirtio_iommu_notify_map(const char *name, uint64_t iova, uint64_t paddr, uint64_t map_size)"mr=%s iova=0x%"PRIx64" pa=0x%" PRIx64" size=0x%"PRIx64
virtio_iommu_notify_unmap(const char *name, uint64_t iova, uint64_t map_size)"mr=%s iova=0x%"PRIx64" size=0x%"PRIx64virtio_iommu_remap(uint64_t iova, uint64_t pa, uint64_t size)"iova=0x%"PRIx64" pa=0x%" PRIx64" size=0x%"PRIx64""hw/virtio/trace-events
Quoted 2 lines
hw/virtio/trace-events +2
-0+virtio_iommu_fill_none_property(uint32_t devid) "devid=%d" +virtio_iommu_fill_pgsize_mask_property(uint32_t devid, uint64_t pgsize_mask,
size_tfilled) "dev= %d, pgsize_mask=0x%"PRIx64" filled=0x%lx"Quoted 1 line
Thanks
Eric
Re: [PATCH v9 8/9] virtio-iommu: Implement probe request
In reply to Bharat BhushanHi Bharat,
A few more things found while rebasing
Quoted 52 lines · Bharat Bhushan
This patch implements the PROBE request. Currently supported page size mask per endpoint is returned. Also append a NONE property in the end.
Signed-off-by Bharat Bhushan <[email protected]>Signed-off-by Eric Auger <[email protected]>--- include/standard-headers/linux/virtio_iommu.h | 6 + hw/virtio/virtio-iommu.c | 161 +++++++++++++++++- hw/virtio/trace-events | 2 + 3 files changed, 166 insertions(+), 3 deletions(-)include/standard-headers/linux/virtio_iommu.h +6
-0@@ -111,6 +111,7 @@ struct virtio_iommu_req_unmap {#define VIRTIO_IOMMU_PROBE_T_NONE 0#define VIRTIO_IOMMU_PROBE_T_RESV_MEM 1 +#define VIRTIO_IOMMU_PROBE_T_PAGE_SIZE_MASK 2#define VIRTIO_IOMMU_PROBE_T_MASK 0xfff@@ -130,6 +131,11 @@ struct virtio_iommu_probe_resv_mem {uint64_t end; }; +struct virtio_iommu_probe_pgsize_mask { +struct virtio_iommu_probe_property head; +uint64_t pgsize_bitmap; +}; +struct virtio_iommu_req_probe {struct virtio_iommu_req_head head;uint32_t endpoint;hw/virtio/virtio-iommu.c +4
-0@@ -38,6 +38,10 @@/* Max size */ #define VIOMMU_DEFAULT_QUEUE_SIZE 256 +#define VIOMMU_PROBE_SIZE 512 + +#define SUPPORTED_PROBE_PROPERTIES (\ + 1 << VIRTIO_IOMMU_PROBE_T_PAGE_SIZE_MASK) typedef struct VirtIOIOMMUDomain { uint32_t id;
hw/virtio/virtio-iommu.c typedef struct VirtIOIOMMUMapping { · line 73
Quoted 8 lines
hw/virtio/virtio-iommu.c +5
-0@@ -62,6 +66,13 @@ typedef struct VirtIOIOMMUMapping {uint32_t flags; } VirtIOIOMMUMapping; +typedef struct VirtIOIOMMUPropBuffer { + VirtIOIOMMUEndpoint *endpoint; + size_t filled; + uint8_t *start; + bool error;
It doesn't seem like bufstate->error gets used anywhere
Quoted 34 lines
hw/virtio/virtio-iommu.c +27
-0+} VirtIOIOMMUPropBuffer; +static inline uint16_t virtio_iommu_get_bdf (IOMMUDevice *dev) {return PCI_BUILD_BDF (pci_bus_num (dev->bus), dev->devfn);@@ -490,6 +501,114 @@ static int virtio_iommu_unmap(VirtIOIOMMU *s,return ret; } +static int virtio_iommu_fill_none_prop (VirtIOIOMMUPropBuffer *bufstate) +{ +struct virtio_iommu_probe_property *prop; + + prop = (struct virtio_iommu_probe_property *) + (bufstate->start + bufstate->filled); + prop->type =0 ; + prop->length =0 ; + bufstate->filled +=sizeof (*prop); +trace_virtio_iommu_fill_none_property (bufstate->endpoint->id); +return 0 ; +} + +static int virtio_iommu_fill_page_size_mask (VirtIOIOMMUPropBuffer *bufstate) +{ +struct virtio_iommu_probe_pgsize_mask *page_size_mask; +size_t prop_size =sizeof (*page_size_mask); +VirtIOIOMMUEndpoint *ep = bufstate->endpoint; +VirtIOIOMMU *s = ep->viommu; +IOMMUDevice *sdev; + +if (bufstate->filled + prop_size >=VIOMMU_PROBE_SIZE ) { + bufstate->error = true; +/* get the traversal stopped by returning true */ +return true;
hw/virtio/virtio-iommu.c static int virtio_iommu_unmap(VirtIOIOMMU *s, · line 538
Quoted 10 lines
hw/virtio/virtio-iommu.c +10
-0+ } + + page_size_mask = (struct virtio_iommu_probe_pgsize_mask *) + (bufstate->start + bufstate->filled); + + page_size_mask->head.type =VIRTIO_IOMMU_PROBE_T_PAGE_SIZE_MASK ; + page_size_mask->head.length = prop_size; + QLIST_FOREACH(sdev, &s->notifiers_list, next) { +if (ep->id == sdev->devfn) { + page_size_mask->pgsize_bitmap = sdev->page_size_mask;
Do we need a cpu_to_le64 here?
Quoted 48 lines
hw/virtio/virtio-iommu.c +48
-0+ } + } + bufstate->filled +=sizeof (*page_size_mask); +trace_virtio_iommu_fill_pgsize_mask_property (bufstate->endpoint->id, + page_size_mask->pgsize_bitmap, + bufstate->filled); +return false; +} + +/* Fill the properties[] buffer with properties of type @type */ +static int virtio_iommu_fill_property (int type, +VirtIOIOMMUPropBuffer *bufstate) +{ +int ret = -ENOSPC ; + +if (bufstate->filled +sizeof (struct virtio_iommu_probe_property ) + >=VIOMMU_PROBE_SIZE ) { +/* no space left for the header */ + bufstate->error = true; + goto out; + } + +switch (type) { +case VIRTIO_IOMMU_PROBE_T_NONE : + ret =virtio_iommu_fill_none_prop (bufstate); +break ; +case VIRTIO_IOMMU_PROBE_T_PAGE_SIZE_MASK : + { + ret =virtio_iommu_fill_page_size_mask (bufstate); +break ; + } +default : + ret = -ENOENT ; +break ; + } +out: +if (ret) { +error_report ("%s property of type=%d could not be filled (%d)," +" remaining size = 0x%lx" , + __func__, type, ret, bufstate->filled); + } +return ret; +} + +/** +* virtio_iommu_probe - Fill the probe request buffer with all +* the properties the device is able to return and add a NONE +* property at the end. @buf points to properties[].
hw/virtio/virtio-iommu.c static int virtio_iommu_unmap(VirtIOIOMMU *s, · line 596
Quoted 10 lines
hw/virtio/virtio-iommu.c +10
-0+*/ +static int virtio_iommu_probe (VirtIOIOMMU *s, +struct virtio_iommu_req_probe *req, +uint8_t *buf) +{ +uint32_t ep_id =le32_to_cpu (req->endpoint); +VirtIOIOMMUEndpoint *ep =virtio_iommu_get_endpoint (s, ep_id); +int16_t prop_types =SUPPORTED_PROBE_PROPERTIES , type; +VirtIOIOMMUPropBuffer bufstate = {.start = buf, .filled =0 , + .error = false, .endpoint = ep};
Probably need to check if ep is valid before going further
hw/virtio/virtio-iommu.c static int virtio_iommu_unmap(VirtIOIOMMU *s, · line 606
Quoted 10 lines
hw/virtio/virtio-iommu.c +10
-0+ +while ((type =ctz32 (prop_types)) !=32 ) { +if (virtio_iommu_fill_property (type, &bufstate)) { + goto failure; + } + prop_types &= ~(1 << type); + } +if (virtio_iommu_fill_property (VIRTIO_IOMMU_PROBE_T_NONE , &bufstate)) { + goto failure; + }
We got rid of the NONE property in the spec, now there is:
"If the device doesn’t fill all probe_size bytes with properties, it
SHOULD fill the remaining bytes of properties with zeroes."
So I think you can get rid of virtio_iommu_fill_none_prop() and fill the rest of the buffer with zeroes here instead.
Thanks,
Jean
Quoted 116 lines
hw/virtio/virtio-iommu.c +44
-3+return VIRTIO_IOMMU_S_OK ; +failure: +return VIRTIO_IOMMU_S_INVAL ; +} +static int virtio_iommu_iov_to_req (struct iovec *iov,unsigned int iov_cnt,void *req,size_t req_sz)@@ -519,6 +638,17 @@ virtio_iommu_handle_req(detach)virtio_iommu_handle_req (map)virtio_iommu_handle_req (unmap) +static int virtio_iommu_handle_probe(VirtIOIOMMU *s, + struct iovec *iov, + unsigned int iov_cnt, + uint8_t *buf) +{ +struct virtio_iommu_req_probe req; +int ret =virtio_iommu_iov_to_req (iov, iov_cnt, &req,sizeof (req)); + + return ret ? ret : virtio_iommu_probe(s, &req, buf); +} + static void virtio_iommu_handle_command(VirtIODevice *vdev, VirtQueue *vq) {VirtIOIOMMU *s =VIRTIO_IOMMU (vdev);@@ -564,17 +694,33 @@ static void virtio_iommu_handle_command(VirtIODevice *vdev, VirtQueue *vq)case VIRTIO_IOMMU_T_UNMAP : tail.status =virtio_iommu_handle_unmap (s, iov, iov_cnt);break ; +case VIRTIO_IOMMU_T_PROBE : + { +struct virtio_iommu_req_tail *ptail; +uint8_t *buf =g_malloc0 (s->config.probe_size +sizeof (tail)); + + ptail = (struct virtio_iommu_req_tail *) + (buf + s->config.probe_size); + ptail->status =virtio_iommu_handle_probe (s, iov, iov_cnt, buf); + + sz =iov_from_buf (elem->in_sg, elem->in_num,0 , + buf, s->config.probe_size +sizeof (tail)); +g_free (buf); +assert (sz == s->config.probe_size +sizeof (tail)); + goto push; + }default : tail.status =VIRTIO_IOMMU_S_UNSUPP ; } -qemu_mutex_unlock (&s->mutex); out: sz =iov_from_buf (elem->in_sg, elem->in_num,0 , &tail,sizeof (tail));assert (sz ==sizeof (tail)); -virtqueue_push (vq, elem,sizeof (tail)); +push: +qemu_mutex_unlock (&s->mutex); +virtqueue_push (vq, elem, sz);virtio_notify (vdev, vq);g_free (elem); }@@ -634,16 +780,23 @@ static IOMMUTLBEntry virtio_iommu_translate(IOMMUMemoryRegion *mr, hwaddr addr,VirtIOIOMMUEndpoint *ep;uint32_t sid, flags;bool bypass_allowed; +hwaddr addr_mask;bool found; interval.low = addr; interval.high = addr +1 ; +if (sdev->page_size_mask) { + addr_mask = (1 <<ctz32 (sdev->page_size_mask)) -1 ; + }else { + addr_mask = (1 <<ctz32 (s->config.page_size_mask)) -1 ; + } +IOMMUTLBEntry entry = { .target_as = &address_space_memory, .iova = addr, .translated_addr = addr, - .addr_mask = (1 <<ctz32 (s->config.page_size_mask)) -1 , + .addr_mask = addr_mask, .perm =IOMMU_NONE , };@@ -831,6 +984,7 @@ static void virtio_iommu_device_realize(DeviceState *dev, Error **errp) s->config.page_size_mask =TARGET_PAGE_MASK ; s->config.input_range.end =-1UL ; s->config.domain_range.end =32 ; + s->config.probe_size =VIOMMU_PROBE_SIZE ;virtio_add_feature (&s->features,VIRTIO_RING_F_EVENT_IDX );virtio_add_feature (&s->features,VIRTIO_RING_F_INDIRECT_DESC );@@ -840,6 +994,7 @@ static void virtio_iommu_device_realize(DeviceState *dev, Error **errp)virtio_add_feature (&s->features,VIRTIO_IOMMU_F_MAP_UNMAP );virtio_add_feature (&s->features,VIRTIO_IOMMU_F_BYPASS );virtio_add_feature (&s->features,VIRTIO_IOMMU_F_MMIO ); +virtio_add_feature (&s->features,VIRTIO_IOMMU_F_PROBE );qemu_mutex_init (&s->mutex);hw/virtio/trace-events +2
-0@@ -76,3 +76,5 @@ virtio_iommu_report_fault(uint8_t reason, uint32_t flags, uint32_t endpoint, uin virtio_iommu_notify_map(const char *name, uint64_t iova, uint64_t paddr, uint64_t map_size) "mr=%s iova=0x%"PRIx64" pa=0x%" PRIx64" size=0x%"PRIx64 virtio_iommu_notify_unmap(const char *name, uint64_t iova, uint64_t map_size) "mr=%s iova=0x%"PRIx64" size=0x%"PRIx64 virtio_iommu_remap(uint64_t iova, uint64_t pa, uint64_t size) "iova=0x%"PRIx64" pa=0x%" PRIx64" size=0x%"PRIx64"" +virtio_iommu_fill_none_property(uint32_t devid) "devid=%d" +virtio_iommu_fill_pgsize_mask_property(uint32_t devid, uint64_t pgsize_mask, size_t filled) "dev= %d, pgsize_mask=0x%"PRIx64" filled=0x%lx"Signature · 1 line
2.17.1
Re: [PATCH v9 8/9] virtio-iommu: Implement probe request
Hi Bharat,
Quoted 60 lines · Jean-Philippe Brucker
Hi Bharat,
A few more things found while rebasing
Quoted 55 lines · Bharat Bhushan
This patch implements the PROBE request. Currently supported page size mask per endpoint is returned. Also append a NONE property in the end.
Signed-off-by Bharat Bhushan <[email protected]>Signed-off-by Eric Auger <[email protected]>--- include/standard-headers/linux/virtio_iommu.h | 6 + hw/virtio/virtio-iommu.c | 161 +++++++++++++++++- hw/virtio/trace-events | 2 + 3 files changed, 166 insertions(+), 3 deletions(-)include/standard-headers/linux/virtio_iommu.h +6
-0@@ -111,6 +111,7 @@ struct virtio_iommu_req_unmap {#define VIRTIO_IOMMU_PROBE_T_NONE 0#define VIRTIO_IOMMU_PROBE_T_RESV_MEM 1 +#define VIRTIO_IOMMU_PROBE_T_PAGE_SIZE_MASK 2#define VIRTIO_IOMMU_PROBE_T_MASK 0xfff@@ -130,6 +131,11 @@ struct virtio_iommu_probe_resv_mem {uint64_t end; }; +struct virtio_iommu_probe_pgsize_mask { +struct virtio_iommu_probe_property head; +uint64_t pgsize_bitmap; +}; +struct virtio_iommu_req_probe {struct virtio_iommu_req_head head;uint32_t endpoint;hw/virtio/virtio-iommu.c +4
-0@@ -38,6 +38,10 @@/* Max size */ #define VIOMMU_DEFAULT_QUEUE_SIZE 256 +#define VIOMMU_PROBE_SIZE 512 + +#define SUPPORTED_PROBE_PROPERTIES (\ + 1 << VIRTIO_IOMMU_PROBE_T_PAGE_SIZE_MASK) typedef struct VirtIOIOMMUDomain { uint32_t id;@@ -62,6 +66,13 @@ typedef struct VirtIOIOMMUMapping {uint32_t flags; } VirtIOIOMMUMapping;
Quoted 7 lines
hw/virtio/virtio-iommu.c typedef struct VirtIOIOMMUMapping { · line 73
Quoted 5 lines
hw/virtio/virtio-iommu.c +5
-0+typedef struct VirtIOIOMMUPropBuffer { + VirtIOIOMMUEndpoint *endpoint; + size_t filled; + uint8_t *start; + bool error;It doesn't seem like
bufstate->errorgets used anywhere
maybe rebase your work on
[PATCH for-4.2 v10 10/15] virtio-iommu: Implement probe request which tests it.
Also in
[Qemu-devel] [PATCH for-4.2 v10 10/15] virtio-iommu: Implement probe request I changed the implementation to keep it simpler.
Thanks
Eric
Quoted 248 lines
Quoted 35 lines
hw/virtio/virtio-iommu.c +27
-0+} VirtIOIOMMUPropBuffer; +static inline uint16_t virtio_iommu_get_bdf (IOMMUDevice *dev) {return PCI_BUILD_BDF (pci_bus_num (dev->bus), dev->devfn);@@ -490,6 +501,114 @@ static int virtio_iommu_unmap(VirtIOIOMMU *s,return ret; } +static int virtio_iommu_fill_none_prop (VirtIOIOMMUPropBuffer *bufstate) +{ +struct virtio_iommu_probe_property *prop; + + prop = (struct virtio_iommu_probe_property *) + (bufstate->start + bufstate->filled); + prop->type =0 ; + prop->length =0 ; + bufstate->filled +=sizeof (*prop); +trace_virtio_iommu_fill_none_property (bufstate->endpoint->id); +return 0 ; +} + +static int virtio_iommu_fill_page_size_mask (VirtIOIOMMUPropBuffer *bufstate) +{ +struct virtio_iommu_probe_pgsize_mask *page_size_mask; +size_t prop_size =sizeof (*page_size_mask); +VirtIOIOMMUEndpoint *ep = bufstate->endpoint; +VirtIOIOMMU *s = ep->viommu; +IOMMUDevice *sdev; + +if (bufstate->filled + prop_size >=VIOMMU_PROBE_SIZE ) { + bufstate->error = true; +/* get the traversal stopped by returning true */ +return true;hw/virtio/virtio-iommu.c static int virtio_iommu_unmap(VirtIOIOMMU *s, · line 538
Quoted 10 lines
hw/virtio/virtio-iommu.c +10
-0+ } + + page_size_mask = (struct virtio_iommu_probe_pgsize_mask *) + (bufstate->start + bufstate->filled); + + page_size_mask->head.type =VIRTIO_IOMMU_PROBE_T_PAGE_SIZE_MASK ; + page_size_mask->head.length = prop_size; + QLIST_FOREACH(sdev, &s->notifiers_list, next) { +if (ep->id == sdev->devfn) { + page_size_mask->pgsize_bitmap = sdev->page_size_mask;Do we need a
cpu_to_le64here?Quoted 48 lines
hw/virtio/virtio-iommu.c +48
-0+ } + } + bufstate->filled +=sizeof (*page_size_mask); +trace_virtio_iommu_fill_pgsize_mask_property (bufstate->endpoint->id, + page_size_mask->pgsize_bitmap, + bufstate->filled); +return false; +} + +/* Fill the properties[] buffer with properties of type @type */ +static int virtio_iommu_fill_property (int type, +VirtIOIOMMUPropBuffer *bufstate) +{ +int ret = -ENOSPC ; + +if (bufstate->filled +sizeof (struct virtio_iommu_probe_property ) + >=VIOMMU_PROBE_SIZE ) { +/* no space left for the header */ + bufstate->error = true; + goto out; + } + +switch (type) { +case VIRTIO_IOMMU_PROBE_T_NONE : + ret =virtio_iommu_fill_none_prop (bufstate); +break ; +case VIRTIO_IOMMU_PROBE_T_PAGE_SIZE_MASK : + { + ret =virtio_iommu_fill_page_size_mask (bufstate); +break ; + } +default : + ret = -ENOENT ; +break ; + } +out: +if (ret) { +error_report ("%s property of type=%d could not be filled (%d)," +" remaining size = 0x%lx" , + __func__, type, ret, bufstate->filled); + } +return ret; +} + +/** +* virtio_iommu_probe - Fill the probe request buffer with all +* the properties the device is able to return and add a NONE +* property at the end. @buf points to properties[]. hw/virtio/virtio-iommu.c static int virtio_iommu_unmap(VirtIOIOMMU *s, · line 596
Quoted 10 lines
hw/virtio/virtio-iommu.c +10
-0+*/ +static int virtio_iommu_probe (VirtIOIOMMU *s, +struct virtio_iommu_req_probe *req, +uint8_t *buf) +{ +uint32_t ep_id =le32_to_cpu (req->endpoint); +VirtIOIOMMUEndpoint *ep =virtio_iommu_get_endpoint (s, ep_id); +int16_t prop_types =SUPPORTED_PROBE_PROPERTIES , type; +VirtIOIOMMUPropBuffer bufstate = {.start = buf, .filled =0 , + .error = false, .endpoint = ep};Probably need to check if ep is valid before going further
hw/virtio/virtio-iommu.c static int virtio_iommu_unmap(VirtIOIOMMU *s, · line 606
Quoted 10 lines
hw/virtio/virtio-iommu.c +10
-0+ +while ((type =ctz32 (prop_types)) !=32 ) { +if (virtio_iommu_fill_property (type, &bufstate)) { + goto failure; + } + prop_types &= ~(1 << type); + } +if (virtio_iommu_fill_property (VIRTIO_IOMMU_PROBE_T_NONE , &bufstate)) { + goto failure; + }We got rid of the NONE property in the spec, now there is:
"If the device doesn’t fill all
probe_sizebytes with properties, it
SHOULD fill the remaining bytes of properties with zeroes."So I think you can get rid of
virtio_iommu_fill_none_prop()and fill the rest of the buffer with zeroes here instead.Thanks,
JeanQuoted 116 lines
hw/virtio/virtio-iommu.c +44
-3+return VIRTIO_IOMMU_S_OK ; +failure: +return VIRTIO_IOMMU_S_INVAL ; +} +static int virtio_iommu_iov_to_req (struct iovec *iov,unsigned int iov_cnt,void *req,size_t req_sz)@@ -519,6 +638,17 @@ virtio_iommu_handle_req(detach)virtio_iommu_handle_req (map)virtio_iommu_handle_req (unmap) +static int virtio_iommu_handle_probe(VirtIOIOMMU *s, + struct iovec *iov, + unsigned int iov_cnt, + uint8_t *buf) +{ +struct virtio_iommu_req_probe req; +int ret =virtio_iommu_iov_to_req (iov, iov_cnt, &req,sizeof (req)); + + return ret ? ret : virtio_iommu_probe(s, &req, buf); +} + static void virtio_iommu_handle_command(VirtIODevice *vdev, VirtQueue *vq) {VirtIOIOMMU *s =VIRTIO_IOMMU (vdev);@@ -564,17 +694,33 @@ static void virtio_iommu_handle_command(VirtIODevice *vdev, VirtQueue *vq)case VIRTIO_IOMMU_T_UNMAP : tail.status =virtio_iommu_handle_unmap (s, iov, iov_cnt);break ; +case VIRTIO_IOMMU_T_PROBE : + { +struct virtio_iommu_req_tail *ptail; +uint8_t *buf =g_malloc0 (s->config.probe_size +sizeof (tail)); + + ptail = (struct virtio_iommu_req_tail *) + (buf + s->config.probe_size); + ptail->status =virtio_iommu_handle_probe (s, iov, iov_cnt, buf); + + sz =iov_from_buf (elem->in_sg, elem->in_num,0 , + buf, s->config.probe_size +sizeof (tail)); +g_free (buf); +assert (sz == s->config.probe_size +sizeof (tail)); + goto push; + }default : tail.status =VIRTIO_IOMMU_S_UNSUPP ; } -qemu_mutex_unlock (&s->mutex); out: sz =iov_from_buf (elem->in_sg, elem->in_num,0 , &tail,sizeof (tail));assert (sz ==sizeof (tail)); -virtqueue_push (vq, elem,sizeof (tail)); +push: +qemu_mutex_unlock (&s->mutex); +virtqueue_push (vq, elem, sz);virtio_notify (vdev, vq);g_free (elem); }@@ -634,16 +780,23 @@ static IOMMUTLBEntry virtio_iommu_translate(IOMMUMemoryRegion *mr, hwaddr addr,VirtIOIOMMUEndpoint *ep;uint32_t sid, flags;bool bypass_allowed; +hwaddr addr_mask;bool found; interval.low = addr; interval.high = addr +1 ; +if (sdev->page_size_mask) { + addr_mask = (1 <<ctz32 (sdev->page_size_mask)) -1 ; + }else { + addr_mask = (1 <<ctz32 (s->config.page_size_mask)) -1 ; + } +IOMMUTLBEntry entry = { .target_as = &address_space_memory, .iova = addr, .translated_addr = addr, - .addr_mask = (1 <<ctz32 (s->config.page_size_mask)) -1 , + .addr_mask = addr_mask, .perm =IOMMU_NONE , };@@ -831,6 +984,7 @@ static void virtio_iommu_device_realize(DeviceState *dev, Error **errp) s->config.page_size_mask =TARGET_PAGE_MASK ; s->config.input_range.end =-1UL ; s->config.domain_range.end =32 ; + s->config.probe_size =VIOMMU_PROBE_SIZE ;virtio_add_feature (&s->features,VIRTIO_RING_F_EVENT_IDX );virtio_add_feature (&s->features,VIRTIO_RING_F_INDIRECT_DESC );@@ -840,6 +994,7 @@ static void virtio_iommu_device_realize(DeviceState *dev, Error **errp)virtio_add_feature (&s->features,VIRTIO_IOMMU_F_MAP_UNMAP );virtio_add_feature (&s->features,VIRTIO_IOMMU_F_BYPASS );virtio_add_feature (&s->features,VIRTIO_IOMMU_F_MMIO ); +virtio_add_feature (&s->features,VIRTIO_IOMMU_F_PROBE );qemu_mutex_init (&s->mutex);hw/virtio/trace-events +2
-0@@ -76,3 +76,5 @@ virtio_iommu_report_fault(uint8_t reason, uint32_t flags, uint32_t endpoint, uin virtio_iommu_notify_map(const char *name, uint64_t iova, uint64_t paddr, uint64_t map_size) "mr=%s iova=0x%"PRIx64" pa=0x%" PRIx64" size=0x%"PRIx64 virtio_iommu_notify_unmap(const char *name, uint64_t iova, uint64_t map_size) "mr=%s iova=0x%"PRIx64" size=0x%"PRIx64 virtio_iommu_remap(uint64_t iova, uint64_t pa, uint64_t size) "iova=0x%"PRIx64" pa=0x%" PRIx64" size=0x%"PRIx64"" +virtio_iommu_fill_none_property(uint32_t devid) "devid=%d" +virtio_iommu_fill_pgsize_mask_property(uint32_t devid, uint64_t pgsize_mask, size_t filled) "dev= %d, pgsize_mask=0x%"PRIx64" filled=0x%lx"Signature · 1 line
2.17.1
Re: [PATCH v9 8/9] virtio-iommu: Implement probe request
Quoted 70 lines · Auger Eric
Hi Bharat,
Quoted 60 lines · Jean-Philippe Brucker
Hi Bharat,
A few more things found while rebasing
Quoted 55 lines · Bharat Bhushan
This patch implements the PROBE request. Currently supported page size mask per endpoint is returned. Also append a NONE property in the end.
Signed-off-by Bharat Bhushan <[email protected]>Signed-off-by Eric Auger <[email protected]>--- include/standard-headers/linux/virtio_iommu.h | 6 + hw/virtio/virtio-iommu.c | 161 +++++++++++++++++- hw/virtio/trace-events | 2 + 3 files changed, 166 insertions(+), 3 deletions(-)include/standard-headers/linux/virtio_iommu.h +6
-0@@ -111,6 +111,7 @@ struct virtio_iommu_req_unmap {#define VIRTIO_IOMMU_PROBE_T_NONE 0#define VIRTIO_IOMMU_PROBE_T_RESV_MEM 1 +#define VIRTIO_IOMMU_PROBE_T_PAGE_SIZE_MASK 2#define VIRTIO_IOMMU_PROBE_T_MASK 0xfff@@ -130,6 +131,11 @@ struct virtio_iommu_probe_resv_mem {uint64_t end; }; +struct virtio_iommu_probe_pgsize_mask { +struct virtio_iommu_probe_property head; +uint64_t pgsize_bitmap; +}; +struct virtio_iommu_req_probe {struct virtio_iommu_req_head head;uint32_t endpoint;hw/virtio/virtio-iommu.c +4
-0@@ -38,6 +38,10 @@/* Max size */ #define VIOMMU_DEFAULT_QUEUE_SIZE 256 +#define VIOMMU_PROBE_SIZE 512 + +#define SUPPORTED_PROBE_PROPERTIES (\ + 1 << VIRTIO_IOMMU_PROBE_T_PAGE_SIZE_MASK) typedef struct VirtIOIOMMUDomain { uint32_t id;@@ -62,6 +66,13 @@ typedef struct VirtIOIOMMUMapping {uint32_t flags; } VirtIOIOMMUMapping;Quoted 7 lines
hw/virtio/virtio-iommu.c typedef struct VirtIOIOMMUMapping { · line 73
Quoted 5 lines
hw/virtio/virtio-iommu.c +5
-0+typedef struct VirtIOIOMMUPropBuffer { + VirtIOIOMMUEndpoint *endpoint; + size_t filled; + uint8_t *start; + bool error;It doesn't seem like
bufstate->errorgets used anywhere
Quoted 3 lines
maybe rebase your work on
[PATCH for-4.2 v10 10/15] virtio-iommu: Implement probe request which tests it.
This was the staring point for me, As of now i moved away from "error" from above struct.
Quoted 55 lines
Also in
[Qemu-devel] [PATCH for-4.2 v10 10/15] virtio-iommu: Implement probe request I changed the implementation to keep it simpler.Thanks
Eric
Quoted 47 lines
Quoted 35 lines
hw/virtio/virtio-iommu.c +27
-0+} VirtIOIOMMUPropBuffer; +static inline uint16_t virtio_iommu_get_bdf (IOMMUDevice *dev) {return PCI_BUILD_BDF (pci_bus_num (dev->bus), dev->devfn);@@ -490,6 +501,114 @@ static int virtio_iommu_unmap(VirtIOIOMMU *s,return ret; } +static int virtio_iommu_fill_none_prop (VirtIOIOMMUPropBuffer *bufstate) +{ +struct virtio_iommu_probe_property *prop; + + prop = (struct virtio_iommu_probe_property *) + (bufstate->start + bufstate->filled); + prop->type =0 ; + prop->length =0 ; + bufstate->filled +=sizeof (*prop); +trace_virtio_iommu_fill_none_property (bufstate->endpoint->id); +return 0 ; +} + +static int virtio_iommu_fill_page_size_mask (VirtIOIOMMUPropBuffer *bufstate) +{ +struct virtio_iommu_probe_pgsize_mask *page_size_mask; +size_t prop_size =sizeof (*page_size_mask); +VirtIOIOMMUEndpoint *ep = bufstate->endpoint; +VirtIOIOMMU *s = ep->viommu; +IOMMUDevice *sdev; + +if (bufstate->filled + prop_size >=VIOMMU_PROBE_SIZE ) { + bufstate->error = true; +/* get the traversal stopped by returning true */ +return true;hw/virtio/virtio-iommu.c static int virtio_iommu_unmap(VirtIOIOMMU *s, · line 538
Quoted 10 lines
hw/virtio/virtio-iommu.c +10
-0+ } + + page_size_mask = (struct virtio_iommu_probe_pgsize_mask *) + (bufstate->start + bufstate->filled); + + page_size_mask->head.type =VIRTIO_IOMMU_PROBE_T_PAGE_SIZE_MASK ; + page_size_mask->head.length = prop_size; + QLIST_FOREACH(sdev, &s->notifiers_list, next) { +if (ep->id == sdev->devfn) { + page_size_mask->pgsize_bitmap = sdev->page_size_mask;Do we need a
cpu_to_le64here?
Ack, yes, even head.type and head.length needed cpu_to_le16().
Quoted 53 lines
Quoted 53 lines
Quoted 53 lines
hw/virtio/virtio-iommu.c +52
-0+ } + } + bufstate->filled +=sizeof (*page_size_mask); +trace_virtio_iommu_fill_pgsize_mask_property (bufstate->endpoint->id, + page_size_mask->pgsize_bitmap, + bufstate->filled); +return false; +} + +/* Fill the properties[] buffer with properties of type @type */ +static int virtio_iommu_fill_property (int type, +VirtIOIOMMUPropBuffer *bufstate) +{ +int ret = -ENOSPC ; + +if (bufstate->filled +sizeof (struct virtio_iommu_probe_property ) + >=VIOMMU_PROBE_SIZE ) { +/* no space left for the header */ + bufstate->error = true; + goto out; + } + +switch (type) { +case VIRTIO_IOMMU_PROBE_T_NONE : + ret =virtio_iommu_fill_none_prop (bufstate); +break ; +case VIRTIO_IOMMU_PROBE_T_PAGE_SIZE_MASK : + { + ret =virtio_iommu_fill_page_size_mask (bufstate); +break ; + } +default : + ret = -ENOENT ; +break ; + } +out: +if (ret) { +error_report ("%s property of type=%d could not be filled (%d)," +" remaining size = 0x%lx" , + __func__, type, ret, bufstate->filled); + } +return ret; +} + +/** +* virtio_iommu_probe - Fill the probe request buffer with all +* the properties the device is able to return and add a NONE +* property at the end. @buf points to properties[]. +*/ +static int virtio_iommu_probe (VirtIOIOMMU *s, +struct virtio_iommu_req_probe *req, +uint8_t *buf)
Quoted 8 lines
Quoted 8 lines
hw/virtio/virtio-iommu.c static int virtio_iommu_unmap(VirtIOIOMMU *s, · line 596
Quoted 6 lines
hw/virtio/virtio-iommu.c +6
-0+{ +uint32_t ep_id =le32_to_cpu (req->endpoint); +VirtIOIOMMUEndpoint *ep =virtio_iommu_get_endpoint (s, ep_id); +int16_t prop_types =SUPPORTED_PROBE_PROPERTIES , type; +VirtIOIOMMUPropBuffer bufstate = {.start = buf, .filled =0 , + .error = false, .endpoint = ep};Probably need to check if ep is valid before going further
yes, will take care
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
hw/virtio/virtio-iommu.c +10
-0+ +while ((type =ctz32 (prop_types)) !=32 ) { +if (virtio_iommu_fill_property (type, &bufstate)) { + goto failure; + } + prop_types &= ~(1 << type); + } +if (virtio_iommu_fill_property (VIRTIO_IOMMU_PROBE_T_NONE , &bufstate)) { + goto failure; + }
Quoted 7 lines
Quoted 7 lines
We got rid of the NONE property in the spec, now there is:
"If the device doesn’t fill all
probe_sizebytes with properties, it
SHOULD fill the remaining bytes of properties with zeroes."So I think you can get rid of
virtio_iommu_fill_none_prop()and fill the rest of the buffer with zeroes here instead.
will do changes accordingly.
Stay Safe !!
Thanks
-Bharat
Quoted 122 lines
Quoted 121 lines
Thanks,
JeanQuoted 116 lines
hw/virtio/virtio-iommu.c +44
-3+return VIRTIO_IOMMU_S_OK ; +failure: +return VIRTIO_IOMMU_S_INVAL ; +} +static int virtio_iommu_iov_to_req (struct iovec *iov,unsigned int iov_cnt,void *req,size_t req_sz)@@ -519,6 +638,17 @@ virtio_iommu_handle_req(detach)virtio_iommu_handle_req (map)virtio_iommu_handle_req (unmap) +static int virtio_iommu_handle_probe(VirtIOIOMMU *s, + struct iovec *iov, + unsigned int iov_cnt, + uint8_t *buf) +{ +struct virtio_iommu_req_probe req; +int ret =virtio_iommu_iov_to_req (iov, iov_cnt, &req,sizeof (req)); + + return ret ? ret : virtio_iommu_probe(s, &req, buf); +} + static void virtio_iommu_handle_command(VirtIODevice *vdev, VirtQueue *vq) {VirtIOIOMMU *s =VIRTIO_IOMMU (vdev);@@ -564,17 +694,33 @@ static void virtio_iommu_handle_command(VirtIODevice *vdev, VirtQueue *vq)case VIRTIO_IOMMU_T_UNMAP : tail.status =virtio_iommu_handle_unmap (s, iov, iov_cnt);break ; +case VIRTIO_IOMMU_T_PROBE : + { +struct virtio_iommu_req_tail *ptail; +uint8_t *buf =g_malloc0 (s->config.probe_size +sizeof (tail)); + + ptail = (struct virtio_iommu_req_tail *) + (buf + s->config.probe_size); + ptail->status =virtio_iommu_handle_probe (s, iov, iov_cnt, buf); + + sz =iov_from_buf (elem->in_sg, elem->in_num,0 , + buf, s->config.probe_size +sizeof (tail)); +g_free (buf); +assert (sz == s->config.probe_size +sizeof (tail)); + goto push; + }default : tail.status =VIRTIO_IOMMU_S_UNSUPP ; } -qemu_mutex_unlock (&s->mutex); out: sz =iov_from_buf (elem->in_sg, elem->in_num,0 , &tail,sizeof (tail));assert (sz ==sizeof (tail)); -virtqueue_push (vq, elem,sizeof (tail)); +push: +qemu_mutex_unlock (&s->mutex); +virtqueue_push (vq, elem, sz);virtio_notify (vdev, vq);g_free (elem); }@@ -634,16 +780,23 @@ static IOMMUTLBEntry virtio_iommu_translate(IOMMUMemoryRegion *mr, hwaddr addr,VirtIOIOMMUEndpoint *ep;uint32_t sid, flags;bool bypass_allowed; +hwaddr addr_mask;bool found; interval.low = addr; interval.high = addr +1 ; +if (sdev->page_size_mask) { + addr_mask = (1 <<ctz32 (sdev->page_size_mask)) -1 ; + }else { + addr_mask = (1 <<ctz32 (s->config.page_size_mask)) -1 ; + } +IOMMUTLBEntry entry = { .target_as = &address_space_memory, .iova = addr, .translated_addr = addr, - .addr_mask = (1 <<ctz32 (s->config.page_size_mask)) -1 , + .addr_mask = addr_mask, .perm =IOMMU_NONE , };@@ -831,6 +984,7 @@ static void virtio_iommu_device_realize(DeviceState *dev, Error **errp) s->config.page_size_mask =TARGET_PAGE_MASK ; s->config.input_range.end =-1UL ; s->config.domain_range.end =32 ; + s->config.probe_size =VIOMMU_PROBE_SIZE ;virtio_add_feature (&s->features,VIRTIO_RING_F_EVENT_IDX );virtio_add_feature (&s->features,VIRTIO_RING_F_INDIRECT_DESC );@@ -840,6 +994,7 @@ static void virtio_iommu_device_realize(DeviceState *dev, Error **errp)virtio_add_feature (&s->features,VIRTIO_IOMMU_F_MAP_UNMAP );virtio_add_feature (&s->features,VIRTIO_IOMMU_F_BYPASS );virtio_add_feature (&s->features,VIRTIO_IOMMU_F_MMIO ); +virtio_add_feature (&s->features,VIRTIO_IOMMU_F_PROBE );qemu_mutex_init (&s->mutex);hw/virtio/trace-events +2
-1@@ -76,3 +76,5 @@ virtio_iommu_report_fault(uint8_t reason, uint32_t flags, uint32_t endpoint, uin virtio_iommu_notify_map(const char *name, uint64_t iova, uint64_t paddr, uint64_t map_size) "mr=%s iova=0x%"PRIx64" pa=0x%" PRIx64" size=0x%"PRIx64 virtio_iommu_notify_unmap(const char *name, uint64_t iova, uint64_t map_size) "mr=%s iova=0x%"PRIx64" size=0x%"PRIx64 virtio_iommu_remap(uint64_t iova, uint64_t pa, uint64_t size) "iova=0x%"PRIx64" pa=0x%" PRIx64" size=0x%"PRIx64"" +virtio_iommu_fill_none_property(uint32_t devid) "devid=%d" +virtio_iommu_fill_pgsize_mask_property(uint32_t devid, uint64_t pgsize_mask, size_t filled) "dev= %d, pgsize_mask=0x%"PRIx64" filled=0x%lx" --2.17.1
Re: [PATCH v9 8/9] virtio-iommu: Implement probe request
Hi Bharat,
Quoted 71 lines · Bharat Bhushan
Quoted 70 lines · Auger Eric
Hi Bharat,
Quoted 67 lines · Jean-Philippe Brucker
Hi Bharat,
A few more things found while rebasing
Quoted 52 lines · Bharat Bhushan
This patch implements the PROBE request. Currently supported page size mask per endpoint is returned. Also append a NONE property in the end.
Signed-off-by Bharat Bhushan <[email protected]>Signed-off-by Eric Auger <[email protected]>--- include/standard-headers/linux/virtio_iommu.h | 6 + hw/virtio/virtio-iommu.c | 161 +++++++++++++++++- hw/virtio/trace-events | 2 + 3 files changed, 166 insertions(+), 3 deletions(-)include/standard-headers/linux/virtio_iommu.h +6
-0@@ -111,6 +111,7 @@ struct virtio_iommu_req_unmap {#define VIRTIO_IOMMU_PROBE_T_NONE 0#define VIRTIO_IOMMU_PROBE_T_RESV_MEM 1 +#define VIRTIO_IOMMU_PROBE_T_PAGE_SIZE_MASK 2#define VIRTIO_IOMMU_PROBE_T_MASK 0xfff@@ -130,6 +131,11 @@ struct virtio_iommu_probe_resv_mem {uint64_t end; }; +struct virtio_iommu_probe_pgsize_mask { +struct virtio_iommu_probe_property head; +uint64_t pgsize_bitmap; +}; +struct virtio_iommu_req_probe {struct virtio_iommu_req_head head;uint32_t endpoint;hw/virtio/virtio-iommu.c +4
-0@@ -38,6 +38,10 @@/* Max size */ #define VIOMMU_DEFAULT_QUEUE_SIZE 256 +#define VIOMMU_PROBE_SIZE 512 + +#define SUPPORTED_PROBE_PROPERTIES (\ + 1 << VIRTIO_IOMMU_PROBE_T_PAGE_SIZE_MASK) typedef struct VirtIOIOMMUDomain { uint32_t id;hw/virtio/virtio-iommu.c typedef struct VirtIOIOMMUMapping { · line 73
Quoted 8 lines
hw/virtio/virtio-iommu.c +5
-0@@ -62,6 +66,13 @@ typedef struct VirtIOIOMMUMapping {uint32_t flags; } VirtIOIOMMUMapping; +typedef struct VirtIOIOMMUPropBuffer { + VirtIOIOMMUEndpoint *endpoint; + size_t filled; + uint8_t *start; + bool error;It doesn't seem like
bufstate->errorgets used anywhere
Quoted 11 lines
Quoted 3 lines
maybe rebase your work on
[PATCH for-4.2 v10 10/15] virtio-iommu: Implement probe request which tests it.This was the staring point for me, As of now i moved away from "error" from above struct.
Quoted 4 lines
Also in
[Qemu-devel] [PATCH for-4.2 v10 10/15] virtio-iommu: Implement probe request I changed the implementation to keep it simpler.
In [PATCH 2/5] virtio-iommu: Implement RESV_MEM probe request I reworked the original implementation. I think this version is simpler to start from. I removed the VirtIOIOMMUPropBuffer struct which looks more complex than requested.
Thanks
Eric
Quoted 267 lines
Quoted 51 lines
Thanks
Eric
Quoted 47 lines
Quoted 35 lines
hw/virtio/virtio-iommu.c +27
-0+} VirtIOIOMMUPropBuffer; +static inline uint16_t virtio_iommu_get_bdf (IOMMUDevice *dev) {return PCI_BUILD_BDF (pci_bus_num (dev->bus), dev->devfn);@@ -490,6 +501,114 @@ static int virtio_iommu_unmap(VirtIOIOMMU *s,return ret; } +static int virtio_iommu_fill_none_prop (VirtIOIOMMUPropBuffer *bufstate) +{ +struct virtio_iommu_probe_property *prop; + + prop = (struct virtio_iommu_probe_property *) + (bufstate->start + bufstate->filled); + prop->type =0 ; + prop->length =0 ; + bufstate->filled +=sizeof (*prop); +trace_virtio_iommu_fill_none_property (bufstate->endpoint->id); +return 0 ; +} + +static int virtio_iommu_fill_page_size_mask (VirtIOIOMMUPropBuffer *bufstate) +{ +struct virtio_iommu_probe_pgsize_mask *page_size_mask; +size_t prop_size =sizeof (*page_size_mask); +VirtIOIOMMUEndpoint *ep = bufstate->endpoint; +VirtIOIOMMU *s = ep->viommu; +IOMMUDevice *sdev; + +if (bufstate->filled + prop_size >=VIOMMU_PROBE_SIZE ) { + bufstate->error = true; +/* get the traversal stopped by returning true */ +return true;hw/virtio/virtio-iommu.c static int virtio_iommu_unmap(VirtIOIOMMU *s, · line 538
Quoted 10 lines
hw/virtio/virtio-iommu.c +10
-0+ } + + page_size_mask = (struct virtio_iommu_probe_pgsize_mask *) + (bufstate->start + bufstate->filled); + + page_size_mask->head.type =VIRTIO_IOMMU_PROBE_T_PAGE_SIZE_MASK ; + page_size_mask->head.length = prop_size; + QLIST_FOREACH(sdev, &s->notifiers_list, next) { +if (ep->id == sdev->devfn) { + page_size_mask->pgsize_bitmap = sdev->page_size_mask;Do we need a
cpu_to_le64here?Ack, yes, even head.type and head.length needed
cpu_to_le16().Quoted 53 lines
Quoted 53 lines
Quoted 53 lines
hw/virtio/virtio-iommu.c +52
-0+ } + } + bufstate->filled +=sizeof (*page_size_mask); +trace_virtio_iommu_fill_pgsize_mask_property (bufstate->endpoint->id, + page_size_mask->pgsize_bitmap, + bufstate->filled); +return false; +} + +/* Fill the properties[] buffer with properties of type @type */ +static int virtio_iommu_fill_property (int type, +VirtIOIOMMUPropBuffer *bufstate) +{ +int ret = -ENOSPC ; + +if (bufstate->filled +sizeof (struct virtio_iommu_probe_property ) + >=VIOMMU_PROBE_SIZE ) { +/* no space left for the header */ + bufstate->error = true; + goto out; + } + +switch (type) { +case VIRTIO_IOMMU_PROBE_T_NONE : + ret =virtio_iommu_fill_none_prop (bufstate); +break ; +case VIRTIO_IOMMU_PROBE_T_PAGE_SIZE_MASK : + { + ret =virtio_iommu_fill_page_size_mask (bufstate); +break ; + } +default : + ret = -ENOENT ; +break ; + } +out: +if (ret) { +error_report ("%s property of type=%d could not be filled (%d)," +" remaining size = 0x%lx" , + __func__, type, ret, bufstate->filled); + } +return ret; +} + +/** +* virtio_iommu_probe - Fill the probe request buffer with all +* the properties the device is able to return and add a NONE +* property at the end. @buf points to properties[]. +*/ +static int virtio_iommu_probe (VirtIOIOMMU *s, +struct virtio_iommu_req_probe *req, +uint8_t *buf)Quoted 8 lines
Quoted 8 lines
hw/virtio/virtio-iommu.c static int virtio_iommu_unmap(VirtIOIOMMU *s, · line 596
Quoted 6 lines
hw/virtio/virtio-iommu.c +6
-0+{ +uint32_t ep_id =le32_to_cpu (req->endpoint); +VirtIOIOMMUEndpoint *ep =virtio_iommu_get_endpoint (s, ep_id); +int16_t prop_types =SUPPORTED_PROBE_PROPERTIES , type; +VirtIOIOMMUPropBuffer bufstate = {.start = buf, .filled =0 , + .error = false, .endpoint = ep};Probably need to check if ep is valid before going further
yes, will take care
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
hw/virtio/virtio-iommu.c +10
-0+ +while ((type =ctz32 (prop_types)) !=32 ) { +if (virtio_iommu_fill_property (type, &bufstate)) { + goto failure; + } + prop_types &= ~(1 << type); + } +if (virtio_iommu_fill_property (VIRTIO_IOMMU_PROBE_T_NONE , &bufstate)) { + goto failure; + }Quoted 7 lines
Quoted 7 lines
We got rid of the NONE property in the spec, now there is:
"If the device doesn’t fill all
probe_sizebytes with properties, it
SHOULD fill the remaining bytes of properties with zeroes."So I think you can get rid of
virtio_iommu_fill_none_prop()and fill the rest of the buffer with zeroes here instead.will do changes accordingly.
Stay Safe !!
Thanks
-BharatQuoted 122 lines
Quoted 121 lines
Thanks,
JeanQuoted 116 lines
hw/virtio/virtio-iommu.c +44
-3+return VIRTIO_IOMMU_S_OK ; +failure: +return VIRTIO_IOMMU_S_INVAL ; +} +static int virtio_iommu_iov_to_req (struct iovec *iov,unsigned int iov_cnt,void *req,size_t req_sz)@@ -519,6 +638,17 @@ virtio_iommu_handle_req(detach)virtio_iommu_handle_req (map)virtio_iommu_handle_req (unmap) +static int virtio_iommu_handle_probe(VirtIOIOMMU *s, + struct iovec *iov, + unsigned int iov_cnt, + uint8_t *buf) +{ +struct virtio_iommu_req_probe req; +int ret =virtio_iommu_iov_to_req (iov, iov_cnt, &req,sizeof (req)); + + return ret ? ret : virtio_iommu_probe(s, &req, buf); +} + static void virtio_iommu_handle_command(VirtIODevice *vdev, VirtQueue *vq) {VirtIOIOMMU *s =VIRTIO_IOMMU (vdev);@@ -564,17 +694,33 @@ static void virtio_iommu_handle_command(VirtIODevice *vdev, VirtQueue *vq)case VIRTIO_IOMMU_T_UNMAP : tail.status =virtio_iommu_handle_unmap (s, iov, iov_cnt);break ; +case VIRTIO_IOMMU_T_PROBE : + { +struct virtio_iommu_req_tail *ptail; +uint8_t *buf =g_malloc0 (s->config.probe_size +sizeof (tail)); + + ptail = (struct virtio_iommu_req_tail *) + (buf + s->config.probe_size); + ptail->status =virtio_iommu_handle_probe (s, iov, iov_cnt, buf); + + sz =iov_from_buf (elem->in_sg, elem->in_num,0 , + buf, s->config.probe_size +sizeof (tail)); +g_free (buf); +assert (sz == s->config.probe_size +sizeof (tail)); + goto push; + }default : tail.status =VIRTIO_IOMMU_S_UNSUPP ; } -qemu_mutex_unlock (&s->mutex); out: sz =iov_from_buf (elem->in_sg, elem->in_num,0 , &tail,sizeof (tail));assert (sz ==sizeof (tail)); -virtqueue_push (vq, elem,sizeof (tail)); +push: +qemu_mutex_unlock (&s->mutex); +virtqueue_push (vq, elem, sz);virtio_notify (vdev, vq);g_free (elem); }@@ -634,16 +780,23 @@ static IOMMUTLBEntry virtio_iommu_translate(IOMMUMemoryRegion *mr, hwaddr addr,VirtIOIOMMUEndpoint *ep;uint32_t sid, flags;bool bypass_allowed; +hwaddr addr_mask;bool found; interval.low = addr; interval.high = addr +1 ; +if (sdev->page_size_mask) { + addr_mask = (1 <<ctz32 (sdev->page_size_mask)) -1 ; + }else { + addr_mask = (1 <<ctz32 (s->config.page_size_mask)) -1 ; + } +IOMMUTLBEntry entry = { .target_as = &address_space_memory, .iova = addr, .translated_addr = addr, - .addr_mask = (1 <<ctz32 (s->config.page_size_mask)) -1 , + .addr_mask = addr_mask, .perm =IOMMU_NONE , };@@ -831,6 +984,7 @@ static void virtio_iommu_device_realize(DeviceState *dev, Error **errp) s->config.page_size_mask =TARGET_PAGE_MASK ; s->config.input_range.end =-1UL ; s->config.domain_range.end =32 ; + s->config.probe_size =VIOMMU_PROBE_SIZE ;virtio_add_feature (&s->features,VIRTIO_RING_F_EVENT_IDX );virtio_add_feature (&s->features,VIRTIO_RING_F_INDIRECT_DESC );@@ -840,6 +994,7 @@ static void virtio_iommu_device_realize(DeviceState *dev, Error **errp)virtio_add_feature (&s->features,VIRTIO_IOMMU_F_MAP_UNMAP );virtio_add_feature (&s->features,VIRTIO_IOMMU_F_BYPASS );virtio_add_feature (&s->features,VIRTIO_IOMMU_F_MMIO ); +virtio_add_feature (&s->features,VIRTIO_IOMMU_F_PROBE );qemu_mutex_init (&s->mutex);hw/virtio/trace-events +2
-1@@ -76,3 +76,5 @@ virtio_iommu_report_fault(uint8_t reason, uint32_t flags, uint32_t endpoint, uin virtio_iommu_notify_map(const char *name, uint64_t iova, uint64_t paddr, uint64_t map_size) "mr=%s iova=0x%"PRIx64" pa=0x%" PRIx64" size=0x%"PRIx64 virtio_iommu_notify_unmap(const char *name, uint64_t iova, uint64_t map_size) "mr=%s iova=0x%"PRIx64" size=0x%"PRIx64 virtio_iommu_remap(uint64_t iova, uint64_t pa, uint64_t size) "iova=0x%"PRIx64" pa=0x%" PRIx64" size=0x%"PRIx64"" +virtio_iommu_fill_none_property(uint32_t devid) "devid=%d" +virtio_iommu_fill_pgsize_mask_property(uint32_t devid, uint64_t pgsize_mask, size_t filled) "dev= %d, pgsize_mask=0x%"PRIx64" filled=0x%lx" --2.17.1
PATCH v9 9/9 virtio-iommu: add iommu notifier memory-region
In reply to Bharat BhushanFinally add notify_flag_changed() to for memory-region access flag iommu flag change notifier
Finally add the memory notifier
--- hw/virtio/virtio-iommu.c | 22 ++++++++++++++++++++++ hw/virtio/trace-events | 2 ++ 2 files changed, 24 insertions(+)
hw/virtio/virtio-iommu.c +22 -0
@@ -966,6 +966,27 @@ unlock:qemu_mutex_unlock (&s->mutex); } +static int virtio_iommu_notify_flag_changed (IOMMUMemoryRegion *iommu_mr, +IOMMUNotifierFlag old, +IOMMUNotifierFlag new, +Error **errp) +{ +IOMMUDevice *sdev =container_of (iommu_mr, IOMMUDevice, iommu_mr); +VirtIOIOMMU *s = sdev->viommu; + +if (old ==IOMMU_NOTIFIER_NONE ) { +trace_virtio_iommu_notify_flag_add (iommu_mr->parent_obj.name); +QLIST_INSERT_HEAD (&s->notifiers_list, sdev, next); +return 0 ; + } + +if (new ==IOMMU_NOTIFIER_NONE ) { +trace_virtio_iommu_notify_flag_del (iommu_mr->parent_obj.name); +QLIST_REMOVE (sdev, next); + } +return 0 ; +} +static void virtio_iommu_device_realize (DeviceState *dev,Error **errp) {VirtIODevice *vdev =VIRTIO_DEVICE (dev);
@@ -1187,6 +1208,7 @@ static void virtio_iommu_memory_region_class_init(ObjectClass *klass, imrc->translate = virtio_iommu_translate; imrc->iommu_set_page_size_mask = virtio_iommu_set_page_size_mask; imrc->replay = virtio_iommu_replay; + imrc->notify_flag_changed = virtio_iommu_notify_flag_changed; }static const TypeInfo virtio_iommu_info = {
hw/virtio/trace-events +2 -0
@@ -78,3 +78,5 @@ virtio_iommu_notify_unmap(const char *name, uint64_t iova, uint64_t map_size) "m virtio_iommu_remap(uint64_t iova, uint64_t pa, uint64_t size) "iova=0x%"PRIx64" pa=0x%" PRIx64" size=0x%"PRIx64"" virtio_iommu_fill_none_property(uint32_t devid) "devid=%d" virtio_iommu_fill_pgsize_mask_property(uint32_t devid, uint64_t pgsize_mask, size_t filled) "dev= %d, pgsize_mask=0x%"PRIx64" filled=0x%lx" +virtio_iommu_notify_flag_add(const char *iommu) "Add virtio-iommu notifier node for memory region %s" +virtio_iommu_notify_flag_del(const char *iommu) "Del virtio-iommu notifier node for memory region %s"
Signature · 1 line
2.17.1
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Subject: [PATCH v9 0/9] virtio-iommu: VFIO integration
Message-id: [email protected]
Type: series
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
9b26a61..29e0855 master -> master
- [tag update] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
8eeb60c virtio-iommu: add iommu notifier memory-region
176e083 virtio-iommu: Implement probe request
221f4ba virtio-iommu: add iommu replay
30211fd virtio-iommu: Call iommu notifier for attach/detach 84f316d virtio-iommu: Add iommu notifier for map/unmap
8cc559f virtio-iommu: set supported page size mask
d4062a9 vfio: set iommu page size as per host supported page size cc9310f memory: Add interface to set iommu page size mask
2b43555 hw/vfio/common: Remove error print on mmio region translation by viommu
=== OUTPUT BEGIN ===
1/9 Checking commit 2b43555a2f62 (hw/vfio/common: Remove error print on mmio region translation by viommu) 2/9 Checking commit cc9310f32d06 (memory: Add interface to set iommu page size mask)
3/9 Checking commit d4062a953cef (vfio: set iommu page size as per host supported page size) 4/9 Checking commit 8cc559f025ae (virtio-iommu: set supported page size mask)
5/9 Checking commit 84f316d68429 (virtio-iommu: Add iommu notifier for map/unmap)
6/9 Checking commit 30211fdb36cd (virtio-iommu: Call iommu notifier for attach/detach) 7/9 Checking commit 221f4ba0d125 (virtio-iommu: add iommu replay)
8/9 Checking commit 176e0834bcee (virtio-iommu: Implement probe request)
ERROR: code indent should never use tabs
#93: FILE: hw/virtio/virtio-iommu.c:539:
+^I}$
ERROR: code indent should never use tabs
#122: FILE: hw/virtio/virtio-iommu.c:568:
+^Ibreak;$
total: 2 errors, 0 warnings, 250 lines checked
Patch 8/9 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
9/9 Checking commit 8eeb60c12ace (virtio-iommu: add iommu notifier memory-region) === OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series failed the docker-mingw@fedora build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.
=== TEST SCRIPT BEGIN ===
#! /bin/bash
export ARCH=x86_64
make docker-image-fedora V=1 NETWORK=1
time make docker-test-mingw@fedora J=14 NETWORK=1
=== TEST SCRIPT END ===
CC x86_64-softmmu/hw/virtio/virtio-blk-pci.o
CC x86_64-softmmu/hw/virtio/virtio-net-pci.o/tmp/qemu-test/src/hw/virtio/virtio-iommu.c: In function 'virtio_iommu_fill_property':/tmp/qemu-test/src/hw/virtio/virtio-iommu.c:576:22: error: format '%lx' expects argument of type 'long unsigned int', but argument 5 has type 'size_t' {aka 'long long unsigned int'} [-Werror=format=]
error_report("%s property of type=%d could not be filled (%d),"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/tmp/qemu-test/src/hw/virtio/virtio-iommu.c:578:43:
---
~~^
%llxcc1: all warnings being treated as errors
make[1]: *** [/tmp/qemu-test/src/rules.mak:69: hw/virtio/virtio-iommu.o] Error 1 make[1]: *** Waiting for unfinished jobs....
CC aarch64-softmmu/hw/scsi/virtio-scsi-dataplane.o
CC aarch64-softmmu/hw/semihosting/config.o
---
CC aarch64-softmmu/hw/virtio/virtio-balloon-pci.o CC aarch64-softmmu/hw/virtio/virtio-iommu-pci.o CC aarch64-softmmu/hw/virtio/virtio-scsi-pci.o
make: *** [Makefile:527: x86_64-softmmu/all] Error 2
make: *** Waiting for unfinished jobs....
CC aarch64-softmmu/hw/virtio/virtio-blk-pci.o
CC aarch64-softmmu/hw/virtio/virtio-net-pci.o
---
CC aarch64-softmmu/hw/arm/virt.o
CC aarch64-softmmu/hw/arm/virt-acpi-build.o/tmp/qemu-test/src/hw/virtio/virtio-iommu.c: In function 'virtio_iommu_fill_property':/tmp/qemu-test/src/hw/virtio/virtio-iommu.c:576:22: error: format '%lx' expects argument of type 'long unsigned int', but argument 5 has type 'size_t' {aka 'long long unsigned int'} [-Werror=format=]
error_report("%s property of type=%d could not be filled (%d),"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/tmp/qemu-test/src/hw/virtio/virtio-iommu.c:578:43:
---
~~^
%llxcc1: all warnings being treated as errors
make[1]: *** [/tmp/qemu-test/src/rules.mak:69: hw/virtio/virtio-iommu.o] Error 1 make[1]: *** Waiting for unfinished jobs....
CC aarch64-softmmu/hw/arm/digic_boards.o
make: *** [Makefile:527: aarch64-softmmu/all] Error 2
Traceback (most recent call last):
File "./tests/docker/docker.py", line 664, in <module>
sys.exit(main())
---
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=480fcb56b8454a80ae140ce373e940ee', '-u', '1003', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew2/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-rkry8xh9/src/docker-src.2020-03-23-05.55.47.1669:/var/tmp/qemu:z,ro', 'qemu:fedora', '/var/tmp/qemu/run', 'test-mingw']' returned non-zero exit status 2. filter=--filter=label=com.qemu.instance.uuid=480fcb56b8454a80ae140ce373e940ee
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-rkry8xh9/src'
make: *** [docker-run-test-mingw@fedora] Error 2
real 3m47.039s
user 0m7.589s
The full log is available at
http://patchew.org/logs/[email protected]/testing.docker-mingw@fedora/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]