This patchset introduces a KVM dispatch mechanism which can be used for handling MMIO/PIO accesses over file descriptors without returning from ioctl(KVM_RUN). This allows device emulation to run in another task separate from the vCPU task. This is achieved through KVM vm ioctl for registering MMIO/PIO regions and a wire protocol that KVM uses to communicate with a task handling an MMIO/PIO access. ioregionfd relies on kmemcg in order to limit the amount of kernel memory that userspace can consume. Can NR_IOBUS_DEVS hardcoded limit be enforced only in case kmemcg is disabled? Elena Afanasova (2): KVM: add initial support for KVM_SET_IOREGION KVM: add initial support for ioregionfd blocking read/write operations arch/x86/kvm/Kconfig | 1 + arch/x86/kvm/Makefile | 1 + arch/x86/kvm/x86.c | 1 + include/linux/kvm_host.h | 17 ++ include/uapi/linux/kvm.h | 23 +++ virt/kvm/Kconfig | 3 + virt/kvm/eventfd.c | 25 +++ virt/kvm/eventfd.h | 14 ++ virt/kvm/ioregion.c | 390 +++++++++++++++++++++++++++++++++++++++ virt/kvm/ioregion.h | 15 ++ virt/kvm/kvm_main.c | 20 +- 11 files changed, 507 insertions(+), 3 deletions(-) create mode 100644 virt/kvm/eventfd.h create mode 100644 virt/kvm/ioregion.c create mode 100644 virt/kvm/ioregion.h -- 2.25.1