Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3869149ybb; Mon, 6 Apr 2020 17:59:13 -0700 (PDT) X-Google-Smtp-Source: APiQypJTG16th6nNUYwR+voFJAsx7cGllaOcb+dObyGgr/I39FFWr1U9yRKayPAaMekR5twDj6JO X-Received: by 2002:a9d:7f19:: with SMTP id j25mr20261330otq.129.1586221153584; Mon, 06 Apr 2020 17:59:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586221153; cv=none; d=google.com; s=arc-20160816; b=FnLzdI5rUS+B/jHa0KL+NxUx7ClsA//oxVyFrS7v8imBvXaiGUQX/tx/c2rbd+6zDv 569Su6HXgViS3Zcjne6avCE9m0Fqjgu9cAG6YAKWuMwQ1wIEvEQ6ADDM9eUenlH/jf+1 i3VFde8AEQibFyf+Cy+9wqJKEi3Ulx/1+0vYe4u/RoZ/PAM93q6VANki1esz+8LE9R0f D8Tu06L7ZUI1AqVbHRLKqnE9UtKBP7DIO5FV8YhtD0FyE8TBUz2xrRE3H3aBDbwlHnXS M+igrR5ZGo+vq4wB2tnbSWpZHz4OYNGQIwscmWAWxpgA15Sorv1SGWkjsmR4E73REy+3 SjsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=TDz9BFmZ8zQpqNsWCTptx0CrsbNAsUuC7AsThVhGJVY=; b=yXPEfv1uD9KHN3lLNyuPxomOqyegZtPMtaNpF2mQnIOH6NZ3HqqWENO/mj82eMVpMr 7lzlqPYUe+F9Szf5TXX5R1Eq6ZSmEl2P1NJe4WKL/tRIQM7ioOE8MiXCvR7MFuR5UtXE 2P0adUsjf981yufO/N1xZOvWQ6HxGL2AK66bnNdQvQAj1ixEK8mj812fcfDatYvpGbuu AM/sDkrky/GADyymlkSJYPvOtdl5F++vdmh8b1L6QXvdxg5LEXkeoqD7batcXuo1551+ jBcXvdgIutsT8OmlKNOODEp2c6qBwwcpVQaBNNpGukpvE4yMCuLV+d3yOjWAkf+5XOU2 WCbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=bmS1u9FM; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h145si1191oib.210.2020.04.06.17.59.01; Mon, 06 Apr 2020 17:59:13 -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=@google.com header.s=20161025 header.b=bmS1u9FM; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726406AbgDGA6e (ORCPT + 99 others); Mon, 6 Apr 2020 20:58:34 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:37856 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726303AbgDGA6e (ORCPT ); Mon, 6 Apr 2020 20:58:34 -0400 Received: by mail-lj1-f194.google.com with SMTP id r24so1800144ljd.4 for ; Mon, 06 Apr 2020 17:58:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=TDz9BFmZ8zQpqNsWCTptx0CrsbNAsUuC7AsThVhGJVY=; b=bmS1u9FMz/4hyaxFYbha1NI2AnffokqKUEnhj0wBpgyduvbsFD1n+97WD4U75p+1ob EnZaumrGvgNO5ochV/LIMm/bYhgMXfD4ViALib44ySCVTBIE7hRrGzgfnQGFvJKVH4Tm 9wJXGyAAVbsTUiaPiPJaKA0QtBuvojNec0BT6DUp1VwTYUWUUQPiLXHTxTZTIuRs2j9g AVAZhVv0QaVNJCJVzLbPNrJQaeInwCs5j5lWTCGIcBd0kX09NR+NmU0MY16u07v/p4K9 bMzmb9zMEWyWTREvKXMA4vbsKfTw3q6vuHRRVFerVwNjGiwI+fU7frloTaX1suC7w10o nhmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=TDz9BFmZ8zQpqNsWCTptx0CrsbNAsUuC7AsThVhGJVY=; b=qpy/fUidbrnc4WgD0g/zEE/8oJnYR1r9aoaxI255bgsXfucqBqh0iFfGBgb8Zsq8t1 2y3EQGKw5W0WFu4gBRFEiO+g6bczxto2akOXEGfy9gpiBwYuv0LG1Owf/kqBBMyrIXJN uZ5/ClWKwHRhQ1W9ZXdCYj4/MHXjdNWJzdxwygKwNs0sz/fLidzXyirFMQe2xIiVnRGY g7trD1kJ0Qso3KOcE6dUZgwc7jFXc75zUvoK6GJw0mTHjkyBwXGcBzXNjwe7EaYsEnW3 RJbWzXHQn0lFP32WPCqnACAZa0MhKGcHE49rvsEG1a3VBHnUtJB6UNHd/dRzrRRXcEYa bdWw== X-Gm-Message-State: AGi0PuaAsNhoL3uUlvAFPOZFmn14nvMMBQuA5CGayy9/HoxTU6W7O8TP eWaHZrKBQRDGG1I2H1O5Ihz+snByvLOXq/40oFTneg== X-Received: by 2002:a2e:894e:: with SMTP id b14mr3817ljk.103.1586221111082; Mon, 06 Apr 2020 17:58:31 -0700 (PDT) MIME-Version: 1.0 References: <0f8a2125c7acb7b38fc51a044a8088e8baa45e3d.1585548051.git.ashish.kalra@amd.com> <8694381f-2083-e477-bea1-04fb572519d0@oracle.com> In-Reply-To: <8694381f-2083-e477-bea1-04fb572519d0@oracle.com> From: Steve Rutherford Date: Mon, 6 Apr 2020 17:57:54 -0700 Message-ID: Subject: Re: [PATCH v6 06/14] KVM: SVM: Add KVM_SEV_RECEIVE_FINISH command To: Krish Sadhukhan Cc: Ashish Kalra , Paolo Bonzini , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Joerg Roedel , Borislav Petkov , Tom Lendacky , X86 ML , KVM list , LKML , David Rientjes , Andy Lutomirski , Brijesh Singh Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 2, 2020 at 3:27 PM Krish Sadhukhan wrote: > > > On 3/29/20 11:21 PM, 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=C4=8Dm=C3=A1=C5=99" > > 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/Documen= tation/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 com= mand can be > > +issued by the hypervisor to make the guest ready for execution. > > + > > +Returns: 0 on success, -negative on error > > + > > References > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > > > 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 *k= vm, struct kvm_sev_cmd *argp) > > return ret; > > } > > > > +static int sev_receive_finish(struct kvm *kvm, struct kvm_sev_cmd *arg= p) > > +{ > > + struct kvm_sev_info *sev =3D &to_kvm_svm(kvm)->sev_info; > > + struct sev_data_receive_finish *data; > > + int ret; > > + > > + if (!sev_guest(kvm)) > > + return -ENOTTY; > > + > > + data =3D kzalloc(sizeof(*data), GFP_KERNEL); > > + if (!data) > > + return -ENOMEM; > > + > > + data->handle =3D sev->handle; > > + ret =3D sev_issue_cmd(kvm, SEV_CMD_RECEIVE_FINISH, data, &argp->e= rror); > > + > > + 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 =3D sev_receive_update_data(kvm, &sev_cmd); > > break; > > + case KVM_SEV_RECEIVE_FINISH: > > + r =3D sev_receive_finish(kvm, &sev_cmd); > > + break; > > default: > > r =3D -EINVAL; > > goto out; > Reviewed-by: Krish Sadhukhan As to ENOTTY, man page for ioctl translates it as "The specified request does not apply to the kind of object that the file descriptor fd references", which seems appropriate here. Reviewed-by: Steve Rutherford