Merge changes I0e012f3f,I14ad16e8 into integration

* changes:
  fix(rss): fix bound check during protocol selection
  fix(mhuv2): provide only the usable size of memory
This commit is contained in:
Manish V Badarkhe 2024-02-08 11:08:21 +01:00 committed by TrustedFirmware Code Review
commit e66b04372a
2 changed files with 10 additions and 3 deletions

View file

@ -308,5 +308,10 @@ size_t mhu_get_max_message_size(void)
assert(num_channels != 0);
return num_channels * sizeof(uint32_t);
/*
* Returns only usable size of memory. As one channel is specifically
* used to inform about the size of payload, discard it from avialable
* memory size.
*/
return (num_channels - 1) * sizeof(uint32_t);
}

View file

@ -59,8 +59,10 @@ static uint8_t select_protocol_version(const psa_invec *in_vec, size_t in_len,
* messages due to ATU configuration costs to allow access to the
* pointers.
*/
if ((comms_embed_msg_min_size + in_size_total > comms_mhu_msg_size - sizeof(uint32_t))
|| (comms_embed_reply_min_size + out_size_total > comms_mhu_msg_size) - sizeof(uint32_t)) {
if ((comms_embed_msg_min_size + in_size_total >
comms_mhu_msg_size - sizeof(uint32_t)) ||
(comms_embed_reply_min_size + out_size_total >
comms_mhu_msg_size - sizeof(uint32_t))) {
return RSS_COMMS_PROTOCOL_POINTER_ACCESS;
} else {
return RSS_COMMS_PROTOCOL_EMBED;