Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754380AbdGXUJE (ORCPT ); Mon, 24 Jul 2017 16:09:04 -0400 Received: from mail-by2nam01on0059.outbound.protection.outlook.com ([104.47.34.59]:4032 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753127AbdGXUGS (ORCPT ); Mon, 24 Jul 2017 16:06:18 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: linux-kernel@vger.kernel.org, x86@kernel.org, kvm@vger.kernel.org Cc: Thomas Gleixner , Borislav Petkov , Joerg Roedel , "Michael S . Tsirkin" , Paolo Bonzini , =?UTF-8?q?=5C=22Radim=20Kr=C4=8Dm=C3=A1=C5=99=5C=22?= , Tom Lendacky , Brijesh Singh Subject: [RFC Part2 PATCH v3 15/26] KVM: SVM: Add support for SEV LAUNCH_START command Date: Mon, 24 Jul 2017 15:02:52 -0500 Message-Id: <20170724200303.12197-16-brijesh.singh@amd.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170724200303.12197-1-brijesh.singh@amd.com> References: <20170724200303.12197-1-brijesh.singh@amd.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: DM3PR12CA0049.namprd12.prod.outlook.com (10.161.151.17) To BY2PR12MB0145.namprd12.prod.outlook.com (10.162.82.18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d21b8972-56e9-41ee-85f5-08d4d2cf13ff X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:BY2PR12MB0145; X-Microsoft-Exchange-Diagnostics: 1;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qHDQulhs+duXu1LUhGKbLFtVS22wPgjKinahmTKHcHuqbV2MNo5dyEWGvCUOpbW/Z5oY6UBdPrGiyccptmIzpkjQW81rhrF8xpU0FoHO1rQ7ZwU+MqcovdN0Pk867g3bQFzhKZQZ/1kU53yfWqkT9vNY8Fut0Cup8LhxIQqFP7KrfOi2m7L8Abf8k8N0s1+VBHXg/5gmdpGiKaonMVYCSt3pdIQavAp67pr+GPM9a6GFME5zAWmQPOigQ0ooVcD4ubxtYnPVlz/u75KxfW4xNPr9i4G0cI8e+vNy3XJYM7g8FBkLFaHCzllphq/142+f3QeyCCEf4Xl3XLG/jyAte3OSFh3u3/4jPt+S5/9EAhoxPRndpgCie/IkiU= X-Microsoft-Exchange-Diagnostics: 1;BY2PR12MB0145;20:h8yAZUIQx2cSBh3Wny5sjOqNTynHQf8Q61Gyin7X6xJ1sV3f8LDsnX4POXZVzlUmEljyCY+TpV2juQbgQUWk1FQVlF7G8U4zalI/XhpuoNKxbtHxiDWAPpvoucDH819o1UibZ3yCfqDiMX6C/3ov752h6pl9NsTfoTH+Xypw3M104az4n2Jb1j3Hkq2EaH+5jN+3H8/ODwDAxIa7q2MJ2e6Otk9MdmCC00mwqdOC5mLSbicNsB5EKp01xmDUz5W7e0GmYwKqx/8J+vX/NDOM3LpW3hSfGulVIjSQRhAORE6siPONVylq1MjpSrpjV36V4li5w8YfqYnYSxk0Nw3ZibI5C1uVcJxNptSafx4MhiLPcpU1WzIAAm7jIGbq/oMjPgWfO+co+kubpM9kvAQ3oYQiFaSxB5hHs7IGvIgUrzxLpyWoa+onnxjtrC8qBztRayzq5X++fjm0XtAxrHTIxhDPJBjwWpilnVRMMaIQQG8mSERfaVDhejJriWB8Si51 X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(3002001)(93006095)(93001095)(100000703101)(100105400095)(10201501046)(6055026)(6041248)(20161123562025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123564025)(20161123555025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:BY2PR12MB0145;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:BY2PR12MB0145; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY2PR12MB0145;4:vxinPhiZjogizu2gwUBrTH7VrMVGcltttTUfN1jxrk?= =?us-ascii?Q?GBgH2ITALO8lVbzwfzHRnXrjIdZ9zixKkqCfXYWUuTmLCLTlDNDB4KwAKiAt?= =?us-ascii?Q?8E2oasTWfOSLzn1p/hwWUnT8Zv2SmPVRntsDtkX2eHmAUDnAOZWXypsvIvtl?= =?us-ascii?Q?wlcVdCYM7XP6aY1OFjdykcWuecl4d6DsHul1RyGOW7PNJgq7OMHWuP5A9eGx?= =?us-ascii?Q?VE2ajE4LAMPnm/zuVFDysbJN+ZeyjW4dLlth5YPqXYdXhF+xcZ7tKqEkBxat?= =?us-ascii?Q?Jlpp0Cff+7fRXnSv+SlIOISm/k9tLgh1U6pVNHt2/tHq9KEhQPhb7hb/oSeB?= =?us-ascii?Q?Ogi8jjzHk0kE1Y5Jil9Z+MbNXwa4X15EEQmzAP8zSDA3sfotGMu/7wGJLY5J?= =?us-ascii?Q?o78njtCZ+92ha2W90C4sCiciE6Q9cPP0bW/tDHRSGSjvsZxNfwJQ671zx7uR?= =?us-ascii?Q?foCwWjh0MyJXJkrT8NvGYaJzJ+ETweLzV+QO8n6hm05KphOGOwbCu16C8OEO?= =?us-ascii?Q?lzPb/48LpUhq6ghNXsb/wORTFNIwZkG7EB3Ix+gNJ4OtveBVfo5TN0Vp81tO?= =?us-ascii?Q?8WBLNMhBvrs2FYHd/0goFeeyyxfHMLHRH5kGYuycwF/jbNnOY0hhz76sUfrh?= =?us-ascii?Q?+4o5DnYVBpPMJN1iaGNi/9KohuC3Co/moebneNYQJlnZHuBvCRYzrrCzqGaO?= =?us-ascii?Q?LbDrpUfA6Xa7jBVZUc8HwQNHWpCOlyhoVQ9b+6DJYpXYffuw+LfQDrFE7M/C?= =?us-ascii?Q?Sha9iYB46pBNpZt0LrCBXQ98tiFQ9EX7iAFcNQH2aEd0MmY2C5FMAFPDopgt?= =?us-ascii?Q?DD7mnO0Uvm1cbLuHPdAYKEtT6jlNuNIfckLlSht7PwASw/jkJnMxYIg4IIeQ?= =?us-ascii?Q?p81JAMvtlnivjlvRak5aX0waGawbfV0RkVHoruIh9P6FPnPoH4u5k4bDCqs7?= =?us-ascii?Q?wDk9QFtExGYyUpyK7ZtbHvX6BD6bDdfYX5X/rHVl3CalNxscmFdDb6LP+6ZQ?= =?us-ascii?Q?h6a3QbwG7vOP8ps2PuYFzwYrCA38dxoNqa4U0ddimn88XmnB5/CIFENss7hI?= =?us-ascii?Q?QhcDioM7t0OzZDBYRgyN1zfaAUQa+SazRToss+fCcR386g1craxj+7wmlgvP?= =?us-ascii?Q?KoiZtlEQNdwCB4yryCuJnwCcozRtQ4GNDjhK3olAIWFZswQNBgMW8JqiCoYy?= =?us-ascii?Q?opQ/U5apC8g2w75dZIpuIbEkD0r1D8W5yA?= X-Forefront-PRVS: 0378F1E47A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(7370300001)(6009001)(39450400003)(39410400002)(39400400002)(39850400002)(39860400002)(39840400002)(189002)(199003)(7350300001)(68736007)(53416004)(105586002)(54906002)(97736004)(50466002)(6486002)(48376002)(2906002)(106356001)(33646002)(6116002)(1076002)(53936002)(3846002)(189998001)(101416001)(6666003)(2950100002)(478600001)(50986999)(76176999)(81156014)(50226002)(38730400002)(47776003)(5003940100001)(86362001)(25786009)(4326008)(36756003)(42186005)(8676002)(81166006)(110136004)(5660300001)(66066001)(7736002)(305945005);DIR:OUT;SFP:1101;SCL:1;SRVR:BY2PR12MB0145;H:ubuntu-010236106000.amd.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY2PR12MB0145;23:9G+/rTs22YdJ7r8sUbKUri2oh7X9/N867fmvx6Q4j?= =?us-ascii?Q?y2SaXkM7kNWtrFTWkc4mVahk8F6FEQGIc9OFYeOUP3epSajX1P8q674R6Q1/?= =?us-ascii?Q?m6S5GK4eWaGkavlywBIe0gbJf8hAQdYnEhv8Mh6e4AG33UwaVfyn+7Xbd20u?= =?us-ascii?Q?jh1Z6ehZNNIgJuNN9IK+sTFDyf03/r4WQ+J/PhZk41PQBBmL5dOHiSwlG8xq?= =?us-ascii?Q?x8uBDfuIbodjige38JvYmscOs5VfEqnY24TXCuxCpL6SQNKNTYktc3YEHvZR?= =?us-ascii?Q?fTQZG+chrhHSRE6Nm8ivp7WL46rPpVAwL3L5hjhR3kHd4fco84Xq2uIe4rHh?= =?us-ascii?Q?+5SUVyLKmqg70xFrdcuK5HKt3F+5O5HoPiFJd3cTCrUvepjIMHrtxyVfiihy?= =?us-ascii?Q?Of896zUvSQCXQ9Zd0hXr1GriR+Y9y/qRs3pI0lwisRNC5ipw8T+aEbAw6nnU?= =?us-ascii?Q?n5QuZOIDbXOQZ3LgDIDod8iqWiz6sDt0ExBdTM0HPsa3t9mWEM+QmI0RgJNX?= =?us-ascii?Q?cVMnesM5byT+Av/AbeaPLWUHLP4a4vtBlKzjGlUEit6mpGlJyxAdYnB8UC4M?= =?us-ascii?Q?69mL8SKIb2cC+D4O0h2vxYRThDMETbCuTb3pMqV+pRtlFlwk5UgkrSuEa+nt?= =?us-ascii?Q?cSs+zg/Cnh3gQPJ3LcKWFfh9YuTJfxSyeGo0qhPn9ea1OCGIvGlQ+tTQtXbF?= =?us-ascii?Q?zO5IS4Pjd93BHZ135J0+8et3AvP5y+hzHHOUxRc0TGSzw1t5fI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FrCsGW9pTGMIfAsLMLDqF7eVcvIpP8SHQUB0nYlF64G7Q/t37D7DISldPs5TrMRQLxsSyIqQ39EdFdBzDNbMvrsYsBSXH4Qhmqr9577La+Xpmnd52cDxjBEXYzIk1CqtNiW2bSTKXVJ84Tdt1b+0i58EtY9goP823unowP93Pxzh3iYvbez9wa/Hvq4scGB+iKaiZHTbkjb1LddiC8UnCNREajdFtjV1xmPoxngnD1/iwBJ32BSsAZho76GqFc6VIALnv7t00AhvBMKhXorDgJ4BwIDHTjlONI= X-Microsoft-Exchange-Diagnostics: 1;BY2PR12MB0145;20:l8l1gMcYg0HGpswZRSuWLi5mmIXBf4/vCUSaE702jyUul9/i2wh/tT8FNIkE1Luh0qruEw/MgfK7g4ixoA6yLTh5bMksF+KUdMeFJ9ynkqRoiZ4yQXGm9BqlkpC0Q0i78vQ51PlUnOd1FU5Lb2rCrD23hOG8ifk99uBQ5lM7EQ0bEwrSYtG05zY06SFHadhGcVg0YENjx/FBglaS508fLbi7eqsMSBRWjXJmye5pzfkepcupwpjxFvy4m0k+f257 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2017 20:03:39.1971 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR12MB0145 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5033 Lines: 208 The command is used to bootstrap SEV guest from unencrypted boot images. The command creates a new VM encryption key (VEK) using the guest owner's policy, public DH certificates, and session information. Signed-off-by: Brijesh Singh --- arch/x86/kvm/svm.c | 165 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 165 insertions(+) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 72f7c27..3e325578 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -329,6 +329,8 @@ static unsigned int max_sev_asid; static unsigned long *sev_asid_bitmap; static int sev_asid_new(void); static void sev_asid_free(int asid); +static void sev_deactivate_handle(struct kvm *kvm, int *error); +static void sev_decommission_handle(struct kvm *kvm, int *error); static bool svm_sev_enabled(void) { @@ -1565,6 +1567,12 @@ static void sev_vm_destroy(struct kvm *kvm) if (!sev_guest(kvm)) return; + /* release the firmware resources for this guest */ + if (sev_get_handle(kvm)) { + sev_deactivate_handle(kvm, &error); + sev_decommission_handle(kvm, &error); + } + sev_asid_free(sev_get_asid(kvm)); sev_firmware_uninit(); } @@ -5635,6 +5643,159 @@ static int sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp) return ret; } +static int sev_issue_cmd(struct kvm *kvm, int id, void *data, int *error) +{ + int fd = sev_get_fd(kvm); + struct fd f; + int ret; + + f = fdget(fd); + if (!f.file) + return -EBADF; + + ret = sev_issue_cmd_external_user(f.file, id, data, error); + fdput(f); + + return ret; +} + +static void sev_decommission_handle(struct kvm *kvm, int *error) +{ + struct sev_data_decommission *data; + + data = kzalloc(sizeof(*data), GFP_KERNEL); + if (!data) + return; + + data->handle = sev_get_handle(kvm); + sev_guest_decommission(data, error); + kfree(data); +} + +static void sev_deactivate_handle(struct kvm *kvm, int *error) +{ + struct sev_data_deactivate *data; + int ret; + + data = kzalloc(sizeof(*data), GFP_KERNEL); + if (!data) + return; + + data->handle = sev_get_handle(kvm); + ret = sev_guest_deactivate(data, error); + if (ret) + goto e_free; + + wbinvd_on_all_cpus(); + + sev_guest_df_flush(error); +e_free: + kfree(data); +} + +static int sev_activate_asid(struct kvm *kvm, unsigned int handle, int *error) +{ + struct sev_data_activate *data; + int asid = sev_get_asid(kvm); + int ret; + + wbinvd_on_all_cpus(); + + ret = sev_guest_df_flush(error); + if (ret) + return ret; + + data = kzalloc(sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + data->handle = handle; + data->asid = asid; + ret = sev_guest_activate(data, error); + if (ret) + goto e_err; + + sev_set_handle(kvm, handle); +e_err: + kfree(data); + return ret; +} + +static int sev_launch_start(struct kvm *kvm, struct kvm_sev_cmd *argp) +{ + struct sev_data_launch_start *start = NULL; + struct kvm_sev_launch_start params; + void *dh_cert_addr = NULL; + void *session_addr = NULL; + int *error = &argp->error; + int ret; + + if (!sev_guest(kvm)) + return -ENOTTY; + + ret = -EFAULT; + if (copy_from_user(¶ms, (void *)argp->data, + sizeof(struct kvm_sev_launch_start))) + goto e_free; + + ret = -ENOMEM; + start = kzalloc(sizeof(*start), GFP_KERNEL); + if (!start) + goto e_free; + + /* Bit 15:6 reserved, must be 0 */ + start->policy = params.policy & ~0xffc0; + + if (params.dh_cert_length && params.dh_cert_address) { + ret = -ENOMEM; + dh_cert_addr = kmalloc(params.dh_cert_length, GFP_KERNEL); + if (!dh_cert_addr) + goto e_free; + + ret = -EFAULT; + if (copy_from_user(dh_cert_addr, (void *)params.dh_cert_address, + params.dh_cert_length)) + goto e_free; + + start->dh_cert_address = __sme_set(__pa(dh_cert_addr)); + start->dh_cert_length = params.dh_cert_length; + } + + if (params.session_length && params.session_address) { + ret = -ENOMEM; + session_addr = kmalloc(params.session_length, GFP_KERNEL); + if (!session_addr) + goto e_free; + + ret = -EFAULT; + if (copy_from_user(session_addr, (void *)params.session_address, + params.session_length)) + goto e_free; + + start->session_address = __sme_set(__pa(session_addr)); + start->session_length = params.session_length; + } + + start->handle = params.handle; + ret = sev_issue_cmd(kvm, SEV_CMD_LAUNCH_START, start, error); + if (ret) + goto e_free; + + ret = sev_activate_asid(kvm, start->handle, error); + if (ret) + goto e_free; + + params.handle = start->handle; + if (copy_to_user((void *) argp->data, ¶ms, + sizeof(struct kvm_sev_launch_start))) + ret = -EFAULT; +e_free: + kfree(dh_cert_addr); + kfree(session_addr); + kfree(start); + return ret; +} + static int svm_memory_encryption_op(struct kvm *kvm, void __user *argp) { struct kvm_sev_cmd sev_cmd; @@ -5650,6 +5811,10 @@ static int svm_memory_encryption_op(struct kvm *kvm, void __user *argp) r = sev_guest_init(kvm, &sev_cmd); break; } + case KVM_SEV_LAUNCH_START: { + r = sev_launch_start(kvm, &sev_cmd); + break; + } default: break; } -- 2.9.4