brintos

brintos / linux-shallow public Read only

0
0
Text · 7.0 KiB · 832c15d Raw
262 lines · c
1/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */2/*3 * Userspace interface for AMD Secure Encrypted Virtualization (SEV)4 * platform management commands.5 *6 * Copyright (C) 2016-2017 Advanced Micro Devices, Inc.7 *8 * Author: Brijesh Singh <brijesh.singh@amd.com>9 *10 * SEV API specification is available at: https://developer.amd.com/sev/11 */12 13#ifndef __PSP_SEV_USER_H__14#define __PSP_SEV_USER_H__15 16#include <linux/types.h>17 18/**19 * SEV platform commands20 */21enum {22	SEV_FACTORY_RESET = 0,23	SEV_PLATFORM_STATUS,24	SEV_PEK_GEN,25	SEV_PEK_CSR,26	SEV_PDH_GEN,27	SEV_PDH_CERT_EXPORT,28	SEV_PEK_CERT_IMPORT,29	SEV_GET_ID,	/* This command is deprecated, use SEV_GET_ID2 */30	SEV_GET_ID2,31	SNP_PLATFORM_STATUS,32	SNP_COMMIT,33	SNP_SET_CONFIG,34	SNP_VLEK_LOAD,35 36	SEV_MAX,37};38 39/**40 * SEV Firmware status code41 */42typedef enum {43	/*44	 * This error code is not in the SEV spec. Its purpose is to convey that45	 * there was an error that prevented the SEV firmware from being called.46	 * The SEV API error codes are 16 bits, so the -1 value will not overlap47	 * with possible values from the specification.48	 */49	SEV_RET_NO_FW_CALL = -1,50	SEV_RET_SUCCESS = 0,51	SEV_RET_INVALID_PLATFORM_STATE,52	SEV_RET_INVALID_GUEST_STATE,53	SEV_RET_INAVLID_CONFIG,54	SEV_RET_INVALID_CONFIG = SEV_RET_INAVLID_CONFIG,55	SEV_RET_INVALID_LEN,56	SEV_RET_ALREADY_OWNED,57	SEV_RET_INVALID_CERTIFICATE,58	SEV_RET_POLICY_FAILURE,59	SEV_RET_INACTIVE,60	SEV_RET_INVALID_ADDRESS,61	SEV_RET_BAD_SIGNATURE,62	SEV_RET_BAD_MEASUREMENT,63	SEV_RET_ASID_OWNED,64	SEV_RET_INVALID_ASID,65	SEV_RET_WBINVD_REQUIRED,66	SEV_RET_DFFLUSH_REQUIRED,67	SEV_RET_INVALID_GUEST,68	SEV_RET_INVALID_COMMAND,69	SEV_RET_ACTIVE,70	SEV_RET_HWSEV_RET_PLATFORM,71	SEV_RET_HWSEV_RET_UNSAFE,72	SEV_RET_UNSUPPORTED,73	SEV_RET_INVALID_PARAM,74	SEV_RET_RESOURCE_LIMIT,75	SEV_RET_SECURE_DATA_INVALID,76	SEV_RET_INVALID_KEY = 0x27,77	SEV_RET_INVALID_PAGE_SIZE,78	SEV_RET_INVALID_PAGE_STATE,79	SEV_RET_INVALID_MDATA_ENTRY,80	SEV_RET_INVALID_PAGE_OWNER,81	SEV_RET_INVALID_PAGE_AEAD_OFLOW,82	SEV_RET_RMP_INIT_REQUIRED,83	SEV_RET_MAX,84} sev_ret_code;85 86/**87 * struct sev_user_data_status - PLATFORM_STATUS command parameters88 *89 * @major: major API version90 * @minor: minor API version91 * @state: platform state92 * @flags: platform config flags93 * @build: firmware build id for API version94 * @guest_count: number of active guests95 */96struct sev_user_data_status {97	__u8 api_major;				/* Out */98	__u8 api_minor;				/* Out */99	__u8 state;				/* Out */100	__u32 flags;				/* Out */101	__u8 build;				/* Out */102	__u32 guest_count;			/* Out */103} __packed;104 105#define SEV_STATUS_FLAGS_CONFIG_ES	0x0100106 107/**108 * struct sev_user_data_pek_csr - PEK_CSR command parameters109 *110 * @address: PEK certificate chain111 * @length: length of certificate112 */113struct sev_user_data_pek_csr {114	__u64 address;				/* In */115	__u32 length;				/* In/Out */116} __packed;117 118/**119 * struct sev_user_data_cert_import - PEK_CERT_IMPORT command parameters120 *121 * @pek_address: PEK certificate chain122 * @pek_len: length of PEK certificate123 * @oca_address: OCA certificate chain124 * @oca_len: length of OCA certificate125 */126struct sev_user_data_pek_cert_import {127	__u64 pek_cert_address;			/* In */128	__u32 pek_cert_len;			/* In */129	__u64 oca_cert_address;			/* In */130	__u32 oca_cert_len;			/* In */131} __packed;132 133/**134 * struct sev_user_data_pdh_cert_export - PDH_CERT_EXPORT command parameters135 *136 * @pdh_address: PDH certificate address137 * @pdh_len: length of PDH certificate138 * @cert_chain_address: PDH certificate chain139 * @cert_chain_len: length of PDH certificate chain140 */141struct sev_user_data_pdh_cert_export {142	__u64 pdh_cert_address;			/* In */143	__u32 pdh_cert_len;			/* In/Out */144	__u64 cert_chain_address;		/* In */145	__u32 cert_chain_len;			/* In/Out */146} __packed;147 148/**149 * struct sev_user_data_get_id - GET_ID command parameters (deprecated)150 *151 * @socket1: Buffer to pass unique ID of first socket152 * @socket2: Buffer to pass unique ID of second socket153 */154struct sev_user_data_get_id {155	__u8 socket1[64];			/* Out */156	__u8 socket2[64];			/* Out */157} __packed;158 159/**160 * struct sev_user_data_get_id2 - GET_ID command parameters161 * @address: Buffer to store unique ID162 * @length: length of the unique ID163 */164struct sev_user_data_get_id2 {165	__u64 address;				/* In */166	__u32 length;				/* In/Out */167} __packed;168 169/**170 * struct sev_user_data_snp_status - SNP status171 *172 * @api_major: API major version173 * @api_minor: API minor version174 * @state: current platform state175 * @is_rmp_initialized: whether RMP is initialized or not176 * @rsvd: reserved177 * @build_id: firmware build id for the API version178 * @mask_chip_id: whether chip id is present in attestation reports or not179 * @mask_chip_key: whether attestation reports are signed or not180 * @vlek_en: VLEK (Version Loaded Endorsement Key) hashstick is loaded181 * @rsvd1: reserved182 * @guest_count: the number of guest currently managed by the firmware183 * @current_tcb_version: current TCB version184 * @reported_tcb_version: reported TCB version185 */186struct sev_user_data_snp_status {187	__u8 api_major;			/* Out */188	__u8 api_minor;			/* Out */189	__u8 state;			/* Out */190	__u8 is_rmp_initialized:1;	/* Out */191	__u8 rsvd:7;192	__u32 build_id;			/* Out */193	__u32 mask_chip_id:1;		/* Out */194	__u32 mask_chip_key:1;		/* Out */195	__u32 vlek_en:1;		/* Out */196	__u32 rsvd1:29;197	__u32 guest_count;		/* Out */198	__u64 current_tcb_version;	/* Out */199	__u64 reported_tcb_version;	/* Out */200} __packed;201 202/**203 * struct sev_user_data_snp_config - system wide configuration value for SNP.204 *205 * @reported_tcb: the TCB version to report in the guest attestation report.206 * @mask_chip_id: whether chip id is present in attestation reports or not207 * @mask_chip_key: whether attestation reports are signed or not208 * @rsvd: reserved209 * @rsvd1: reserved210 */211struct sev_user_data_snp_config {212	__u64 reported_tcb  ;   /* In */213	__u32 mask_chip_id:1;   /* In */214	__u32 mask_chip_key:1;  /* In */215	__u32 rsvd:30;          /* In */216	__u8 rsvd1[52];217} __packed;218 219/**220 * struct sev_data_snp_vlek_load - SNP_VLEK_LOAD structure221 *222 * @len: length of the command buffer read by the PSP223 * @vlek_wrapped_version: version of wrapped VLEK hashstick (Must be 0h)224 * @rsvd: reserved225 * @vlek_wrapped_address: address of a wrapped VLEK hashstick226 *                        (struct sev_user_data_snp_wrapped_vlek_hashstick)227 */228struct sev_user_data_snp_vlek_load {229	__u32 len;				/* In */230	__u8 vlek_wrapped_version;		/* In */231	__u8 rsvd[3];				/* In */232	__u64 vlek_wrapped_address;		/* In */233} __packed;234 235/**236 * struct sev_user_data_snp_vlek_wrapped_vlek_hashstick - Wrapped VLEK data237 *238 * @data: Opaque data provided by AMD KDS (as described in SEV-SNP Firmware ABI239 *        1.54, SNP_VLEK_LOAD)240 */241struct sev_user_data_snp_wrapped_vlek_hashstick {242	__u8 data[432];				/* In */243} __packed;244 245/**246 * struct sev_issue_cmd - SEV ioctl parameters247 *248 * @cmd: SEV commands to execute249 * @opaque: pointer to the command structure250 * @error: SEV FW return code on failure251 */252struct sev_issue_cmd {253	__u32 cmd;				/* In */254	__u64 data;				/* In */255	__u32 error;				/* Out */256} __packed;257 258#define SEV_IOC_TYPE		'S'259#define SEV_ISSUE_CMD	_IOWR(SEV_IOC_TYPE, 0x0, struct sev_issue_cmd)260 261#endif /* __PSP_USER_SEV_H */262