Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2208885ybb; Thu, 2 Apr 2020 15:34:37 -0700 (PDT) X-Google-Smtp-Source: APiQypIwW8XdNM4uyFuwdzOXUZ8qRF/3yU3oSoblIkWZwa3MQTmDsiNQPPY2NblXBVIAKEO2lLQm X-Received: by 2002:aca:aac1:: with SMTP id t184mr1016737oie.14.1585866877342; Thu, 02 Apr 2020 15:34:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585866877; cv=none; d=google.com; s=arc-20160816; b=YAtuI8Ig2FGxTPPndNngRjfYPDVH9SrQqI6AiIKxs2u+jv9WkYNIFN8pXBMLRC/CK+ 7EFvQKHI6xd7M+NIlaDkPkd6AJE5a3Nl2PdYK2nxluFuItUV6E9saaikHTOwgsjEWRZV MaKbwDRd9355lfpToG0ne0HVaZ+zpkZrVJQE1NaZ9BHm/pukbk5hQdQLdXeHLmW8G01S 5C/UGKSfVOJZKYGRZ1P/5PezHFaQFURpjas8bS3bnh+nbXqpGGyUmvNE0gvOiI8kng7M 8lhFnTZ3ikwt3tmOfmEcTSTnndEnjZ9KRVZqkv21LEPtz7eNmG07P0dR4G/7Earut5HM 6X5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=vG7MC2PNgxon4CeEkpAfEDnqjImA+hC2tBGaFp2oSTA=; b=Z3hZQ4efzL89gSC4HNxJcuwFl5z1B+gKD2+VpoFfOzRS+swO5OWGW96iP1CaNhncmY he9ytN3MVeVCoWR20lHvRkMfIXi2pvml/rD5xRN2l1U/tM1tPM6VrGou1t5AusxPzONT XY56TePIctPsEqfOAIlWyxAQFnp9DWRp/GVstcIRCczmvY0qJY2vBOUfAfawQ48xDAoq neolPA72i9O+yxCcWPDqzGyIRwyn6s8ERRXsjJLShAxIKcwaqnJFG/OtQ+AHYxptcHBa G3qQ5KdvcuCGYpvEMYeVTL4AcNUnyo/YU/bPYGxSRR/KP3oL4+S3ZvZ/LYsuiCpQ9I9E YxnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=uWogSPw7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a128si2899249oif.202.2020.04.02.15.34.25; Thu, 02 Apr 2020 15:34:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=uWogSPw7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389848AbgDBWZ2 (ORCPT + 99 others); Thu, 2 Apr 2020 18:25:28 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:49122 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726963AbgDBWZ2 (ORCPT ); Thu, 2 Apr 2020 18:25:28 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 032M9wGp140607; Thu, 2 Apr 2020 22:25:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : content-transfer-encoding : in-reply-to; s=corp-2020-01-29; bh=vG7MC2PNgxon4CeEkpAfEDnqjImA+hC2tBGaFp2oSTA=; b=uWogSPw74NKyE5+4Al78711YJ5745W2SKqzk/T2WMuszmZoSSu+XkSHWZJmxFsPwXHSW 6JQlNMcsaph5FmmhogFrzPk49IzRV499vExfSjEo5g+G86Zd/JjaMS4KwBh8JL6OCM8L EeeaYItz00GPQ+Oznwghdfn+cCdRzH/aimedrGPrV9ohsE1jy/opGzbAdQvJLCXSKMR4 qOi/r9pZ/7R+7hSyomioaSR9+FZ9fYSXoSRX2H2ALbyV1PLkbcxFPB24e/82BFNXx8YX c9AQCKwWZpNCaj6Phf5r+kiz3/ULb0jPdY5Cog/OZVYWBj/YfpLXQJDfFkfcB9vXe2fl /Q== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 303yungrht-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Apr 2020 22:25:04 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 032M8HxX048377; Thu, 2 Apr 2020 22:25:04 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 302ga3864b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Apr 2020 22:25:04 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 032MP2cJ009676; Thu, 2 Apr 2020 22:25:02 GMT Received: from vbusired-dt (/10.154.166.66) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 02 Apr 2020 15:25:01 -0700 Date: Thu, 2 Apr 2020 17:24:57 -0500 From: Venu Busireddy To: Ashish Kalra Cc: pbonzini@redhat.com, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, joro@8bytes.org, bp@suse.de, thomas.lendacky@amd.com, x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, rientjes@google.com, srutherford@google.com, luto@kernel.org, brijesh.singh@amd.com Subject: Re: [PATCH v6 06/14] KVM: SVM: Add KVM_SEV_RECEIVE_FINISH command Message-ID: <20200402222457.GA659325@vbusired-dt> References: <0f8a2125c7acb7b38fc51a044a8088e8baa45e3d.1585548051.git.ashish.kalra@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <0f8a2125c7acb7b38fc51a044a8088e8baa45e3d.1585548051.git.ashish.kalra@amd.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9579 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 spamscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004020164 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9579 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 lowpriorityscore=0 malwarescore=0 adultscore=0 priorityscore=1501 mlxlogscore=999 bulkscore=0 suspectscore=1 mlxscore=0 spamscore=0 impostorscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004020164 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-03-30 06:21:36 +0000, Ashish Kalra wrote: > From: Brijesh Singh > > The command finalize the guest receiving process and make the SEV guest > ready for the execution. > > Cc: Thomas Gleixner > Cc: Ingo Molnar > Cc: "H. Peter Anvin" > Cc: Paolo Bonzini > Cc: "Radim Krčmář" > Cc: Joerg Roedel > Cc: Borislav Petkov > Cc: Tom Lendacky > Cc: x86@kernel.org > Cc: kvm@vger.kernel.org > Cc: linux-kernel@vger.kernel.org > Signed-off-by: Brijesh Singh > Signed-off-by: Ashish Kalra > --- > .../virt/kvm/amd-memory-encryption.rst | 8 +++++++ > arch/x86/kvm/svm.c | 23 +++++++++++++++++++ > 2 files changed, 31 insertions(+) > > diff --git a/Documentation/virt/kvm/amd-memory-encryption.rst b/Documentation/virt/kvm/amd-memory-encryption.rst > index 554aa33a99cc..93cd95d9a6c0 100644 > --- a/Documentation/virt/kvm/amd-memory-encryption.rst > +++ b/Documentation/virt/kvm/amd-memory-encryption.rst > @@ -375,6 +375,14 @@ Returns: 0 on success, -negative on error > __u32 trans_len; > }; > > +15. KVM_SEV_RECEIVE_FINISH > +------------------------ > + > +After completion of the migration flow, the KVM_SEV_RECEIVE_FINISH command can be > +issued by the hypervisor to make the guest ready for execution. > + > +Returns: 0 on success, -negative on error > + > References > ========== > > diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c > index 5fc5355536d7..7c2721e18b06 100644 > --- a/arch/x86/kvm/svm.c > +++ b/arch/x86/kvm/svm.c > @@ -7573,6 +7573,26 @@ static int sev_receive_update_data(struct kvm *kvm, struct kvm_sev_cmd *argp) > return ret; > } > > +static int sev_receive_finish(struct kvm *kvm, struct kvm_sev_cmd *argp) > +{ > + struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info; > + struct sev_data_receive_finish *data; > + int ret; > + > + if (!sev_guest(kvm)) > + return -ENOTTY; Noticed this in earlier patches too. Is -ENOTTY the best return value? Aren't one of -ENXIO, or -ENODEV, or -EINVAL a better choice? What is the rationale for using -ENOTTY? > + > + data = kzalloc(sizeof(*data), GFP_KERNEL); > + if (!data) > + return -ENOMEM; > + > + data->handle = sev->handle; > + ret = sev_issue_cmd(kvm, SEV_CMD_RECEIVE_FINISH, data, &argp->error); > + > + kfree(data); > + return ret; > +} > + > static int svm_mem_enc_op(struct kvm *kvm, void __user *argp) > { > struct kvm_sev_cmd sev_cmd; > @@ -7632,6 +7652,9 @@ static int svm_mem_enc_op(struct kvm *kvm, void __user *argp) > case KVM_SEV_RECEIVE_UPDATE_DATA: > r = sev_receive_update_data(kvm, &sev_cmd); > break; > + case KVM_SEV_RECEIVE_FINISH: > + r = sev_receive_finish(kvm, &sev_cmd); > + break; > default: > r = -EINVAL; > goto out; > -- > 2.17.1 >