From patchwork Wed Nov 1 21:16:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 10037589 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 AFA4A603B5 for ; Wed, 1 Nov 2017 22:05:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A187A28AEE for ; Wed, 1 Nov 2017 22:05:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 960CF28C11; Wed, 1 Nov 2017 22:05:17 +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 DDF6E28AEE for ; Wed, 1 Nov 2017 22:05:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933528AbdKAVRK (ORCPT ); Wed, 1 Nov 2017 17:17:10 -0400 Received: from mail-bn3nam01on0059.outbound.protection.outlook.com ([104.47.33.59]:44352 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933524AbdKAVRE (ORCPT ); Wed, 1 Nov 2017 17:17:04 -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=MuWgt1c6IBJFHHIrB8+z1S8n3WbDr76xAXBDaA8VeJE=; b=NF4nUXj3+1rvM9q3VKElZPkpV4vsDyhPHF6+IlSL06EpFTCbVyw7ykY3qmeSgqYqJaP22dCYU6qpzLQoojNorTi5sQofcpJezpfQhWV0ZY7XgBjGXdQLCqvaxG4D4l3q5S9RCYzDrOTxpaSaiDhhUvOuO8WWJ/CvY9eoK8FM7RM= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from wsp141597wss.amd.com (165.204.78.1) by DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.178.6; Wed, 1 Nov 2017 21:16:46 +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 v7 16/38] crypto: ccp: Implement SEV_PEK_GEN ioctl command Date: Wed, 1 Nov 2017 16:16:01 -0500 Message-Id: <20171101211623.71496-17-brijesh.singh@amd.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171101211623.71496-1-brijesh.singh@amd.com> References: <20171101211623.71496-1-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: DM5PR06CA0064.namprd06.prod.outlook.com (2603:10b6:3:37::26) To DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2cde6174-c54f-44e9-7f3c-08d5216ddc17 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(4534020)(4602075)(2017052603199); S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QP8OKTw2Q9l1UOzYM3WDKUUSzwvIuM/5J38uu/exfsyfQHJ/jc8GR/VyORnBkg6bpUZC5g5qUgNkSY3t5NdMz+7GZKi/+NKmjVXDB81HgEMyuxicPmVNEbngEywgckZr9ibtqSuvCAcNh4QfW+x6J2EAVoam0CYpcrfZvTkCiXIpQ1ByZMWgl9Ir/R3ucBM2nYSizB8KtB1uuxoyvOpoy4wJ0dD25belJTbO4U7hWTOFLP4rAHBR1qjhVOmWP9PRSAY+PHBWt6FP8H8VUYzTNELaJJvqXSwXWOXmY+FQq/DkqLFoqclFbxZ5dDXZuLG5LgoktUfB4p1HKMmmNNJZG7JnEZqg4Nn4WWf/88qlm6gwiTLReE7vscicEU2YgOYnZjiJ2RTGd3Bmbu1Kk6P5; 4:Z6cUpoYAz5G43Qpy2psKTceVXa4SQL0zHdmRRCDlg5hP8wxK+IAkqDy/F7GaH+yE66Cngmx8Qb0LQKo+M59zAMUi2yScMqJ8s0MvEIqCQmOxsk3sLSVmipeBR2H/I4jZLxTqQHDAqTjYIj+sjPM4CWVYLDYs+GUf8h7jfTNsAZ/28Qut49Zyl2MfE+sW5rAJeMXDmxAzOjjVFeo7O8yuzttNzpwbzUpd8O34XFoX5YztOBbeukXRizADHAr4VcVT0cWAMtTfEEuutLOf4cWuxyUTshJMbWF1dgN9mDHI79MFtVVKmvM4PbAUjiHMvgxljngHu7HKImN+D3xoWABZWw== 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)(100000703101)(100105400095)(3231020)(10201501046)(93006095)(93001095)(3002001)(6055026)(6041248)(20161123560025)(20161123555025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM2PR12MB0155; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM2PR12MB0155; X-Forefront-PRVS: 0478C23FE0 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(979002)(6009001)(39860400002)(376002)(346002)(189002)(199003)(1076002)(6116002)(97736004)(66066001)(50466002)(3846002)(25786009)(4326008)(54906003)(316002)(8676002)(47776003)(36756003)(23676003)(50986999)(478600001)(81156014)(81166006)(105586002)(53416004)(53936002)(189998001)(106356001)(2906002)(16526018)(2870700001)(76176999)(33646002)(305945005)(7736002)(86362001)(5660300001)(6486002)(101416001)(50226002)(68736007)(8936002)(2950100002)(6666003)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0155; 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?MTtETTJQUjEyTUIwMTU1OzIzOnpvbzZKT0pkVUgwa1B0Y2VhU2RySTE0WEl0?= =?utf-8?B?ODJYazNObVdpUDVMbmF2MmRVcTdUL1pic1REeTc2RUdIemtYUUZtNURpM1JC?= =?utf-8?B?S3BhTzFleHRZNzhrdWlWeHUxR0hXbWhqL0RodGp0MytUWk8vT1E2N01ZazBu?= =?utf-8?B?RFVjVXYyamZNK0JQeUxKVHdxMHVCZVBScmJYeVcvR20xUjBCdUwxaisrTUZH?= =?utf-8?B?VEpLT0Vud1hzNHBQRDhnMHlKUko5Ky9qQXdNRmlmMUx5bmJrR0E5OXQxdGVB?= =?utf-8?B?MzFJeWt5bUxlTW9YeFJnUVV3VG5qaUR3ZlY5V2Z5SnM2MWNZWGlJYS8vdVQz?= =?utf-8?B?TnQ0RFJWR3BGQzBtUXZNSDIyTi8zNmRS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imu4Is=; 7:twpuk3oxExJw0ow1mRC1TK34kcF6PIujqei3lLdHKseFMdUcUBwonvQu1nndNkL1a/HpVfCsSDO6kLWiavgZRfm4bi43cB0umJyAwzftHZ5tgdtmsboLxSWlwEfpXZJZcSXxvsUVxJPQiC00NylM/AJdjxM15Tlq2stQELch5PLM+kM5ZQ45FiYJuS8s+CSZXnfI4K/G2oOMDsygDG8jE20hfS5r1iwb/fYCC++b27UTnqbCGW8/1hGmKZShCbny SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:8fm3UT1CJQoVI0kio2G20Y2fIp70so/QUvO/gX07O/RK+pD/1kF/oP39FSUMcIkPRUaYLnj4jxmjMpfJWskclM6OywV1sBJI/pDJCpCcHN2vxlYbh+V9GoBMwiF32YK9etuvsYqb8noOW2hsNA34SdXkipfXZ3Xo5goQ36ZM1Js8QN76lTh3JeRGmdwsAslo5M8kgu42g3ulAuvinZyIpBBP+4/d0GoHgJY/4FIOxfzZHYwNswPxc1sPQLAFzgPC X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2017 21:16:46.7035 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2cde6174-c54f-44e9-7f3c-08d5216ddc17 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0155 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 ef473ec4a413..2c28c36d7ae8 100644 --- a/drivers/crypto/ccp/psp-dev.c +++ b/drivers/crypto/ccp/psp-dev.c @@ -285,6 +285,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(psp_master->sev_init, &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; @@ -313,6 +326,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;