Re: [PATCH v2 1/3] KVM: x86: Add a helper to prepare vcpu->run for a SHUTDOWN exit to userspace

From: Binbin Wu

Date: Tue Sep 29 2026 - 23:04:28 EST


On 9/30/2026 8:11 AM, Sean Christopherson wrote:
> Add kvm_prepare_shutdown_exit() to dedup the paths that exit to userspace
> with KVM_EXIT_SHUTDOWN, all of which happen to be x86 (presumably other
> architectures use KVM_EXIT_SYSTEM_EVENT?).
>
> Note, this adds a clearing of mmio_needed for SVM's shutdown_interception().
> Not clearing mmio_needed in that case is all but guaranteed to be benign;
> KVM should never enter the guest with outstanding emulated MMIO operations
> (the equivalent VMX and TDX paths likely copy+pasted the code from
> KVM_REQ_TRIPLE_FAULT, which does need to clear mmio_needed as KVM can
> synthesize a triple fault shutdown in the middle of instruction emulation).
>
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>

Reviewed-by: Binbin Wu <binbin.wu@xxxxxxxxxxxxxxx>