diff options
author | Mikael Olsson <mikael.olsson@arm.com> | 2023-06-13 12:17:04 +0200 |
---|---|---|
committer | Mikael Olsson <mikael.olsson@arm.com> | 2023-06-16 17:05:51 +0200 |
commit | 09965b094429c45f4da273bb5c11f1c177acf9fd (patch) | |
tree | 622bb8e2d9477c7b54d3a2eea7c57c3bb36f4939 /kernel/ethosu_mailbox.h | |
parent | 252ed6a0f9af7a002d70a9c7644fec5b0b78ead5 (diff) | |
download | ethos-u-linux-driver-stack-09965b094429c45f4da273bb5c11f1c177acf9fd.tar.gz |
Add type check when getting message by ID
When the kernel driver handles incoming rpmsg messages, it uses the ID
in the message header to find the corresponding mailbox message. The
mailbox messages are stored as a generic message struct that is later
cast to the specific message type.
There is currently no type information stored in the generic message
struct so only the ID is used to distinguish between the mailbox
messages. This means if an incorrect ID is received that matches a
mailbox message with a different type, the kernel driver will cast the
message struct to the wrong type.
Type information has now been added to the generic message struct and
will be checked when trying to find the corresponding mailbox message so
both the ID and type must be correct to find a matching message.
Change-Id: Ifdbceea6ec4ae7078f424a32ce1ff5474bd22fef
Diffstat (limited to 'kernel/ethosu_mailbox.h')
-rw-r--r-- | kernel/ethosu_mailbox.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/kernel/ethosu_mailbox.h b/kernel/ethosu_mailbox.h index edf922b..c192b54 100644 --- a/kernel/ethosu_mailbox.h +++ b/kernel/ethosu_mailbox.h @@ -51,8 +51,9 @@ struct ethosu_mailbox { }; struct ethosu_mailbox_msg { - int id; - void (*fail)(struct ethosu_mailbox_msg *msg); + int id; + uint32_t type; + void (*fail)(struct ethosu_mailbox_msg *msg); }; /**************************************************************************** @@ -93,7 +94,8 @@ void ethosu_mailbox_deregister(struct ethosu_mailbox *mbox, * Return: a valid pointer on success, otherwise an error ptr. */ struct ethosu_mailbox_msg *ethosu_mailbox_find(struct ethosu_mailbox *mbox, - int msg_id); + int msg_id, + uint32_t msg_type); /** * ethosu_mailbox_fail() - Fail mailbox messages |