From patchwork Tue Dec 5 01:04:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 10091953 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 E675160327 for ; Tue, 5 Dec 2017 01:15:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB07228AD2 for ; Tue, 5 Dec 2017 01:15:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CFA1028B2B; Tue, 5 Dec 2017 01:15:36 +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 5182828AD2 for ; Tue, 5 Dec 2017 01:15:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752346AbdLEBNu (ORCPT ); Mon, 4 Dec 2017 20:13:50 -0500 Received: from mail-bn3nam01on0083.outbound.protection.outlook.com ([104.47.33.83]:27456 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752297AbdLEBFg (ORCPT ); Mon, 4 Dec 2017 20:05:36 -0500 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=4+PiGyZYcgYU+FOcutFaCkfDAH0N1aykpx2Grvbf9rw=; b=yAO+ZPiyxb1Gr3QslW9MPrAsVGK6HW3+uACaa4aRnGdEp0s+m0eUqSgm9mEtg90GYtOIFDB61/SV8ap0KEgasKG7x28HDkds6S0YKCtq1zM5K2Oe7bzBibtIwkbAY/crPOffOovCdaOQ00qMuCzoowKJutnj9mBIYWxvdeH+ROI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from wsp141597wss.amd.com (165.204.78.1) by CY1PR12MB0149.namprd12.prod.outlook.com (10.161.173.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.282.5; Tue, 5 Dec 2017 01:05:07 +0000 From: Brijesh Singh To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, x86@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 v9 15/38] crypto: ccp: Implement SEV_PLATFORM_STATUS ioctl command Date: Mon, 4 Dec 2017 19:04:15 -0600 Message-Id: <20171205010438.5773-16-brijesh.singh@amd.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171205010438.5773-1-brijesh.singh@amd.com> References: <20171205010438.5773-1-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: CY4PR0601CA0087.namprd06.prod.outlook.com (52.132.96.156) To CY1PR12MB0149.namprd12.prod.outlook.com (10.161.173.19) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2852992d-ed82-4d71-9247-08d53b7c3a52 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(5600026)(4604075)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(48565401081)(2017052603286); SRVR:CY1PR12MB0149; X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0149; 3:5y6NpmzZbNkPgDXpdZ5CgmfQSWX/SuEEct3ys8bBwoHa3p3C+bEjbjDq3pOjwbgRkzQ2C0Ql3O2oaTrVxJ/731T5wtRUbBN1rlDykZ0Rcho16/AD4leuKCtTOleuLVwdi/YgwGfG1Wzbl84vmZbNXF6AuRR/eDTZf70JD72efT5VS2B/uxxJgJeSoWwHtODgiQFHJnzfAtMc8whyrLQeDwt+C2uX9F10oJp6lgijT0S3D7/FnolScyCD82d+nxht; 25:coHI16F9piDNNmZJkHjg5yeSKmbddK0mIFm3XUrq7oJPjRV9uDrvL05MiLTmi+Ck6u8zHjrBf4wkQNkZfrWreBX1Q5pBWIdvtnTBuhqNXy27WKEEgKf1Ibcp3nXbjImQwmrBlPUYgfkt/gd0mn7YXDQDu62mc0sS4d593+M1N+h6680An3uRe3SPIDk1gn755/CQsppvdr1oruj5I5Jl1jh5utmP/whbpSQ37ajIyRHGTx9TUGu7SRY5LPaXzlp4Rvu4E0JzApb4yxy/T2J3yaKP5aNXE02LLTkQXsWqClkTT30BtE8Sed0Jz75uIOl78e/HRVv/oo1q68Pk/0/n7w==; 31:8wVoFEpfeomfRuq9QbzBR15Jx3wRmYkTTUGMk5omzRpdA9Q/goGDREUFJEuy2m2Cfkdci8nhbndXt3NBFCZ90DrfDnsf7bYDZSg8kY52dwWDxGoaOxMFJ56L1fu2i/RiXK8MV3WMXZLYhs76PkTJhx8TIbtEIrmvf3GJWWDLWcnt7x+8rnZoULK4w3avFJqLxSvikAVRN7/UiZLMbBruV/c91Wi+Js1qi91R4zUrnPw= X-MS-TrafficTypeDiagnostic: CY1PR12MB0149: X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0149; 20:JGGUdXUvjocb30Wt0gfUAclg8eLLn3RyQ6Ro3aUKaqB5ejvKU21vpevn1PmMJKp0qePqvCK6tPIGIFZvOcZe/yNap2H6/7u6U9LBsTOz2+CBfZGUeN+AzYt9IWKP8/Je8+HGwl0NVp/CC+Y/d12XnHpGDc2q5GXk5RTJAjw1wJiQ+s/eDdwBBBWQhphT+aoN7hmrlHLjKi3ZCok6unTN04jVSyeAelNpi3MgNgMN2wwNpN1ddXfpPJr5WE3wuSPTm6Ih+w90Ebo7XFdsdZY/S2qnPNTl8rgdWaMd3rh+S4nAf3rJA2pe7Ee/KKDqtxxnstYX8j02IsM254iLCkG/f53/R6OvuQvM377NMaACDtLBdtSxL0dsIHbsuPoOKYwWNFKzjeTu6+5B3YZ5NmqYNDCVBm19nTgV9F7pTK4HJoUGRx8kpig2CmR2Y8rpmXDQsPUIHR8gz1aa3CrixogKYVgPv0Biem2sPJcpzJy7Osg9teTdDj98WInwB6anJ1ZO; 4:k4RLmZNGL01Jf2KYAxCRFebi6J9VY3QiHqFbQohQMkvPc4H76QNDWOZUh+jQEAIS0mHw+l3/I+Kr4s+/KVNJV7c70Nf2Us9yIOpTwiiXUWF9s7l982S+HbGbEtAD4vWdHpzDvi+wmo394n8Mouwnc+neEMotVnD06P7d3DlWwCMsCPHYoIz1DIN9cJ+hYjHYLZhbTd4nI8px59Z2QIVB8gpy216NV9YPHb6W/472LyfDLZEo/9S+ftG6NHSmlFti8X6sVwOpeNZaZPGH5umlUGdDgWmoDqdUTkBbXdOhO/JoOQ6QeC9hlDq866T7/JqiwJ5cOkUTqLHcUtAGQYSChw== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055)(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3002001)(3231022)(6055026)(6041248)(20161123558100)(20161123555025)(20161123562025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(6072148)(201708071742011); SRVR:CY1PR12MB0149; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:CY1PR12MB0149; X-Forefront-PRVS: 0512CC5201 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(366004)(39860400002)(346002)(376002)(45074003)(189002)(199003)(16526018)(189998001)(106356001)(478600001)(2870700001)(101416001)(23676004)(52116002)(97736004)(86362001)(7696005)(33646002)(54906003)(25786009)(105586002)(76176011)(316002)(2950100002)(6666003)(7736002)(2906002)(6486002)(50226002)(81166006)(81156014)(8936002)(53936002)(8676002)(4326008)(1076002)(305945005)(66066001)(6116002)(53416004)(5660300001)(47776003)(68736007)(3846002)(50466002)(36756003); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR12MB0149; 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?MTtDWTFQUjEyTUIwMTQ5OzIzOm1sNmIwNUdDUnhXRzZueDdHRXpTenU5dHFG?= =?utf-8?B?RnRyT1BpZUVnYmtMYnN6WkdBWEFMa0Q0VndJQVdHR0w3emlkLzN3aW4yL0FO?= =?utf-8?B?cU91K1JGemx0dFpKRGtjOFpnbE1jVStoNVZyZngyVVJZMzhjT0s2K1l3N2hX?= =?utf-8?B?T01PVzZpOEJ6VkEvTVpqQ214b1FaVHdzdEpHTUhFYzIzd3dzMnd5OGh2WHJB?= =?utf-8?B?Y3dySTUwSTdQN1J3V3BiZ2dGZXNhRnRpUzdnbElUM0g4elZTNkQrS1hmQmI3?= =?utf-8?B?NytYL0RvRnVCcmgwWEt6OTZUaWFxMmdmZGtwcWl1LzQ1dVN6cFY5aWlaN2p1?= =?utf-8?B?Qnc2L05BTFdIODRrYzFYRTBiNi8xZUJxeXAzay8yb2RrbXJIaFUwcXdHalps?= =?utf-8?B?UC81a2FIVDhTaitydityMEhUNE4rOGZSRHpSTFBjUkYzTUp4b3UxenFWNEhS?= =?utf-8?B?TUo4aUxWUDl3ZDEwMGh4ZEFpT3lsME5uQWZ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vxuWjitFExoDhfsF6U/4M7y SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0149; 20:cxo+qHDHB2vhGU7jEJwE2KZaqIlkPRUGZuyODlWuBmr2MmHPl7zB7hWob6MIp2oEaT2Edx/Daypow1VoYO51NCEoFmoKKjv1jFIzETanZGNsjejhemJZFSPXoXwH//ymT0n1g3Zm9ilZ6alixmpFtb/bmaguxNQVj2ENiTp9MYnAAaKtZjBqPD3wfUeJE2+taXqp8r8Eu3l6RUp4ghs6V5v2I8hYZ+bYI1/8RtStUmYd1H8xZvLG3vsFScjvc51Y X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2017 01:05:07.7641 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2852992d-ed82-4d71-9247-08d53b7c3a52 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR12MB0149 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 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c index b49583a45a55..a5072b166ab8 100644 --- a/drivers/crypto/ccp/psp-dev.c +++ b/drivers/crypto/ccp/psp-dev.c @@ -274,6 +274,21 @@ static int sev_ioctl_do_reset(struct sev_issue_cmd *argp) return __sev_do_cmd_locked(SEV_CMD_FACTORY_RESET, 0, &argp->error); } +static int sev_ioctl_do_platform_status(struct sev_issue_cmd *argp) +{ + struct sev_user_data_status *data = &psp_master->status_cmd_buf; + int ret; + + ret = __sev_do_cmd_locked(SEV_CMD_PLATFORM_STATUS, data, &argp->error); + if (ret) + return ret; + + if (copy_to_user((void __user *)argp->data, data, sizeof(*data))) + ret = -EFAULT; + + return ret; +} + static long sev_ioctl(struct file *file, unsigned int ioctl, unsigned long arg) { void __user *argp = (void __user *)arg; @@ -299,6 +314,9 @@ static long sev_ioctl(struct file *file, unsigned int ioctl, unsigned long arg) case SEV_FACTORY_RESET: ret = sev_ioctl_do_reset(&input); break; + case SEV_PLATFORM_STATUS: + ret = sev_ioctl_do_platform_status(&input); + break; default: ret = -EINVAL; goto out;