Re: [PATCH 1/2] KVM: x86: Ensure vendor's exit handler runs before fastpath userspace exits

Huang, Kai
2026-04-23T21:48:47Z

On Thu, 2026-04-23 at 09:26 -0700, Sean Christopherson wrote:
> Move the handling of fastpath userspace exits into vendor code to ensure
> KVM runs vendor specific operations that need to run before userspace gains
> control of the vCPU. E.g. for VMX (and soon to be for SVM as well), KVM
> needs to flush the PML buffer prior to exiting to userspace, otherwise any
> memory written by the final KVM_RUN might never be flagged as dirty.
>
> Note, waiting to snapshot CR0 and CR3 until svm_handle_exit() is flawed in
> general, as that risks consuming stale state in a fastpath handler. That
> will be addressed in a future change.
>
> Fixes: f7f39c50edb9 ("KVM: x86: Exit to userspace if fastpath triggers one on instruction skip")
> Cc: stable@vger.kernel.org
> Cc: Nikunj A. Dadhania <nikunj@amd.com>
> Signed-off-by: Sean Christopherson <seanjc@google.com>
>

Reviewed-by: Kai Huang <kai.huang@intel.com>