From patchwork Fri Oct 20 02:33:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 10018719 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 10F6960234 for ; Fri, 20 Oct 2017 02:43:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F13BA28E8B for ; Fri, 20 Oct 2017 02:43:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E63B628E8D; Fri, 20 Oct 2017 02:43:33 +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 908A728E8B for ; Fri, 20 Oct 2017 02:43:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751723AbdJTCnQ (ORCPT ); Thu, 19 Oct 2017 22:43:16 -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 S1752044AbdJTCfL (ORCPT ); Thu, 19 Oct 2017 22:35:11 -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=rAnHjQSb2pMZ9v+Ghmvybi0mELUYk73QGKlUO7Zo2o0=; b=wVBvhFgplV6s0EvJoB5y9KgV2KdgTjxlO94dIzHz3T1Iko5/sA6OemjUf+RVShrO+gTunhPcScoWaN29V7iTO4CPOWUJz8zfTs9cEmBbtA2aBCqbeap8Td/Irs3d7//Kl6a+JX8pckVOzfawzKJl9+U4cvPfetke6a+4uV9qG/Q= 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:01 +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 15/38] crypto: ccp: Implement SEV_PLATFORM_STATUS ioctl command Date: Thu, 19 Oct 2017 21:33:50 -0500 Message-Id: <20171020023413.122280-16-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: 6b5a13da-d1bd-41a8-d026-08d517632ac2 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:U4iKTRLkM4ElzZzpYtalS63v9djKjv7aGa0mn8UK0QoLjna23wi8xGxvEawR47FcfHbnO196ntasdjfonzGeP+b2Yqyp6TKk0CReHmgJ7jxfLNdo+dISf6VXnpEBPUo8JRAUlHap9SYx3285bUpNxuULvL9ozbAqig4vUUxWEiodSMXJRGVsPSOcjtRHSm3PGzOqhlwLJ20cUDT83Pqp+meXmKKjf7Z4bk6WJGt5mzdLS8N0VE2CE+vPQ8mgzR1x; 25:2oAXPzB1ToKILHcgtLzIBKQloqZHTOSE56LytDvNKf+DGscUKUa6XIIeAFSz9Yz07VtOh7kuaF40SvlunSnc0xRkyEybr2jeD7SqIAW1VBBJoUCIXFWomxe+OksmVtgnZGS9eeN38IKTyzayUhs5fwRSPdK6hl3/mHGwPtBj6TeZprtGFYbPYVeMSyBhkFMFsgYj2fvFnJUK57/GUSqawothw8O9hwiNTzVRmHSxGEv+derOIvfsbHulwvV6O0qqyPihyddO9lngc03pUhMrQKGNrqCPf1aRV7ufaAOFx6OBYvB9+q05ISUfxqk3eH/QTs6s29RgMkaCK3+B9jSSHQ==; 31:ZxXcbSK80Wle8TkMr/baAMuJipunT/dCFnvYck+6XpVuYZUsJZuIvH/W/Yg0wZLDwYAY0SIWyzOiwKqJAnAEhJHdiXPF5T4Rmw8DpfDraulbrJbpotsOvaBET0JAZ2QQlRYfWEkjhWq1FVpgklPdwFrtDkPtocMTXWnNlB9GDjVoSUbb6mW7EX8heD/lmNwGJJxD+EDord9P+aPKxAHiekoWymtbyaZj64JyLRtEos0= X-MS-TrafficTypeDiagnostic: SN1PR12MB0157: X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0157; 20:01MzdkQ5I9ygsuK7uLH7pHBG2ujeFG7O2RckkK7vHCg/30rlPgfBSlmx1Hz4i7cnHt4xuir0vPgTmWTmUt9S5hHW/UWe2kkKyFbGi0fScj0XDcLX75p8p+8dUDBtB1G4qTFvMAihCmAaok3NzCbG7sXwCJ8PfRwChUNntoqMhrHoegjspEOsYCKttkSMgxBpwSdb9/rUK4h04F0ZQoBTHjqIImU7o5rDCEX9vg08duO5VE14Xsx1HMMCIdaWp+Wn40oUtxdFxYSfRfGCVxxw7gU4HEktTKgUd8jfzKyp33smirGixFdkeuBiAjEWiEvZlmW1KPYBXC0xZn63DqYgf0Gl1yr5l8HCXsE/EeofyjwN8ziTZOFin29siwYNW6nyTwTCRPqV81ttqQ7zx1bofB2CH8GJIQNF51MMV9glYAvxkobk4YpVxgmpeG3gRB0hXBy5emORFr2h6vlD994KJEyeUpJNMQVLO1bSyc+2rq/H8kZxbsot6ySnwkXw2J+o; 4:c6aDq9JmphhM2ckRlUMdmXhEjAVqD+1rdc/xOBSxm6DW09twJNfMr30BSdXlzR7w1ZM2Uj9zqeDcrz37vaNrKujE+4Pjp6TTYu5s8xZN1k0ncJCJrVCcVmP2f+LPu94uefP/igMfY1/2Kyj5GJccOq3dXtBbQa/aguPvBXm894Lqz7YvfBDDgrWH68raBq8PaF6X4kA9tdG96AwlSIgSIWG53cSkKl0t+zbvbr7g1LO2ruYsW29rGWVclinY6a6DP2eVKsJRql9ZZg/kNj0T14Yge7SBCmfHBUVBiCHLofOxk9sefjTembce582+KsDrSCwhnEGQ4gSGD9cpZBM64w== 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)(45074003)(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?MTtTTjFQUjEyTUIwMTU3OzIzOkFzcVp6bnFUcThQUmtKaWxRYzBVM014MjJL?= =?utf-8?B?dGhrMmVXVW81eGNlOHRBTXZGQ2Fmczh2YWwzUnI4SDBVbzBabkY1L3N0c2pm?= =?utf-8?B?RDkydCtMRkhER0ZEdnZDSENaSG9jWDRGdmlzV0dQYlpZS1J6M2hWMXp4VFFI?= =?utf-8?B?anFTZVZ3TTYrTm56MHNjeGpaL3JCVmZaVXdJUVpUbTlTMjR4WnErRFZreDUy?= =?utf-8?B?SjlONTVFekZQT3hqOC9ESXU1NTRDRXpzSksrK3hMSVZxNDJvZjB5Y1A0bWFJ?= =?utf-8?B?RWxQaVpvMko5TXIzbStiMVpia2toMlBrYWYydU82TGo1dXlndk9BRTZkWDdR?= =?utf-8?B?OXBRNGxCL3dOQ1pkWXlLRkFQWkF0NVd1cXBMTXllalljOUZHa2NVWnc3cHJG?= =?utf-8?B?SVQvSj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Dzt+962gX+VPSYYQZyNaEbB5EKyr6zodX3HHxj6U/B9j7X37uTGU9gHDY0HpwD0zRayUF5U4j1a4n7OGmIDHUljk2i4GzEc= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0157; 20:HFU2jgoGzXH2Pp4kyGKEIfdlEv4+jCFc2W3JGynsoWnD77F3IPaW6jdCmn70WqfdJdGAfQD2bG/ewLaKDTTfsNZoO18CvmUJAzbJqgayTQk1B+2y7Wqh5Y9AE59+kK/SxPn3g17O9FcRcehqtH4llmmDZvp5Ka2xL/p1IzyM5zGbfXD+qeCKxfipt93rxLTzkyBYEfP9IbRA20+E+BVfwyyCdEHjrvW946H8AZ+obJbz1thbpTBR5XYwdzjwX/7X X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2017 02:35:01.4717 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6b5a13da-d1bd-41a8-d026-08d517632ac2 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_PLATFORM_STATUS command can be used by the platform owner to get the current status of the platform. The command is defined in SEV spec section 5.5. 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 | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c index 99f3761206da..5c921b36bc23 100644 --- a/drivers/crypto/ccp/psp-dev.c +++ b/drivers/crypto/ccp/psp-dev.c @@ -174,6 +174,27 @@ static int sev_do_cmd(int cmd, void *data, int *psp_ret) return ret; } +static int sev_ioctl_do_platform_status(struct sev_issue_cmd *argp) +{ + struct sev_user_data_status *data; + int ret; + + data = kzalloc(sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + ret = sev_do_cmd(SEV_CMD_PLATFORM_STATUS, data, &argp->error); + if (ret) + goto e_free; + + if (copy_to_user((void __user *)argp->data, data, sizeof(*data))) + ret = -EFAULT; + +e_free: + kfree(data); + return ret; +} + static long sev_ioctl(struct file *file, unsigned int ioctl, unsigned long arg) { void __user *argp = (void __user *)arg; @@ -194,6 +215,9 @@ static long sev_ioctl(struct file *file, unsigned int ioctl, unsigned long arg) case SEV_FACTORY_RESET: ret = sev_do_cmd(SEV_CMD_FACTORY_RESET, 0, &input.error); break; + case SEV_PLATFORM_STATUS: + ret = sev_ioctl_do_platform_status(&input); + break; default: ret = -EINVAL; goto out;