From patchwork Sat Oct 7 01:06:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 9991033 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 927D760244 for ; Sat, 7 Oct 2017 01:08:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84FAD28B20 for ; Sat, 7 Oct 2017 01:08:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 79D4028DAF; Sat, 7 Oct 2017 01:08:26 +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 20E1828B20 for ; Sat, 7 Oct 2017 01:08:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753128AbdJGBIM (ORCPT ); Fri, 6 Oct 2017 21:08:12 -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 S1751869AbdJGBGZ (ORCPT ); Fri, 6 Oct 2017 21:06:25 -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=dlj/dbMN0N1X2hOW7JC+SbiOqO7eNeK1I6bdwEmVCeo=; b=RYEPzMA+Sw1OcEGyDhiidLTWK0Nr2Wlpnbx0SHNjcWtTfELkhu3SIUT8jLtGfCwRrO+NFSDE0cSpR4+oJ67IUT/X8wyLM2PWZXeXMaBva1nispemFCkiLN9pmKT7WsyIetD1Vvs4dUrWxuRDxPwhX66YY2d8rEBgNFeCbb7OkFA= 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:20 +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.4/31] crypto: ccp: Implement SEV_PLATFORM_STATUS ioctl command Date: Fri, 6 Oct 2017 20:06:02 -0500 Message-Id: <20171007010607.78088-4-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: 43ef6b1a-fa40-4269-e090-08d50d1f9f2a 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:O80LF+j33Edpklj7/UjYCp9Z5f6C9U4krjAaVP9XJ1JHC04AVsriXa5I1B1XffIon/VFjPO1T+9J8pKQABwNw7TF1ENCdEZty6Y/Yez87zrDfvmQkftXoL3yIPVMgLts7PJhnMadgHXgV6YkamlCIJTWbEAA0ZdBOe49hncirH+TAZVvECIIJnSLzpLW+01KIcb9yQrVge6yFWPDjGL9XecsmTRCZ3cFNawFCJCXvqFDg+c5FTPc15t2OdwsSRSc; 25:OVHW2CRQTtnHtbZ9TbOdc3bWUxl//iOMReXsFYlA8UdG80aOC0xFoJHv0nwOh0yPeHy87/ENNGSK2D+Z5HYjrfKQVl3zu4AnKjR6+8nViu4ZxYRnSxzPw9Ya9hkWOCOxaYkzlJt/so73qcIPC20FLFI5XvsGgf2V3OkdFS3WMcljzqhUbFMbzoOuht2JHvSszvqGj5s6IdEXBCCLMvOMambmV8FsEyT0BzpvTUVz9H2LPSolxMH4rab00LYl2i/EDMeUrp9Ebpctkk2Msrq6AuZNvCPPucBwlto18KPsqn1/47aHGJ0hifl1kYiXffURdrlov/YzkHG6L/u9TtO7WQ==; 31:I1ki1hBzXtdJZiJe3dnoBmIRQ7oIMS9MLEEhCfj0z0N2a45AwPzZdNsfCbEC5j4FeVT6KFlMoWfIxYaQD10v8nl68q3Jy6argrfSY/yVhcusoEBD9M1pPK42XY4gLidH5cbQZc5RZSVv2RC9a2Hgwgp2aV5VcYYK+CRZoTE9/1ysQH4zjmwVPEgqp4GSioW9rZjuWqlJ+LaEC4Xzx3eaPgTvuqy9BS1YmW3DowW827c= X-MS-TrafficTypeDiagnostic: CY1PR12MB0150: X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0150; 20:h5Os+ttN+zqJRaV68jkBzV6487XJn6Tt5TtMJI8x8UkFQXB75fbTVNE5+xz9ytMfhxJ/V912iRBcMRm03FY47Io9kGmORngFw5pWrhD4272N3IkE1usc7V1NDi7W8mmtSKWQHG3vsXA+wjt1yqJvaL7kZ402DbAoXtxqOUwMY7cGpd+jr6dvANadX99ex+Yapp1nCxku6cVmb/wk2YS3GYCiaPC2/L/gspSrga0FKeZiyxQokUDOO/RvlZiohCdDvzfoibtnXM41YD69D/uxxQyU28ujcjtOYkui2mjHKEO/L4lrjb6s/iRyENDzi0qFFoFGdZv+ke75ov0PQ1EF/hxbrx7KjJeLDG0YpJFth6VCGE60C6qUynnQdgbh1sFM4GIDZZIzx5ahZpHItMuAMDKW09TmV4UssPfijjjm0/afS6YOFqaxc4a+DpF5WwgCHHHZtDDe4TcFHApuutgLZEikzunpEfLZgxVRnVq+vUKoAv/JFalvj9UXu2l827Qw; 4:tAEVT6r0GKo4O7Q6Kxx1+zlCDX2KFX7qZpM9yCmRPaGa/XZtdKVpHVcYTki90fQ0XNVb8Dj1MI/RBr0aTexBbyB+DvUc+hw2fN+y75ce/GXPs4yJDUaJBHQeNEdb5WGMn6bmDq24j/swElPEey9WD6izKqZtnzEXtfpTRcHq8H6G3mEG7G8RcqDfwoMuOMIlfv1sIf2IdoSWtkfNut+PlpcV9Kf180SORFTxqHQMASuz6GJQQKlOCf2B3C+BgvF+gbO0ZsbLs0D/iDRLSHwg8N33Dfj44VmpIS//7A3xR2GmSJUpDvOWM7ui181rRbZE6NNbOB4IIUvfxlBAhk7h1w== 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)(6009001)(376002)(346002)(5423002)(199003)(189002)(45074003)(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); 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?MTtDWTFQUjEyTUIwMTUwOzIzOnJna1BMS0hjSEtZQ1FlNXJLRG9hRm56WHBL?= =?utf-8?B?UndUTTExNmM0Yyt1Mi9LTzV0SkZPZ3FlT1FUOHNwWVF5akdpai83U1pORTNs?= =?utf-8?B?QzdlazN0WjY3dHU4NEsxeFY0MU96d1ZHWlAvMDdwVTcydklqc2c3RmF2eVB0?= =?utf-8?B?bG5XUUNYSWpGTmJpQ05iL3FQSGJTdXFQT3h5bkxjUktIK01vSGVkMXlQUlVN?= =?utf-8?B?ZGsxYUpxZ2Z5RnI4bGF4bEo5cGl4eDE3Snpadmd3T0RiODFIMDNWa2ZIU3Ez?= =?utf-8?B?SkRoUGh0TDJUMG9LeGlXcVAzQ29kYlpteC9NOFp2THl0MEw2WExyOWtwT2I1?= =?utf-8?B?YXB0WXFKQVFqVDMyUWEwRzRJMXdFaExLVzNT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6297vfn17m1/PsYvS6hZ1PsCVs1NYfscmdQq9031uCSsMExgQTILaXbHD1OS+RqYQdcOFthmOcbHyDstmvggh03o6W5FohonmOZG5EBCdIldL85peHuoID+TpX9sx0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0150; 20:C8J2Xhcp7EYeubVah7IDaKqJWi72QuUfe7/OK6wVbGo4JZgH+hDTgylEoNlj1LvAq2TWaGSo0LwzE8RIUL1+XxRZxA6bCaINcn0DFin6vFWuUvBShlGx+snOQRmZ5p3kGXXOrk0tOhEA3q8Kgx/ZuPASpRg6LLTll7SW7JTVo1QHGtYUKq3aYjI1bhvHYvq2pIjbNLtCnx+TQw7sZCjj3KjhrcZclvAgYjBC7d9HLp52YDWMnyMJ9Rsk11f3Lp1e X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Oct 2017 01:06:20.3171 (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_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 Signed-off-by: Brijesh Singh --- drivers/crypto/ccp/psp-dev.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c index 94a08c371bda..d68303a06464 100644 --- a/drivers/crypto/ccp/psp-dev.c +++ b/drivers/crypto/ccp/psp-dev.c @@ -177,6 +177,36 @@ static int sev_handle_cmd(int cmd, void *data, int *psp_ret) return ret; } +static int sev_ioctl_platform_status(struct sev_issue_cmd *argp) +{ + struct sev_user_data_status out; + struct sev_data_status *data; + int ret; + + data = kzalloc(sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + ret = sev_handle_cmd(SEV_CMD_PLATFORM_STATUS, data, &argp->error); + if (ret) + goto e_free; + + out.api_major = data->api_major; + out.api_minor = data->api_minor; + out.state = data->state; + out.owner = data->owner; + out.config = data->config; + out.build = data->build; + out.guest_count = data->guest_count; + if (copy_to_user((void __user *)(uintptr_t) argp->data, + &out, sizeof(struct sev_user_data_status))) + 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; @@ -198,6 +228,10 @@ static long sev_ioctl(struct file *file, unsigned int ioctl, unsigned long arg) ret = sev_handle_cmd(SEV_CMD_FACTORY_RESET, 0, &input.error); break; } + case SEV_PLATFORM_STATUS: { + ret = sev_ioctl_platform_status(&input); + break; + } default: ret = -EINVAL; break;