From patchwork Wed Oct 11 17:01:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 10000101 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 5387A602BF for ; Wed, 11 Oct 2017 17:01:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 599F828AC8 for ; Wed, 11 Oct 2017 17:01:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4E3E128ACD; Wed, 11 Oct 2017 17:01:46 +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 B350228AC8 for ; Wed, 11 Oct 2017 17:01:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752120AbdJKRBo (ORCPT ); Wed, 11 Oct 2017 13:01:44 -0400 Received: from mail-sn1nam02on0073.outbound.protection.outlook.com ([104.47.36.73]:43824 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751908AbdJKRBl (ORCPT ); Wed, 11 Oct 2017 13:01:41 -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=bQJtLXBEk3iJtanKoxDAMm1z+mVFJ1f2AQTZchUDQkc=; b=lZ+E3PnLAdTYt+GBtszHlAqqH4XSGIpnGRfEgOB+JYga/BtivAj1Zw1Q3+hOabmszODsWQkXY31DpTYw0r0bkF4Q9+RYLENzCRSfXDeRNJwCHUustH6CgcpsSIjVcC0DTOXS1KX75M0AQhRrZJq0F4WkNdxmzMUE6HlRVmgcFGI= Received: from ubuntu-010236106000.amd.com (165.204.78.1) by SN1PR12MB0160.namprd12.prod.outlook.com (10.162.3.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.77.7; Wed, 11 Oct 2017 17:01:38 +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.2 12.4/31] crypto: ccp: Implement SEV_PLATFORM_STATUS ioctl command Date: Wed, 11 Oct 2017 12:01:26 -0500 Message-Id: <20171011170126.116154-1-brijesh.singh@amd.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171007010607.78088-4-brijesh.singh@amd.com> References: <20171007010607.78088-4-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: BN6PR04CA0043.namprd04.prod.outlook.com (10.174.93.160) To SN1PR12MB0160.namprd12.prod.outlook.com (10.162.3.147) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5e4d160e-f04d-4cf3-8125-08d510c9bd46 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254152)(48565401081)(2017052603199)(201703131423075)(201703031133081)(201702281549075); SRVR:SN1PR12MB0160; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB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bkFiTj9oD23NOOMFvDeGmiqipVJXnvYM7NYhAuNntGlGOGERD3wJiw1DEZvYceQk2XI4Je+ZZ5lW+HIDoRWvDuP4vYQQw179U9+RAu5sGr/HU1WFfFLSPtuYjHTk9TL3Ae3MCoA3F6ZXZV4UoJFdOmnPdw3SOGB1S+2yXQl4h2l2n+stmqhPzDkBd5Tzj1GGjX2RVggv9zG9G2taA60IsBKqFnIOPxxLEAQBSbpXSc75yAZVlRT4B8JMna/Kikdfv9PJsBnS58lUpeCGD6u2vr8JOmmzEDwTBgrT8jLD6SjIaC8fhzcvolxHcgi1FTOVKdPkIhbW0hYpBRUf5vmGPubafTOpY5; 4:q3SWn6DPsn5Hk0c+m70JOXGKzukOLB4lPfpxHpdnpbkBWaEiDRhjdy0juih3OH2QR0zCWXLjZS+WgWA0+hckPh3CPKOkM9YHAt6R67zvHqhd7KHXYCX4mDolbWovS3YZYgQ5UIA80sTLofqbSQgKnncUXp7vvXx8sMPh09H9GfWKRR8ON/n2+R0UoF+umcylcbfylNHuZxKC2sHTrsQM5xyyTIrmFsMVmbxvoCFKJZP9aXn6r1jA5XxWbPJO3cuF//9G2ksmc+UWu0DZawBkY555ZhdxzUI5Tgl1zaLmTeD7Uwj92qw5o1zmMf1/CIhsO3USxHE3tN2trocMFfAU4w== 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)(100000703101)(100105400095)(10201501046)(3002001)(6055026)(6041248)(20161123562025)(20161123555025)(20161123560025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SN1PR12MB0160; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SN1PR12MB0160; X-Forefront-PRVS: 0457F11EAF X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(39860400002)(346002)(376002)(45074003)(189002)(5423002)(199003)(101416001)(33646002)(53936002)(6916009)(50226002)(50986999)(76176999)(2870700001)(106356001)(81166006)(105586002)(66066001)(1076002)(53416004)(50466002)(8936002)(2950100002)(6666003)(2906002)(47776003)(6116002)(3846002)(97736004)(316002)(2361001)(86362001)(2351001)(36756003)(305945005)(16526018)(4326008)(68736007)(81156014)(23676002)(5660300001)(189998001)(7736002)(25786009)(6486002)(478600001)(54906003)(8676002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0160; H:ubuntu-010236106000.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:3; A:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtTTjFQUjEyTUIwMTYwOzIzOjh2UGpLRkE1RVcwaXJ3Qy9vdEFvU1NKL1Z5?= =?utf-8?B?MFB6cGlsTzhtaDU5U29KZUFQc0k2SHc1NW1pOEtGVVd1SzQxbm9pb3NuV1hR?= =?utf-8?B?WEtMU04vMUl1TmJsQ2tsd2l1cmdnZzVnazZHUWhWd1BkZTdpRzdqWmhlVTg2?= =?utf-8?B?RVV6MTVzV29oM3lhbGhlWU1pRmpzcDh0Sm4zdGhGN0MrbEpvVVJ3ay9lTk56?= =?utf-8?B?aVB3S1lUbDJ6NEFkNnJTZUNlRkszbS82d2tLMzVsYXdXcnptMVU2U0hJRzgv?= =?utf-8?B?anN5aGJhZ3NxVzBFK3BIb1hZcmdWVk9hRTBmVG8ybFMwSWJiaHNtUXBMalU0?= =?utf-8?B?a0F4dkxxTjMyaVVhTkhJMlhyVG1lZ1ZCTTFqVXV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Lv9+SfVqreSXZxbG7LIkbc0yIdg21rC33iS2UvlvDE8Y9wR54NKDBO+K49taXIIzDGKQ7dw0sbMRDAQk4uPoglhAL4Bf0UZS0Lb+5+YxepJwGtvwwg/tc/ck4+j3edNmz+ywQeV5Z0JrKlseAPmrCrQRL+sGLThIWd86CPXJu6nHJS+imTgrq//g99LyAKHdFdo5qLqkqY/6E5XfHeHA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0160; 20:5SeiUNjH0pc9Rx2tXn5u4QKQ8/TOs/0dk+Bo6AhVUiH/hOQ+b6lvVt4sbmpibrP330H5WknpMR8Mk88vRb50JjiF+PwYcl/gBo5zt8Vz3HDgXQHNb8sPmmmJgNP3VGKbj2bF/dNZ4A6oiu3N9MTWvuCJd614Tb7cIkAdQ5Yc30OrWiBOr4DWW5xsSlWJsJdIxBe6iQA96N0JGbyKCRZvWry3sF9vA21fprofAgscRQSISHcs0AXpyY3mWJ5uBu5F X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Oct 2017 17:01:38.4341 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0160 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 --- Changes since v5.1: * rename sev_handle_cmd -> sev_do_cmd 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 a9c885a39910..1f4925cf9ae5 100644 --- a/drivers/crypto/ccp/psp-dev.c +++ b/drivers/crypto/ccp/psp-dev.c @@ -177,6 +177,36 @@ static int sev_do_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_do_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_do_cmd(SEV_CMD_FACTORY_RESET, 0, &input.error); break; } + case SEV_PLATFORM_STATUS: { + ret = sev_ioctl_platform_status(&input); + break; + } default: ret = -EINVAL; goto out;