From patchwork Sat Oct 7 01:06: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: 9991039 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 11AF460244 for ; Sat, 7 Oct 2017 01:08:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 03F4928B20 for ; Sat, 7 Oct 2017 01:08:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC71128DAF; Sat, 7 Oct 2017 01:08:56 +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 5342B28B20 for ; Sat, 7 Oct 2017 01:08:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753201AbdJGBIj (ORCPT ); Fri, 6 Oct 2017 21:08:39 -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 S1752834AbdJGBGX (ORCPT ); Fri, 6 Oct 2017 21:06:23 -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=FUTbPLdhMejE5Hv8jA/tokQfcVXRBqP3XyY2Yutu8i0=; b=4uAIcbwM4Wb0X0pSj7kcR8rIgUoQW8971zB5bP44FYgRWT7JIeztJJ1W5NMsKJo12BOvQQlTKs35McZXR+gr3eRGstIAVoHqSEWFhapcRRK0xis+blCoUvelvbJvvr9LJvWxLmnbGwThef1HlmtAMeJgGor+20DFeItsol81xSA= 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:19 +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.3/31] crypto: ccp: Implement SEV_FACTORY_RESET ioctl command Date: Fri, 6 Oct 2017 20:06:01 -0500 Message-Id: <20171007010607.78088-3-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: 306f16f0-7a97-47be-ab5c-08d50d1f9eb3 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:Ofw6ZRYlQwRAcbqnfO406trIRPz0IEa84166ApxSTVbhImotQgqZD0eFuZwjlb8XzHCFpL1oClZM6dG6GHGeb/pjjAK/hMSaXtlXmKh0/A9MaTOfVAj1k32G2EOu/TyrYS+ZZ+s1TC7HmsAUpp+neTVHGLSmuqmF74e0iK6omYtHT8qqAKUxqDqn+GP9K5p1cUGuSFZHS2h6k3O8cNDmz5KtW3tLUcyydg/qFvjifvMr19wIaQtRDEQlMFuhoEyN; 25:RxuZzFhffE0KUZf03FU7T4GjZBEvRMPmhEp7XhlG0526iq8HyuZLZ3QMwlwnwoCXsz1mD8FsF5bAGDNOHpB6zMFO2QCUcYKOM36PorPdhUEpZhm+Gi+zvR0lRBZcfmRaMLExTeE7XlUWqfqoxJu2R+k/H7clNHgRW+yld0CHrK39dIBTDI1bb5m8TIski55Gw2kHdmORb5hBIXQgEeQ/G1LqVet7lTWvgYa4aXWYYS920qYnd5JS++eiIfT6m7mTN2e1uyJpRp/EmPa2YbNCLnNNsP5+vGmDvG+d8mCdnAcWHkwwrz4EHAjpZiAQJ5Us1/sr8FnbtOkI9kRu+rPoJg==; 31:lbdB8r4BDI0KtJK/06Oip6NOQScHgKNHjjCKiyu2BTVOM9cbeCPO0gHeSNUIRTo3KZWBD3UEFeuvcqpQbjTQYixyXkpRFamuSBr2dkxgMdiTsOO2KKWm+aQ0LJiAns8EVlw3tsIBvTKiWsnKVWvBKMiRsM8tPAx1YMXc1M3VzMhtxB5qmEjvGtkuylc2z/+6htT3p+mJyQN1dmKa0rsdviniLB9qC+y5l6W1IzFBagI= X-MS-TrafficTypeDiagnostic: CY1PR12MB0150: X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0150; 20:tCaXJwujNTbnnUU8eosm8haLaVXMvt/mJjz97rI4N0Mx79U1WIsUb3onGG8PKZ29PNLtRZMsq+B8i7QreWQZIRbCiK93J5OuVfZOQLEWlqMY2qGk7Qjb1BjMLbd7OIxupIKGllUhDtVQKFy11JfL+TgYQryY945My0IPaggXm/zgXgMu2kmI0LhMf7i8L/Kyl9FYyWlEcZbTvWZRbtBYhDp2CL/Wl0zMo3HjTaIKp4YLVh9MUi8jBJpeZYsHXKUvzZo2Btt1NkClAmkEt54Y6R+xi/r0U2we5lYohZCH4++H8zTdpYeljVRyuPKdioQl4eC6V4c/Z16zosKMqaVCymd6ihHEKI9841J9Eh8kJSxP+1Mgc+tbFNsBTBt+yz+x44sS2KjYznfiyOn4mEeUP6AfebzLkkWTkdWzLkKoV53UPb+QjPwRicuv5EMwZ+vMPkUal2hkzLRVCXpOubS3tECsADggqgp2coH1fjFhhtVUglK0S/6u4SieyXWf5cDU; 4:nU+gJOETXqVbUamdryS8Q4SiYnc4XhR8YRPKkwmfZ2hsnWLCOICbWmpviitOnXFuVlime0WldnzB3vw6395Git4++BRB3+bogc3xGeJwlM0lyi+Jt6dKJk/Cz6AURjq7mvJbYG3WeJ5YlruPi3t8oBLCIX99Rys6/LWbfQ1tISfmIbhhnjb+holpFzWmL3s7bCF5n3co+XdITlZD2qsslmUlYajumnF1CpPr2K/D749WWCmDikYCpMfsfoSl3Jb2uj1WQjO5GKciF1+sr1bZI1Q3eeGgt0kxN2kFshkYaUvs55XOViji9wriAfzzQwaB2YNxqrpob3zPvUpnYbXNHw== 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)(979002)(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)(969003)(989001)(999001)(1009001)(1019001); 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?MTtDWTFQUjEyTUIwMTUwOzIzOi9PNnRUZjdjZXM3UDBDaGk2UmsxRkI1WnJZ?= =?utf-8?B?bFJRVFMySktOL1A1S21vajB0ekZFQktEek91dURoMDVSdmd4T0x0NWovTHRa?= =?utf-8?B?WmdUTkVGQnQ2Yno5cEdZSnZ4NFl3RUJvRXZTQkVlV21xYTVRcmIvd3I4eHZr?= =?utf-8?B?bjRBUURqcjRhNTlQRGlwekpGbm9PSmthUzZpdFpNaWhGaHNZZWZ5a2hVazJp?= =?utf-8?B?ZHR5WStHaFdKSDlRNk1ISnNnd0w2dXA1Z25xeGc0RGxtdk11bmFtZy9zbWxM?= =?utf-8?B?QVNuOTRqOEIzVDR3RFA5YlhpenhvSFFKWnpwSnd0SmtyVWVJQjdCRHlkUklD?= =?utf-8?B?amt3bTRLQ3NxUXpZUUFZV2h0VEV6eFl5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G79rh1xEEkjFHMbEE3VLu9SI6jrPX0=; 7:kL/gZ1gd/eDYbQK1zotsEAu3IPVhYriJ6S/2VoJeenJ0wFC9QwM103JAsHmLl05iALrGfI/lLJHWhmZ7YpBnmLKknMIJ/FoYv3i5zTesQe2Lbpw+TA533vsGI63gp9tk5+o9D20PQazvJdDc4+c3Zg+XkwdJpOpe9+4c0Cj2JsprOo22IGlFjjdYaZZ8gNy8AWoUVpajGlFvkFw9wVy6vGAMVArcswa8v6pUZZ+9AsU= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0150; 20:pN6psLpGOLI5mtyZUX+wONxFv7bMU3Vd6F8/rK8mVYVdnTtgqfmmcggBItiR/wDU3LUHzA9N+iQSO50FGNmg2TSowO5NcitJFo9XTdO7Hk+WDZgNpb+NYSxqO+5eIWOotzd9AVhPCbqEMPCxMK42MDNzTQqpdQFz0H+4cnn2cOIuT3sbGA15eDGrPrcyeMZopsTKK1zJFCLaEhxKhChY1nOKZCYADfED+8jdOycIjZgg9gYHO4Z0egsK8dMgR5sI X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Oct 2017 01:06:19.5671 (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_FACTORY_RESET command can be used by the platform owner to reset the non-volatile SEV related data. The command is defined in SEV spec section 5.4 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 | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c index e9b776c3acb2..94a08c371bda 100644 --- a/drivers/crypto/ccp/psp-dev.c +++ b/drivers/crypto/ccp/psp-dev.c @@ -179,7 +179,34 @@ static int sev_handle_cmd(int cmd, void *data, int *psp_ret) static long sev_ioctl(struct file *file, unsigned int ioctl, unsigned long arg) { - return -ENOTTY; + void __user *argp = (void __user *)arg; + struct sev_issue_cmd input; + int ret = -EFAULT; + + if (ioctl != SEV_ISSUE_CMD) + return -EINVAL; + + if (copy_from_user(&input, argp, sizeof(struct sev_issue_cmd))) + return -EFAULT; + + if (input.cmd > SEV_CMD_MAX) + return -EINVAL; + + switch (input.cmd) { + + case SEV_FACTORY_RESET: { + ret = sev_handle_cmd(SEV_CMD_FACTORY_RESET, 0, &input.error); + break; + } + default: + ret = -EINVAL; + break; + } + + if (copy_to_user(argp, &input, sizeof(struct sev_issue_cmd))) + ret = -EFAULT; + + return ret; } const struct file_operations sev_fops = {