@@ -1576,6 +1576,7 @@ struct kvm_arch {
#define SPLIT_DESC_CACHE_MIN_NR_OBJECTS (SPTE_ENT_PER_PAGE + 1)
struct kvm_mmu_memory_cache split_desc_cache;
+ bool use_vm_enc_ctxt_op;
gfn_t gfn_direct_bits;
/*
@@ -442,6 +442,8 @@ static int __sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp,
if (ret)
goto e_no_asid;
+ kvm->arch.use_vm_enc_ctxt_op = true;
+
init_args.probe = false;
ret = sev_platform_init(&init_args);
if (ret)
@@ -6624,7 +6624,14 @@ static int kvm_vm_move_enc_context_from(struct kvm *kvm, unsigned int source_fd)
if (r)
goto out_mark_migration_done;
- r = kvm_x86_call(vm_move_enc_context_from)(kvm, source_kvm);
+ /*
+ * Different types of VMs will allow userspace to define if moving
+ * encryption context should be required.
+ */
+ if (kvm->arch.use_vm_enc_ctxt_op &&
+ kvm_x86_ops.vm_move_enc_context_from) {
+ r = kvm_x86_call(vm_move_enc_context_from)(kvm, source_kvm);
+ }
kvm_unlock_two_vms(kvm, source_kvm);
out_mark_migration_done: