From patchwork Wed Nov 1 21:15:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 10037169 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 17565603B5 for ; Wed, 1 Nov 2017 21:17:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 13F9828BDB for ; Wed, 1 Nov 2017 21:17:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 088EF28BE9; Wed, 1 Nov 2017 21:17:03 +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 76FD728BDB for ; Wed, 1 Nov 2017 21:17:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933505AbdKAVRA (ORCPT ); Wed, 1 Nov 2017 17:17:00 -0400 Received: from mail-bn3nam01on0059.outbound.protection.outlook.com ([104.47.33.59]:44352 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933175AbdKAVQz (ORCPT ); Wed, 1 Nov 2017 17:16:55 -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=mLK1VanX//kegZu3Kdw48stSdHRXfWVjJkjkcaJwWgk=; b=0Wk/HTR9s6jIodgwpwYgDi6BDaOefq8+QmYLebekU9IzG4kG4a0stcT1n2YoizxTQ+NzQMx4czrHamTaA83h3fl3ekLRNrrPzmz8L0C/ht/vc2gHj3HJlaTjnPQQvAC9CkADtjmVcqKHEd168HQQufJV1YOXGTVE9A/AJfwrHMw= 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:42 +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 10/38] crypto: ccp: Define SEV userspace ioctl and command id Date: Wed, 1 Nov 2017 16:15:55 -0500 Message-Id: <20171101211623.71496-11-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: 643a617b-b504-45db-dbc5-08d5216dd987 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(4534020)(4602075)(2017052603199); SRVR:DM2PR12MB0155; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 3:xXubVq+PKaS2FbRdRlKngIJgYhhXTBExIQmtgdAMpk3ax0QqzvuTsj0+/RmFtbPOkT2YYoQhpbillhJBEmcAY63rGJf8gLBNiv8R18yirQr0puFb+I6FY1lkZIpYZYzmRFI28hxSMcXWhsgf7+bGEmCAxixfcT02uWGt05CH3pdHW6c/ZwXYrxwSxnhQ4RKXGJn8An3nBCp8xADP28H9PhDDd7f4rR5+gSDd+d1iC2KOOfnbuNDUSwPv+krEqqDp; 25:1+O/aixD79RKZoBGkVOC11Egwo2/UqGmluUeXPc3Y6R8OECH5EXWecT2TkPeQt4F3zmn3585BYSerIq/w5Bazg30JTQoul9SB7CR+D8EuuKTWGlZVLFbQCLuRJddjUf7wwHvGCjhoHRkMcAlcancRYoQWUqpBvOEAJApU1JEjrP/z/Eqocly5YI8Df/zjY4LO6u9Xk0LoEy77T8pXhXHQNWU980QEUYkzPqhr5ghaNlDdlEla1EJbNVjtOOwaWfLWVBH3r8hxBsMIm5rK4Eg2FD/BcB8tcd4Ei0qhcdrDuh69jeezzF+ayy+mgWHcNHQmNWAj8Ph30oj0uB1sQJoSA==; 31:fazFS/HfDUCl7s16R90FPNVbx96TGTtg5YI0Syz0FclS1F8sNX1+51HGX9+47ym5xy9x7OSX4jcQ43YcZ8JhwUkhfJmxIEqfkLDOFUIm1MLJsootRmyKTZ9cp/oZwPcVu1+rZP3shERqY01IajEJ9gXpseX+GuXDNEcSVJwqwGIad31+m5Mt2EBb/di8M3C0QDpTCYIrSSi3m3H77JyyWg4YbJl4SxbcwfT6Qi2Oj0I= X-MS-TrafficTypeDiagnostic: DM2PR12MB0155: X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:F3o8M+IXjD+49lTjUq19iXs3hX2RfVogkxMhh7Y36IJDzhn0Ip4asJH7gi5i9iaMbwFdRXBZvQ849yusWjN16prRRJOutwWHnXfFKwl/29ZEXmSdTn8qOFV+9qarH6MaSk/el7j/SdrIaS2oqR89JugJ8GBA3iDVenehajsLE8xDh0pk2q+jOxZva61APJIk+PJGIELrn0TDEYOgrZjz+X+rxf/Yj18dYTFoc4jQdNP7MMgqGAcUCGUtR7HI2ccs0QEH4LM7qcsiY2Fg2qvRLvKQnB9Kk8rvYaXRhgbttuYyp968zFgGGK6EG3Lev4TB4kh1YFYDMzeIXxIgwH6fRM33c05ZEVT8FjV8RWgGWzoKGISfELsqF8xM/i6XMzJu7F8AV2Jd/X0l75xQGDSqTJSaYbYH2UOYCZuS7PBGFQLS24V7U5f2e61TP5vZ4P6VDea1W4ukT7jgRGKM9hZNtKTsy7Qty3ZoX+2SZNu96qWUsoQUHdPv06mk4IriPh7h; 4:2Y9knfanQMdqNuBz+JvjkT2Z8wFB6xk5qlcbe83jd3zlDb1QvuztgcOu8eXl7dDNsFxr9TlAHV38SktVbIL4p9djeFoz/yL2g4lPmhUvje9bWhUpsEsJaVOGnoL2pfoAe2vlC2edzfYzpqKNxAgUuUnJIl/xRkZTY09gfkROyxLNK6b26TzHphYs8BtDzNHxfTOaI3EZh1nHNZkRhn0KE+8CfJiE0/ytyoKfE9yZZCsoOGvnnV/mKFKTHkRv1VB6mwt22K7V7CoJW0fWFtLaYNA2Tg5MazNiga8gl5S6oR39FTf1dshlkyb66/nh64G2IVRzE1kmfqXwUxv06vAteQ== 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)(189002)(199003)(1076002)(6116002)(97736004)(66066001)(50466002)(3846002)(25786009)(6306002)(4326008)(54906003)(966005)(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)(2004002); 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?MTtETTJQUjEyTUIwMTU1OzIzOmNWZU1adXJpY1FMVFJZSWZtV3dwRVUrZjBv?= =?utf-8?B?ejZKUzlZcEdYOERXMy9PeVZ6MFFleE1VZHVEUmlIQysvYlE5cU0wcEpwcjZj?= =?utf-8?B?MjNnU1lyY2F4UllHVmlIb1hlMlE1bDV2bU9ySnlNVHpEOUN4Z0lyNS9wc2Uv?= =?utf-8?B?Y3E3d3d6WU1KYWgzc1lNMzJBZGNXVGxlbUZoaEdzS3BDTGNaZHFIaWxXUlY3?= =?utf-8?B?bFhsTGFRUy9DRmhFQXdkYkVxYWJqYlFTR0IwRnNxalYvWURFdjMzOGtqREx2?= =?utf-8?B?RGFkTTA5V1h2bWZVR2p5MzFYL215dDRtZ0NzYVFTV1NjenZlMTNIZzE2a3Fu?= =?utf-8?B?N3BuUjJ6cXEzQUR5bElKOUZGUFJnSEVFcjNFMDhIWjQ3Zk1WcTVuZGt0ZkEw?= =?utf-8?B?U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XgqUKGA+5BnnEYwgXmjZjizyEhRfpl838TOkQfH4fJ4EOK3DEl5ZlkmYP8/ekHizbOVYTO20znFPrrZWnamfgdAcZ+nYzeFsuJk+FuhMQqqAsRsipeB+Cf1BbnKETti8mKgoOHcf7n6MjEwaaZ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:qvQRiCmZfs5athXbQtpy44BuAXWkcPZGBiVmGwDkKlMIYV5C3BU1/KQUamK1AxbNY98GRCn6AWtHForhixconhBIFGk8J10GAWcXFIx621S2P3hspJ4WvhQR1haBiIXZJr8HTqRqTvGttlV5xBKGpZMB3V4cX9hkhEyxY4qsH5dvzYlZ8DILEUwR1SaL1IP40ngkLfdgq7nljQfi2qQfkduogWyDgd7Y1NUjF1ZiACoDlU+5CFJMxtSON8uHkpfm X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2017 21:16:42.4223 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 643a617b-b504-45db-dbc5-08d5216dd987 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 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 */