@@ -574,6 +574,7 @@ enum kvm_tdx_cmd_id {
KVM_TDX_INIT_VCPU,
KVM_TDX_INIT_MEM_REGION,
KVM_TDX_FINALIZE_VM,
+ KVM_TDX_RELEASE_VM,
KVM_TDX_CMD_NR_MAX,
};
@@ -6908,6 +6908,7 @@ void kvm_arch_flush_shadow_all(struct kvm *kvm)
static_call_cond(kvm_x86_flush_shadow_all_private)(kvm);
kvm_mmu_zap_all(kvm);
}
+EXPORT_SYMBOL_GPL(kvm_arch_flush_shadow_all);
static void kvm_mmu_zap_memslot(struct kvm *kvm, struct kvm_memory_slot *slot)
{
@@ -2818,6 +2818,15 @@ int tdx_vm_ioctl(struct kvm *kvm, void __user *argp)
case KVM_TDX_FINALIZE_VM:
r = tdx_td_finalizemr(kvm);
break;
+ case KVM_TDX_RELEASE_VM: {
+ int idx;
+
+ idx = srcu_read_lock(&kvm->srcu);
+ kvm_arch_flush_shadow_all(kvm);
+ srcu_read_unlock(&kvm->srcu, idx);
+ r = 0;
+ break;
+ }
default:
r = -EINVAL;
goto out;