Skip to content

RFC VT-d unit test

Peter Xu kvm 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest14 patches 43 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/14x86: vm: allow multiple init for vm setuplib/x86/vm.c+7 -06 replies
2/14x86: smp: allow multiple init for smp setuplib/x86/smp.c+6 -04 replies
3/14x86: intel-iommu: add vt-d init testlib/x86/intel-iommu.c lib/x86/intel-iommu.h x86/Makefile.x86_64 +1 more+287 -04 replies
4/14pci: refactor init process to pci_dev_init()lib/pci.c lib/pci.h x86/vmexit.c+80 -462 replies
5/14page: add page alignment checkerlib/asm-generic/page.h+5 -03 replies
6/14util: move MAX/MIN macro into util.hlib/alloc.c lib/util.h+3 -32 replies
7/14vm/page: provide PGDIR_OFFSET() macrolib/x86/asm/page.h lib/x86/vm.c+5 -21 reply
8/14x86: pci: add pci_config_{read|write}[bw]() helperslib/x86/asm/pci.h+34 -32 replies
9/14pci: provide pci_set_master()lib/pci.c+9 -02 replies
10/14pci: add bdf helperslib/pci.h+6 -02 replies
11/14pci: edu: introduce pci-edu helperslib/pci-edu.c lib/pci-edu.h+157 -04 replies
12/14x86: intel-iommu: add dmar testlib/x86/intel-iommu.c lib/x86/intel-iommu.h x86/Makefile.common +1 more+208 -02 replies
13/14pci: add msi support for 32/64bit addresslib/pci.c lib/pci.h+61 -02 replies
14/14x86: intel-iommu: add IR testlib/pci-edu.c lib/pci-edu.h lib/x86/intel-iommu.c +2 more+161 -32 replies

Reviews trailers per patch

1 of 14 patches has a Reviewed-by or Acked-by.

PatchAndrew Jones
1/14
2/14
3/14
4/14
5/14
6/14
7/14R-b
8/14
9/14
10/14
11/14
12/14
13/14
14/14

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

Read the v1 thread

Cover letter [kvm-unit-tests RFC PATCH 00/14] VT-d unit test

This series is adding simplest test cases for VT-d.

The series contains some conflict with Alex's PCI framework enhancement, so I am marking it as RFC, I can rebase to Alex's work after it's merged. Besides the conflict, the codes is workable, and passed smoke test.

Currently only a very small test scope is covered:

* VT-d init
* DMAR: 4 bytes copy
* IR: MSI

However this series could be a base point to add more test cases for VT-d. The problem is, there are many IOMMU error conditions which are very hard to be triggered in a real guest (IOMMU has merely no interface for guest user, and it's totally running in the background). This piece of work can be a start point if we want to do more complicated things and play around with Intel IOMMU devices (also for IOMMU regression tests).

Please review. Thanks,

=================

To run the test:

./x86/run ./x86/intel-iommu.flat \
-M q35,kernel-irqchip=split -global ioapic.version=0x20 \
-device intel-iommu,intremap=on -device edu

Sample output:

pxdev:kvm-unit-tests [new-iommu-ut]# ./iommu_run.sh
/root/git/qemu/bin/x86_64-softmmu/qemu-system-x86_64 -enable-kvm -device pc-testdev -device isa-debug-exit,iobase=0xf4,iosize=0x4 -vnc none -serial stdio -device pci-testdev -kernel ./x86/intel-iommu.flat -M q35,kernel-irqchip=split -global ioapic.version=0x20 -device intel-iommu,intremap=on -device edu enabling apic
paging enabled
cr0 = 80010011
cr3 = 7fff000
cr4 = 20

VT-d version:   0x10
     cap:       0x0012008c22260206
     ecap:      0x0000000000f00f1a

PASS: init status check
PASS: fault status check
PASS: QI enablement
DMAR table address: 0x0000000007ff9000
PASS: DMAR table setup
IR table address: 0x0000000007ff8000
PASS: IR table setup
PASS: DMAR enablement
PASS: IR enablement
PASS: DMAR support 39 bits address width
PASS: DMAR support huge pages
PCI: init dev 0x0020 BAR 0 [MEM] addr 0xfea00000 PCI detected cap 0x5
Detected MSI for device 0x20 offset 0x40
allocated vt-d root entry for PCI bus 0
allocated vt-d context entry for devfn 0x20
map 4K page IOVA 0x0 to 0x7ff7000 (sid=0x0020)
edu device DMA start TO addr 0x0 size 0x4 off 0x0 edu device DMA start FROM addr 0x4 size 0x4 off 0x0
PASS: DMAR 4B memcpy test
INTR: setup IRTE index 0
MSI: dev 0x20 init 64bit address: addr=0xfee00010, data=0x0
PASS: EDU factorial INTR test

SUMMARY: 11 tests

=================

Peter Xu (14):
x86: vm: allow multiple init for vm setup
x86: smp: allow multiple init for smp setup
x86: intel-iommu: add vt-d init test
pci: refactor init process to pci_dev_init()
page: add page alignment checker
util: move MAX/MIN macro into util.h vm/page: provide PGDIR_OFFSET() macro
x86: pci: add pci_config_{read|write}[bw]() helpers
pci: provide pci_set_master()
pci: add bdf helpers
pci: edu: introduce pci-edu helpers
x86: intel-iommu: add dmar test
pci: add msi support for 32/64bit address
x86: intel-iommu: add IR test

 lib/alloc.c            |   3 -
 lib/asm-generic/page.h |   5 +
 lib/pci-edu.c          | 140 +++++++++++++++++++
 lib/pci-edu.h          |  36 +++++
 lib/pci.c              | 143 +++++++++++++++----
 lib/pci.h              |  37 ++++-
 lib/util.h             |   3 +
 lib/x86/asm/page.h     |   3 +
 lib/x86/asm/pci.h      |  37 ++++-
 lib/x86/intel-iommu.c  | 363 +++++++++++++++++++++++++++++++++++++++++++++++++
 lib/x86/intel-iommu.h  | 130 ++++++++++++++++++
 lib/x86/smp.c          |   6 +
 lib/x86/vm.c           |  11 +-
 x86/Makefile.common    |   1 +
 x86/Makefile.x86_64    |   2 +
 x86/intel-iommu.c      | 138 +++++++++++++++++++
 x86/vmexit.c           |  22 +--
 17 files changed, 1026 insertions(+), 54 deletions(-)
 create mode 100644 lib/pci-edu.c
 create mode 100644 lib/pci-edu.h
 create mode 100644 lib/x86/intel-iommu.c
 create mode 100644 lib/x86/intel-iommu.h
 create mode 100644 x86/intel-iommu.c
Signature · 1 line
2.7.4