From patchwork Fri Oct 20 02:33:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 10018739 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 65FCA60234 for ; Fri, 20 Oct 2017 02:44:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 525AF28DD9 for ; Fri, 20 Oct 2017 02:44:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4588B28E8C; Fri, 20 Oct 2017 02:44:49 +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 BE18F28DD9 for ; Fri, 20 Oct 2017 02:44:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751865AbdJTCoa (ORCPT ); Thu, 19 Oct 2017 22:44:30 -0400 Received: from mail-bl2nam02on0081.outbound.protection.outlook.com ([104.47.38.81]:36505 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751974AbdJTCe7 (ORCPT ); Thu, 19 Oct 2017 22:34:59 -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=2yPgm/g3ltyQibSws92HC28W84kbPgy3k2I00iMhbCY=; b=S7eEDR9aBdmtq0yJZu9JhmVeIg2zVonqDm1jpmoMj+ZUjxllRWKj+V4os1nqE2VuVGsSyOSwMb9xg4ObJl6zcfWCuK2fq3LvbSs6urxvGu/gM0B/SgbtHeWWidzFhUuB/heiWgjGQoazmVe+RSS7IGbY2LHXzdbo4Jxw4LWZlWE= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from ubuntu-010236106000.amd.com (165.204.78.1) by SN1PR12MB0157.namprd12.prod.outlook.com (10.162.3.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.156.4; Fri, 20 Oct 2017 02:34:51 +0000 From: Brijesh Singh To: kvm@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, linux-kernel@vger.kernel.org Subject: [Part2 PATCH v6 10/38] crypto: ccp: Define SEV userspace ioctl and command id Date: Thu, 19 Oct 2017 21:33:45 -0500 Message-Id: <20171020023413.122280-11-brijesh.singh@amd.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171020023413.122280-1-brijesh.singh@amd.com> References: <20171020023413.122280-1-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: MWHPR1701CA0020.namprd17.prod.outlook.com (10.172.58.30) To SN1PR12MB0157.namprd12.prod.outlook.com (10.162.3.144) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 57df3ad3-cc52-4e05-b00a-08d5176324b2 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(4534020)(4602075)(4627075)(201703031133081)(201702281549075)(2017052603199); SRVR:SN1PR12MB0157; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0157; 3:ViMu1W9SF6KrUGDkLM1hUEkjUcfyNxgBlkcQ8uYSPzADcJQVZC24GiStr2G9WCUAFTTXPgLXOg1iBz/eqeoAOrDZx7eqWjnH37hHI0eP3Cfc1uR/If7Mt4DIR4nbJjIZxg4zPlxfmBcxOvudGPUJIB/cAA/74TSZwNq8M6Id1RnTyhMDPCTRLnzgrO7GjUhhhe65bprNgoc5yy6bJpuf7ZdX60AYWxWeR5w9OqW1qvzWMPK6g1G3Iy3HoiPWjsus; 25:3x3OO/iFVxazOdRODHDxDdWMj28f0tL0oe6zwDVg5aknz3fkwIhIqrNOsHl/KLImM31qt5L4oS6Ktd883Jr+5/wbGts7pxGNN8lUXLHrWDKu2ffRatvktvy7uqLSpnfGhxVfPgx1J8bw1zzGX4b+RTb91wQzhIl067T0K7iEEZPhugbm+LHQfs1govawxSNSfLfbOm9z+GB05iedvVpV0kW3ZARuMeDWgOn+qeInYm2J1QVAEpXiA3ir1DotvMt36tSw+y2VMaMz6M0rmVn+E1LylxKvX7BZUSAf1I5l3BnSt1cVMPxdYq/lMorman4tK7qiTR0FiYbpT7MH0NTPog==; 31:ZFBq2PYC0EfD4NkohgXslaJWU6JQNCUmmhbEq1vDoryId8x9OjnAkyFdu7VIrd6ArluAeQFd7f1QHXUHmRWYiHa+sItv4g2BSPIGGt/fDzLDRSVPRCsj+8LBPMbAvBbZUli3zxW9qUiVIkSbsO0YGLtUw4Q61FlS9qisugsJjqNHmZrjwZ/4c8Yns8F5qnq/ziG8GX5FJGkDryNlw36hw6nrGuAc0DEJlVha7Wp6ikM= X-MS-TrafficTypeDiagnostic: SN1PR12MB0157: X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0157; 20:OwRab+SnHX+NrNTgZt75Tb9iED0XzvKApndFnMNqSreIeYk0kZSpxcr3C7E6sEu44VOFidf3mYgfbmY0sC2VCcMshwKNJQqyV4z4r8jwZBckLZZdfQaitPD2mugXtSwyYXTPFEGZHxH22bXFVLhNBwJ2hF7bORXnDPVe+KYFIeVtq4pCPl2quxnOIXZijVBtshGW466hxiFCqry07HB0ts1WnldAwnEAfNH4kun4zdFE42/E6piCMgn33K0VeesV7dTQc3HGFDepNjr/ocFndOKrjznU66WP0dp9h7vofOP9ZaCRS6/v8RQEAIi+1Cpg2E5Ce4CxjtmwfNvn6lWUbVHLCQ3GvXN9+oHWH5cxvzvIil9P8pldyL7j02dvrrHd9p9sKOnwdjTqiN1xsIpxYEuHop7fwkPvHCpg9MRsn7tTP35oDoI0K9IoZMtNgVFGFO6+mJXnMaxMI2tCwO5cUlH4Vl0270RHUh4MkRp/dHvbzqW0Q3k9NC6MMiRffcwP; 4:ywHEydE+I257+uxFlvnrvqIGIu0h4DZVMtdszwbIrfldH9vNHt6eOH8KGTjBbqTcW9QG56iz0ObDK+68dvIpnCcpVBJcw9j9IRZNwJqr5yaqV0p1S20zBpXLIT4jEFbfCsSSynjs2XFQuvhpRTrFwqbNhBYyQCtOGvp0UNiTOhZ6nCYgBUOf1Sh2VoYPoYEFH/qDdclQD/LhHW9+uE8LtBIT8wER6K0dtgZ5/1a1hgaGzeli83jT/OIbHNp3Ek8qrhwmLN5NqUjzVMmFeV6x529+BGbrBMXTkkC3rB9277DhxicvgFLry64sjPiJQD9h3iticfEH0MRWEJYFBJTTqg== 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)(3231020)(100000703101)(100105400095)(10201501046)(93006095)(93001095)(3002001)(6055026)(6041248)(20161123555025)(20161123564025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SN1PR12MB0157; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SN1PR12MB0157; X-Forefront-PRVS: 0466CA5A45 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(346002)(376002)(39860400002)(199003)(189002)(966005)(36756003)(7736002)(68736007)(50466002)(1076002)(478600001)(4326008)(16526018)(316002)(53936002)(6486002)(86362001)(305945005)(6306002)(53416004)(54906003)(50226002)(2351001)(106356001)(101416001)(81166006)(105586002)(8676002)(2361001)(76176999)(2870700001)(2906002)(50986999)(6916009)(23676002)(66066001)(47776003)(6666003)(97736004)(6116002)(2950100002)(189998001)(8936002)(3846002)(33646002)(81156014)(5660300001)(25786009)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0157; 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?MTtTTjFQUjEyTUIwMTU3OzIzOmxuZGRveGJINVVwU3l3VU8xMElWRUpXSUpk?= =?utf-8?B?OHdFUGhHT3JBVEozbUVzUmJtLzZ2VUFkVVhHWUxLaEZsemI5Si8rVmpWakUr?= =?utf-8?B?S1o2Qk11Vm44NlZZQWwxQlpPeGpKRFdSd1k2ejZmOC9UTisvMWxwbUlkd1pR?= =?utf-8?B?aktBVmxzd0JGUTBteldUWlFnVDVvSjlqQTJOQ3A1cTJ3VTZqL0dIOUFicXBE?= =?utf-8?B?a0lQNWxwMlQ2U3dtcUxEZlFad3gvZXYzUjZNS0l2cEZuNXAxTkRoWTRJZmVJ?= =?utf-8?B?aGc4WnB3cUFZczQzRGFua0xvUHZsODNRb1YyVlR4a2xTcm14TDU5eis2alI2?= =?utf-8?B?NnVidkkyZkNRc2NDV0w0REJka2RMdGNHRkoxWXNtYmFhaUFHc3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qzSNYFfbn2wIEMMR7gGwU+o65fEl1knw2LNrwkuOyTn1qBHThuxBbTu24VC9Onk7qxn2QteAHJmBL4sPDbL/EwoEoXUKJtGuZ16A5SqXTQ4f0iGeHclbkR38yhNcYBWorVg/XpbXGWPJoXcbX/eyzk87AvrB4D7Ic= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0157; 20:CjnMxCs2MB73TMXTaQNoZZ2QYBsBgtdVcZgOEfpWa1Ig6ExsfXbU1Aq8HJRct6etrWoPllctup0tZD3CChqw5UVcJ80In9lEmwFHKZFsGZ2nkLFQ/5wACMsroDp+vz4yYlUahLe23q4Hr2aBwnnPDUeNFp1j/1f/0M7aVBfKSMI6Bc7oIHRB2X0Hh6nTT6wTsWa4SUqCRw5NDLqFoENrQQtxt1CV6M2Zl/SOyfAPidHueN9I8Lr6BchFwrGjFDir X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2017 02:34:51.2684 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 57df3ad3-cc52-4e05-b00a-08d5176324b2 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0157 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 Acked-by: Gary R Hook --- include/uapi/linux/psp-sev.h | 113 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 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..1dd98ba4ff22 --- /dev/null +++ b/include/uapi/linux/psp-sev.h @@ -0,0 +1,113 @@ +/* + * 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 + * @flags: 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 */ + __u32 flags; /* 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 */