Re: [PATCH 2/6] KVM: Add KVM_CREATE_COALESCED_MMIO_BUFFER ioctl

Paul Durrant
2024-07-12T13:22:58Z

On 10/07/2024 10:52, Ilias Stamatis wrote:
> The current MMIO coalescing design has a few drawbacks which limit its
> usefulness. Currently all coalesced MMIO zones use the same ring buffer.
> That means that upon a userspace exit we have to handle potentially
> unrelated MMIO writes synchronously. And a VM-wide lock needs to be
> taken in the kernel when an MMIO exit occurs.
>
> Additionally, there is no direct way for userspace to be notified about
> coalesced MMIO writes. If the next MMIO exit to userspace is when the
> ring buffer has filled then a substantial (and unbounded) amount of time
> may have passed since the first coalesced MMIO.
>
> Add a KVM_CREATE_COALESCED_MMIO_BUFFER ioctl to KVM. This ioctl simply
> returns a file descriptor to the caller but does not allocate a ring
> buffer. Userspace can then pass this fd to mmap() to actually allocate a
> buffer and map it to its address space.
>
> Subsequent patches will allow userspace to:
>
> - Associate the fd with a coalescing zone when registering it so that
> writes to that zone are accumulated in that specific ring buffer
> rather than the VM-wide one.
> - Poll for MMIO writes using this fd.
>
> Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
> ---
> include/linux/kvm_host.h | 1 +
> include/uapi/linux/kvm.h | 2 +
> virt/kvm/coalesced_mmio.c | 142 +++++++++++++++++++++++++++++++++++---
> virt/kvm/coalesced_mmio.h | 9 +++
> virt/kvm/kvm_main.c | 4 ++
> 5 files changed, 150 insertions(+), 8 deletions(-)
>

Reviewed-by: Paul Durrant <paul@xen.org>