From patchwork Fri Oct 20 02:33:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 10018707 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 C785760234 for ; Fri, 20 Oct 2017 02:42:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3F9928E8B for ; Fri, 20 Oct 2017 02:42:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A8A2028E8E; Fri, 20 Oct 2017 02:42:57 +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 24E7928E8B for ; Fri, 20 Oct 2017 02:42:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752195AbdJTCmn (ORCPT ); Thu, 19 Oct 2017 22:42:43 -0400 Received: from mail-bl2nam02on0081.outbound.protection.outlook.com ([104.47.38.81]:36505 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752075AbdJTCfP (ORCPT ); Thu, 19 Oct 2017 22:35:15 -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=XuTepHFA4Za+dWMBYvZYj77zBt57e6I9hYT3ksPbyAM=; b=pk1O8wo/nk1SKLwnanbt5oIpnlNtZ/gxGNn7B9unuHcgCauxa7ihiT7HSZnxU5IomHW8MyuXguHYEXbQeRYJrlMbOK0ybtgW4NbVkR5RkHI9mETF5O6ZmEzJDsu/7uBANrqFeL6vCxihHQq/Gz7ZQUHtXVFRHUZx7ax5KuUOdk8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from ubuntu-010236106000.amd.com (165.204.78.1) by SN1PR12MB0157.namprd12.prod.outlook.com (10.162.3.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.156.4; Fri, 20 Oct 2017 02:35:03 +0000 From: Brijesh Singh To: kvm@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, linux-kernel@vger.kernel.org Subject: [Part2 PATCH v6 16/38] crypto: ccp: Implement SEV_PEK_GEN ioctl command Date: Thu, 19 Oct 2017 21:33:51 -0500 Message-Id: <20171020023413.122280-17-brijesh.singh@amd.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171020023413.122280-1-brijesh.singh@amd.com> References: <20171020023413.122280-1-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: MWHPR1701CA0020.namprd17.prod.outlook.com (10.172.58.30) To SN1PR12MB0157.namprd12.prod.outlook.com (10.162.3.144) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 21aa56d9-854e-4bbf-eb4c-08d517632be0 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(4534020)(4602075)(4627075)(201703031133081)(201702281549075)(2017052603199); SRVR:SN1PR12MB0157; X-Microsoft-Exch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yMQRiYj3lgiGrkcI4fiIHIVmzwrzLlmY9AsiUvqzCggidk4EL/i0pd4nFzKJd3qY+8BjL5c14Kkn99yG18ksYN8vkGvJESzC6dQLuxHj9453NFDm7yba7NxGAXCLV5dECX8jE/e0n80fz6CT2zbxZoDyhI3PDHrme1Qn+Qkxe5oyuMEuvYcWHt3bk+8XAc52RBhmQiDjGbtXrZxo7CvLTwAuGQgH4+btPh6cmwjhbDxhbZSaSyKQL8wZjx4qQfntekBhk3qSOHtUN8/UEYo2EJT187ZOpn3TPwW/TsP09LcxmpFs6UrmzB/afhxOHaXSi9vvNxGifFMLv3UGVQ88/7MiDnZ0gFqTInS99Xzxs1BXwSuNB; 4:8mWa1tv2BVN9nMBPLZVNBWehcmOknjjDI5KCf9kgc7zPuVyGT6ImSfGBsJX/b79ejQitKbdVqPAL7KVkfsg6Ooz9eX/Rh7mFeNnuyDds/s37BlY0jG6qyiC8f1LlF61bRHBMOAPNkLn8CSyzwNAf4ktXYvl2MP/1HKSz5zQ2VnBj30eLsLRGBAtgRDgYrYjmwToj937x2nJMIwekFrx42NtN2ZH12vhejhyVgEzECLJJB2BCPfl7Sj7qQu+RvxOZSysRPZfFngjQx0i3ALUF5/jS7mf7ZcquttHzFUisCHadv0O9LocGVh1mF0mYw7rO 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)(3231020)(100000703101)(100105400095)(10201501046)(93006095)(93001095)(3002001)(6055026)(6041248)(20161123555025)(20161123564025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SN1PR12MB0157; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SN1PR12MB0157; X-Forefront-PRVS: 0466CA5A45 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(346002)(376002)(39860400002)(199003)(189002)(36756003)(7736002)(68736007)(50466002)(1076002)(478600001)(4326008)(16526018)(316002)(53936002)(6486002)(86362001)(305945005)(53416004)(54906003)(50226002)(2351001)(106356001)(101416001)(81166006)(105586002)(8676002)(2361001)(76176999)(2870700001)(2906002)(50986999)(6916009)(23676002)(66066001)(47776003)(6666003)(97736004)(6116002)(2950100002)(189998001)(8936002)(3846002)(33646002)(81156014)(5660300001)(25786009); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0157; 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?MTtTTjFQUjEyTUIwMTU3OzIzOjZoeFg5SlNZNXJaS3dzdGdQeEUvQ1lXS0lG?= =?utf-8?B?azFFdE9rU0ZGVmlaSE5GdGRLcTJlYVpzRlhXaFFkR0lod3lObi8yS0d1YTVo?= =?utf-8?B?YVU5by9QaitSWmk3c2FhK3JBQy9HOXh4aTJOWUR1UWdHSlJYUmVOb0NyTFJB?= =?utf-8?B?VlhoWkFSY21GL1I4MWhCTlZXUWFRanl0M1BsdDlrRjJUUjlFVWFWKy9DSHZu?= =?utf-8?B?Slh6M3AvYVh1T3I0akEzRGJCWjNhYW5uLzZ4RlRYZjBob3pVU3FKQVVpU3Rw?= =?utf-8?B?RVF1L1RQTm1neVZKSncvQWR0UWt2ZTk4bERXRUU5cmFjSU9kWXkvbVpJMUhK?= =?utf-8?B?ZHBwTHlWYURTT3BxY3BQRnZhNzJ3cVZ2eE16dE50NXhqOVRNYzRoQllqT0ZU?= =?utf-8?B?SWtLL0pWUGJaR0d1VnZaYUpXMjdFSj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GqY81D/mfcFiH7WtRYtZ05U2bRpOofUrVa0ZzLrgCo= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0157; 20:Zn8bp+XACLkh3fvyA97CP0XMUocaYsACL8uFvs3Az5vq97zyXGGq8YBWvqj52K+ovGpm5fSrWZ6qkyCvQPasYNQnvW6GS7sAoUZWSEL+Sbqx8r20/0yOTGcT8qwm/mY2DJQTQqkh6R+zTMKplpVZ32IrvGancd3I/smvgI915h8ZiTrV1YCgwWXOsfAwXJ49tkqerw8cOz6wT8Wf0MC4+Hsvq2KMNN1g4TJ949sJ89zMCeNpF70zCMzLD0KrFXsl X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2017 02:35:03.3311 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 21aa56d9-854e-4bbf-eb4c-08d517632be0 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0157 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@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 Signed-off-by: Brijesh Singh --- drivers/crypto/ccp/psp-dev.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c index 5c921b36bc23..1d7212da25a5 100644 --- a/drivers/crypto/ccp/psp-dev.c +++ b/drivers/crypto/ccp/psp-dev.c @@ -195,6 +195,24 @@ 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 ret, err; + + ret = sev_platform_init(NULL, &argp->error); + if (ret) + return ret; + + ret = sev_do_cmd(cmd, 0, &argp->error); + + if (sev_platform_shutdown(&err)) { + argp->error = err; + ret = -EIO; + } + + return ret; +} + static long sev_ioctl(struct file *file, unsigned int ioctl, unsigned long arg) { void __user *argp = (void __user *)arg; @@ -218,6 +236,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;