From patchwork Fri Oct 20 02:33:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 10018727 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 459E160234 for ; Fri, 20 Oct 2017 02:44:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31D8628E8B for ; Fri, 20 Oct 2017 02:44:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 26DA128E8D; Fri, 20 Oct 2017 02:44:02 +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 C0D8528E8B for ; Fri, 20 Oct 2017 02:44:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751879AbdJTCnk (ORCPT ); Thu, 19 Oct 2017 22:43:40 -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 S1751920AbdJTCfJ (ORCPT ); Thu, 19 Oct 2017 22:35:09 -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=PYtwd6jnvfRyS1asvpIK5spmuDzoG0TfAZlk0rNtVVc=; b=3L30HJ6SnEyBLbbR+zOIfIDUcqleTW4/PfJqVGYIOuDPjhVapCzkxS5JwqSwDMpQquQRjpMtaJufdHUAsIIBApVPESJlQaPZjHRyhrHHvVf05n4RMqgk9pD22mYeSGTRYvZY6nSgqC7N8Jn3iSjoIaoLHcmoZoIwO0416F8whSA= 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:34:59 +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 14/38] crypto: ccp: Implement SEV_FACTORY_RESET ioctl command Date: Thu, 19 Oct 2017 21:33:49 -0500 Message-Id: <20171020023413.122280-15-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: d637e44a-7e20-4b59-6979-08d517632958 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-Exchange-Diagnostics: 1; SN1PR12MB0157; 3:NDXta/bjRnHKjL2XggrlFqHf8GyNSLN8xpRFxSwdvR95LyLBOC9K+aKbq/6LFIFbV1Eq0xUnbzXD1DOMqgPksSIjUCreUhpn8OAbSK7JkuPmlTbtns5PiMdvF6/D1QBsYHoc/WIXdwFr+40BCrMd+eGcS58WJGTmauJotKTvbrtEBvStEfKbihg03FEzsXZc6oTi7YxUvO/HXf4VAiSvMaQOPS2Fex3PcvOn79ptjxUFLuTKTqH+IqrzkOeAurCS; 25:M8Jai4vKUH0gRp8ZmH2oe2qRvebfmgyq6BXSCf0PL2Gxf26J3WzFlyuBnNNgiH4rQpOyCtSNQONlXcX9p2e0u+necLRqknq8a8eUcr6qRujnSX6zu61Vt2KMmhokctpZWpUNcnmIUN5jdviwG/fugAC37OvORFAZbEFObbeiFUPDB7RebEKwfopzU0VFomJNiQK+7XRy9GXdXxcqjXAHiWsqh71zr8r5ghnuaaBEM6HJaM16bj9DyJaNKtNFjEYSHPrRz30PIjjwnzZSTPqFgrtg+wIsZ+7jXZ5jexby/uKOr3TkTIJXTj5qIjza5KPjpuAyQm3dLegjLJDqX9MM/w==; 31:jThpewEgf06+iHOr27AMUZxiVpSlW+5VvLXslLMkh2A8AUxBhaGx4dC73CsnHgtXI6+C54k3pu/5DJyIXAtZJET4tZYeddllAt5d4RJzkW26Lw/sGFiG+mnbhEGhEQ5YQrGaNg9+wArrjC/euCSG7OO+D53H2FkG7XZqzXN1IhGbYRhvTeYB9DZLH7oFYj/iecoUjXQ4nSk9gVMS8JVm51msCXzZWWBcV3bV2ZqVGc4= X-MS-TrafficTypeDiagnostic: SN1PR12MB0157: X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0157; 20:fh8Q6RqqDyEc5jJDQIAjrh2mnJa+V1jtwyUAXqaHPSOlf2g6BpPlYNUfsSDmcsMk68BkRsv7mPWcZyNNAa+Pw8LQbQCkL+9FJw6y3fgou0s6uMn6JBuq/wFxpPB0qEMZz19HcsLV4htRrj0w5CSZvRc6NTfbT0o8yD36z1QLs0ZAmfX9LiUcbHmXJpxWs4cwSsqwzCJmV7uddhILOkmv/sPHbk/ZAMsEA51a/S781PoPsYPB3r6Hil6jvNwQtDkULHffPGQYNplQmNPWoGqt+Z/4hk0ssznMmtB8bqPp6NdeH2o/1nwjQwc3/3Q19CAUhkOFPbVHKDiTv1EABqivzvnu7UTZNdhmOkmyfrOuiiPMZ3zNjCJefBUjOzHZSRNDl9V53XabeF+og5WSsdDJKZZ859EUAiqkvXnQ5GhMa+sfjcCYG31WxBZnvhr++hA0iSLKccly9GVmTb/7bdadq2SUJb3VOtZpj5f8NHpZl7MwrtgQmYxQWoXhJtG9Ht9L; 4:jyTuxbK/jDRPlDT9377FDOSqItB7S8SHNiXfdSVAqy/24P1Fv+nbbSE0D2wblPRkdECNnIf5gqGWWSV095wxl6MgB1oDvvCxUr0WZuva4k3wxPV9GCOFh3VAvaA37V/D4NDHcdd+Clrt/eSOD539xoUpvF5wpt52VxP+7s+O2fadIaHL7tmnLd+XqjUvuSqM4qP75rt2d5RcZQz8BBfZspokpArK7/oOwfyEeZgCYED0l+dTnUKCfOtP/WWcCgBegz08nKbwtRvE9tlAl/rOgf36LPTZRHi0t01wmt1LcKfacYTs9UXcMH8pZ1gxNRraUNNK2TB+zk55iofjhEvAig== 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?MTtTTjFQUjEyTUIwMTU3OzIzOmNNWjUwSEplbUd4Z0dHVGZXU2lacHU1OFRw?= =?utf-8?B?NGl2WWJ0SjYvWnlFRWNZVUZTYTVzdTNQbjZYdExHNDAyS2R2bUlIbm83c2JU?= =?utf-8?B?UWQ3NmVmdHdrSURGWit5cnFFeWphK1pHQUpKK1NQbXpWcVhJMHVzNlc4UlF3?= =?utf-8?B?U3BmY3RSWlJCTWR1cWI3MW8vMlhFN3VrVzYxL3NESjEwNDdvQU5iSGk3Q2RI?= =?utf-8?B?TzVEcFQwNlhaWGJobGtkUXlSUE50MzF0MGZPTlNEQXZmei9QRWpWekJYTVkw?= =?utf-8?B?VzVVTm01cHBsdXFtZE5OSjJrL1E5T3FhQWI2cmxqK29mb3FpMmUya0NrMmxT?= =?utf-8?B?N1VESG9KTUFrTjJ1c2RFRlhXN3d0VWFkVnlOb3VqTFA0M3ZSZlJpOFJheU1J?= =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vGEruCVCFvWUI4O0oA9Zbr19fldPTZInpdcZwE4P8SuP9ymRJLLl+Nq3UkC9cs+5nCKuOrshF2eMT8EGI4CMPfr0bMeQ= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0157; 20:GxZiq1JtltLvQWk4B+aX+S1t+WFlRWKffFUF2G2e+8cZW2Bur+Nm3CZYsqpUFhsxryeXu+y9sZUT5Ui2qV6n2j6MZlv42xtMev4qcHmgio2BrPNTzXoYqu8NJXV2mMXLAe69aHvpWNBiWy1Bdwb8Rk3rQlhSZeQV5VahaugDKmkjf5pdJ5PdOP0hKbVxHmbJGKETlSQeuibnZT/Sv3jSoLUXqoUqvaGpofOSADlrGVxWtEQi6JRuBhOmYFg7pgpL X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2017 02:34:59.0810 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d637e44a-7e20-4b59-6979-08d517632958 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0157 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 Improvements-by: Borislav Petkov Signed-off-by: Brijesh Singh Reviewed-by: Borislav Petkov Acked-by: Gary R Hook --- drivers/crypto/ccp/psp-dev.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c index e9966d5fc6c4..99f3761206da 100644 --- a/drivers/crypto/ccp/psp-dev.c +++ b/drivers/crypto/ccp/psp-dev.c @@ -176,7 +176,33 @@ static int sev_do_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_MAX) + return -EINVAL; + + switch (input.cmd) { + + case SEV_FACTORY_RESET: + ret = sev_do_cmd(SEV_CMD_FACTORY_RESET, 0, &input.error); + break; + default: + ret = -EINVAL; + goto out; + } + + if (copy_to_user(argp, &input, sizeof(struct sev_issue_cmd))) + ret = -EFAULT; +out: + return ret; } static const struct file_operations sev_fops = {