From patchwork Sat Oct 14 09:21:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Borislav Petkov X-Patchwork-Id: 10006283 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 280DF6037E for ; Sat, 14 Oct 2017 09:22:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 128D6291B3 for ; Sat, 14 Oct 2017 09:22:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 07710291C5; Sat, 14 Oct 2017 09:22:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 97E2C291B3 for ; Sat, 14 Oct 2017 09:22:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752082AbdJNJVx (ORCPT ); Sat, 14 Oct 2017 05:21:53 -0400 Received: from mail.skyhub.de ([5.9.137.197]:58650 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751950AbdJNJVw (ORCPT ); Sat, 14 Oct 2017 05:21:52 -0400 X-Virus-Scanned: Nedap ESD1 at mail.skyhub.de Received: from mail.skyhub.de ([127.0.0.1]) by localhost (blast.alien8.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id A4-zkZXupUJr; Sat, 14 Oct 2017 11:21:50 +0200 (CEST) Received: from pd.tnic (p2003008C2F638D00A843DA5E8027BE35.dip0.t-ipconnect.de [IPv6:2003:8c:2f63:8d00:a843:da5e:8027:be35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id AEE2E1EC05C2; Sat, 14 Oct 2017 11:21:50 +0200 (CEST) Date: Sat, 14 Oct 2017 11:21:39 +0200 From: Borislav Petkov To: Brijesh Singh Cc: x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , Joerg Roedel , Borislav Petkov , Tom Lendacky Subject: Re: [Part2 PATCH v5 17/31] KVM: SVM: Add KVM_SEV_INIT command Message-ID: <20171014092139.iw4mnrir52pket4n@pd.tnic> References: <20171004131412.13038-1-brijesh.singh@amd.com> <20171004131412.13038-18-brijesh.singh@amd.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20171004131412.13038-18-brijesh.singh@amd.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Wed, Oct 04, 2017 at 08:13:58AM -0500, Brijesh Singh wrote: > The command initializes the SEV platform context and allocates a new ASID > for this guest from the SEV ASID pool. The firmware must be initialized > before we issue any guest launch commands to create a new memory encryption > context. > > 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 > --- > arch/x86/include/asm/kvm_host.h | 7 ++ > arch/x86/kvm/svm.c | 189 +++++++++++++++++++++++++++++++++++++++- > 2 files changed, 195 insertions(+), 1 deletion(-) Just minor cleanups. With those applied: Reviewed-by: Borislav Petkov diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 26380627e7f9..7b3b199e15a1 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -1189,8 +1189,8 @@ static __init int svm_hardware_setup(void) static int sev_platform_get_state(int *state, int *error) { - int ret; struct sev_data_status *data; + int ret; data = kzalloc(sizeof(*data), GFP_KERNEL); if (!data) @@ -1201,7 +1201,7 @@ static int sev_platform_get_state(int *state, int *error) *state = data->state; pr_info_once("SEV firmware major %d minor %d build %d\n", - data->api_major, data->api_minor, data->build); + data->api_major, data->api_minor, data->build); kfree(data); return ret; @@ -5577,6 +5577,7 @@ static int sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp) sev->active = true; sev->asid = asid; + return 0; e_shutdown: @@ -5598,17 +5599,19 @@ static int svm_mem_enc_op(struct kvm *kvm, void __user *argp) mutex_lock(&kvm->lock); switch (sev_cmd.id) { - case KVM_SEV_INIT: { + case KVM_SEV_INIT: r = sev_guest_init(kvm, &sev_cmd); break; - } + default: break; } mutex_unlock(&kvm->lock); + if (copy_to_user(argp, &sev_cmd, sizeof(struct kvm_sev_cmd))) r = -EFAULT; + return r; }