diff options
| author | Scott Larson <[email protected]> | 2020-10-16 11:57:42 -0700 |
|---|---|---|
| committer | Scott Larson <[email protected]> | 2020-10-16 11:57:42 -0700 |
| commit | 6773d468ae877ce36feda1c86842510fb33501a3 (patch) | |
| tree | f151f40723c3f794adc97f302f3df54a74c081b8 /ports/cortex_m33/iar/src | |
| parent | c2df92c885c06b85a3800617b46f291342ea184e (diff) | |
6.1.1 patch: add stack sealing to armv8-m, fix misra warning, fix stack check link errorv6.1.1_rel
Diffstat (limited to 'ports/cortex_m33/iar/src')
| -rw-r--r-- | ports/cortex_m33/iar/src/tx_thread_secure_stack.c | 52 |
1 files changed, 35 insertions, 17 deletions
diff --git a/ports/cortex_m33/iar/src/tx_thread_secure_stack.c b/ports/cortex_m33/iar/src/tx_thread_secure_stack.c index d1a9d182..d790bca0 100644 --- a/ports/cortex_m33/iar/src/tx_thread_secure_stack.c +++ b/ports/cortex_m33/iar/src/tx_thread_secure_stack.c @@ -20,6 +20,7 @@ /**************************************************************************/ /**************************************************************************/ + #include "tx_api.h" /* If TX_SINGLE_MODE_SECURE or TX_SINGLE_MODE_NON_SECURE is defined, @@ -40,6 +41,10 @@ #define TX_THREAD_SECURE_STACK_MAXIMUM 1024 #endif +/* 8 bytes added to stack size to "seal" stack. */ +#define TX_THREAD_STACK_SEAL_SIZE 8 +#define TX_THREAD_STACK_SEAL_VALUE 0xFEF5EDA5 + /* Secure stack info struct to hold stack start, stack limit, current stack pointer, and pointer to owning thread. This will be allocated for each thread with a secure stack. */ @@ -58,7 +63,7 @@ typedef struct TX_THREAD_SECURE_STACK_INFO_STRUCT /* FUNCTION RELEASE */ /* */ /* _tx_thread_secure_stack_initialize Cortex-M33/IAR */ -/* 6.1 */ +/* 6.1.1 */ /* AUTHOR */ /* */ /* Scott Larson, Microsoft Corporation */ @@ -90,7 +95,9 @@ typedef struct TX_THREAD_SECURE_STACK_INFO_STRUCT /* */ /* DATE NAME DESCRIPTION */ /* */ -/* 09-30-2020 Scott Larson Initial Version 6.1 */ +/* 09-30-2020 Scott Larson Initial Version 6.1 */ +/* 10-16-2020 Scott Larson Modified comment(s), */ +/* resulting in version 6.1.1 */ /* */ /**************************************************************************/ __attribute__((cmse_nonsecure_entry)) @@ -114,8 +121,8 @@ void _tx_thread_secure_stack_initialize(void) /* */ /* FUNCTION RELEASE */ /* */ -/* _tx_thread_secure_mode_stack_allocate PORTABLE C */ -/* 6.1 */ +/* _tx_thread_secure_mode_stack_allocate Cortex-M33/IAR */ +/* 6.1.1 */ /* AUTHOR */ /* */ /* Scott Larson, Microsoft Corporation */ @@ -154,7 +161,10 @@ void _tx_thread_secure_stack_initialize(void) /* */ /* DATE NAME DESCRIPTION */ /* */ -/* 09-30-2020 Scott Larson Initial Version 6.1 */ +/* 09-30-2020 Scott Larson Initial Version 6.1 */ +/* 10-16-2020 Scott Larson Modified comment(s), */ +/* added stack sealing, */ +/* resulting in version 6.1.1 */ /* */ /**************************************************************************/ __attribute__((cmse_nonsecure_entry)) @@ -184,14 +194,13 @@ UCHAR *stack_mem; else { - /* Allocate space for secure stack info. */ info_ptr = calloc(1, sizeof(TX_THREAD_SECURE_STACK_INFO)); if(info_ptr != TX_NULL) { - /* If stack info allocated, allocate a stack. */ - stack_mem = malloc(stack_size); + /* If stack info allocated, allocate a stack & seal. */ + stack_mem = malloc(stack_size + TX_THREAD_STACK_SEAL_SIZE); if(stack_mem != TX_NULL) { @@ -201,6 +210,9 @@ UCHAR *stack_mem; info_ptr -> tx_thread_secure_stack_ptr = info_ptr -> tx_thread_secure_stack_start; info_ptr -> tx_thread_ptr = thread_ptr; + /* Seal bottom of stack. */ + *(ULONG*)info_ptr -> tx_thread_secure_stack_start = TX_THREAD_STACK_SEAL_VALUE; + /* Save info pointer in thread. */ thread_ptr -> tx_thread_secure_stack_context = info_ptr; @@ -236,8 +248,8 @@ UCHAR *stack_mem; /* */ /* FUNCTION RELEASE */ /* */ -/* _tx_thread_secure_mode_stack_free PORTABLE C */ -/* 6.1 */ +/* _tx_thread_secure_mode_stack_free Cortex-M33/IAR */ +/* 6.1.1 */ /* AUTHOR */ /* */ /* Scott Larson, Microsoft Corporation */ @@ -269,7 +281,9 @@ UCHAR *stack_mem; /* */ /* DATE NAME DESCRIPTION */ /* */ -/* 09-30-2020 Scott Larson Initial Version 6.1 */ +/* 09-30-2020 Scott Larson Initial Version 6.1 */ +/* 10-16-2020 Scott Larson Modified comment(s), */ +/* resulting in version 6.1.1 */ /* */ /**************************************************************************/ __attribute__((cmse_nonsecure_entry)) @@ -317,8 +331,8 @@ TX_THREAD_SECURE_STACK_INFO *info_ptr; /* */ /* FUNCTION RELEASE */ /* */ -/* _tx_thread_secure_stack_context_save PORTABLE C */ -/* 6.1 */ +/* _tx_thread_secure_stack_context_save Cortex-M33/IAR */ +/* 6.1.1 */ /* AUTHOR */ /* */ /* Scott Larson, Microsoft Corporation */ @@ -350,7 +364,9 @@ TX_THREAD_SECURE_STACK_INFO *info_ptr; /* */ /* DATE NAME DESCRIPTION */ /* */ -/* 09-30-2020 Scott Larson Initial Version 6.1 */ +/* 09-30-2020 Scott Larson Initial Version 6.1 */ +/* 10-16-2020 Scott Larson Modified comment(s), */ +/* resulting in version 6.1.1 */ /* */ /**************************************************************************/ __attribute__((cmse_nonsecure_entry)) @@ -399,8 +415,8 @@ ULONG sp; /* */ /* FUNCTION RELEASE */ /* */ -/* _tx_thread_secure_stack_context_restore PORTABLE C */ -/* 6.1 */ +/* _tx_thread_secure_stack_context_restore Cortex-M33/IAR */ +/* 6.1.1 */ /* AUTHOR */ /* */ /* Scott Larson, Microsoft Corporation */ @@ -431,7 +447,9 @@ ULONG sp; /* */ /* DATE NAME DESCRIPTION */ /* */ -/* 09-30-2020 Scott Larson Initial Version 6.1 */ +/* 09-30-2020 Scott Larson Initial Version 6.1 */ +/* 10-16-2020 Scott Larson Modified comment(s), */ +/* resulting in version 6.1.1 */ /* */ /**************************************************************************/ __attribute__((cmse_nonsecure_entry)) |
