From patchwork Wed Nov 1 21:16:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 10037173 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 30755603B5 for ; Wed, 1 Nov 2017 21:17:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D67D28BDB for ; Wed, 1 Nov 2017 21:17:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 206FD28BE9; Wed, 1 Nov 2017 21:17:16 +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=ham 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 4658228BDB for ; Wed, 1 Nov 2017 21:17:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933532AbdKAVRL (ORCPT ); Wed, 1 Nov 2017 17:17:11 -0400 Received: from mail-bn3nam01on0087.outbound.protection.outlook.com ([104.47.33.87]:27280 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933175AbdKAVRD (ORCPT ); Wed, 1 Nov 2017 17:17:03 -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=osPAT5YDOH59HbKup033vXez110fGLt7nHi3c8v+qxU=; b=RSi93CL5Ci4huMf8bo3OGPT0xtRcGqWj8Kaz5okvXypRim7EQjH3arH82LWvasyhAznKTSXsBTv4v96SBSvfE+zqhMkU8Dc/HSiQ+I1+OgfTXT/AXeVgkv2AzcnI41JZAJRyi1F6EiH4xeAvj41cixkk++lPUfKjrFAl33FXAb0= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from wsp141597wss.amd.com (165.204.78.1) by DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.178.6; Wed, 1 Nov 2017 21:16:46 +0000 From: Brijesh Singh To: kvm@vger.kernel.org, linux-kernel@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 Subject: [Part2 PATCH v7 15/38] crypto: ccp: Implement SEV_PLATFORM_STATUS ioctl command Date: Wed, 1 Nov 2017 16:16:00 -0500 Message-Id: <20171101211623.71496-16-brijesh.singh@amd.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171101211623.71496-1-brijesh.singh@amd.com> References: <20171101211623.71496-1-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: DM5PR06CA0064.namprd06.prod.outlook.com (2603:10b6:3:37::26) To DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 52ef0166-750e-4ca8-5cff-08d5216ddbb3 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(4534020)(4602075)(2017052603199); SRVR:DM2PR12MB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pE78qgdawHjra5+2RBwnM6+DBEjwiNMNcC/mSAaqma2YIdKV/z+bHbYs/TPG28NdcM1S7Jg1spo+mwpjAnXpF4qIHIND7GziHBMl7wNjnCjRmUgpq35Hoakc5gw4WNR5mU+l/5tXcdrnLqpHXDY6IAhCVfgesuz5WPCeGeHoNbM0x4QneU4RWBjsMy1tDGCzwUMJJZq7ZVtueOdKXE9kck/15trejcqRVeVxGcuOYw7cIYmiCFyMIug3tiQsHj3flT4rgd9cJZd0Ba8hSLM9Iup+AFk1ZxU1CRwpm1vCXNWzQchOtrKuJb1zQKcZxzElw240iphqLaQBTzj3otZIJUMOnhDrRyXK/XYQi7yh4Ac4BwFVqDIakmm0KB7iuwkreIyf2QnjlP; 4:a6lPfn+vF1VLXKAgN4+Tfg/KTyxDmpgaF6v5WW2n/s19afrnAq07c6Q4mfSmGcWL+412uMWvjhsIvULfHqdGoUAuOiC2dXWWnPPURfNd6mvXwwMV6UwVsNMr9PGpB8nUOEcI0U0XXIL+hdr2ZytlBPTMpVODWhoR0l6CoqSzzawzy3npkFau0D/TOZ3SpTKTZPKJt9Yz0gWSDJOMho3ezOUtxCS6jGl82VpDZvrPTGgyHfJifFKoqM8hinXOfXuzf97b8ITWftIR1cCMj8Mj14oqvgIQL5HtthHOK5+MGXaAvm9U5O8Lo/CcebeTUN7FwJsmuq3I6mU3N1X16Mwm5Q== 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)(100000703101)(100105400095)(3231020)(10201501046)(93006095)(93001095)(3002001)(6055026)(6041248)(20161123560025)(20161123555025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM2PR12MB0155; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM2PR12MB0155; X-Forefront-PRVS: 0478C23FE0 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(39860400002)(376002)(346002)(45074003)(189002)(199003)(1076002)(6116002)(97736004)(66066001)(50466002)(3846002)(25786009)(4326008)(54906003)(316002)(8676002)(47776003)(36756003)(23676003)(50986999)(478600001)(81156014)(81166006)(105586002)(53416004)(53936002)(189998001)(106356001)(2906002)(16526018)(2870700001)(76176999)(33646002)(305945005)(7736002)(86362001)(5660300001)(6486002)(101416001)(50226002)(68736007)(8936002)(2950100002)(6666003); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0155; 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?MTtETTJQUjEyTUIwMTU1OzIzOmoyNCtLL2F1S0FxeTNOSUFMTEZoV0JxeVZN?= =?utf-8?B?SHl3SEF4ZWZqRmhkSWNJYmhoUTJ0NlNBcW55STdCRVY3dTJkclhCaVNpVU45?= =?utf-8?B?NmRaME1vREs3RVRkWG9iRVM4WENSMXNoaFJaRjZIL3RMeVIybC9vL29kNDlx?= =?utf-8?B?bHBWNGFvcEMvVlNlQTR6dGpsZzBmRWlvcnA1VXNCLzlFYk04YkJvWC9pM0dQ?= =?utf-8?B?TjFFT0o1cHF2YXZxZVpzbHpISXBVSGIzQlFLVHhXbjhpc1dHU1RUaC9GajBm?= =?utf-8?B?Ly80MUIyVWRMUnU1UFVyVDdkMHd2cDNTb1ZsQldZZjgxNUg1Z0trR1ZsOHo5?= =?utf-8?B?N0lOa0JvZXB1VkdidWFId0JyakZ6U1BmekpiRjU1WnhOeURJMUdWTlducGQ4?= =?utf-8?B?OV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yDd1paq4fsbhX3n8osZTbMtzikH4up++z4TuqWbfg0u2Sa/ZneywkCtrtU/Gx3UM1Zbv+R1RVHP6jbYx6Xh4J/FfZg2KLKrYiveY17QHChTG8kGfUrjyzciG SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:hZ1O3vW8Vx90f1+vORMoC93JTDVu+d92cTN3K1C4v5dAwUpgqs8U+RZwK7Y9NbEEKNpVW6OMjaoZ397wR/BDJz4OsKw89QEiWvIJmH2UQu6bO+XZxiWXL3Qs9wRKCgMY7DuGIHoI7I2O9k1rJywRaCq2IAxDHu1Ki2czZr1C3Bjo3ktergFKUzMWDVEZBRhg50a+AL29KPtfMmy+Zm+5YRJAT30K9DoHpxgXHL7W7aiWCYMIhXj4DMlcVh3VkNCz X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2017 21:16:46.0628 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 52ef0166-750e-4ca8-5cff-08d5216ddbb3 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0155 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 a757bd1c34e8..ef473ec4a413 100644 --- a/drivers/crypto/ccp/psp-dev.c +++ b/drivers/crypto/ccp/psp-dev.c @@ -270,6 +270,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->sev_status; + 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; @@ -295,6 +310,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;