Message ID | 148846787592.2349.5101158172858135011.stgit@brijesh-build-machine (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <kvm-owner@kernel.org> 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 A917A60453 for <patchwork-kvm@patchwork.kernel.org>; Thu, 2 Mar 2017 21:04:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 99475285EE for <patchwork-kvm@patchwork.kernel.org>; Thu, 2 Mar 2017 21:04:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B2D5285F5; Thu, 2 Mar 2017 21:04:18 +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,DKIM_SIGNED, DKIM_VALID,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 65E24285EE for <patchwork-kvm@patchwork.kernel.org>; Thu, 2 Mar 2017 21:04:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751076AbdCBVCm (ORCPT <rfc822;patchwork-kvm@patchwork.kernel.org>); Thu, 2 Mar 2017 16:02:42 -0500 Received: from mail-co1nam03on0080.outbound.protection.outlook.com ([104.47.40.80]:10583 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751029AbdCBVCj (ORCPT <rfc822;kvm@vger.kernel.org>); Thu, 2 Mar 2017 16:02:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=SAmoYNHDk5W5wMw7ygIjSCK0otFqbdvMjYsvGPCIhAo=; b=n3sT8zv1agoKj7ZVSDPHnX54aZj91U1cD0cGdUseFF8590cXuK7uBakg9p0GokvkWZ7t+20B4Z2oTP1JbcLpCUfjTSN3U3dl5NxUqEZyByKbPCBMts5Y0YayRoZGrPArQVhU+PWYUrjRNA/sy/oN83Ma57qygn4yTfXPWhVR1+o= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from [127.0.1.1] (165.204.77.1) by BN6PR12MB1601.namprd12.prod.outlook.com (10.172.20.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.947.12; Thu, 2 Mar 2017 15:17:58 +0000 Subject: [RFC PATCH v2 27/32] kvm: svm: Add support for SEV LAUNCH_FINISH command From: Brijesh Singh <brijesh.singh@amd.com> To: <simon.guinot@sequanux.org>, <linux-efi@vger.kernel.org>, <brijesh.singh@amd.com>, <kvm@vger.kernel.org>, <rkrcmar@redhat.com>, <matt@codeblueprint.co.uk>, <linux-pci@vger.kernel.org>, <linus.walleij@linaro.org>, <gary.hook@amd.com>, <linux-mm@kvack.org>, <paul.gortmaker@windriver.com>, <hpa@zytor.com>, <cl@linux.com>, <dan.j.williams@intel.com>, <aarcange@redhat.com>, <sfr@canb.auug.org.au>, <andriy.shevchenko@linux.intel.com>, <herbert@gondor.apana.org.au>, <bhe@redhat.com>, <xemul@parallels.com>, <joro@8bytes.org>, <x86@kernel.org>, <peterz@infradead.org>, <piotr.luc@intel.com>, <mingo@redhat.com>, <msalter@redhat.com>, <ross.zwisler@linux.intel.com>, <bp@suse.de>, <dyoung@redhat.com>, <thomas.lendacky@amd.com>, <jroedel@suse.de>, <keescook@chromium.org>, <arnd@arndb.de>, <toshi.kani@hpe.com>, <mathieu.desnoyers@efficios.com>, <luto@kernel.org>, <devel@linuxdriverproject.org>, <bhelgaas@google.com>, <tglx@linutronix.de>, <mchehab@kernel.org>, <iamjoonsoo.kim@lge.com>, <labbott@fedoraproject.org>, <tony.luck@intel.com>, <alexandre.bounine@idt.com>, <kuleshovmail@gmail.com>, <linux-kernel@vger.kernel.org>, <mcgrof@kernel.org>, <mst@redhat.com>, <linux-crypto@vger.kernel.org>, <tj@kernel.org>, <pbonzini@redhat.com>, <akpm@linux-foundation.org>, <davem@davemloft.net> Date: Thu, 2 Mar 2017 10:17:56 -0500 Message-ID: <148846787592.2349.5101158172858135011.stgit@brijesh-build-machine> In-Reply-To: <148846752022.2349.13667498174822419498.stgit@brijesh-build-machine> References: <148846752022.2349.13667498174822419498.stgit@brijesh-build-machine> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR09CA0026.namprd09.prod.outlook.com (10.172.184.140) To BN6PR12MB1601.namprd12.prod.outlook.com (10.172.20.23) X-MS-Office365-Filtering-Correlation-Id: 43eed15e-e966-462a-b6e1-08d4617f5146 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081); SRVR:BN6PR12MB1601; X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1601; 3:WUuDF2p6e8DGbfmWsQ3Lrp+fxzQQR+6QphFFSj0O8jX1u/YFtcXcPApaV15KcUAs0f0XgLiW6jsWS3MwCkwcXJvwZa+m9zJQYP67eOv5QfjOGhAKQ6iByaGSW1Oh9vOlnX9g8scVVIFzLkRRZPtE0+x47JWMPGUB4NX5jGuDb8Ych8y6O1oKmDs2p9xAVw89yWhuK210zoCwXb1/JK5JE0nbkfPG1+mSR4pGV0114W3pRRRQP3/RhFan68PreheSLL7xrguaB0DXGK0W/YeXS7gVHwC0a9Xp7+qnzNHhYDU=; 25:IuyWeyIekWd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9CcqFpYD7jQbTN+tqjbgZQl6I6RdPdDgiLvQ1GwctrZ25N9vrmUWSUSIZV4+6EuXhYcLkyo7nwcTW719QFSAHVqrLk3pjpJEBN+LgY5cE5xtwVD8guQMFmk0IKQB8JvNtRapU1wmeq8tzYrSCJawe0dnOqN9CaLhlfOpg5 X-Microsoft-Antispam-PRVS: <BN6PR12MB16012875F4D3A84A88087B0DE5280@BN6PR12MB1601.namprd12.prod.outlook.com> X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026)(6041248)(20161123558025)(20161123555025)(20161123564025)(20161123560025)(20161123562025)(6072148); SRVR:BN6PR12MB1601; BCL:0; PCL:0; RULEID:; SRVR:BN6PR12MB1601; X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1601; 4:GVrzkT0hU6EIvUy1gfPSLOFwItmQnQOD/deKKVgPOtly52uiHtI2lfPzZjH5IFuDd5q3ib3XCoMxAcO3cdJUs0IKVNF0mffEHxrej4gQ9gvtx36GaQTYdXagH1O/nQyg+/I9fddV+Dek7Xrao43NyYcghgLQk3WHbQpeum6YmdLwhaf03vHb7o30cC2Hr2mW8XRT+rBHElJDU5pehok22YGp17QfwxaRZCm21xLCMNtEA3MaQsj8Bg9XHXLeCYLnmlb4wtvTPhwE2U+fb0MUXpuRiauFQRM8nJPJTNZ1m2MSulK1+Jx1tYACzcxxNvzjeQfgYAaFhGh+AQ7srLanQPBaOga/dEoEd4W3b3GDTLL6wv8aEbtZShajS97EJYRitw7oi7es2f6Aa8k8oBUdEZ0a/4KUz+RRH20NFVPLl9EapTUHfYxG5tVDoLQUYe4b/Vsue8xL3CrH3YOtEVFbXFBiTtg255vR3r2DU+pnCiZaXI+PAev5vLx2JmpxBPUuQoOupyoxiu1F+WfrqCYLDhEb034eqwpnl+0y4MFRNulV6cazzoDSazPtfun0NWfNB4OoZ3+O54ObvrAwK6Xoq8rao0BCJ6LV0V7CLltH/EAqoX8WOaFyrcA3fpWXPAtK8jdW5zi5NCwc/hWK7XLtw+S6mvG+4zBLmfGQsfh8YjU= X-Forefront-PRVS: 023495660C X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6049001)(6009001)(7916002)(39410400002)(39450400003)(39840400002)(39860400002)(39850400002)(53936002)(33716001)(4001350100001)(38730400002)(92566002)(8676002)(3846002)(7416002)(23676002)(81166006)(6116002)(77096006)(25786008)(7406005)(2201001)(90366009)(54356999)(33646002)(76176999)(50986999)(6486002)(86362001)(9686003)(83506001)(2950100002)(230700001)(47776003)(66066001)(1191002)(7736002)(42186005)(2906002)(305945005)(50466002)(5660300001)(189998001)(103116003)(921003)(2101003)(83996005)(84006005)(217873001)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR12MB1601; H:[127.0.1.1]; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCTjZQUjEyTUIxNjAxOzIzOmMyTitKSVJkKzBoMVg0dzROTW9sbit2WnZo?= =?utf-8?B?emo1OTFxZndFWEkwdmRyWUVvdVlUMENZd3lFbXRhMHMwMDUzTElHNnd2WEtM?= =?utf-8?B?OUduRmhiME1HemZJeTQrRDlyUTYrbU93R1Rad2pJRi9adTBMczhLbkw2UTVZ?= =?utf-8?B?SWc3OWJZSjBkMVRUNEFhYWdudDhWb1RqOGl5TU5YTVN4aWFsSFVtVlhza0JI?= =?utf-8?B?RlIxWFg4cFVzQXRJMTVKMHNYVFZrK0IwS1lBZ3l5Z3UySWRtRW85L3dCN200?= =?utf-8?B?T1M5TjBCRnR4S3pKMExtSWxCTTN6YldPeU1NNGRPMVpLSHVyRlRuNzB1MjJJ?= =?utf-8?B?YzNZOXVCNHhJNitQNy9FV2plOE1sWWFJdTJ3eXFJamdmRlpvWmt3cU5sdHBI?= =?utf-8?B?bmxnOUdVdXlsMUpQY3g0cVRK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dkcA==; 24:sOqUtMkr3qnSrwh2vSgK+lMv+tMq2fJoUP52IOQidnWrpNGk39LuiT7rzOIq8FohqkUhlZ3p1C+9FD7+4esO01L7BHV7UQHmgX2H9nR2zTs= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1601; 7:xlcyfurRpfaohYPKNoWfbWHIzUT92duKjXslT7X05+zKqMpmEV1J9t7QAPUFHjwcFK0KeodVddwCAJ7WbKOhmeJck4h9CySHZIPRnv0sZdEigAEnVygOWpKnvBPWJFgICe/pc6fGGbE+ivp3ks4m4fpTd38TPsHSeMigxGfMU3KJC2uYZ+AYJSNkmQw03Pb7QW0e+sCKjiF9piJCixIXYC3jsJjE2Tbu5dG9nnMei0/HZnFeQ2nryJ4XdCKV5yLVYRJUF8z5mpBlLbIyv+R5Slgz0R7NfttQwK/1qbrv7HHhUeO8M0zRM4FzjtHmFlsPtOBVPi4cGphdy+6jXF7czA==; 20:tyGgK+pscLamccuuzsu2AerzzVgkoQNr5E/RcppNBi9SR19FvkeAVqHF6PG6YDQtpBI9sCz8ugfu+58mzTegzNGBrw7llWwwBpjXjzEm4Guqat0LoptpvyaxX7ZJQxcJmQ3/cOT05wfhTEuj4Q3xbEadA4uKVDv6bzDS0310Vp44aaQu31C953nSyS7mR8/jcCCj1KHYLQHN8ZrTCbIjd9O2Oo24bWViCzYjeiOuKwTapqtnOy1xX84G4t4021gn X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2017 15:17:58.2322 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1601 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: <kvm.vger.kernel.org> X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP |
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 62c2b22..c108064 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -5921,6 +5921,38 @@ static int sev_launch_update_data(struct kvm *kvm, struct kvm_sev_cmd *argp) return ret; } +static int sev_launch_finish(struct kvm *kvm, struct kvm_sev_cmd *argp) +{ + int i, ret; + struct sev_data_launch_finish *data; + struct kvm_vcpu *vcpu; + + if (!sev_guest(kvm)) + return -EINVAL; + + data = kzalloc(sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + /* launch finish */ + data->handle = sev_get_handle(kvm); + ret = sev_issue_cmd(kvm, SEV_CMD_LAUNCH_FINISH, data, &argp->error); + if (ret) + goto err_1; + + /* Iterate through each vcpus and set SEV KVM_SEV_FEATURE bit in + * KVM_CPUID_FEATURE to indicate that SEV is enabled on this vcpu + */ + kvm_for_each_vcpu(i, vcpu, kvm) { + sev_init_vmcb(to_svm(vcpu)); + svm_cpuid_update(vcpu); + } + +err_1: + kfree(data); + return ret; +} + static int amd_memory_encryption_cmd(struct kvm *kvm, void __user *argp) { int r = -ENOTTY; @@ -5940,6 +5972,10 @@ static int amd_memory_encryption_cmd(struct kvm *kvm, void __user *argp) r = sev_launch_update_data(kvm, &sev_cmd); break; } + case KVM_SEV_LAUNCH_FINISH: { + r = sev_launch_finish(kvm, &sev_cmd); + break; + } default: break; }
The command is used for finializing the SEV guest launch process. Signed-off-by: Brijesh Singh <brijesh.singh@amd.com> --- arch/x86/kvm/svm.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)