Add support for version 1 of the virtio transport to kvmtool. Based on a RFC by Sasha Levin [1], I've been trying to complete it here and there. It's long overdue and is quite painful to rebase, so let's get it merged. Several reasons why the legacy transport needs to be replaced: * Only 32 feature bits are supported. Most importantly VIRTIO_F_ACCESS_PLATFORM, which forces a Linux guest to use the DMA API, cannot be enabled. So we can't support private guests that decrypt or share only their DMA memory with the host. * Legacy virtqueue address is a 32-bit pfn, aligned on 4kB. Since Linux guests bypass the DMA API they can't support large GPAs. * New devices types (iommu, crypto, memory, etc) and new features cannot be supported. * New guests won't implement the legacy transport. Existing guests will eventually drop legacy support. Support for modern transport becomes the default and legacy is enabled with --virtio-legacy. I only tested what I could: vsock, scsi and vhost-net are currently broken and can be fixed later (they have issues with mem regions and feature mask, among other things). I also haven't tested big-endian. Find the series at https://jpbrucker.net/git/kvmtool/ virtio/devel [1] https://lore.kernel.org/all/1447823472-17047-1-git-send-email-sasha.levin@xxxxxxxxxx/ The SOB was kept in patch 21 Jean-Philippe Brucker (24): virtio: Add NEEDS_RESET to the status mask virtio: Remove redundant test virtio/vsock: Remove redundant state tracking virtio: Factor virtqueue initialization virtio: Support modern virtqueue addresses virtio: Add config access helpers virtio: Fix device-specific config endianness virtio/console: Remove unused callback virtio: Remove set_guest_features() device op Add memcpy_fromiovec_safe virtio/net: Offload vnet header endianness conversion to tap virtio/net: Prepare for modern virtio virtio/net: Implement VIRTIO_F_ANY_LAYOUT feature virtio/console: Add VIRTIO_F_ANY_LAYOUT feature virtio/blk: Implement VIRTIO_F_ANY_LAYOUT feature virtio/pci: Factor MSI route creation virtio/pci: Delete MSI routes virtio: Extract init_vq() for PCI and MMIO virtio/pci: Make doorbell offset dynamic virtio: Move PCI transport to pci-legacy virtio: Add support for modern virtio-pci virtio: Move MMIO transport to mmio-legacy virtio: Add support for modern virtio-mmio virtio/pci: Initialize all vectors to VIRTIO_MSI_NO_VECTOR Makefile | 4 + arm/include/arm-common/kvm-arch.h | 6 +- include/kvm/disk-image.h | 3 +- include/kvm/iovec.h | 2 + include/kvm/kvm-config.h | 1 + include/kvm/kvm.h | 6 + include/kvm/pci.h | 11 + include/kvm/virtio-9p.h | 2 +- include/kvm/virtio-mmio.h | 29 ++- include/kvm/virtio-pci-dev.h | 4 + include/kvm/virtio-pci.h | 48 +++- include/kvm/virtio.h | 52 ++-- mips/include/kvm/kvm-arch.h | 2 - powerpc/include/kvm/kvm-arch.h | 2 - x86/include/kvm/kvm-arch.h | 2 - builtin-run.c | 2 + disk/core.c | 26 +- net/uip/core.c | 71 ++++-- util/iovec.c | 31 +++ virtio/9p.c | 27 +-- virtio/balloon.c | 46 ++-- virtio/blk.c | 102 ++++---- virtio/console.c | 33 +-- virtio/core.c | 82 ++++++- virtio/mmio-legacy.c | 150 ++++++++++++ virtio/mmio-modern.c | 157 ++++++++++++ virtio/mmio.c | 202 ++-------------- virtio/net.c | 122 +++++----- virtio/pci-legacy.c | 205 ++++++++++++++++ virtio/pci-modern.c | 386 ++++++++++++++++++++++++++++++ virtio/pci.c | 361 ++++++---------------------- virtio/rng.c | 15 +- virtio/scsi.c | 44 ++-- virtio/vsock.c | 39 ++- 34 files changed, 1490 insertions(+), 785 deletions(-) create mode 100644 virtio/mmio-legacy.c create mode 100644 virtio/mmio-modern.c create mode 100644 virtio/pci-legacy.c create mode 100644 virtio/pci-modern.c -- 2.36.1