@@ -1445,6 +1445,8 @@ struct kvm_arch {
*/
#define SPLIT_DESC_CACHE_MIN_NR_OBJECTS (SPTE_ENT_PER_PAGE + 1)
struct kvm_mmu_memory_cache split_desc_cache;
+
+ bool vm_move_enc_ctxt_supported;
};
struct kvm_vm_stat {
@@ -256,6 +256,8 @@ static int sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp)
goto e_no_asid;
sev->asid = asid;
+ kvm->arch.vm_move_enc_ctxt_supported = true;
+
ret = sev_platform_init(&argp->error);
if (ret)
goto e_free;
@@ -6351,7 +6351,14 @@ static int kvm_vm_move_enc_context_from(struct kvm *kvm, unsigned int source_fd)
if (r)
goto out_mark_migration_done;
- r = static_call(kvm_x86_vm_move_enc_context_from)(kvm, source_kvm);
+ /*
+ * Different types of VMs will allow userspace to define if moving
+ * encryption context should be supported.
+ */
+ if (kvm->arch.vm_move_enc_ctxt_supported &&
+ kvm_x86_ops.vm_move_enc_context_from) {
+ r = static_call(kvm_x86_vm_move_enc_context_from)(kvm, source_kvm);
+ }
kvm_unlock_two_vms(kvm, source_kvm);
out_mark_migration_done: