On Fri, Mar 06, 2026 at 12:56:54PM +0000, Thanos Makatos wrote: > Add a new flag, KVM_IOEVENTFD_FLAG_POST_WRITE, when assigning an > ioeventfd that results in the value written by the guest to be copied > to user-supplied memory instead of being discarded. > > The goal of this new mechanism is to speed up doorbell writes on NVMe > controllers emulated outside of the VMM. Currently, a doorbell write to > an NVMe SQ tail doorbell requires returning from ioctl(KVM_RUN) and the > VMM communicating the event, along with the doorbell value, to the NVMe > controller emulation task. With POST_WRITE, the NVMe emulation task is > directly notified of the doorbell write and can find the doorbell value > in a known location, without involving VMM. > > Add tests for this new functionality. > > LLM (claude-4.6-opus-high) was used mainly for the tests and to a > lesser extent for pre-reviewing this patch. > > Signed-off-by: Thanos Makatos > --- > Documentation/virt/kvm/api.rst | 13 +- > include/uapi/linux/kvm.h | 6 +- > tools/testing/selftests/kvm/Makefile.kvm | 1 + > tools/testing/selftests/kvm/ioeventfd_test.c | 624 +++++++++++++++++++ > virt/kvm/eventfd.c | 23 + > virt/kvm/kvm_main.c | 1 + > 6 files changed, 666 insertions(+), 2 deletions(-) > create mode 100644 tools/testing/selftests/kvm/ioeventfd_test.c Sean, Paolo: Ping I would like to enable ioeventfd support in QEMU's NVMe device emulation and this requires POST_WRITE for Windows guests (they don't support NVMe's Doorbell Buffer Config feature so it's necessary to capture the latest value written to the doorbell somehow). POST_WRITE applies to any device that has a doorbell register where the latest value needs to be captured. This looks like a reasonable extension to ioeventfd. I also looked into alternatives, like using userfaultfd, and didn't find anything better. Please consider merging this. Thanks! Stefan