On 23/08/2016 01:28, Brijesh Singh wrote: > +static int sev_launch_start(struct kvm *kvm, > + struct kvm_sev_launch_start __user *arg, > + int *psp_ret) > +{ > + int ret, asid; > + struct kvm_sev_launch_start params; > + struct psp_data_launch_start *start; > + > + /* Get parameter from the user */ > + if (copy_from_user(¶ms, arg, sizeof(*arg))) > + return -EFAULT; > + > + start = kzalloc(sizeof(*start), GFP_KERNEL); > + if (!start) > + return -ENOMEM; > + > + ret = sev_pre_start(kvm, &asid); You need some locking in sev_asid_{new,free}. Probably &kvm_lock. The SEV_ISSUE_CMD ioctl instead should take &kvm->lock. Paolo > + if (ret) > + goto err_1; > + > + start->hdr.buffer_len = sizeof(*start); > + start->flags = params.flags; > + start->policy = params.policy; > + start->handle = params.handle; > + memcpy(start->nonce, ¶ms.nonce, sizeof(start->nonce)); > + memcpy(start->dh_pub_qx, ¶ms.dh_pub_qx, sizeof(start->dh_pub_qx)); > + memcpy(start->dh_pub_qy, ¶ms.dh_pub_qy, sizeof(start->dh_pub_qy)); > + > + /* launch start */ > + ret = psp_guest_launch_start(start, psp_ret); > + if (ret) { > + printk(KERN_ERR "SEV: LAUNCH_START ret=%d (%#010x)\n", > + ret, *psp_ret); > + goto err_2; > + } > + > + ret = sev_post_start(kvm, asid, start->handle, psp_ret); > + if (ret) > + goto err_2; Paolo > + kfree(start); > + return 0; > + > +err_2: > + sev_asid_free(asid); > +err_1: > + kfree(start); > + return ret; > +} > + > +static int amd_sev_issue_cmd(struct kvm *kvm, > + struct kvm_sev_issue_cmd __user *user_data) > +{ > + int r = -ENOTTY; > + struct kvm_sev_issue_cmd arg; > + > + if (copy_from_user(&arg, user_data, sizeof(struct kvm_sev_issue_cmd))) > + return -EFAULT; > + > + switch (arg.cmd) { > + case KVM_SEV_LAUNCH_START: { > + r = sev_launch_start(kvm, (void *)arg.opaque, > + &arg.ret_code); > + break; > + } > + default: > + break; > + } > + > + if (copy_to_user(user_data, &arg, sizeof(struct kvm_sev_issue_cmd))) > + r = -EFAULT; > + return r; > +} > + > static struct kvm_x86_ops svm_x86_ops __ro_after_init = { > .cpu_has_kvm_support = has_svm, > .disabled_by_bios = is_disabled, > @@ -5313,6 +5517,8 @@ static struct kvm_x86_ops svm_x86_ops __ro_after_init = { > > .pmu_ops = &amd_pmu_ops, > .deliver_posted_interrupt = svm_deliver_avic_intr, > + > + .sev_issue_cmd = amd_sev_issue_cmd, > }; > > static int __init svm_init(void) > > -- > To unsubscribe, send a message with 'unsubscribe linux-mm' in > the body to majordomo@xxxxxxxxx. For more info on Linux MM, > see: http://www.linux-mm.org/ . > Don't email: <a href=mailto:"dont@xxxxxxxxx"> email@xxxxxxxxx </a> > _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel