From patchwork Wed Oct 11 16:46:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 10000073 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 5EBBE60216 for ; Wed, 11 Oct 2017 16:46:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 56FA528ADC for ; Wed, 11 Oct 2017 16:46:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B92A28ADE; Wed, 11 Oct 2017 16:46:35 +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 2374528ADC for ; Wed, 11 Oct 2017 16:46:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751527AbdJKQqc (ORCPT ); Wed, 11 Oct 2017 12:46:32 -0400 Received: from mail-co1nam03on0041.outbound.protection.outlook.com ([104.47.40.41]:26272 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751350AbdJKQqb (ORCPT ); Wed, 11 Oct 2017 12:46:31 -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=XVnDgRb0bPTy0EtJcH6SH8VrO2zzOmBVY8lco0glUFA=; b=RracD2Kmasczv6GcUGjYAcfIpyjzsrqIVHKwlUScxwC7jOR9KvmW+E8CP9WHuUb7FRlcSkBkdITWmP1G06oLu0OYTnFnKg+/XwlRBYY1DCojyOqHcCn5eVLV2nMEDi/IPeelKV0mxfL4PnnTzSR80vHNdN7Oh0ojOUbFJ9e6Ezc= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from ubuntu-010236106000.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.77.7; Wed, 11 Oct 2017 16:46:27 +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.1/31] crypto: ccp: Define SEV userspace ioctl and command id Date: Wed, 11 Oct 2017 11:46:05 -0500 Message-Id: <20171011164605.115592-1-brijesh.singh@amd.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171007010607.78088-2-brijesh.singh@amd.com> References: <20171007010607.78088-2-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: BN6PR03CA0057.namprd03.prod.outlook.com (2603:10b6:404:4c::19) To DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3258ef5a-bd78-4e49-b43b-08d510c79e46 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254152)(48565401081)(2017052603199)(201703131423075)(201703031133081)(201702281549075); SRVR:DM2PR12MB0155; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 3:/IIyjv80KvjBl5ZUHo7QeDGkt+CdHzSdbdV4UJa0xSBwRkXii1MkB8zT7c8bAWNkkcAPU2TVMePtIMaXZgrsAryzchbHjvrTV4ZDuJdQtJvJR2hTZ+sPMX5WjvgA8ReDmM+FBGoT1fpmKGwrWiErwPseShWWs7tCKEzB4Hsu1UvYeMlaR99h0SwacbgcwSjTPsG+KBWScH5QQ2MQIJ7droo+kcRkyBmNkuDym8H9mFGjPNhqneprc44Wp+aQL7RR; 25:H8cLQkpbwyxXKkONh3Dl0eHjldSElbm5s+nZivagzR+hcpxnEdl5XMlfgUiJudENMyMvnwfX31gDrnxM8/8IjYCmKC9t+0+HdnJQ7VmH6ObWMnmUk5Vm9lqA2TwvZKCGLAOJTUCKgKmpUaWkylBmro0vWNL1glJ0mnTA5GI8OzhXEA02Klod5c9L7SdRYAc7OTsoNIr9gG6t1HK7y/JtarX5Zz6xn6ogfrEag4cMb9/zIWr87qimFPb6BvUtZ25wVj2yeUIVLbcCI5DQEVreBN3d+XPGUKvgMF8Mv+Jigh8/mcny92MleY4077ICWOAQdyzl2HA+1svZs7wCHoqw7w==; 31:yQrNYk5wTE/qcE+xyuXQbrPozJW4ZVX0F9dc0OsBlFUbSdSVgfxsTbW2s6eJXSMoSYrYVIuig5+H6Gai9ucvgsgsXRzoTftFUmefIFwhUz0enuwjRG1MuCmO6udILdXQenx5RrLN5rCHMWvc80Avam+LhzRoCLxTLuWuMsNy1WTP2NTC3IH/4ZvtE4Yx1Q0fY3cMLnkuJyhlnXDupRqgLxNJSgi772lGgSdx95DJIpU= X-MS-TrafficTypeDiagnostic: DM2PR12MB0155: X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:jZRxIo1C2NQST5Gnumvdee/8JQs88IjUEk//7wN5yCkX/MmEIymBLwkGebr+5Kvi7RamS9NQGoL74Kxh+nZphVxkVpI9VRgzC+hij64aSj4ahv8GP++GJO0M3cmEa0uDFI9RkaIakkRRLAi0QxVdkAnlQepaglfT/lhLBkp11sqRYFN3NKkuP3nJDaeQvvKLi3b6HD1cJz1SFHGJQzQAdZj0WZkTMGtZGT27E6pL+Lqt6bCC+EU8wOZfY3Nz/2kt0DFdGJaN6FM28VMKNw9CE8BJr3pPkxpZo/eZzV4pW5ZwaZr5SgQNhDQzMxQd4gcmdmtouU6RlighykYztvV3IcWmxqHLicy/dGzM6QQxzLN7Mp+ZurOrlLx3Krops4SsiU07PO7/IgLIhUA1hMfvFba+MgglQJu9hoCWnbYPiB481QqcdXaCAAzmkpm0Wy06IjQS5Hd8pvGsHCmHCWr7FHgoG1Ykgaa4x2y/PPcP+a3xG+u55vYarb3pnMibWPWi; 4:oPvkrEn5fn9U7vyIX+MXYqPfB1+caAQNzsmjYvJCJXAD6n6ULC18dpG17VFEP4AoQQGkrmQh2DoOce3RMaGRL7bFNPbAPZRqMNAJ35c2XdTceoaDubrUfdTxMM2gDvplesTGaQg1B88sjqzkOKY+/cCPhQvFvs4sOqZC82WxxIuZqs9OsLx1IReLBCCopMGRSSvm0omPLZ39qPZeCJF6Lke1v47e7SIeYU6YW3X/LCIG7uXj1GsFUIn7pRdOgztC049EYZWFoTSkl7UjW0QQ8KDut/lIK/I0iuVBxjeRSl+r7DlqyN7STp3S/OFMdKfPBzLdiutCpsXtyxXdxSc35OW+KXNmqy4kds7JIqM+CbQ= X-Exchange-Antispam-Report-Test: UriScan:(166708455590820)(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)(10201501046)(3002001)(93006095)(93001095)(100000703101)(100105400095)(6055026)(6041248)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123560025)(20161123555025)(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: 0457F11EAF X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(39860400002)(346002)(376002)(189002)(5423002)(199003)(66066001)(47776003)(478600001)(4326008)(16526018)(53936002)(966005)(68736007)(6116002)(3846002)(1076002)(6486002)(23676002)(50226002)(86362001)(54906003)(25786009)(6666003)(81156014)(2870700001)(81166006)(2351001)(189998001)(316002)(33646002)(5660300001)(97736004)(2906002)(8676002)(7736002)(53416004)(8936002)(305945005)(6306002)(2361001)(76176999)(36756003)(50466002)(6916009)(2950100002)(106356001)(105586002)(101416001)(50986999)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0155; H:ubuntu-010236106000.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?MTtETTJQUjEyTUIwMTU1OzIzOlo5L0E5WDdFZ1pIWk03azE5Y3ZKQzF5dTdl?= =?utf-8?B?dW1SazFQQ2o5R05zTmZJM1FaeEg5YTRWSUVrT3dUVURnY2RCYUEvUWdCTmdE?= =?utf-8?B?eEtwZTVRSisvR1JuQzIyLzdmK2o5RFRnUUU0Z2tTRXFKOFFTeTc0Tm1uRlZ4?= =?utf-8?B?bTBaTS9lZVp5NG84MlpidjFUNmswYVFvUDhVZ2llMDlFU3Z3SFBnanlzWWhX?= =?utf-8?B?YXkwZWRnbkJTcWhVVEIwTThDKzVlSjYyQ29LR2lCU3NTN1lqRExBNnVhdjBV?= =?utf-8?B?TkladVdOTi8vaXU5M0Myb3NNZThpN3BrNDRkZXZGZ000b1lJQ29tUU9tL2lu?= =?utf-8?B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tLf+izZ1l4qur/gta3j7jg+mnHLInxidX5uw3dLCdL4HbqsDZ7IEm3H7qkYEEug=; 7:yOm5fHsLNVuXvh3NAbrir4ug0y7J9+ol/5XsKztoCgzlBzYcwDS+nUvZVriQgeoMaypyECJ8btdp80Sjner2pHijQV5TcvZbxEVV3vVgFvA5FvLqc/8V9Zmi3ectMyOlXijiZRCO9HfxGgEQxy9sJ0zAmsKGXI1jAPed4Q+5+ZwBPkl6WK+GY4RVDnWbVVGD7SSXGuhIzyKzHQ7L7Zeu3Az7JszUVa5Pc4TB+FO3BT4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:onYKlJuEFLADs+NV8ZBHFcpcaRMImJO7zIUZHvdGRHep3bACA2Rbu18qQBjMi1Empg/+Ji/ja/fnGbXKv8LUOSAl49jPnMRjTWm7kdSBjvCEYjeAxcko87ZXqJDxL6T7d4IrrJtXnoBAqlvaJKQE+A3XoTy8F/pTvB3a7zDcfCLhHQRUwweJZMOrqKh8tYKxkZpWVHEZZ1X0fCXxlhkwhtKHIjs66Jd22x+utRD7yiOa5olAusy8gwSORGxyrgGE X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Oct 2017 16:46:27.3701 (UTC) 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 Add a include file which defines the ioctl and command id used for issuing SEV platform management specific commands. 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 --- Make it as the first patch in the series (changed from 12.2/31 -> 12.1/31) Changes since v5.1: * add __packed improvement from Boris The full tree is available at: repo: https://github.com/codomania/kvm branch: sev-v5-p2+fixes include/uapi/linux/psp-sev.h | 115 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 include/uapi/linux/psp-sev.h diff --git a/include/uapi/linux/psp-sev.h b/include/uapi/linux/psp-sev.h new file mode 100644 index 000000000000..b63e116f18c1 --- /dev/null +++ b/include/uapi/linux/psp-sev.h @@ -0,0 +1,115 @@ +/* + * Userspace interface for AMD Secure Encrypted Virtualization (SEV) + * platform management commands. + * + * Copyright (C) 2016-2017 Advanced Micro Devices, Inc. + * + * Author: Brijesh Singh + * + * SEV spec 0.14 is available at: + * http://support.amd.com/TechDocs/55766_SEV-KM%20API_Specification.pdf + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef __PSP_SEV_USER_H__ +#define __PSP_SEV_USER_H__ + +#include + +/** + * SEV platform commands + */ +enum { + SEV_FACTORY_RESET = 0, + SEV_PLATFORM_STATUS, + SEV_PEK_GEN, + SEV_PEK_CSR, + SEV_PDH_GEN, + SEV_PDH_CERT_EXPORT, + SEV_PEK_CERT_IMPORT, + + SEV_MAX, +}; + +/** + * struct sev_user_data_status - PLATFORM_STATUS command parameters + * + * @major: major API version + * @minor: minor API version + * @state: platform state + * @owner: self-owned or externally owned + * @config: platform config flags + * @build: firmware build id for API version + * @guest_count: number of active guests + */ +struct sev_user_data_status { + __u8 api_major; /* Out */ + __u8 api_minor; /* Out */ + __u8 state; /* Out */ + __u8 owner; /* Out */ + __u32 config; /* Out */ + __u8 build; /* Out */ + __u32 guest_count; /* Out */ +} __packed; + +/** + * struct sev_user_data_pek_csr - PEK_CSR command parameters + * + * @address: PEK certificate chain + * @length: length of certificate + */ +struct sev_user_data_pek_csr { + __u64 address; /* In */ + __u32 length; /* In/Out */ +} __packed; + +/** + * struct sev_user_data_cert_import - PEK_CERT_IMPORT command parameters + * + * @pek_address: PEK certificate chain + * @pek_len: length of PEK certificate + * @oca_address: OCA certificate chain + * @oca_len: length of OCA certificate + */ +struct sev_user_data_pek_cert_import { + __u64 pek_cert_address; /* In */ + __u32 pek_cert_len; /* In */ + __u64 oca_cert_address; /* In */ + __u32 oca_cert_len; /* In */ +} __packed; + +/** + * struct sev_user_data_pdh_cert_export - PDH_CERT_EXPORT command parameters + * + * @pdh_address: PDH certificate address + * @pdh_len: length of PDH certificate + * @cert_chain_address: PDH certificate chain + * @cert_chain_len: length of PDH certificate chain + */ +struct sev_user_data_pdh_cert_export { + __u64 pdh_cert_address; /* In */ + __u32 pdh_cert_len; /* In/Out */ + __u64 cert_chain_address; /* In */ + __u32 cert_chain_len; /* In/Out */ +} __packed; + +/** + * struct sev_issue_cmd - SEV ioctl parameters + * + * @cmd: SEV commands to execute + * @opaque: pointer to the command structure + * @error: SEV FW return code on failure + */ +struct sev_issue_cmd { + __u32 cmd; /* In */ + __u64 data; /* In */ + __u32 error; /* Out */ +} __packed; + +#define SEV_IOC_TYPE 'S' +#define SEV_ISSUE_CMD _IOWR(SEV_IOC_TYPE, 0x0, struct sev_issue_cmd) + +#endif /* __PSP_USER_SEV_H */