x86/kvm: Alloc dummy async #PF token outside of raw spinlock
authorSean Christopherson <seanjc@google.com>
Thu, 19 May 2022 14:57:11 +0000 (07:57 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 6 Jun 2022 06:43:38 +0000 (08:43 +0200)
commit7b54eb6319342eccd2c95a3e479e10282a5946c8
tree91f808e214bff536443154a6e8f19bcd927ac97b
parent1b6bcda5df8cae10228c4332f92f4d2e310310da
x86/kvm: Alloc dummy async #PF token outside of raw spinlock

commit 0547758a6de3cc71a0cfdd031a3621a30db6a68b upstream.

Drop the raw spinlock in kvm_async_pf_task_wake() before allocating the
the dummy async #PF token, the allocator is preemptible on PREEMPT_RT
kernels and must not be called from truly atomic contexts.

Opportunistically document why it's ok to loop on allocation failure,
i.e. why the function won't get stuck in an infinite loop.

Reported-by: Yajun Deng <yajun.deng@linux.dev>
Cc: stable@vger.kernel.org
Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/kernel/kvm.c