Internships/ProjectIdeas/IORegionFD

From QEMU
Revision as of 10:36, 13 August 2020 by Stefanha (talk | contribs) (Created page with "=== ioregionfd - new device access dispatch mechanism === '''Summary:''' Implement the ioregionfd device access dispatch mechanism in the Linux kvm.ko kernel module so that d...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

ioregionfd - new device access dispatch mechanism

Summary: Implement the ioregionfd device access dispatch mechanism in the Linux kvm.ko kernel module so that device emulation processes or threads can handle device accesses without jumping through the QEMU vCPU thread.

Virtual devices including graphics cards, network cards, storage controllers, and more can be emulated in dedicated tasks (processes or threads) instead of running in QEMU's vCPU or main loop threads. Dedicated tasks can have security and performance advantages over handling device emulation in QEMU's normal threads.

However, certain devices cannot be emulated efficiently in a dedicated task yet because there is no way for the Linux kvm.ko kernel module to dispatch device accesses from the guest directly to the device emulation task. Today it is necessary to jump through the QEMU vCPU thread first and then forward the access to the dedicated task, which is slow. A few existing devices use the ioeventfd mechanism to avoid the performance overhead of jumping through QEMU's vCPU thread but it only works for "doorbell" writes, not for read accesses or non-doorbell writes.

Here is how read accesses and non-doorbell writes need to be dispatched today:

kvm.ko  <---ioctl(KVM_RUN)---> QEMU <---messages---> device task

ioregionfd has been proposed as a solution that lets kvm.ko dispatch device accesses directly to device emulation tasks. It eliminates the extra step through QEMU and looks like this:

kvm.ko  <---ioregionfd---> device task

This project consists of implementing the KVM_SET_IOREGIONFD ioctl in the Linux kvm.ko kernel module and writing test cases that exercise the kvm.ko. As a stretch goal you could use ioregionfd in QEMU's NVMe device emulation code so that it can run in a dedicated QEMU IOThread.

This project idea is suitable if you would like to gain Linux kernel programming and virtualization/emulation experience. No prior kernel programming experience is required but you must be fluent in C and able to write production-quality code.

Links:

Details:

  • Skill level: advanced
  • Language: C
  • Mentor: Stefan Hajnoczi <stefanha@redhat.com>