From e88be303cba653d09ab78266574da13498ddf884 Mon Sep 17 00:00:00 2001 From: Manorit Chawdhry Date: Tue, 29 Oct 2024 15:13:01 +0530 Subject: [PATCH] plat-k3: drivers: Add check for host ID as well in ti_sci_get_response It could be helpful in cases where we get response from some different host that had sent the message before op-tee started but op-tee ended up receiving the message. Signed-off-by: Manorit Chawdhry --- core/arch/arm/plat-k3/drivers/ti_sci.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/core/arch/arm/plat-k3/drivers/ti_sci.c b/core/arch/arm/plat-k3/drivers/ti_sci.c index 476b68d376f..7bf3c43f961 100644 --- a/core/arch/arm/plat-k3/drivers/ti_sci.c +++ b/core/arch/arm/plat-k3/drivers/ti_sci.c @@ -107,10 +107,20 @@ static inline int ti_sci_get_response(struct ti_sci_xfer *xfer) hdr = (struct ti_sci_msg_hdr *)msg->buf; /* Sanity check for message response */ - if (hdr->seq == message_sequence) - break; + if (hdr->seq != message_sequence) { + EMSG("Message with sequence ID %u not expected", + hdr->seq); + ret = TEE_ERROR_CORRUPT_OBJECT; + } + + if (hdr->host != OPTEE_HOST_ID) { + EMSG("Message with Host ID %u not expected", + hdr->host); + ret = TEE_ERROR_CORRUPT_OBJECT; + } - IMSG("Message with sequence ID %u is not expected", hdr->seq); + if (!ret) + break; } if (!retry) { EMSG("Timed out waiting for message"); @@ -122,7 +132,7 @@ static inline int ti_sci_get_response(struct ti_sci_xfer *xfer) return TEE_ERROR_ACCESS_DENIED; } - return 0; + return ret; } /**