Skip to content

virtio/vhost DMAR support

Jason Wang qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest11 patches 38 repliesIn review

Changes from RFC from the cover letter

- rebase to HEAD
- switch to use new vhost device IOTLB API
- use the new feature bit VIRITO_F_IOMMU_PLATFORM
- finalize basic ATS implementation
- add ATSR for Root port ATS transaction
- fix the iommu notifier handling during unregistering
- use snprintf() in patch 3
- correc the loop in address_space_get_iotlb_entry()
- small tweak on the address calculation during device iotlb descriptor processing.

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/11linux-headers: update to 4.8-rc4include/standard-headers/linux/input-event-codes.h include/standard-headers/linux/input.h include/standard-headers/linux/virtio_config.h +8 more+142 -73 replies
2/11virtio: convert to use DMA apihw/block/virtio-blk.c hw/char/virtio-serial-bus.c hw/scsi/virtio-scsi.c +5 more+98 -3911 replies
3/11intel_iommu: name vtd address space with devfnhw/i386/intel_iommu.c+3 -11 reply
4/11intel_iommu: allocate new key when creating new address spacehw/i386/intel_iommu.c+3 -20 replies
5/11exec: introduce address_space_get_iotlb_entry()exec.c include/exec/memory.h+39 -00 replies
6/11intel_iommu: support device iotlb descriptorhw/i386/intel_iommu.c hw/i386/intel_iommu_internal.h hw/i386/x86-iommu.c +1 more+102 -83 replies
7/11virtio-pci: address space translation service (ATS) supporthw/pci/pcie.c hw/virtio/virtio-pci.c hw/virtio/virtio-pci.h +3 more+43 -02 replies
8/11acpi: add ATSR for q35hw/i386/acpi-build.c include/hw/acpi/acpi-defs.h+10 -00 replies
9/11memory: handle alias for iommu notifiermemory.c+9 -01 reply
10/11Revert "intel_iommu: Throw hw_error on notify_started"hw/i386/intel_iommu.c+0 -1214 replies
11/11vhost_net: device IOTLB supporthw/virtio/vhost-backend.c hw/virtio/vhost.c include/hw/virtio/vhost-backend.h +3 more+291 -253 replies

Reviews trailers per patch

3 of 11 patches have a Reviewed-by or Acked-by.

PatchPeter Xu
1/11
2/11
3/11A-b
4/11A-b
5/11
6/11
7/11
8/11
9/11R-b
10/11
11/11

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [Qemu-devel] [PATCH for 2.8 00/11] virtio/vhost DMAR support

Hi all:

As the userspace vitio driver became popular, more and more request were received for secure DMA environemt (DMAR). So this series tries to makeDMAR works for virtio/vhost. The idea is let virtio/vhost co-work with userspace iommu implememtation. This is done through:

- for virtio, when platform supports IOMMU (VIRTIO_F_IOMMU_PLATFORM), virtio will not assume address_space_memory, instead a transport specific method were introduced for querying the dma address space and dma helpers were used in device emulation codes.
- for vhost, implement a device IOTLB by using device IOTLB API supported by recent kernel. With this API, vhost kernel can query IOTLB entry for a specified iova from qemu, qemu can invalidate an arbitrary range of iova in vhost kernel.

The device IOTLB API is totaly architecture independent, an example implementation was done with intel iommu by:

- implement basic ATS (Address Translation Service) for virtio-pci, this will make device IOTLB visible for iommu driver in guest.
- implement device IOTLB descriptor processing in intel iommu (enabled through device-iotlb=on), and trigger the device IOTLB invalidation in vhost through iommu notifier.

It could be easily ported to other IOMMU or architecture even if it doesn't support device IOTLB. (e.g just invalidate the vhost IOTLB during IOMMU IOTLB invalidation).

Test was done by:

- intel_iommu=on/strict in guest.
- vfio l2fwd in guest.

This main use case is the programs that use fixed mapping in guest (e.g dpdk). If 1G hugepage were used in guest, thanks to the SLLPS support, we can get 100% TLB hit rate for l2fwd in guest.

For the normal kernel driver which uses lots of dynamic mapping and unmapping, we may see performance penalty, this could be optimized in the future.

TODO:
- non ATS support (userspace IOTLB snooping)
- more platforms and IOMMU support
- performance optimizations

Changes from RFC:
- rebase to HEAD
- switch to use new vhost device IOTLB API
- use the new feature bit VIRITO_F_IOMMU_PLATFORM
- finalize basic ATS implementation
- add ATSR for Root port ATS transaction
- fix the iommu notifier handling during unregistering
- use snprintf() in patch 3
- correc the loop in address_space_get_iotlb_entry()
- small tweak on the address calculation during device iotlb descriptor processing.

Please reivew.

Jason Wang (10):
linux-headers: update to 4.8-rc4
virtio: convert to use DMA api
intel_iommu: name vtd address space with devfn
intel_iommu: allocate new key when creating new address space
exec: introduce address_space_get_iotlb_entry()
intel_iommu: support device iotlb descriptor
virtio-pci: address space translation service (ATS) support
acpi: add ATSR for q35
memory: handle alias for iommu notifier
vhost_net: device IOTLB support

Peter Xu (1):
Revert "intel_iommu: Throw hw_error on notify_started"

 exec.c                                             |  33 +++++
 hw/block/virtio-blk.c                              |   2 +-
 hw/char/virtio-serial-bus.c                        |   3 +-
 hw/i386/acpi-build.c                               |   9 ++
 hw/i386/intel_iommu.c                              | 100 +++++++++++---
 hw/i386/intel_iommu_internal.h                     |  13 +-
 hw/i386/x86-iommu.c                                |  17 +++
 hw/pci/pcie.c                                      |  16 +++
 hw/scsi/virtio-scsi.c                              |   4 +-
 hw/virtio/vhost-backend.c                          | 104 ++++++++++++++
 hw/virtio/vhost.c                                  | 149 +++++++++++++++++----
 hw/virtio/virtio-pci.c                             |  21 +++
 hw/virtio/virtio-pci.h                             |   4 +
 hw/virtio/virtio.c                                 |  62 +++++----
 include/exec/memory.h                              |   6 +
 include/hw/acpi/acpi-defs.h                        |  12 ++
 include/hw/i386/x86-iommu.h                        |   1 +
 include/hw/pci/pcie.h                              |   4 +
 include/hw/virtio/vhost-backend.h                  |  14 ++
 include/hw/virtio/vhost.h                          |   4 +
 include/hw/virtio/virtio-access.h                  |  87 ++++++++++--
 include/hw/virtio/virtio-bus.h                     |   1 +
 include/hw/virtio/virtio.h                         |   8 +-
 include/standard-headers/linux/input-event-codes.h |  32 +++++
 include/standard-headers/linux/input.h             |   1 +
 include/standard-headers/linux/pci_regs.h          |   1 +
 include/standard-headers/linux/virtio_config.h     |  10 +-
 include/standard-headers/linux/virtio_ids.h        |   1 +
 include/standard-headers/linux/virtio_net.h        |   3 +
 linux-headers/asm-arm/kvm.h                        |   4 +-
 linux-headers/asm-arm64/kvm.h                      |   2 +
 linux-headers/asm-s390/kvm.h                       |  41 ++++++
 linux-headers/asm-x86/unistd_x32.h                 |   4 +-
 linux-headers/linux/kvm.h                          |  18 ++-
 linux-headers/linux/vhost.h                        |  33 +++++
 memory.c                                           |   9 ++
 net/tap.c                                          |   1 +
 37 files changed, 740 insertions(+), 94 deletions(-)
Signature · 1 line
2.7.4