> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 58b82d6fd77c..045c61cc7e54 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -12890,11 +12890,11 @@ void kvm_arch_destroy_vm(struct kvm *kvm) > mutex_unlock(&kvm->slots_lock); > } > kvm_unload_vcpu_mmus(kvm); > + kvm_destroy_vcpus(kvm); > kvm_x86_call(vm_destroy)(kvm); > kvm_free_msr_filter(srcu_dereference_check(kvm->arch.msr_filter, &kvm->srcu, 1)); > kvm_pic_destroy(kvm); > kvm_ioapic_destroy(kvm); > - kvm_destroy_vcpus(kvm); > kvfree(rcu_dereference_check(kvm->arch.apic_map, 1)); > kfree(srcu_dereference_check(kvm->arch.pmu_event_filter, &kvm->srcu, 1)); > kvm_mmu_uninit_vm(kvm); After this change, now the sequence is that 1. kvm_arch_pre_destroy_vm() 2. kvm_arch_destroy_vm() 2.1 kvm_destroy_vcpus() 2.2 .vm_destroy hook 2.3 kvm_mmu_uninit_vm() --> mirror root ref is 1 upon here. Zap the mirror root and reclaim SETP page table pages. 2.4 .vm_free hook Since TDX needs to reclaim the TDR page after reclaiming all other pages, we currently added a vm_free hook at 2.4, after 2.3. Could we move kvm_mmu_uninit_vm() before the .vm_destroy hook and after kvm_destroy_vcpus()? Or move the .vm_destroy hook after kvm_mmu_uninit_vm(), e.g. after kvm_page_track_cleanup()? Otherwise, TDX still needs to introduce the .vm_free hook, which is invoked at the end of kvm_arch_destroy_vm().