lkml.org 
[lkml]   [2021]   [Jul]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 2/3] KVM, SEV: Add support for SEV local migration
From
Date


On 6/21/21 11:31 AM, Peter Gonda wrote:

> + if (!sev_guest(kvm))
> + return -ENOTTY;
> +
> + if (sev->es_active)
> + return -EPERM;
> +
> + if (sev->info_token != 0)
> + return -EEXIST;
> +
> + if (copy_from_user(&params, (void __user *)(uintptr_t)argp->data,
> + sizeof(params)))
> + return -EFAULT;
> +
> + entry = kzalloc(sizeof(*entry), GFP_KERNEL);
> + if (!entry)
> + return -ENOMEM;
> +
> + entry->asid = sev->asid;
> + entry->handle = sev->handle;
> + entry->pages_locked = sev->pages_locked;
> + entry->misc_cg = sev->misc_cg;
> +
> + INIT_LIST_HEAD(&entry->regions_list);
> + list_replace_init(&sev->regions_list, &entry->regions_list);

I believe the entry->regions_list will be NULL if the command is called
before the memory regions are registered. The quesiton is, do you need
to check whether for a valid sev->handle (i.e, LAUNCH_START is done)?


> +
> /* Userspace wants to query session length. */
> static int
> __sev_send_start_query_session_length(struct kvm *kvm, struct kvm_sev_cmd *argp,
> @@ -1513,6 +1711,18 @@ int svm_mem_enc_op(struct kvm *kvm, void __user *argp)
> goto out;
> }
>
> + /*
> + * If this VM has started exporting its SEV contents to another VM,
> + * it's not allowed to do any more SEV operations that may modify the
> + * SEV state.
> + */
> + if (to_kvm_svm(kvm)->sev_info.info_token &&
> + sev_cmd.id != KVM_SEV_DBG_ENCRYPT &&
> + sev_cmd.id != KVM_SEV_DBG_DECRYPT) {
> + r = -EPERM;
> + goto out;
> + }

Maybe move this check in a function so that it can later extended for
SEV-SNP (cmd ids for the debug is different).

Something like:

static bool is_local_mig_active(struct kvm *)
{
....
}

Once the migration range hypercall is merged, we also need to preserve
any metadata memory maintained by KVM for the unencrypted ranges.

-Brijesh

\
 
 \ /
  Last update: 2021-07-12 23:10    [W:0.139 / U:0.680 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site