If loading PDPTRs from guest memory fails, the KVM_SET_SREGS ioctl returns before resetting the MMU context and with stale PDPTRs. Mark the VM dead on the error path, so that the vCPU cannot run with inconsistent state; userspace should anyway use KVM_SET_SREGS2, which provides the cached PDPTRs and avoids the guest-memory read. Signed-off-by: Paolo Bonzini --- arch/x86/kvm/regs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/kvm/regs.c b/arch/x86/kvm/regs.c index b7c25b16ffca..3a11a6d06889 100644 --- a/arch/x86/kvm/regs.c +++ b/arch/x86/kvm/regs.c @@ -634,6 +634,7 @@ static int __set_sregs_common(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs, r = load_pdptrs(vcpu, kvm_read_cr3(vcpu)); if (r < 0) { srcu_read_unlock(&vcpu->kvm->srcu, idx); + kvm_vm_dead(vcpu->kvm); return r; } *mmu_reset_needed = 1; -- 2.52.0