diff options
author | Chris Brand <chris.brand@cypress.com> | 2019-07-05 15:34:27 -0700 |
---|---|---|
committer | David Hu <david.hu@arm.com> | 2019-07-12 05:14:02 +0000 |
commit | 845a83d9113b8d32e4e9bab80fa6b2c1b4d70520 (patch) | |
tree | 8bd50099b804be9df3ac4216fb175cda06d529e1 | |
parent | dd7d1c9b9cdaa941ba67d4efeb7407ead3032e26 (diff) | |
download | trusted-firmware-m-845a83d9113b8d32e4e9bab80fa6b2c1b4d70520.tar.gz |
plat: Move semaphore data to NS side
The secure side can access NS data, but the reverse isn't true,
so allocating the variable for the semaphore data on the secure
side means that we can't protect the secure data.
Change-Id: Iff51f4958331b0062e0e731e3b5776352e340c4a
Signed-off-by: Chris Brand <chris.brand@cypress.com>
-rw-r--r-- | platform/ext/target/psoc6/mailbox/platform_ns_mailbox.c | 9 | ||||
-rw-r--r-- | platform/ext/target/psoc6/mailbox/platform_spe_mailbox.c | 21 |
2 files changed, 18 insertions, 12 deletions
diff --git a/platform/ext/target/psoc6/mailbox/platform_ns_mailbox.c b/platform/ext/target/psoc6/mailbox/platform_ns_mailbox.c index c058efc876..2b5a33cda6 100644 --- a/platform/ext/target/psoc6/mailbox/platform_ns_mailbox.c +++ b/platform/ext/target/psoc6/mailbox/platform_ns_mailbox.c @@ -6,6 +6,7 @@ */ /* -------------------------------------- Includes ----------------------------------- */ +#include <limits.h> #include <string.h> #include "cmsis.h" @@ -44,8 +45,12 @@ int32_t mailbox_notify_peer(void) static int32_t mailbox_sema_init(void) { - if (Cy_IPC_Sema_Init(PLATFORM_MAILBOX_IPC_CHAN_SEMA, (uint32_t)NULL, - (uint32_t *)NULL) != CY_IPC_SEMA_SUCCESS) { + /* semaphore data */ + static uint32_t tfm_sema; + + if (Cy_IPC_Sema_Init(PLATFORM_MAILBOX_IPC_CHAN_SEMA, + sizeof(tfm_sema) * CHAR_BIT, + &tfm_sema) != CY_IPC_SEMA_SUCCESS) { return PLATFORM_MAILBOX_INIT_ERROR; } return PLATFORM_MAILBOX_SUCCESS; diff --git a/platform/ext/target/psoc6/mailbox/platform_spe_mailbox.c b/platform/ext/target/psoc6/mailbox/platform_spe_mailbox.c index f906446d76..ebd2f437ee 100644 --- a/platform/ext/target/psoc6/mailbox/platform_spe_mailbox.c +++ b/platform/ext/target/psoc6/mailbox/platform_spe_mailbox.c @@ -39,17 +39,18 @@ static void mailbox_ipc_config(void) static int32_t tfm_mailbox_sema_init(void) { - /* semaphore data */ - static uint32_t tfm_sema; - - if (Cy_IPC_Sema_Init(PLATFORM_MAILBOX_IPC_CHAN_SEMA, - sizeof(tfm_sema) * 8ul/*bits per byte*/, - &tfm_sema) == CY_IPC_SEMA_SUCCESS) { - if (MAILBOX_SEMAPHORE_NUM < Cy_IPC_Sema_GetMaxSems()){ - return PLATFORM_MAILBOX_SUCCESS; - } + if (Cy_IPC_Sema_Init(PLATFORM_MAILBOX_IPC_CHAN_SEMA, 0, + NULL) != CY_IPC_SEMA_SUCCESS) { + return PLATFORM_MAILBOX_INIT_ERROR; } - return PLATFORM_MAILBOX_INIT_ERROR; + + if (MAILBOX_SEMAPHORE_NUM >= Cy_IPC_Sema_GetMaxSems()) { + return PLATFORM_MAILBOX_INIT_ERROR; + } + + /* TODO Check that the semaphore data is in NS memory */ + + return PLATFORM_MAILBOX_SUCCESS; } #else |