From patchwork Sat Oct 7 01:06:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 9991009 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 0AD6160244 for ; Sat, 7 Oct 2017 01:07:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F18EA28B20 for ; Sat, 7 Oct 2017 01:07:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E659228DAF; Sat, 7 Oct 2017 01:07:27 +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 6099A28B20 for ; Sat, 7 Oct 2017 01:07:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753156AbdJGBGg (ORCPT ); Fri, 6 Oct 2017 21:06:36 -0400 Received: from mail-sn1nam01on0081.outbound.protection.outlook.com ([104.47.32.81]:49120 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753136AbdJGBG2 (ORCPT ); Fri, 6 Oct 2017 21:06:28 -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=Ovw6YTApxAX6yoBit5OdNWiArxYQCEWMItUlwlq36LY=; b=rvGwW8J0QDaL36hY4D8+PpZsyIOYFMOjeFqKSvnKJUH0blWTVyzW4trdyHdMFUrLHkBWdN1e2ySAFyl0dxoRtGRIh2G/JVUWeONlG3jc5WmltWep5oj1SLgAJZGEYphDXoYICYCFCVUBi4gE2h4CFMtJPDOXlq430dQ1bmwhfJI= 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.77.7; Sat, 7 Oct 2017 01:06:22 +0000 From: Brijesh Singh To: bp@suse.de Cc: Brijesh Singh , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Herbert Xu , Gary Hook , Tom Lendacky , linux-crypto@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [Part2 PATCH v5.1 12.6/31] crypto: ccp: Implement SEV_PDH_GEN ioctl command Date: Fri, 6 Oct 2017 20:06:04 -0500 Message-Id: <20171007010607.78088-6-brijesh.singh@amd.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171007010607.78088-1-brijesh.singh@amd.com> References: <20171004131412.13038-13-brijesh.singh@amd.com> <20171007010607.78088-1-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: DM3PR12CA0085.namprd12.prod.outlook.com (10.161.151.157) To CY1PR12MB0150.namprd12.prod.outlook.com (10.161.173.20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4ed00fdb-93f0-44e6-abaf-08d50d1fa03a X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254152)(48565401081)(2017052603199)(201703131423075)(201703031133081)(201702281549075); SRVR:CY1PR12MB0150; X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0150; 3:Kq92jQlfb+gKypJ3JDpquqLsjOGTw6CXTZ1+uDv3t50DIeKvX7bO5TXYxx0E1VfoUHWeawRxS6XZ68y4xn7c/dS8StYq3p9F4EkXgvj/Eu9QytWkBrZD97B4DMnM0yksRyP5KGcaW+Waie5d43AGurrdVhnsAob+OPJ/dIYzkgD1cTOwnmDoOWnIypmygZwg3Jgf7tuNaXizcIgwtbxqhoUhaMKxVtdGP49J3HxWoQtjbW3T+UDn8I5E1lqzdyIb; 25:XCptxvL+d2ENDzpab9r7eP20pWvmL9P6ASsT+wwaBL88eSF7GXL3XFMijt4ihEBlzlBBLK1taDBqL4onwQPTnsl/Dd/Gk5DNGwHQdcwlyODHKKPj1e4cRA49IUe1hIicgmXxsqFUgU2EENjDpiSZhSPbsIreXErvxxgBzRySA5kg3MHhY0MumRTG09lcPYSNhnyzwyjYLXIyDvDLhzkaCUNwBMLIHprqTTJB8zC8QQe0ToiSO+kCDhkupzECSYlMTarbxYEUZUNrGb1dyBaX/SglOGurU699OnWGymjJgjrdbUtmCc+ZyLXwuAcwlXAZdIDW9UV49C8Yu5XJDXEcNw==; 31:BZFEYN0yFznSkL4vtNDkC8WJ3zaM9MiljvxBRMJf2lcS5nGh1KAkKGoBMhkYU9cF82FNZCGmuR9jSpNslb3d8C9t2VQPhwUF3AcTd+tgKlVidP2dDD5FqHlY7dMC5Vr0KtugsHJq8IV1bF5sv3tw63lWlRWPTmoI1uY0KCN1LQ3gGJwUI9uk6QrMiHKtNyqtbJSeoAdL9iz85t5HYokIPjCG40EX/ud3yEAL47IQabU= X-MS-TrafficTypeDiagnostic: CY1PR12MB0150: X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0150; 20:I2cAnfBWcFkXh6bmWj4GvEj/uWKTc7BKd8NL/pUQc2ma4JpHMU8bEqAZkgjLnE7sEVRunPm3xyehcjEJR9oBw0GCgtLtX843Vsc64OA1OoS1tm6PY83aUPf9bMOPHcyzRdPmU35tTRGL6v+MxAj9KkuIFCpS9XDJby78yvv4hyiR+YmbPJH2R6EgoqW79VpFpqDKh6zcl7jgK3EtkaeABF/HnwazF/6pwVsevSAn78w3hxsLAN3qAlDg2ZuHeszQD4Ut4xBZMoMAGH2nSpzon3pzf1PgaKaI9Qkra+7P5YRZgsF5K8lDaFYpfjtSfLbh9iT4zNPg6JNQOHdv0giI0LDTsj/GutjX3i9yWdlMNWs8BnnSZV5VqyM6HSJQipGO52D34jpxrIBYAAnOp/ExKVeTlVtPEoP6ekw5+mCMCYNRbrPmlcSw5M2Bdzp2IJ26MjvNzxi/p5Xpm+gEI5gaKqGgXqC2ukuP/iAWgHo2zHinsSqvIz15z2rG/ztDLctR; 4:HPr+GFah/5WbKpc49IQ5CGlV7SDsTpm0udeeNbozr1ddUMFFBYQjF7P8dkPKkeRNLzcWC7SpR8LRp1wsPUx5AypWUI/QTGBf4RYjH5GwBabFOs6zCskW5f40x7urH34WG1WOUSaiyOfiDgoPEpCM3kqCax8U6LblACOJKDAvQU2mZgjdiGbZd2szIcIpQ1nX3mwNzj72qwzMbJZ3csjtvX9sxPYISsBvApHFdpXDQiEFNsBLhL4tKAbTMZRWb2zaEQBM0ltQps08Bbv9sgHW58unsgFG60g8sgBxje3YhFbzMtdD12XFx80WKz2nBcGD 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)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3002001)(100000703101)(100105400095)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123555025)(20161123558100)(20161123562025)(20161123564025)(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: 045315E1EE X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(376002)(346002)(5423002)(199003)(189002)(6916009)(53936002)(316002)(50466002)(36756003)(6486002)(25786009)(4326008)(2351001)(16526018)(478600001)(5660300001)(2870700001)(2361001)(2906002)(47776003)(54906003)(53416004)(6666003)(86362001)(76176999)(6116002)(106356001)(3846002)(105586002)(66066001)(81156014)(50226002)(68736007)(101416001)(8676002)(97736004)(305945005)(1076002)(33646002)(23676002)(50986999)(8936002)(189998001)(2950100002)(7736002)(81166006); 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?MTtDWTFQUjEyTUIwMTUwOzIzOnRmRGd3dUIwTnhZcVl3K1BYUFYrVkIvT29z?= =?utf-8?B?a2hLMTA4SnBZTUE5ODRvcHQ4WDgyL20ydW0yaWpKT3Z3QlZMbys0YjdzdWR0?= =?utf-8?B?b1ZqMWRranZYT29RRUFHY2dUeDRrWk5VWkpKc3lKcThwbkV2b09kaVdlSWtQ?= =?utf-8?B?YnN1WGFIcisxbjJBcjVvMFVncENCRTdUYzdwS3kvUGRPNHlDU25Rd0QydHBF?= =?utf-8?B?SWhtS2ZmOERIQTQ2TlUyRU1RT0t4WmZoY1FUamJFem51WkxKd3lMMCs1aFor?= =?utf-8?B?eVpIYU4vQk4yZzJTUS81T2krUUNVRkY3d1RiVG8wUkJhZU80M1JsTTR1VmVC?= =?utf-8?B?dFpucDR6LzNNZkZxL0ZJam85eHNNN2E1S3FvSVZ3R1B5Sms5OW5NVlR1TnIy?= =?utf-8?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DnkfISZYzrhrMPH/m6i+doS0iy1pamQGygSQRI8EZRlbqP3B7ULGLjaJmoLoVkugIQ= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0150; 20:fs35CYI2EjEQJDxxNunh4oT2dW8KLGSMH5Me495WnEUgNQ381cZqXaKrSHGKM8oZn4V5HmvNyhKlFqdhKReUfnipXLPfeeecQ6sKzNnuVWO+uHTJWxrqkv1xOHChkxd9XuGWnOy30zWsul4YKL7IV1DBJYnFzSZ6KVPIxRCHmxnPIfAKEEE20OgKHG8dNXu60r/PZXH8dsE2w2w23rmUcdFsAxsoNjVSOadGyUCeof+inzU1IVpwyLtwY4kS1esS X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Oct 2017 01:06:22.1296 (UTC) 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_PDH_GEN command is used to re-generate the Platform Diffie-Hellman (PDH) key. The command is defined in SEV spec section 5.9. 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 Signed-off-by: Brijesh Singh --- drivers/crypto/ccp/psp-dev.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c index 03d7bd03ad58..28efb7a9245a 100644 --- a/drivers/crypto/ccp/psp-dev.c +++ b/drivers/crypto/ccp/psp-dev.c @@ -271,6 +271,34 @@ static int sev_ioctl_pek_gen(struct sev_issue_cmd *argp) return ret; } +static int sev_ioctl_pdh_gen(struct sev_issue_cmd *argp) +{ + int ret, state, do_shutdown = 0; + + /* + * PDH_GEN command can be issued when platform is in INIT or WORKING + * state. If we are in UNINIT state then transition in INIT state + * before issuing the command. + */ + ret = sev_platform_get_state(&state, &argp->error); + if (ret) + return ret; + + if (state == SEV_STATE_UNINIT) { + ret = sev_firmware_init(&argp->error); + if (ret) + return ret; + do_shutdown = 1; + } + + ret = sev_handle_cmd(SEV_CMD_PDH_GEN, 0, &argp->error); + + if (do_shutdown) + sev_handle_cmd(SEV_CMD_SHUTDOWN, 0, NULL); + + return ret; +} + static long sev_ioctl(struct file *file, unsigned int ioctl, unsigned long arg) { void __user *argp = (void __user *)arg; @@ -300,6 +328,10 @@ static long sev_ioctl(struct file *file, unsigned int ioctl, unsigned long arg) ret = sev_ioctl_pek_gen(&input); break; } + case SEV_PDH_GEN: { + ret = sev_ioctl_pdh_gen(&input); + break; + } default: ret = -EINVAL; break;