Skip to content

Commit e60ce3f

Browse files
tmlemanlgirdwood
authored andcommitted
ipc4: setdx: validate message payload
Reading and validation of the ipc message payload. Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com> Signed-off-by: Rafal Redzimski <rafal.f.redzimski@intel.com>
1 parent 96c3268 commit e60ce3f

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

‎src/ipc/ipc4/handler.c‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,7 @@ static int ipc4_module_process_d0ix(union ipc4_message_header *ipc4)
742742
static int ipc4_module_process_dx(union ipc4_message_header *ipc4)
743743
{
744744
struct ipc4_module_set_dx dx;
745+
struct ipc4_dx_state_info dx_info;
745746
uint32_t module_id, instance_id;
746747

747748
memcpy_s(&dx, sizeof(dx), ipc4, sizeof(dx));
@@ -754,6 +755,23 @@ static int ipc4_module_process_dx(union ipc4_message_header *ipc4)
754755
return IPC4_INVALID_RESOURCE_ID;
755756
}
756757

758+
memcpy_s(&dx_info, sizeof(dx_info), (const void *)MAILBOX_HOSTBOX_BASE, sizeof(dx_info));
759+
760+
/* check if core enable mask is valid */
761+
if (dx_info.core_mask > MASK(CONFIG_CORE_COUNT - 1, 0)) {
762+
tr_err(&ipc_tr, "ipc4_module_process_dx: CONFIG_CORE_COUNT: %d < core enable mask: %d",
763+
CONFIG_CORE_COUNT, dx_info.core_mask);
764+
return IPC4_ERROR_INVALID_PARAM;
765+
}
766+
767+
/* check primary core first */
768+
if ((dx_info.core_mask & BIT(PLATFORM_PRIMARY_CORE_ID)) &&
769+
(dx_info.dx_mask & BIT(PLATFORM_PRIMARY_CORE_ID))) {
770+
/* core0 can't be activated more, it's already active since we got here */
771+
tr_err(&ipc_tr, "Core0 is already active");
772+
return IPC4_BAD_STATE;
773+
}
774+
757775
/* nothing to do since core 0 is active now */
758776

759777
return 0;

0 commit comments

Comments
 (0)