From patchwork Mon Oct 30 03:13:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 10031941 X-Patchwork-Delegate: herbert@gondor.apana.org.au 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 F03A5603FF for ; Mon, 30 Oct 2017 03:15:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFB1A28675 for ; Mon, 30 Oct 2017 03:15:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C44DB2018E; Mon, 30 Oct 2017 03:15:01 +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 3D8CF2018E for ; Mon, 30 Oct 2017 03:15:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752042AbdJ3DOg (ORCPT ); Sun, 29 Oct 2017 23:14:36 -0400 Received: from mail-sn1nam01on0080.outbound.protection.outlook.com ([104.47.32.80]:36192 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751673AbdJ3DOe (ORCPT ); Sun, 29 Oct 2017 23:14:34 -0400 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=EBiie/3aRfJdp0k3udLpF68LNOZnXQPndaUBfhOgzyk=; b=Ffe7CQrjTnpvJINto9S5F6fYvK4A0dvLk5EbV3jKwY2Izz531N8b0CNhlzqpGWjBOyfWkTSU8Vsi9oZI9EyjRbE9NGM+sk6qkSvhqcHy/yJ8L3dkoWbEsaev87elNacB6iXpcq22ZWcpt3d5WeP1rvwSXCJt9kfupBIgZlmh1ik= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from ubuntu-010236106000.amd.com (165.204.78.1) by CY1PR12MB0150.namprd12.prod.outlook.com (10.161.173.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.178.6; Mon, 30 Oct 2017 03:14:30 +0000 From: Brijesh Singh To: bp@alien8.de Cc: Brijesh Singh , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Borislav Petkov , Herbert Xu , Gary Hook , Tom Lendacky , linux-crypto@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [Part2 PATCH v6.1 15/38] crypto: ccp: Implement SEV_PEK_GEN ioctl command Date: Sun, 29 Oct 2017 22:13:18 -0500 Message-Id: <20171030031318.19055-1-brijesh.singh@amd.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171020023413.122280-16-brijesh.singh@amd.com> References: <20171020023413.122280-16-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: BN6PR18CA0015.namprd18.prod.outlook.com (10.175.188.25) To CY1PR12MB0150.namprd12.prod.outlook.com (10.161.173.20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 86a3a58c-2986-48f4-a8bc-08d51f4456c7 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(4534020)(4602075)(48565401081)(2017052603199); SRVR:CY1PR12MB0150;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OD6/LmrBYwm55Ci0Bx1agwAWnVMoKt2iJNP/v9fHFLVF2TBxhN8laFdrYFyLgECLylAmaYOyjb/tK+sw1nXDC70O5y0AzKdxdLS4qJzYFaSJLCKWTxTh9LNFGu/V82aFFhIbPYkUstE1xAuF/PLc9w4w5VjgyhfkeQtPxpamoZuYsc7wTmHb1R189WV8RCf8dsl/0Txc1WQT7vVBgANwXrWPyuPQleigv+IXOK7O9yVVJKw1VslP4mMnwEibgtIn7MBTxYxECYfssD5lltKgrmhCBLBWmGk03oJBvvcag+QGvh3MdpgpKMv999FSmy5qbhwKVV9DSwbpB/XHk6juJrCV29IXmK51S42nnDmj5YqUPcYXsIqjMhq7MtYBoAHwny8rQxXMz2dL8; 4:UETTt3/ud55QRmSu4A3uIePO+4N/TgGnjIavYe7wsU93+ClZ+qUDWy62g7iQfBYJ8Dg1Fv/Tm5orEOVx7l0kCzbjPA0XVjd5zRJstm9lWStoLubMskrXzzvs03Z2QZ7jrWzuPAMMEZgonc4i1pbFGPkmMveVMlgD+wxqGvV//hJ+ycMX9IZ0gitQYqjN5MqIZ+X/udJf5mTun4T/bGcm5HqnnEDT1gwk7sszOCFYXP+P2JsQvds2t5UCa0FUYqaO9lfXAeSC/2fybb2fTobhQyyP7L53cDEt8f0ww3fqF+tXOt9cKH5k+CWexX0W0CvQ3NcivxdOEejqS+xz1xSVtA== X-Exchange-Antispam-Report-Test: UriScan:(9452136761055)(767451399110); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(3002001)(10201501046)(100000703101)(100105400095)(93006095)(93001095)(3231020)(6055026)(6041248)(20161123560025)(20161123555025)(20161123558100)(20161123564025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:CY1PR12MB0150; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:CY1PR12MB0150; X-Forefront-PRVS: 0476D4AB88 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(39860400002)(376002)(346002)(199003)(189002)(68736007)(2361001)(189998001)(2351001)(16526018)(105586002)(53416004)(106356001)(101416001)(2870700001)(25786009)(8676002)(76176999)(316002)(81166006)(81156014)(478600001)(97736004)(47776003)(53936002)(7736002)(54906003)(23676002)(305945005)(6486002)(50226002)(6116002)(66066001)(4326008)(5660300001)(33646002)(50986999)(8936002)(6666003)(2950100002)(6916009)(2906002)(50466002)(3846002)(1076002)(36756003)(86362001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR12MB0150; H:ubuntu-010236106000.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDWTFQUjEyTUIwMTUwOzIzOkVzc0VXdjVKV3lJbk9qMXQ5YlFQcGJxRWlC?= =?utf-8?B?RUZnbUlZTWJacHhUdFlSTUJoMk1GNHpSN2svRk9uZ0grbnNVb2pFajVGVElG?= =?utf-8?B?TFFucGU4YXJGckI4a1B3T2g1WmZ3cTFzTnB6bWtmbWUwUm8wYmpLOWU1RFZ1?= =?utf-8?B?ejVUNlFBQk12bzBSSXdWQlRTM2szOVBoZGttOTRHaS9aWmNWSnJFRzBxR1ZY?= =?utf-8?B?eWtTN1A1d3pDRTFVRE5nbnZVS250c1pRNlpEN1JpWHV5Nm9qM0NwKzVGd25E?= =?utf-8?B?VlppYTFvTWtIVGI1VVpHWXRRU3ZkSE9MYWUzV21DYldLMjVURjdpcWxQckZN?= =?utf-8?B?UUhNMlVJbFlJTkdtVWZaU1VqNUpUL0QyUlRiZjVxeDNCL3ZoSUhyb0xWZzlq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DLdON3DN36Wm987VGozdlKjE2bjbiHJWOqz3CHHlT4zxEphLJM6Lavt5lQHiXGlDdqDHxJV8G3SRMiGIxOmD8Je99yARh4J7sIDV4ycFpGe3fWVjGLWRuP8Ph3qxg1VFN5Nkn9oeo/rF+XrZ0fj+S3g+0Me3yF2E SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0150; 20:/y87y3MBPG/2qWH3SSZrwA8XKEE2KiCTEk4cy2qkoasxMa7M9o9h5CQm5FoA3o6Sf3J+4Lt+ODgvHDH59xAPCy1WLa38zXor46q9YiGmxQpzgFeWJBRpwU6g95ZZjoQbY7IEygKmE1MWUUBPhTjfkNG6xK9hQvGRKnOIRoat2klDX+4shkBAnjn/SLq2S8edJhtvS3J+MMD90G8XanYD7SP4CJKWdhSP6StlngapvlLl1QmiyAqiHpUPvyxgAlHc X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2017 03:14:30.5393 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 86a3a58c-2986-48f4-a8bc-08d51f4456c7 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR12MB0150 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The SEV_PEK_GEN command is used to generate a new Platform Endorsement Key (PEK). The command is defined in SEV spec section 5.6. Cc: Paolo Bonzini Cc: "Radim Krčmář" Cc: Borislav Petkov Cc: Herbert Xu Cc: Gary Hook Cc: Tom Lendacky Cc: linux-crypto@vger.kernel.org Cc: kvm@vger.kernel.org Cc: linux-kernel@vger.kernel.org Reviewed-by: Borislav Petkov Improvements-by: Borislav Petkov Signed-off-by: Brijesh Singh Acked-by: Gary R Hook --- Boris, I had your R-b in v6 and have kept it. The changes in this patch are very minor. Let me know if you are okay with it - thanks Changes since v6: * use psp->sev_state to check if FW is in correct state before doing the INIT transition drivers/crypto/ccp/psp-dev.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c index 24a970809ded..53fbbc41b521 100644 --- a/drivers/crypto/ccp/psp-dev.c +++ b/drivers/crypto/ccp/psp-dev.c @@ -240,6 +240,19 @@ static int sev_ioctl_do_platform_status(struct sev_issue_cmd *argp) return ret; } +static int sev_ioctl_do_pek_pdh_gen(int cmd, struct sev_issue_cmd *argp) +{ + int rc; + + if (psp_master->sev_state == SEV_STATE_UNINIT) { + rc = sev_platform_init_locked(NULL, &argp->error); + if (rc) + return rc; + } + + return sev_do_cmd_locked(cmd, 0, &argp->error); +} + static long sev_ioctl(struct file *file, unsigned int ioctl, unsigned long arg) { void __user *argp = (void __user *)arg; @@ -268,6 +281,9 @@ static long sev_ioctl(struct file *file, unsigned int ioctl, unsigned long arg) case SEV_PLATFORM_STATUS: ret = sev_ioctl_do_platform_status(&input); break; + case SEV_PEK_GEN: + ret = sev_ioctl_do_pek_pdh_gen(SEV_CMD_PEK_GEN, &input); + break; default: ret = -EINVAL; goto out;