Path: blob/master/drivers/firmware/efi/stmm/mm_communication.h
26482 views
/* SPDX-License-Identifier: GPL-2.0+ */1/*2* Headers for EFI variable service via StandAloneMM, EDK2 application running3* in OP-TEE. Most of the structs and defines resemble the EDK2 naming.4*5* Copyright (c) 2017, Intel Corporation. All rights reserved.6* Copyright (C) 2020 Linaro Ltd.7*/89#ifndef _MM_COMMUNICATION_H_10#define _MM_COMMUNICATION_H_1112/*13* Interface to the pseudo Trusted Application (TA), which provides a14* communication channel with the Standalone MM (Management Mode)15* Secure Partition running at Secure-EL016*/1718#define PTA_STMM_CMD_COMMUNICATE 01920/*21* Defined in OP-TEE, this UUID is used to identify the pseudo-TA.22* OP-TEE is using big endian GUIDs while UEFI uses little endian ones23*/24#define PTA_STMM_UUID \25UUID_INIT(0xed32d533, 0x99e6, 0x4209, \260x9c, 0xc0, 0x2d, 0x72, 0xcd, 0xd9, 0x98, 0xa7)2728#define EFI_MM_VARIABLE_GUID \29EFI_GUID(0xed32d533, 0x99e6, 0x4209, \300x9c, 0xc0, 0x2d, 0x72, 0xcd, 0xd9, 0x98, 0xa7)3132/**33* struct efi_mm_communicate_header - Header used for SMM variable communication3435* @header_guid: header use for disambiguation of content36* @message_len: length of the message. Does not include the size of the37* header38* @data: payload of the message39*40* Defined in the PI spec as EFI_MM_COMMUNICATE_HEADER.41* To avoid confusion in interpreting frames, the communication buffer should42* always begin with efi_mm_communicate_header.43*/44struct efi_mm_communicate_header {45efi_guid_t header_guid;46size_t message_len;47u8 data[];48} __packed;4950#define MM_COMMUNICATE_HEADER_SIZE \51(sizeof(struct efi_mm_communicate_header))5253/* SPM return error codes */54#define ARM_SVC_SPM_RET_SUCCESS 055#define ARM_SVC_SPM_RET_NOT_SUPPORTED -156#define ARM_SVC_SPM_RET_INVALID_PARAMS -257#define ARM_SVC_SPM_RET_DENIED -358#define ARM_SVC_SPM_RET_NO_MEMORY -55960#define SMM_VARIABLE_FUNCTION_GET_VARIABLE 161/*62* The payload for this function is63* SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME.64*/65#define SMM_VARIABLE_FUNCTION_GET_NEXT_VARIABLE_NAME 266/*67* The payload for this function is SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE.68*/69#define SMM_VARIABLE_FUNCTION_SET_VARIABLE 370/*71* The payload for this function is72* SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO.73*/74#define SMM_VARIABLE_FUNCTION_QUERY_VARIABLE_INFO 475/*76* It is a notify event, no extra payload for this function.77*/78#define SMM_VARIABLE_FUNCTION_READY_TO_BOOT 579/*80* It is a notify event, no extra payload for this function.81*/82#define SMM_VARIABLE_FUNCTION_EXIT_BOOT_SERVICE 683/*84* The payload for this function is VARIABLE_INFO_ENTRY.85* The GUID in EFI_SMM_COMMUNICATE_HEADER is gEfiSmmVariableProtocolGuid.86*/87#define SMM_VARIABLE_FUNCTION_GET_STATISTICS 788/*89* The payload for this function is SMM_VARIABLE_COMMUNICATE_LOCK_VARIABLE90*/91#define SMM_VARIABLE_FUNCTION_LOCK_VARIABLE 89293#define SMM_VARIABLE_FUNCTION_VAR_CHECK_VARIABLE_PROPERTY_SET 99495#define SMM_VARIABLE_FUNCTION_VAR_CHECK_VARIABLE_PROPERTY_GET 109697#define SMM_VARIABLE_FUNCTION_GET_PAYLOAD_SIZE 1198/*99* The payload for this function is100* SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT101*/102#define SMM_VARIABLE_FUNCTION_INIT_RUNTIME_VARIABLE_CACHE_CONTEXT 12103104#define SMM_VARIABLE_FUNCTION_SYNC_RUNTIME_CACHE 13105/*106* The payload for this function is107* SMM_VARIABLE_COMMUNICATE_GET_RUNTIME_CACHE_INFO108*/109#define SMM_VARIABLE_FUNCTION_GET_RUNTIME_CACHE_INFO 14110111/**112* struct smm_variable_communicate_header - Used for SMM variable communication113114* @function: function to call in Smm.115* @ret_status: return status116* @data: payload117*/118struct smm_variable_communicate_header {119size_t function;120efi_status_t ret_status;121u8 data[];122};123124#define MM_VARIABLE_COMMUNICATE_SIZE \125(sizeof(struct smm_variable_communicate_header))126127/**128* struct smm_variable_access - Used to communicate with StMM by129* SetVariable and GetVariable.130131* @guid: vendor GUID132* @data_size: size of EFI variable data133* @name_size: size of EFI name134* @attr: attributes135* @name: variable name136*137*/138struct smm_variable_access {139efi_guid_t guid;140size_t data_size;141size_t name_size;142u32 attr;143u16 name[];144};145146#define MM_VARIABLE_ACCESS_HEADER_SIZE \147(sizeof(struct smm_variable_access))148/**149* struct smm_variable_payload_size - Used to get the max allowed150* payload used in StMM.151*152* @size: size to fill in153*154*/155struct smm_variable_payload_size {156size_t size;157};158159/**160* struct smm_variable_getnext - Used to communicate with StMM for161* GetNextVariableName.162*163* @guid: vendor GUID164* @name_size: size of the name of the variable165* @name: variable name166*167*/168struct smm_variable_getnext {169efi_guid_t guid;170size_t name_size;171u16 name[];172};173174#define MM_VARIABLE_GET_NEXT_HEADER_SIZE \175(sizeof(struct smm_variable_getnext))176177/**178* struct smm_variable_query_info - Used to communicate with StMM for179* QueryVariableInfo.180*181* @max_variable_storage: max available storage182* @remaining_variable_storage: remaining available storage183* @max_variable_size: max variable supported size184* @attr: attributes to query storage for185*186*/187struct smm_variable_query_info {188u64 max_variable_storage;189u64 remaining_variable_storage;190u64 max_variable_size;191u32 attr;192};193194#define VAR_CHECK_VARIABLE_PROPERTY_REVISION 0x0001195#define VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY BIT(0)196/**197* struct var_check_property - Used to store variable properties in StMM198*199* @revision: magic revision number for variable property checking200* @property: properties mask for the variable used in StMM.201* Currently RO flag is supported202* @attributes: variable attributes used in StMM checking when properties203* for a variable are enabled204* @minsize: minimum allowed size for variable payload checked against205* smm_variable_access->datasize in StMM206* @maxsize: maximum allowed size for variable payload checked against207* smm_variable_access->datasize in StMM208*209*/210struct var_check_property {211u16 revision;212u16 property;213u32 attributes;214size_t minsize;215size_t maxsize;216};217218/**219* struct smm_variable_var_check_property - Used to communicate variable220* properties with StMM221*222* @guid: vendor GUID223* @name_size: size of EFI name224* @property: variable properties struct225* @name: variable name226*227*/228struct smm_variable_var_check_property {229efi_guid_t guid;230size_t name_size;231struct var_check_property property;232u16 name[];233};234235#endif /* _MM_COMMUNICATION_H_ */236237238