@param[in] This The EFI_MM_COMMUNICATION_PROTOCOL instance.\r
@param[in, out] CommBufferPhysical Physical address of the MM communication buffer\r
@param[in, out] CommBufferVirtual Virtual address of the MM communication buffer\r
- @param[in, out] CommSize The size of the data buffer being passed in. On exit, the\r
- size of data being returned. Zero if the handler does not\r
+ @param[in, out] CommSize The size of the data buffer being passed in. On input,\r
+ when not omitted, the buffer should cover EFI_MM_COMMUNICATE_HEADER\r
+ and the value of MessageLength field. On exit, the size\r
+ of data being returned. Zero if the handler does not\r
wish to reply with any data. This parameter is optional\r
and may be NULL.\r
\r
@retval EFI_SUCCESS The message was successfully posted.\r
- @retval EFI_INVALID_PARAMETER CommBufferPhysical was NULL or CommBufferVirtual was NULL.\r
+ @retval EFI_INVALID_PARAMETER CommBufferPhysical or CommBufferVirtual was NULL, or\r
+ integer value pointed by CommSize does not cover\r
+ EFI_MM_COMMUNICATE_HEADER and the value of MessageLength\r
+ field.\r
@retval EFI_BAD_BUFFER_SIZE The buffer is too large for the MM implementation.\r
If this error is returned, the MessageLength field\r
in the CommBuffer header or the integer pointed by\r
sizeof (CommunicateHeader->HeaderGuid) +\r
sizeof (CommunicateHeader->MessageLength);\r
\r
- // If the length of the CommBuffer is 0 then return the expected length.\r
- if (CommSize != 0) {\r
+ // If CommSize is not omitted, perform size inspection before proceeding.\r
+ if (CommSize != NULL) {\r
// This case can be used by the consumer of this driver to find out the\r
// max size that can be used for allocating CommBuffer.\r
if ((*CommSize == 0) ||\r
}\r
\r
//\r
- // CommSize must match MessageLength + sizeof (EFI_MM_COMMUNICATE_HEADER);\r
+ // CommSize should cover at least MessageLength + sizeof (EFI_MM_COMMUNICATE_HEADER);\r
//\r
- if (*CommSize != BufferSize) {\r
+ if (*CommSize < BufferSize) {\r
return EFI_INVALID_PARAMETER;\r
}\r
}\r