add vIOMMU support with irq remapping function of virtual VT-d
Get series with b4
b4 am [email protected]Versions newest first
- v4 Latest28 patches 54 repliesIn review
Changes in v4 from the cover letter
- add logic to build DMAR table for PVH guest. But only very limited tests are performed on PVH guest.
- use one interface to binding guest remappable and non-remappable interrupts with physical interrupts. To achieve this, current binding interface should be changed. The advantage is that it can simplify the code to support the new format guest interrupt. But the disadvantage is clearly incompatible with old QEMU.
- VT-d posted interrupt feature can be used to deliver guest remappable interrupt. The guest interrupt attributes (vector, affinity) are decoded from guest IRTE and then accordingly written to host IRTE. In this version, when guest invalidates an IRTE, the host IRTE will be updated according to the new guest IRTE.
- add draining in-flight interrupt support. When guest invalidates an IRTE, the in-flight interrupt related to the IRTE should be drained. This version provides a very simple solution: process QI only when no interrupt is delivering which definitely implies there is no in-flight interrupt.
- use locks in QI and fault handling sub-feature. These locks guarantee the registers/status won't be changed by guest when vvtd is dealing with faults or invalidation requests.
- move viommu structure under hvm domain rather than making it a field of struct domain.
- remove unneeded domctl interface for destroying viommu. Currently, dynamic destruction aren't needed.
- reorder the patches per Roger's suggestion: the viommu abstract goes first, then the implementation of emulated VT-d, several hooks of configuring/delivering guest interrupt and EOI, and related changes of toolstack.
- fix many coding style issues pointed out by Roger.
Patches in v4 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/28 | Xen/doc: Add Xen virtual IOMMU docdocs/ | +120 | 2 replies | |
| 2/28 | VIOMMU: Add vIOMMU framework and vIOMMU domctldocs/ xen/ xen/ +8 more | +253 | 2 replies | |
| 3/28 | VIOMMU: Add irq request callback to deal with irq remappingxen/ xen/ xen/ | +75 | 2 replies | |
| 4/28 | VIOMMU: Add get irq info callback to convert irq remapping requestxen/ xen/ xen/ | +30 | 2 replies | |
| 5/28 | VIOMMU: Introduce callback of checking irq remapping modexen/ xen/ | +19 | 3 replies | |
| 6/28 | vtd: clean-up and preparation for vvtdxen/ | +48 | 2 replies | |
| 7/28 | x86/hvm: Introduce a emulated VTD for HVMxen/ xen/ xen/ | +163 | 3 replies | |
| 8/28 | x86/vvtd: Add MMIO handler for VVTDxen/ | +55 | 6 replies | |
| 9/28 | x86/vvtd: Set Interrupt Remapping Table Pointer through GCMDxen/ xen/ | +100 | 4 replies | |
| 10/28 | x86/vvtd: Enable Interrupt Remapping through GCMDxen/ xen/ | +100 | 4 replies | |
| 11/28 | x86/vvtd: Process interrupt remapping requestxen/ xen/ | +234 | 3 replies | |
| 12/28 | x86/vvtd: decode interrupt attribute from IRTExen/ | +25 | 2 replies | |
| 13/28 | x86/vvtd: add a helper function to decide the interrupt formatxen/ | +10 | 1 reply | |
| 14/28 | x86/vvtd: Handle interrupt translation faultsxen/ xen/ | +333 | 2 replies | |
| 15/28 | x86/vvtd: Enable Queued Invalidation through GCMDxen/ xen/ | +20 | 2 replies | |
| 16/28 | x86/vvtd: Add queued invalidation (QI) supportxen/ xen/ | +293 | 2 replies | |
| 17/28 | x86/vvtd: save and restore emulated VT-dxen/ xen/ | +56 | 3 replies | |
| 18/28 | x86/vioapic: Hook interrupt delivery of vIOAPICxen/ xen/ | +18 | 3 replies | |
| 19/28 | x86/vioapic: extend vioapic_get_vector() to support remapping format RTExen/ | +13 | 1 reply | |
| 20/28 | xen/pt: when binding guest msi, accept the whole msi messagetools/ tools/ xen/ +3 more | +40 | 2 replies | |
| 21/28 | vvtd: update hvm_gmsi_info when binding guest msi with pirq orxen/ xen/ xen/ +3 more | +147 | 2 replies | |
| 22/28 | x86/vmsi: Hook delivering remapping format msi to guest and handling eoixen/ xen/ xen/ | +54 | 0 replies | |
| 23/28 | tools/libacpi: Add DMA remapping reporting (DMAR) ACPI table structurestools/ | +61 | 0 replies | |
| 24/28 | tools/libacpi: Add new fields in acpi_config for DMAR tabletools/ tools/ tools/ | +59 | 0 replies | |
| 25/28 | tools/libxl: Add an user configurable parameter to control vIOMMU attributesdocs/ tools/ tools/ +2 more | +136 | 0 replies | |
| 26/28 | tools/libxl: build DMAR table for a guest with one virtual VTDtools/ tools/ tools/ +1 more | +111 | 0 replies | |
| 27/28 | tools/libxl: create vIOMMU during domain constructiontools/ | +17 | 0 replies | |
| 28/28 | tools/libxc: Add viommu operations in libxctools/ tools/ tools/ | +55 | 0 replies |
Reviews trailers per patch
1 of 28 patches has a Reviewed-by or Acked-by.
| Patch | Roger Pau Monné |
|---|---|
| 1/28 | |
| 2/28 | |
| 3/28 | |
| 4/28 | |
| 5/28 | |
| 6/28 | R-b |
| 7/28 | |
| 8/28 | |
| 9/28 | |
| 10/28 | |
| 11/28 | |
| 12/28 | |
| 13/28 | |
| 14/28 | |
| 15/28 | |
| 16/28 | |
| 17/28 | |
| 18/28 | |
| 19/28 | |
| 20/28 | |
| 21/28 | |
| 22/28 | |
| 23/28 | |
| 24/28 | |
| 25/28 | |
| 26/28 | |
| 27/28 | |
| 28/28 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v4 00/28] add vIOMMU support with irq remapping function of virtual VT-d
This patchset is to introduce vIOMMU framework and add virtual VTD's interrupt remapping support according "Xen virtual IOMMU high level design doc V3"(https://lists.xenproject.org/archives/html/xen-devel/ 2016-11/msg01391.html).
- vIOMMU framework
New framework provides viommu_ops and help functions to abstract vIOMMU operations(E,G create, destroy, handle irq remapping request and so on). Vendors(Intel, ARM, AMD and son) can implement their vIOMMU callbacks.
- Virtual VTD
We enable irq remapping function and covers both
MSI and IOAPIC interrupts. Don't support post interrupt mode emulation and post interrupt mode enabled on host with virtual VTD. will add later.
In case of conflicts, this series also can be found in my personal github:
Xen: https://github.com/gc1008/viommu_xen.git vIOMMU4
Qemu: https://github.com/gc1008/viommu_qemu.git vIOMMU3
Any comments would be highly appreciated. And below is change history.
Changes since v3:
- add logic to build DMAR table for PVH guest. But only very limited tests are performed on PVH guest.
- use one interface to binding guest remappable and non-remappable interrupts with physical interrupts. To achieve this, current binding interface should be changed. The advantage is that it can simplify the code to support the new format guest interrupt. But the disadvantage is clearly incompatible with old QEMU.
- VT-d posted interrupt feature can be used to deliver guest remappable interrupt. The guest interrupt attributes (vector, affinity) are decoded from guest IRTE and then accordingly written to host IRTE. In this version, when guest invalidates an IRTE, the host IRTE will be updated according to the new guest IRTE.
- add draining in-flight interrupt support. When guest invalidates an IRTE, the in-flight interrupt related to the IRTE should be drained. This version provides a very simple solution: process QI only when no interrupt is delivering which definitely implies there is no in-flight interrupt.
- use locks in QI and fault handling sub-feature. These locks guarantee the registers/status won't be changed by guest when vvtd is dealing with faults or invalidation requests.
- move viommu structure under hvm domain rather than making it a field of struct domain.
- remove unneeded domctl interface for destroying viommu. Currently, dynamic destruction aren't needed.
- reorder the patches per Roger's suggestion: the viommu abstract goes first, then the implementation of emulated VT-d, several hooks of configuring/delivering guest interrupt and EOI, and related changes of toolstack.
- fix many coding style issues pointed out by Roger.
Change since v2:
1) Remove vIOMMU hypercall of query capabilities and introduce when
necessary.
2) Remove length field of vIOMMU create parameter of vIOMMU hypercall
3) Introduce irq remapping mode callback to vIOMMU framework and vIOMMU
device models
can check irq remapping mode by vendor specific ways.
4) Update vIOMMU docs.
5) Other changes please see patches' change logs.
Change since v1:
1) Fix coding style issues
2) Add definitions for vIOMMU type and capabilities
3) Change vIOMMU kconfig and select vIOMMU default on x86
4) Put vIOMMU creation in libxl__arch_domain_create()
5) Make vIOMMU structure of tool stack more general for both PV and HVM.
Change since RFC v2:
1) Move vvtd.c to drivers/passthrough/vtd directroy.
2) Make vIOMMU always built in on x86
3) Add new boot cmd "viommu" to enable viommu function
4) Fix some code stype issues.
Change since RFC v1:
1) Add Xen virtual IOMMU doc docs/misc/viommu.txt
2) Move vIOMMU hypercall of create/destroy vIOMMU and query
capabilities from dmop to domctl suggested by Paul Durrant. Because these hypercalls can be done in tool stack and more VM mode(E,G PVH or other modes don't use Qemu) can be benefit.
3) Add check of input MMIO address and length.
4) Add iommu_type in vIOMMU hypercall parameter to specify
vendor vIOMMU device model(E,G Intel VTD, AMD or ARM IOMMU. So far only support Intel VTD).
5) Add save and restore support for vvtd
Chao Gao (23):
vtd: clean-up and preparation for vvtd
x86/hvm: Introduce a emulated VTD for HVM
x86/vvtd: Add MMIO handler for VVTD
x86/vvtd: Set Interrupt Remapping Table Pointer through GCMD x86/vvtd: Enable Interrupt Remapping through GCMD x86/vvtd: Process interrupt remapping request
x86/vvtd: decode interrupt attribute from IRTE
x86/vvtd: add a helper function to decide the interrupt format x86/vvtd: Handle interrupt translation faults
x86/vvtd: Enable Queued Invalidation through GCMD x86/vvtd: Add queued invalidation (QI) support
x86/vvtd: save and restore emulated VT-d
x86/vioapic: Hook interrupt delivery of vIOAPIC x86/vioapic: extend vioapic_get_vector() to support remapping format
RTE
xen/pt: when binding guest msi, accept the whole msi message
vvtd: update hvm_gmsi_info when binding guest msi with pirq or x86/vmsi: Hook delivering remapping format msi to guest and handling
eoi
tools/libacpi: Add DMA remapping reporting (DMAR) ACPI table
structures
tools/libacpi: Add new fields in acpi_config for DMAR table tools/libxl: Add an user configurable parameter to control vIOMMU
attributes
tools/libxl: build DMAR table for a guest with one virtual VTD tools/libxl: create vIOMMU during domain construction tools/libxc: Add viommu operations in libxc
Lan Tianyu (5):
Xen/doc: Add Xen virtual IOMMU doc
VIOMMU: Add vIOMMU framework and vIOMMU domctl
VIOMMU: Add irq request callback to deal with irq remapping
VIOMMU: Add get irq info callback to convert irq remapping request
VIOMMU: Introduce callback of checking irq remapping mode
docs/man/xl.cfg.pod.5.in | 27 + docs/misc/viommu.txt | 120 +++ docs/misc/xen-command-line.markdown | 7 + tools/firmware/hvmloader/ovmf.c | 2 +- tools/libacpi/acpi2_0.h | 61 ++ tools/libacpi/build.c | 61 ++ tools/libacpi/libacpi.h | 10 + tools/libxc/Makefile | 1 + tools/libxc/include/xenctrl.h | 10 +- tools/libxc/xc_domain.c | 14 +- tools/libxc/xc_viommu.c | 51 ++ tools/libxl/libxl_arch.h | 1 + tools/libxl/libxl_create.c | 47 ++ tools/libxl/libxl_types.idl | 12 + tools/libxl/libxl_x86.c | 21 +- tools/libxl/libxl_x86_acpi.c | 98 ++- tools/xl/xl_parse.c | 50 +- xen/arch/x86/Kconfig | 1 + xen/arch/x86/hvm/hvm.c | 5 +- xen/arch/x86/hvm/irq.c | 6 + xen/arch/x86/hvm/vioapic.c | 23 +- xen/arch/x86/hvm/vmsi.c | 33 +- xen/arch/x86/xen.lds.S | 3 + xen/common/Kconfig | 3 + xen/common/Makefile | 1 + xen/common/domctl.c | 7 + xen/common/viommu.c | 171 +++++ xen/drivers/passthrough/io.c | 144 ++-- xen/drivers/passthrough/vtd/Makefile | 7 +- xen/drivers/passthrough/vtd/iommu.h | 197 +++-- xen/drivers/passthrough/vtd/vvtd.c | 1301 ++++++++++++++++++++++++++++++++ xen/include/asm-x86/hvm/domain.h | 3 + xen/include/asm-x86/hvm/hvm.h | 2 + xen/include/asm-x86/hvm/irq.h | 6 +- xen/include/asm-x86/viommu.h | 82 ++ xen/include/public/arch-x86/hvm/save.h | 18 +- xen/include/public/domctl.h | 39 +- xen/include/xen/viommu.h | 85 +++ 38 files changed, 2603 insertions(+), 127 deletions(-) create mode 100644 docs/misc/viommu.txt create mode 100644 tools/libxc/xc_viommu.c create mode 100644 xen/common/viommu.c create mode 100644 xen/drivers/passthrough/vtd/vvtd.c create mode 100644 xen/include/asm-x86/viommu.h create mode 100644 xen/include/xen/viommu.h
Signature · 7 lines
1.8.3.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel