1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Headers for EFI variable service via StandAloneMM, EDK2 application running
6 * Copyright (c) 2017, Intel Corporation. All rights reserved.
7 * Copyright (C) 2020 Linaro Ltd. <sughosh.ganu@linaro.org>
8 * Copyright (C) 2020 Linaro Ltd. <ilias.apalodimas@linaro.org>
11 #ifndef _MM_COMMUNICATION_H_
12 #define _MM_COMMUNICATION_H_
17 * Interface to the pseudo Trusted Application (TA), which provides a
18 * communication channel with the Standalone MM (Management Mode)
19 * Secure Partition running at Secure-EL0
22 #define PTA_STMM_CMDID_COMMUNICATE 0
24 /* OP-TEE is using big endian GUIDs while UEFI uses little endian ones */
25 #define PTA_STMM_UUID { 0xed32d533, 0x99e6, 0x4209, {\
26 0x9c, 0xc0, 0x2d, 0x72, 0xcd, 0xd9, 0x98, 0xa7 } }
28 #define EFI_MM_VARIABLE_GUID \
29 EFI_GUID(0xed32d533, 0x99e6, 0x4209, \
30 0x9c, 0xc0, 0x2d, 0x72, 0xcd, 0xd9, 0x98, 0xa7)
32 /* Defined in EDK2 MdePkg/Include/Protocol/MmCommunication.h */
35 * struct efi_mm_communicate_header - Header used for SMM variable communication
37 * @header_guid: header use for disambiguation of content
38 * @message_len: length of the message. Does not include the size of the
40 * @data: payload of the message
42 * Defined in EDK2 as EFI_MM_COMMUNICATE_HEADER.
43 * To avoid confusion in interpreting frames, the communication buffer should
44 * always begin with efi_mm_communicate_header.
46 struct __packed efi_mm_communicate_header {
47 efi_guid_t header_guid;
52 #define MM_COMMUNICATE_HEADER_SIZE \
53 (sizeof(struct efi_mm_communicate_header))
55 /* Defined in EDK2 ArmPkg/Include/IndustryStandard/ArmMmSvc.h */
57 /* SPM return error codes */
58 #define ARM_SVC_SPM_RET_SUCCESS 0
59 #define ARM_SVC_SPM_RET_NOT_SUPPORTED -1
60 #define ARM_SVC_SPM_RET_INVALID_PARAMS -2
61 #define ARM_SVC_SPM_RET_DENIED -3
62 #define ARM_SVC_SPM_RET_NO_MEMORY -5
64 /* Defined in EDK2 MdeModulePkg/Include/Guid/SmmVariableCommon.h */
66 #define SMM_VARIABLE_FUNCTION_GET_VARIABLE 1
68 * The payload for this function is
69 * SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME.
71 #define SMM_VARIABLE_FUNCTION_GET_NEXT_VARIABLE_NAME 2
73 * The payload for this function is SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE.
75 #define SMM_VARIABLE_FUNCTION_SET_VARIABLE 3
77 * The payload for this function is
78 * SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO.
80 #define SMM_VARIABLE_FUNCTION_QUERY_VARIABLE_INFO 4
82 * It is a notify event, no extra payload for this function.
84 #define SMM_VARIABLE_FUNCTION_READY_TO_BOOT 5
86 * It is a notify event, no extra payload for this function.
88 #define SMM_VARIABLE_FUNCTION_EXIT_BOOT_SERVICE 6
90 * The payload for this function is VARIABLE_INFO_ENTRY.
91 * The GUID in EFI_SMM_COMMUNICATE_HEADER is gEfiSmmVariableProtocolGuid.
93 #define SMM_VARIABLE_FUNCTION_GET_STATISTICS 7
95 * The payload for this function is SMM_VARIABLE_COMMUNICATE_LOCK_VARIABLE
97 #define SMM_VARIABLE_FUNCTION_LOCK_VARIABLE 8
99 #define SMM_VARIABLE_FUNCTION_VAR_CHECK_VARIABLE_PROPERTY_SET 9
101 #define SMM_VARIABLE_FUNCTION_VAR_CHECK_VARIABLE_PROPERTY_GET 10
103 #define SMM_VARIABLE_FUNCTION_GET_PAYLOAD_SIZE 11
105 * The payload for this function is
106 * SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT
108 #define SMM_VARIABLE_FUNCTION_INIT_RUNTIME_VARIABLE_CACHE_CONTEXT 12
110 #define SMM_VARIABLE_FUNCTION_SYNC_RUNTIME_CACHE 13
112 * The payload for this function is
113 * SMM_VARIABLE_COMMUNICATE_GET_RUNTIME_CACHE_INFO
115 #define SMM_VARIABLE_FUNCTION_GET_RUNTIME_CACHE_INFO 14
118 * struct smm_variable_communicate_header - Used for SMM variable communication
120 * @function: function to call in Smm.
121 * @ret_status: return status
124 * Defined in EDK2 as SMM_VARIABLE_COMMUNICATE_HEADER.
126 struct smm_variable_communicate_header {
127 efi_uintn_t function;
128 efi_status_t ret_status;
132 #define MM_VARIABLE_COMMUNICATE_SIZE \
133 (sizeof(struct smm_variable_communicate_header))
136 * struct smm_variable_access - Used to communicate with StMM by
137 * SetVariable and GetVariable.
140 * @data_size: size of EFI variable data
141 * @name_size: size of EFI name
143 * @name: variable name
145 * Defined in EDK2 as SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE.
148 struct smm_variable_access {
150 efi_uintn_t data_size;
151 efi_uintn_t name_size;
156 #define MM_VARIABLE_ACCESS_HEADER_SIZE \
157 (sizeof(struct smm_variable_access))
159 * struct smm_variable_payload_size - Used to get the max allowed
160 * payload used in StMM.
162 * @size: size to fill in
164 * Defined in EDK2 as SMM_VARIABLE_COMMUNICATE_GET_PAYLOAD_SIZE.
167 struct smm_variable_payload_size {
172 * struct smm_variable_getnext - Used to communicate with StMM for
173 * GetNextVariableName.
176 * @name_size: size of the name of the variable
177 * @name: variable name
179 * Defined in EDK2 as SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME.
181 struct smm_variable_getnext {
183 efi_uintn_t name_size;
187 #define MM_VARIABLE_GET_NEXT_HEADER_SIZE \
188 (sizeof(struct smm_variable_getnext))
191 * struct smm_variable_query_info - Used to communicate with StMM for
194 * @max_variable_storage: max available storage
195 * @remaining_variable_storage: remaining available storage
196 * @max_variable_size: max variable supported size
197 * @attr: attributes to query storage for
199 * Defined in EDK2 as SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO.
201 struct smm_variable_query_info {
202 u64 max_variable_storage;
203 u64 remaining_variable_storage;
204 u64 max_variable_size;
208 #define VAR_CHECK_VARIABLE_PROPERTY_REVISION 0x0001
209 #define VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY BIT(0)
211 * struct var_check_property - Used to store variable properties in StMM
213 * @revision: magic revision number for variable property checking
214 * @property: properties mask for the variable used in StMM.
215 * Currently RO flag is supported
216 * @attributes: variable attributes used in StMM checking when properties
217 * for a variable are enabled
218 * @minsize: minimum allowed size for variable payload checked against
219 * smm_variable_access->datasize in StMM
220 * @maxsize: maximum allowed size for variable payload checked against
221 * smm_variable_access->datasize in StMM
223 * Defined in EDK2 as VAR_CHECK_VARIABLE_PROPERTY.
225 struct var_check_property {
234 * struct smm_variable_var_check_property - Used to communicate variable
235 * properties with StMM
238 * @name_size: size of EFI name
239 * @property: variable properties struct
240 * @name: variable name
242 * Defined in EDK2 as SMM_VARIABLE_COMMUNICATE_VAR_CHECK_VARIABLE_PROPERTY.
244 struct smm_variable_var_check_property {
246 efi_uintn_t name_size;
247 struct var_check_property property;
251 #endif /* _MM_COMMUNICATION_H_ */