On Tue, Oct 25, 2022, Paolo Bonzini wrote:out of KVM_RUN> is at best half of the solution.
That said, I believe the limited memslot API makes it more than just a QEMU
problem. Because KVM_GET_DIRTY_LOG cannot be combined atomically with
KVM_SET_USER_MEMORY_REGION(MR_DELETE), any VMM that uses dirty-log regions
while the VM is running is liable to losing the dirty status of some pages.
... and doesn't already do the sane thing and pause vCPUs _and anything else that
can touch guest memory_ before modifying memslots. I honestly think QEMU is the > only VMM that would ever use this API. Providing a way to force vCPUs
- a refcounting scheme to track the number of "holds" put on the system
- serialization to ensure KVM_RESUME_ALL_KICKED_VCPUS completes before a new
KVM_KICK_ALL_RUNNING_VCPUS is initiated
- to prevent _all_ ioctls() because it's not just KVM_RUN that consumes memslots
- to stop anything else in the system that consumes KVM memslots, e.g. KVM GT
- to signal vCPU tasks so that the system doesn't livelock if a vCPU is stuck
outside of KVM, e.g. in get_user_pages_unlocked() (Peter Xu's series)
And because of the nature of KVM, to support this API on all architectures, KVM
needs to make change on all architectures, whereas userspace should be able to
implement a generic solution.