Re: [PATCH v2] KVM: SVM: Fix SNP AP destroy race with VMRUN
From: Sean Christopherson
Date: Fri Apr 25 2025 - 19:24:34 EST
On Thu, 27 Mar 2025 12:39:56 -0500, Tom Lendacky wrote:
> An AP destroy request for a target vCPU is typically followed by an
> RMPADJUST to remove the VMSA attribute from the page currently being
> used as the VMSA for the target vCPU. This can result in a vCPU that
> is about to VMRUN to exit with #VMEXIT_INVALID.
>
> This usually does not happen as APs are typically sitting in HLT when
> being destroyed and therefore the vCPU thread is not running at the time.
> However, if HLT is allowed inside the VM, then the vCPU could be about to
> VMRUN when the VMSA attribute is removed from the VMSA page, resulting in
> a #VMEXIT_INVALID when the vCPU actually issues the VMRUN and causing the
> guest to crash. An RMPADJUST against an in-use (already running) VMSA
> results in a #NPF for the vCPU issuing the RMPADJUST, so the VMSA
> attribute cannot be changed until the VMRUN for target vCPU exits. The
> Qemu command line option '-overcommit cpu-pm=on' is an example of allowing
> HLT inside the guest.
>
> [...]
Applied to kvm-x86 svm, thanks!
[1/1] KVM: SVM: Fix SNP AP destroy race with VMRUN
https://github/kvm-x86/linux/commit/309d28576f0a
--
https://github.com/kvm-x86/linux/tree/next