Re: [PATCH 4/4] KVM: use signals to abort enter_guest/blocking and retry

From: Paolo Bonzini
Date: Tue Oct 25 2022 - 06:13:49 EST


On 10/24/22 09:43, Emanuele Giuseppe Esposito wrote:
Since the userspace should anyway avoid going into this effectively-busy
wait, what about clearing the request after the first exit?  The
cancellation ioctl can be kept for vCPUs that are never entered after
KVM_KICK_ALL_RUNNING_VCPUS.  Alternatively, kvm_clear_all_cpus_request
could be done right before up_write().

Clearing makes sense, but should we "trust" the userspace not to go into
busy wait?

I think so, there are many other ways for userspace to screw up.

What's the typical "contract" between KVM and the userspace? Meaning,
should we cover the basic usage mistakes like forgetting to busy wait on
KVM_RUN?

Being able to remove the second ioctl if you do (sort-of pseudocode based on this v1)

kvm_make_all_cpus_request(kvm, KVM_REQ_USERSPACE_KICK);
down_write(&kvm->memory_transaction);
up_write(&kvm->memory_transaction);
kvm_clear_all_cpus_request(kvm, KVM_REQ_USERSPACE_KICK);

would be worth it, I think.

Paolo