From patchwork Tue Dec 5 01:04:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 10091895 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 D5D0B60327 for ; Tue, 5 Dec 2017 01:12:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9C14294DE for ; Tue, 5 Dec 2017 01:12:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE181294F1; Tue, 5 Dec 2017 01:12:00 +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=ham 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 28F99294DE for ; Tue, 5 Dec 2017 01:12:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752229AbdLEBL6 (ORCPT ); Mon, 4 Dec 2017 20:11:58 -0500 Received: from mail-bn3nam01on0088.outbound.protection.outlook.com ([104.47.33.88]:33708 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752342AbdLEBFm (ORCPT ); Mon, 4 Dec 2017 20:05:42 -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=ek1zM3XBcMy2aR3sswJvqDh8WekbfrQdwj3WS+Sxcvt8Q/kLaJ0gqMkiH/UYZGfUVKMzkByVDZIHyEYaBatWkuSGAhDSj7XkHyyyoWcopP6yXC0zeqL7GKAooCI/4GdcnJzI5S9d2LPrvDwxT805k1I++9mIi+r2nvJxvT/CkqQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from wsp141597wss.amd.com (165.204.78.1) by CY1PR12MB0149.namprd12.prod.outlook.com (10.161.173.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.282.5; Tue, 5 Dec 2017 01:05:08 +0000 From: Brijesh Singh To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, x86@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 v9 16/38] crypto: ccp: Implement SEV_PEK_GEN ioctl command Date: Mon, 4 Dec 2017 19:04:16 -0600 Message-Id: <20171205010438.5773-17-brijesh.singh@amd.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171205010438.5773-1-brijesh.singh@amd.com> References: <20171205010438.5773-1-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: CY4PR0601CA0087.namprd06.prod.outlook.com (52.132.96.156) To CY1PR12MB0149.namprd12.prod.outlook.com (10.161.173.19) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 700fc7a3-098c-4bf3-14ad-08d53b7c3ad8 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(5600026)(4604075)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(48565401081)(2017052603286); SRVR:CY1PR12MB0149; X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0149; 3:wfQ4PVAx4mSOgbK9dMMkUcA2VsdQXJ3ehmFS8xSlr3ztD/p6FUjYg55w8y9z7Y1SIxOsPyepGW5ohbzuaHspnFWCj7Y/OunOQv6zNO/82veyZ+hFE5qXitlkan24Bso1SBJbrjgM+tUGFM4R7g8wa+Yrx3U5DHDHIi5aLBJgf1w//MfRb+5Jkceor6gvVVeDlGahV5+l+TS7jHZ0EW7QaZYdi9aRcHUiCsdSTE+RbIauFH/O/6hTFidYCReA8/zk; 25:uFXw2DhZGQukaCudCJ2HWUGnwGwMcoTWEOl1ML1jph6L3jk3UN8MC1KAJn/BboRTpOcxVR+QZLpCKHpZ9DLpCPW2isib4aW17N5vn2mca1cak8kDeQIaGOa4L1APpJx7sUPHdnX6oE85GE3uS/HR0jSZzcDcMkC+cIJYi+RKtDEy5YJUjvtR33xbvi7rrGF7D7WDuN8UXbLkfCND15T5/WYQvqebkZCkvprl9/6UT91+GGx+eGACXBWeqUEcYgFzk3vrgc2Y/QOnVNoGdUQm1jaMmy51gI30m/N5tE54SEUWDsWwumoMaHHMdr33DSoZNUwFedsx9f37QYxaLuJk9Q==; 31:8HV3im9R/MPhgJBex1qg1sQnPPwhIC4ROqh2CWqnsMAGM+WtCnKjlAcQHZ+cFAXFiOKvCFw2pfaPEOQprNDAHP0pH4+nNRbACFPBZ8ie40skAQSP4v50Yywo5KNqbr2piUQt6LrSwrRwfCeAszA4odIXr8WbK1hMfUNxNIj0MUsniMBQ/C0bQWN+DQp8jALV6fj7esmxUU00zpJZx/0tVFPMqRiPknYpsZ40bBaq2fM= X-MS-TrafficTypeDiagnostic: CY1PR12MB0149: X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0149; 20:2lPIjAsEKZaS6VX9PLSkCjXrwYFm1xoqpt9hYJiKFkTZx0IJ706sEcWKEOnEqgMA/AsYeCmV1NiqNjkUVdhfOLMWT+sKRAa3hUHqKLEyDeg/wmV9ZvQ6AHsnhTch4mfnymDFPkUCkMRhhiZ1WwU1PWaroSODdSElP2GABxHYSTTPJiL0sZNSUumJsGu8ZtgwzGXR4rEgSohF12aM8c167RwlWyef+hpJJQOArYYzgciuxRZU0pkgIjkxWUwIIs/F6CBtdyDyRTrgvljbrYnUrvdTLR0uzNBZj6DkY+8sl9CSwEltqhpGTbAqQnYEGCYA/6N2LI9YLhTW+6gEs1bZvpjp9vGmtpCtzNzTYwwsu22eTzXJdL9OESYYU0ATj1EPxeiLmiQpNfv3rgCorIkIvTq/esB8B4M27zO8baOouGLh6Nk83tZeIzJ2h5xIxecl2AAE/oTAhGQp4gj/l/FwWZxkZFZexGu5BMmK+IFt4LJj0+JNPRmNnPAtj/Lc0MkS; 4:FW/Pmm4a2E3qshVP/Jpbs/13FoT6RHSY2x/wAYiDSuFTdeRqBZD2k/0+nwGEU7IEQ/T+0L/Z8EPhBTtGH7rcGufqYcmGlQYcZdAKTLeG6hH2QePWr4itNCt8nesrRua5En9+VmcuIKlEC60Dpo9T6/DEzJga5DToMLSUqaHsB3zyiswmtn8TBsZ9zRXYGfoirqFQQH1IdxZX86F7WIDkitx69tF8EohLO3XrCL/i+spVSc7FusCtirv9iMoSOLzlm041BCfMfeMIE3exOuOPIAvRkrgaEWbg3SSCC7YE5xweC4HeNNEXc0HNZQfxfEp6OiOUXT7MpEgzNbQswdttdw== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055)(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3002001)(3231022)(6055026)(6041248)(20161123558100)(20161123555025)(20161123562025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(6072148)(201708071742011); SRVR:CY1PR12MB0149; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:CY1PR12MB0149; X-Forefront-PRVS: 0512CC5201 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(366004)(39860400002)(346002)(376002)(189002)(199003)(16526018)(189998001)(106356001)(478600001)(2870700001)(101416001)(23676004)(52116002)(97736004)(86362001)(7696005)(33646002)(54906003)(25786009)(105586002)(76176011)(316002)(2950100002)(6666003)(7736002)(2906002)(6486002)(50226002)(81166006)(81156014)(8936002)(53936002)(8676002)(4326008)(1076002)(305945005)(66066001)(6116002)(53416004)(5660300001)(47776003)(68736007)(3846002)(50466002)(36756003); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR12MB0149; 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?MTtDWTFQUjEyTUIwMTQ5OzIzOkZPb3FHUm5ZZEQya3hYVEk5RnJ6K0Zva3A2?= =?utf-8?B?clVtZ2FKZmdGRUZOR3FNRFlyR1hlL2tmVGpuOWtPY2NZM0JiaVN0a05zTkZl?= =?utf-8?B?MVNpMnJTcjRqVnZNcDJBRlc2OVhGeHhvZE5uZHZrTXdHak5kWjhvZVpLbVpG?= =?utf-8?B?bXN3clFlRTFiNUQ3djNQM1R5SnhlNFFxMi8wQTBxMUVraW1EWGtZajFJSE80?= =?utf-8?B?azNwa1JCcHFVSFlzTlJ0d3lzYkl6dUYwVXZyNzdMeHNJV0F5em5Bb0J5WXJt?= =?utf-8?B?RVp6OEthOUlGM0tHZWZFQkRySWtDS1pDMnhnQ09MWW5SUUZrakNDa3Q1dEpD?= =?utf-8?B?NzMzbnBKSmZpQ0RFeDVnUlZJV0Mvc1pxZFpxbUNPK3hYN0JLV2c5TG8wZGpN?= =?utf-8?B?NXVUSDlXNzJBYTIrU2ZWbDExcnJySTBrVlc2bFBXWml1WXJJRE5UTFRxVnd0?= =?utf-8?B?N1l1Qk1kOFErNUx1UUlKdTRKNlV6Q2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U0l71nHSmbXo5p0UL SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0149; 20:kSZwIopRnfs6eLWdsnftHuvN1HsbuW4j5wtSJLBVkxIvSnIcCRF3K9KLTvemYLsvyc1HNRPXxDP1xg2beF2a13ezsS+mqgD8AZqzkFzhiAcpebWTuAxxebuqMamSZlSnP7sJe2Ci7PK3/LlX+cDlr+d5Crww0U8bvzCCVVI4BQQ5f7Ll/VBU/Nni8/2NPP+BleR+94X5t1hCT9CF0Uk5l/VWkBHc2PRPxIQl/cYyiuHaTsglZhMfCgldtHFsdCnl X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2017 01:05:08.6391 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 700fc7a3-098c-4bf3-14ad-08d53b7c3ad8 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR12MB0149 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;