Skip to content

SMMUv3 Emulation support

Prem Mallappa qemu-devel 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest9 patches 24 repliesIn review
  2. v18 patches 3 repliesSuperseded

Changes in v2 from the cover letter

- Adopted review comments from Eric Auger
- Make SMMU_DPRINTF to internally call qemu_log (since translation requests are too many, we need control on the type of log we want)
- SMMUTransCfg modified to suite simplicity
- Change RegInfo to uint64 register array
- Code cleanup
- Test cleanups
- Reshuffled patches

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9log: Add new IOMMU typeinclude/qemu/log.h util/log.c+3 -05 replies
2/9devicetree: Added new APIs to make use of more fdt functionsdevice_tree.c include/sysemu/device_tree.h+53 -02 replies
3/9hw: arm: SMMUv3 emulation modelhw/arm/smmu-common.c hw/arm/smmu-common.h hw/arm/smmu-v3.c +2 more+2095 -12 replies
4/9hw: arm: Added SMMUv3 files for builddefault-configs/aarch64-softmmu.mak hw/arm/Makefile.objs+2 -00 replies
5/9hw: arm: Add SMMUv3 to virt platform, create DTS accordinglyhw/arm/virt.c include/hw/arm/smmu.h include/hw/arm/virt.h+97 -02 replies
6/9hw: misc: added testdev for smmuhw/misc/Makefile.objs hw/misc/pci-testdev-smmu.c hw/misc/pci-testdev-smmu.h+262 -12 replies
7/9tests: libqos: generic pci probing helperstests/libqos/pci-generic.c tests/libqos/pci-generic.h+255 -00 replies
8/9tests: SMMUv3 unit teststests/Makefile.include tests/smmuv3-test.c+956 -00 replies
9/9arm: smmu-v3: ACPI IORT initial supporthw/arm/virt-acpi-build.c include/hw/acpi/acpi-defs.h+127 -05 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [Qemu-devel] [PATCH v2 0/9] SMMUv3 Emulation support

v1 -> v2:
- Adopted review comments from Eric Auger
- Make SMMU_DPRINTF to internally call qemu_log (since translation requests are too many, we need control on the type of log we want)
- SMMUTransCfg modified to suite simplicity
- Change RegInfo to uint64 register array
- Code cleanup
- Test cleanups
- Reshuffled patches

RFC -> v1:
- As per SMMUv3 spec 16.0 (only is_ste_consistant() is noticeable)
- Reworked register access/update logic
- Factored out translation code for
- single point bug fix
- sharing/removal in future
- (optional) Unit tests added, with PCI test device
- S1 with 4k/64k, S1+S2 with 4k/64k
- (S1 or S2) only can be verified by Linux 4.7 driver
- (optional) Priliminary ACPI support

RFC:
- Implements SMMUv3 spec 11.0
- Supported for PCIe devices,
- Command Queue and Event Queue supported
- LPAE only, S1 is supported and Tested, S2 not tested
- BE mode Translation not supported
- IRQ support (legacy, no MSI)
- Tested with DPDK and e1000

Patch 1: Add new log type for IOMMU transactions

Patch 2: Adds support in virt.c to create both SMMUv3 device and dts entries

Patch 2: Adds SMMUv3 model to QEMU
Multiple files, big ones, translate functionality is split across to accomodate SMMUv2 model, and to remove when common translation feature (if) becomes available.

Patch 3: Adds SMMU build support

Patch 4: Some devicetree function to add support for SMMU's multiple interrupt
assignment with names

<< optional patches >>
Optional patches are posted for completeness or for those who wants to test.

Patch 5: A simple PCI device which does DMA from 'src' to 'dst' given
src_addr, dst_addr and size, and is used by unit test, uses pci_dma_read and pci_dma_write in a crude way but serves the purpose.

Patch 6: Current libqos PCI helpers are x86 only, this addes a generic interface

Patch 7: Unit tests for SMMU,
- initializes SMMU device
- initializes Test device
- allocates page tables 1:1 mapping va == pa
- allocates STE/CD accordingly for S1, S2, S1+S2
- initiates DMA via PCI test device
- verifies transfered data

Patch 8: Added ACPI IORT tables, was needed for internal project purpose, but
posting here for anyone looking for testing ACPI on ARM platforms. (P.S: Linux side IORT patches are WIP)

Repo:
https://github.com/pmallappa/qemu/tree/upstream/smmuv3/v2

To Test:

$ make tests/smmuv3-test
$ QTEST_QEMU_BINARY=aarch64-softmmu/qemu-system-aarch64 tests/smmuv3-test
<< expect lot of prints >>

Any comments welcome..

Cheers
/Prem

Prem Mallappa (9):
log: Add new IOMMU type
devicetree: Added new APIs to make use of more fdt functions
hw: arm: SMMUv3 emulation model
hw: arm: Added SMMUv3 files for build
hw: arm: Add SMMUv3 to virt platform, create DTS accordingly [optional] hw: misc: added testdev for smmu [optional] tests: libqos: generic pci probing helpers [optional] tests: SMMUv3 unit tests
[optional] arm: smmu-v3: ACPI IORT initial support

 default-configs/aarch64-softmmu.mak |    1 +
 device_tree.c                       |   35 +
 hw/arm/Makefile.objs                |    1 +
 hw/arm/smmu-common.c                |  152 ++++
 hw/arm/smmu-common.h                |  141 ++++
 hw/arm/smmu-v3.c                    | 1369 +++++++++++++++++++++++++++++++++++
 hw/arm/smmuv3-internal.h            |  432 +++++++++++
 hw/arm/virt-acpi-build.c            |   43 ++
 hw/arm/virt.c                       |   62 ++
 hw/misc/Makefile.objs               |    2 +-
 hw/misc/pci-testdev-smmu.c          |  239 ++++++
 hw/misc/pci-testdev-smmu.h          |   22 +
 hw/vfio/common.c                    |    2 +-
 include/hw/acpi/acpi-defs.h         |   84 +++
 include/hw/arm/smmu.h               |   33 +
 include/hw/arm/virt.h               |    2 +
 include/qemu/log.h                  |    1 +
 include/sysemu/device_tree.h        |   18 +
 tests/Makefile.include              |    4 +
 tests/libqos/pci-generic.c          |  197 +++++
 tests/libqos/pci-generic.h          |   58 ++
 tests/smmuv3-test.c                 |  952 ++++++++++++++++++++++++
 util/log.c                          |    2 +
 23 files changed, 3850 insertions(+), 2 deletions(-)
 create mode 100644 hw/arm/smmu-common.c
 create mode 100644 hw/arm/smmu-common.h
 create mode 100644 hw/arm/smmu-v3.c
 create mode 100644 hw/arm/smmuv3-internal.h
 create mode 100644 hw/misc/pci-testdev-smmu.c
 create mode 100644 hw/misc/pci-testdev-smmu.h
 create mode 100644 include/hw/arm/smmu.h
 create mode 100644 tests/libqos/pci-generic.c
 create mode 100644 tests/libqos/pci-generic.h
 create mode 100644 tests/smmuv3-test.c
Signature · 1 line
2.9.3