From patchwork Mon Nov 6 18:11:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 10044075 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 3D3A560247 for ; Mon, 6 Nov 2017 18:19:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 334142905E for ; Mon, 6 Nov 2017 18:19:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 28209290CE; Mon, 6 Nov 2017 18:19:55 +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 031012905E for ; Mon, 6 Nov 2017 18:19:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932727AbdKFSMf (ORCPT ); Mon, 6 Nov 2017 13:12:35 -0500 Received: from mail-dm3nam03on0078.outbound.protection.outlook.com ([104.47.41.78]:9872 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932700AbdKFSMa (ORCPT ); Mon, 6 Nov 2017 13:12:30 -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=zWSrc2yJmEapgymghxYFxUD+2hBR+279kfihJ4hMbFQ=; b=HVb4QsLcWJta/s5NO31kA+kNsN2DacxkenTF/jK1NQw7t55Ri2NGCleK8lpS6eiHq1Ceb6ZP/Wtb8fDuo9eShQrUu7NnE5Sy7RI+Ptqt/waxosvH+7AGgLR82ioeAXIR4rfIyVTcyBhrxULGa2bAOtggavE3aeb8CCC2uagnHg8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from wsp141597wss.amd.com (165.204.78.1) by SN1PR12MB0159.namprd12.prod.outlook.com (10.162.3.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.197.13; Mon, 6 Nov 2017 18:12:15 +0000 From: Brijesh Singh To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: bp@alien8.de, 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 Subject: [Part2 PATCH v8 16/38] crypto: ccp: Implement SEV_PEK_GEN ioctl command Date: Mon, 6 Nov 2017 12:11:08 -0600 Message-Id: <20171106181130.68491-17-brijesh.singh@amd.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171106181130.68491-1-brijesh.singh@amd.com> References: <20171106181130.68491-1-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: BN6PR10CA0031.namprd10.prod.outlook.com (10.175.102.145) To SN1PR12MB0159.namprd12.prod.outlook.com (10.162.3.146) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 82ef3c00-102b-4ee1-66da-08d52541e97a X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(48565401081)(2017052603199); SRVR:SN1PR12MB0159; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0159; 3:e5HPujff29I58DgO0Da5/Mw+N3VhcK1RxNAV4Hqc24gDfJdJrCmoryu2qi1EHOBqZiHHYoCTPAC0VBcscwGCD5hpGbgvHfJhOe6XajV0C3Vx1U5oiDvPK4/zTxGoUIRii2Ig+AsOQtcvRHgIioZJT2tQ29Ahcd1g+iibXFrojWTOjP8VrqEvGJL3NPlVuWARxQne/juYkw+7xYKWdzdESWV//4bDxezV+PKvqSP/K7sLG60VgbglwlIIcpobYNFG; 25:iOgA8Eqip3jN3EfeJSQZHfozPmNqJ2dO+vXxykKz5rV5RcRWrNL1Aty64QQF/QUmgcmegPDvw+RAk8MkXTOua6db1BrFnZyiPVDKiQXwREevh9N3fn883rVrs6CYD/ud3YFVU0rp+e/EASsbklmtaOJ4+bUiH2S1XS/yQ8Yr4UcwUMOb4WZ3wWQiFOYKmcNqMbgfElZlD5tJ+BYcyMCsi1pVIeBh94bI840wPkuhjTZ63s1g5jfoQR2G16e9MQnqpm5lSpP0pX9QMvm08yyDqzsQVgO8Dihl6H7J6izcq4+bguXRoP+s+fu8t+G3cANC8raLJMWYP+bcMvFzjYe3+w==; 31:6fHtO89pbJsWHQT/ZnY05VJcSa8Q68UIHO5/t46IukqfztmGwFI1fOp9WPIcoZNegmsXmHbAYDjOko9NLabHfnkyqJcfy4GMf8BkqffP0peMY3TdHZ0PSRHj49pbftNjnrLWG9Gk4WLa+2z2R3GzNHDrc0n6HWact0d7UVIjI+2zQ3lrq7MOJu/kTydQDglwpmKUwu2HRzjsexuQBZQT0/OLTuX1d6ps/DIpcUTk4vk= X-MS-TrafficTypeDiagnostic: SN1PR12MB0159: X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0159; 20:ofJxaRWOLqgIeLOqg9jDP3+0DfGo32S4PTPz/LSkh6xdnOUee4uX2dlifYApq6Iqn3sF0aL0RP9TwXjC9xjXJ7AamEDmsu425J7LX9RslWhChHJ6cOR/yJyTXH/h43IdLgQZvMDozPcKkR3iWhFC4/7qX3oBvc66xsCXdj7p9mS6v7S3zCKuDUDnC/+8VS+ZTNl1JZ/JASMl6tjdM5POLnLEoLtLfChpf/QIu9lsMfyyqEJxicHALUfkcGhUgNkGqi3bC92qaE0imkjdssSV01sPG0pnw+FhSW9xvWzMdGL9HYf3NEDaAPrpGDFSWmt4MTRKi5nzYvuC+7FWZ0zlKDlj8S5y0xQ46p+MjHviFZdpc+PQC167ZBuXLlA1Js9+NPc7gbmxnKjza0YkgI6gZpd9CLFVIFDT2pfbxTNEafaXxl+16voaLhiIw7HUgF4M3EXEAmksSMboQUWfoqLmw2m06xXKnFnWn5FJiE/UVDSYIW4seenyWmmvVV1QLDmn; 4:uWlZy7AH9TSI4kIMK4Ye1H+S2Qact4+HivXmBRpgauincgypE6HtuLevxG4WYDz+2V0D8s01xgPcgvj9FZ3kgJdfIAYF1w1Q4fIf5L16MzeCrrRgP+UjNQoqDampfIqkcfDEaSRTy26IN24TglQNnHhIe8ONUU8XLh50m76cEAoV4y6DeZLtNSu2xvs/y7KsJ5c4+H5BJ7MFYTqKcuH6M+1uVkpztm0tGvVpa7FSYWjex5nb850LyNEbU1YaA3s4cFS7wiM5AQDTz1M3nXq/0oibKslpBgdwLJ0zZ4Hbc2RtXjWKv7p5m+Oka5MT7SHQWAlj8KkgKlyqfBKD6COV3Q== 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)(3231021)(100000703101)(100105400095)(3002001)(93006095)(93001095)(10201501046)(6055026)(6041248)(20161123564025)(20161123562025)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SN1PR12MB0159; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SN1PR12MB0159; X-Forefront-PRVS: 048396AFA0 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(346002)(376002)(39860400002)(189002)(199003)(68736007)(97736004)(4326008)(316002)(16526018)(54906003)(7736002)(8936002)(2906002)(81166006)(81156014)(25786009)(53936002)(8676002)(2870700001)(1076002)(6116002)(23676003)(50226002)(189998001)(305945005)(86362001)(3846002)(50466002)(33646002)(66066001)(36756003)(53416004)(47776003)(5660300001)(76176999)(478600001)(6486002)(105586002)(50986999)(2950100002)(101416001)(106356001)(6666003); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0159; H:wsp141597wss.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtTTjFQUjEyTUIwMTU5OzIzOmxMNnBsUHRucTRGbVowTVZoQzRUNUtrK2Fk?= =?utf-8?B?bFM0Y2sxQW9FRTRPU3Z5UWxUbTMybVFLek1sR3dtallRVHZqc3F0TnhqQjEx?= =?utf-8?B?YjlzYmFsNFMrS1k4M2MyU2QxeXBKcXdXb0lndnNXSHhON1g5enI2cmtzSUE2?= =?utf-8?B?bXdLWjZoYjYzd0RoUjAxbTRHc0ZFdjhJS0c4WEgvVzREL0o3Z2tnN2tUQ002?= =?utf-8?B?ZmJIa3ZxSzBBMmx0SWFoejJpLy9zU2pveUxJeExaNlhYMzkrZXUwS0l3T3Fv?= =?utf-8?B?a0ZQeTErNjJkWGtFTWpCN29TTDJxRXMwcDVPdkZoTVlHWXYrZHdQcm1ZVGNz?= =?utf-8?B?ay9zdnVmR1d3UUV2dytFTDJqZkw4dkk5VDhHZWhVSXc2dEN1S3FRRERCOEJn?= =?utf-8?B?TnJZTmUvcGo5Y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z2UUXSl/fnpxure67DvMbfbgsEhI+VlJ8ofzmmYOkAxAz8vpw+EDts5ws4bLiGjur0wLu SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0159; 20:vAZvCOU74XeVp7UxjSFJaPt8X8U50KquPWoUWBkg/JzEokWbigfolsAcrtx1RumUPc72D632vB+9Rcsy7U2RwpcQOV0gh9CxWsuAkidshm+WyGgz51ralpahz6RTQT2nUbzpw4p8mUroL0eGB5bdyyPT83YedlEwE6NUmajz7OikEDL54vMoepboGJ/QHRWzTuFU6vDo9OaE1/NWMmybEQ2ej8GtnFtHBYZYycIJomNcykkM8fkQ1ZwAYqDW6tcm X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2017 18:12:15.4101 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 82ef3c00-102b-4ee1-66da-08d52541e97a X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0159 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 --- 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 a5072b166ab8..8aa8036023e0 100644 --- a/drivers/crypto/ccp/psp-dev.c +++ b/drivers/crypto/ccp/psp-dev.c @@ -289,6 +289,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(&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; @@ -317,6 +330,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;