kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH kvm-unit-tests 00/17] VT-d unit test
@ 2016-10-26  7:47 Peter Xu
  2016-10-26  7:47 ` [PATCH kvm-unit-tests 01/17] x86: intel-iommu: add vt-d init test Peter Xu
                   ` (16 more replies)
  0 siblings, 17 replies; 67+ messages in thread
From: Peter Xu @ 2016-10-26  7:47 UTC (permalink / raw)
  To: kvm; +Cc: drjones, rkrcmar, peterx, agordeev, jan.kiszka, pbonzini

This series is adding simplest test cases for VT-d. From this version
and so on, the work is rebased to Alex's PCI series v8. Removing the
"RFC" prefix.

Thanks to Drew for a lot of review work for v1 of this series. I think
it's time to send another spin since the changelog is going out of
control...

RFC -> v1:
- when init edu device fail, report_skip() rather than return error
  [Radim]
- use asserts rather than "static bool inited" to avoid multiple init
  of components (affects patch 1/2) [Drew]
- moving the first two patches out of the series [Drew]
- int vtd_init(), do not setup_idt() since smp_init() did it [Drew]
- when edu do not have MSI enabled, skip interrupt test [Radim]
- rename vtd_reg_*() into vtd_{read|write}[lq](), and move them to
  header file [Drew]
- use PAGE_MASK when able [Drew]
- use "&" instead of "|" in intel-iommu init test (three places)
  [Drew]
- use "vtd_init()" in unit test [Drew]
- mention that where intel-iommu.h comes from [Drew]
- re-written vtd_gcmd_or(), make it also work on even hardware [Drew]
- remove most of the oneline wrapper for VT-d registers, instead, use
  vtd_{read|write}* with register names [Drew]
- remove useless BDF helpers [Drew]
- move edu device macros into header file [Drew]
- make edu_check_alive static inline [Drew]
- remove all useless wrappers in pci-edu.c [Drew]
- remove pci_dma_dir_t and all its users, instead, use "bool
  from_device" [Drew]
- not use typedef for structs, to follow Linux/kvm-unit-tests coding
  style [Drew]
- let pci_dev_init() clean and simple, then provide
  pci_enable_defaults() for more complicated things [Drew]
- add one more patch to add intel-iommu test into x86/unittest [Radim]
- use 0x60 intr request instead of factorial to trigger edu device
  interrupt [Drew]
- ...and some other changes I just forgot to note down...

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

Peter Xu (17):
  x86: intel-iommu: add vt-d init test
  libcflat: add IS_ALIGNED() macro, and page sizes
  libcflat: moving MIN/MAX here
  vm/page: provide PGDIR_OFFSET() macro
  x86/asm: add cpu_relax()
  pci: introduce struct pci_dev
  pci: provide pci_scan_bars()
  x86/vmexit: leverage pci_scan_bars()
  pci: add pci_config_write[wb]()
  pci: provide pci_set_master()
  pci: provide pci_enable_defaults()
  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 MSI test
  x86/unittests: add intel-iommu test

 lib/alloc.c            |   3 -
 lib/libcflat.h         |   8 ++
 lib/pci-edu.c          |  74 ++++++++++++
 lib/pci-edu.h          |  80 +++++++++++++
 lib/pci-host-generic.c |  25 +++-
 lib/pci-testdev.c      |  13 +-
 lib/pci.c              | 160 +++++++++++++++++++++----
 lib/pci.h              |  39 ++++--
 lib/x86/asm/barrier.h  |  11 ++
 lib/x86/asm/page.h     |   3 +
 lib/x86/asm/pci.h      |  14 +++
 lib/x86/intel-iommu.c  | 313 +++++++++++++++++++++++++++++++++++++++++++++++++
 lib/x86/intel-iommu.h  | 139 ++++++++++++++++++++++
 lib/x86/vm.c           |   4 +-
 x86/Makefile.common    |   1 +
 x86/Makefile.x86_64    |   2 +
 x86/intel-iommu.c      | 121 +++++++++++++++++++
 x86/unittests.cfg      |   7 ++
 x86/vmexit.c           |  25 ++--
 19 files changed, 978 insertions(+), 64 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

-- 
2.7.4


^ permalink raw reply	[flat|nested] 67+ messages in thread

end of thread, other threads:[~2016-11-08 19:59 UTC | newest]

Thread overview: 67+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-26  7:47 [PATCH kvm-unit-tests 00/17] VT-d unit test Peter Xu
2016-10-26  7:47 ` [PATCH kvm-unit-tests 01/17] x86: intel-iommu: add vt-d init test Peter Xu
2016-11-04 16:12   ` Andrew Jones
2016-11-07 16:32     ` Peter Xu
2016-11-08 10:52   ` Alexander Gordeev
2016-11-08 15:24     ` Peter Xu
2016-11-08 17:40       ` Alexander Gordeev
2016-11-08 17:42         ` Peter Xu
2016-10-26  7:47 ` [PATCH kvm-unit-tests 02/17] libcflat: add IS_ALIGNED() macro, and page sizes Peter Xu
2016-11-04 16:14   ` Andrew Jones
2016-10-26  7:47 ` [PATCH kvm-unit-tests 03/17] libcflat: moving MIN/MAX here Peter Xu
2016-11-04 16:15   ` Andrew Jones
2016-10-26  7:47 ` [PATCH kvm-unit-tests 04/17] vm/page: provide PGDIR_OFFSET() macro Peter Xu
2016-10-26  7:47 ` [PATCH kvm-unit-tests 05/17] x86/asm: add cpu_relax() Peter Xu
2016-11-04 16:18   ` Andrew Jones
2016-11-07 16:40     ` Peter Xu
2016-10-26  7:47 ` [PATCH kvm-unit-tests 06/17] pci: introduce struct pci_dev Peter Xu
2016-11-04 16:41   ` Andrew Jones
2016-11-07 17:05     ` Peter Xu
2016-11-07 18:02       ` Andrew Jones
2016-11-07 19:42         ` Peter Xu
2016-11-08 10:16           ` Andrew Jones
2016-11-08 15:33             ` Peter Xu
2016-11-08 17:27               ` Andrew Jones
2016-11-08 12:27     ` Alexander Gordeev
2016-11-08 15:48       ` Peter Xu
2016-11-08 17:35         ` Andrew Jones
2016-11-08 17:54           ` Alexander Gordeev
2016-11-08 19:59             ` Peter Xu
2016-11-08 17:46         ` Alexander Gordeev
2016-10-26  7:47 ` [PATCH kvm-unit-tests 07/17] pci: provide pci_scan_bars() Peter Xu
2016-11-04 16:47   ` Andrew Jones
2016-11-07 17:16     ` Peter Xu
2016-10-26  7:47 ` [PATCH kvm-unit-tests 08/17] x86/vmexit: leverage pci_scan_bars() Peter Xu
2016-11-04 16:54   ` Andrew Jones
2016-11-08 13:43     ` Alexander Gordeev
2016-11-08 15:55       ` Peter Xu
2016-10-26  7:47 ` [PATCH kvm-unit-tests 09/17] pci: add pci_config_write[wb]() Peter Xu
2016-11-04 16:59   ` Andrew Jones
2016-11-05 17:06   ` Alexander Gordeev
2016-11-07 17:25     ` Peter Xu
2016-10-26  7:47 ` [PATCH kvm-unit-tests 10/17] pci: provide pci_set_master() Peter Xu
2016-11-04 17:04   ` Andrew Jones
2016-11-07 17:35     ` Peter Xu
2016-11-07 17:59       ` Andrew Jones
2016-11-07 19:45         ` Peter Xu
2016-10-26  7:47 ` [PATCH kvm-unit-tests 11/17] pci: provide pci_enable_defaults() Peter Xu
2016-11-04 17:08   ` Andrew Jones
2016-10-26  7:47 ` [PATCH kvm-unit-tests 12/17] pci: add bdf helpers Peter Xu
2016-11-04 17:51   ` Andrew Jones
2016-10-26  7:47 ` [PATCH kvm-unit-tests 13/17] pci: edu: introduce pci-edu helpers Peter Xu
2016-11-04 17:18   ` Andrew Jones
2016-11-07 17:41     ` Peter Xu
2016-11-04 17:24   ` Andrew Jones
2016-11-07 17:44     ` Peter Xu
2016-10-26  7:47 ` [PATCH kvm-unit-tests 14/17] x86: intel-iommu: add dmar test Peter Xu
2016-11-04 17:53   ` Andrew Jones
2016-10-26  7:47 ` [PATCH kvm-unit-tests 15/17] pci: add msi support for 32/64bit address Peter Xu
2016-11-04 17:33   ` Andrew Jones
2016-11-07 17:58     ` Peter Xu
2016-10-26  7:47 ` [PATCH kvm-unit-tests 16/17] x86: intel-iommu: add IR MSI test Peter Xu
2016-11-04 17:40   ` Andrew Jones
2016-10-26  7:47 ` [PATCH kvm-unit-tests 17/17] x86/unittests: add intel-iommu test Peter Xu
2016-11-04 17:46   ` Andrew Jones
2016-11-07 18:06     ` Peter Xu
2016-11-08 10:39       ` Andrew Jones
2016-11-08 15:57         ` Peter Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).