From: Alex Williamson <alex.williamson@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: John G Johnson <john.g.johnson@oracle.com>,
Daniele Buono <dbuono@us.ibm.com>,
slp@redhat.com, "Michael S. Tsirkin" <mst@redhat.com>,
qemu-devel@nongnu.org,
"marcandre.lureau@redhat.com" <marcandre.lureau@redhat.com>,
Hubertus Franke <frankeh@us.ibm.com>,
rust-vmm@lists.opendev.org,
Thanos Makatos <thanos.makatos@nutanix.com>
Subject: Re: Requirements for out-of-process device emulation
Date: Fri, 9 Oct 2020 13:44:49 -0600 [thread overview]
Message-ID: <20201009134449.041b5e71@x1.home> (raw)
In-Reply-To: <20201009161815.GA321402@stefanha-x1.localdomain>
On Fri, 9 Oct 2020 17:18:15 +0100
Stefan Hajnoczi <stefanha@redhat.com> wrote:
> Device emulation
> ----------------
> Device resources
> ````````````````
> Devices provide resources that drivers interact with such as hardware
> registers, memory, or interrupts. The fundamental requirement of
> out-of-process device emulation is exposing device resources.
>
> The following types of device resources are needed:
>
> Synchronous MMIO/PIO accesses
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> The most basic device emulation operation is the hardware register
> access. This is a memory-mapped I/O (MMIO) or programmed I/O (PIO)
> access to the device. A read loads a value from a device register. A
> write stores a value to a device register. These operations are
> synchronous because the vCPU is paused until completion.
> Asynchronous doorbells
>
> Devices often have doorbell registers, allowing the driver to inform the
> device that new requests are ready for processing. The vCPU does not
> need to wait since the access is a posted write.
>
> The kvm.ko ioeventfd mechanism can be used to implement asynchronous
> doorbells.
>
> Shared device memory
> ~~~~~~~~~~~~~~~~~~~~
> Devices may have memory-like regions that the CPU can access (such as
> PCI Memory BARs). The device emulation process therefore needs to share
> a region of its memory space with the VMM so the guest can access it.
> This mechanism also allows device emulation to busy wait (poll) instead
> of using synchronous MMIO/PIO accesses or asynchronous doorbells for
> notifications.
>
> Direct Memory Access (DMA)
> ~~~~~~~~~~~~~~~~~~~~~~~~~~
> Devices often require read and write access to a memory address space
> belonging to the CPU. This allows network cards to transmit packet
> payloads that are located in guest RAM, for example.
>
> Early out-of-process device emulation interfaces simply shared guest
> RAM. The allowed DMA to any guest physical memory address. More advanced
> IOMMU and address space identifier mechanisms are now becoming
> ubiquitous. Therefore, new out-of-process device emulation interfaces
> should incorporate IOMMU functionality.
>
> The key requirement for IOMMU mechanisms is allowing the VMM to grant
> access to a region of memory so the device emulation process can read
> from and/or write to it.
>
> Interrupts
> ~~~~~~~~~~
> Devices notify the CPU using interrupts. An interrupt is simply a
> message sent by the device emulation process to the VMM. Interrupt
> configuration is flexible on modern devices, meaning the driver may be
> able to select the number of interrupts and a mapping (using one
> interrupt with multiple event sources). This can be implemented using
> the Linux eventfd mechanism or via in-band device emulation protocol
> messages, for example.
>
> Extensibility for new bus types
> ```````````````````````````````
> It should be possible to support multiple bus types. vhost-user only
> supports vhost devices. VFIO is more extensible but currently focussed
> on PCI devices.
Wait a sec, the vfio API essentially deconstructs devices into exactly
the resources you've outlined above. We not only have a vfio-pci
device convention within vfio, but we've defined vfio-platform,
vfio-amba, vfio-ccw, vfio-ap, and we'll likely be adding vfio-fsl-mc in
the next kernel. The core device, group, and container model within
vfio is completely device/bus agnostic. So while it's true that
vfio-pci is the most mature and featureful convention, that's largely a
reflection that PCI is the most ubiquitous device interface currently
available. Thanks,
Alex
next prev parent reply other threads:[~2020-10-09 20:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-09 16:18 Requirements for out-of-process device emulation Stefan Hajnoczi
2020-10-09 19:44 ` Alex Williamson [this message]
2020-10-12 15:39 ` Stefan Hajnoczi
2020-10-12 17:16 ` Alex Bennée
2020-11-11 11:17 ` [Rust-VMM] " Stefan Hajnoczi
[not found] <CAJSP0QUUR72Rr_deeckz+RHpZMEBv692V4XupWy9ai3i2QD8bw@mail.gmail.com>
2020-01-14 14:06 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201009134449.041b5e71@x1.home \
--to=alex.williamson@redhat.com \
--cc=dbuono@us.ibm.com \
--cc=frankeh@us.ibm.com \
--cc=john.g.johnson@oracle.com \
--cc=marcandre.lureau@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rust-vmm@lists.opendev.org \
--cc=slp@redhat.com \
--cc=stefanha@redhat.com \
--cc=thanos.makatos@nutanix.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).