On 18/11/2024 17:58, Vitaly Kuznetsov wrote:
Nikita Kalyazin <kalyazin@xxxxxxxxxx> writes:
On x86, async pagefault events can only be delivered if the page fault
was triggered by guest userspace, not kernel. This is because
the guest may be in non-sleepable context and will not be able
to reschedule.
We used to set KVM_ASYNC_PF_SEND_ALWAYS for Linux guests before
commit 3a7c8fafd1b42adea229fd204132f6a2fb3cd2d9
Author: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Date: Fri Apr 24 09:57:56 2020 +0200
x86/kvm: Restrict ASYNC_PF to user space
but KVM side of the feature is kind of still there, namely
kvm_pv_enable_async_pf() sets
vcpu->arch.apf.send_user_only = !(data & KVM_ASYNC_PF_SEND_ALWAYS);
and then we check it in
kvm_can_deliver_async_pf():
if (vcpu->arch.apf.send_user_only &&
kvm_x86_call(get_cpl)(vcpu) == 0)
return false;
and this can still be used by some legacy guests I suppose. How about
we start with removing this completely? It does not matter if some
legacy guest wants to get an APF for CPL0, we are never obliged to
actually use the mechanism.
If I understand you correctly, the change you propose is rather
orthogonal to the original one as the check is performed after the work
has been already allocated (in kvm_setup_async_pf). Would you expect
tangible savings from omitting the send_user_only check?
--
Vitaly