diff options
Diffstat (limited to 'ports/cortex_m33/gnu')
| -rw-r--r-- | ports/cortex_m33/gnu/src/tx_thread_secure_stack.c | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/ports/cortex_m33/gnu/src/tx_thread_secure_stack.c b/ports/cortex_m33/gnu/src/tx_thread_secure_stack.c index 79d8e9e0..396aefb3 100644 --- a/ports/cortex_m33/gnu/src/tx_thread_secure_stack.c +++ b/ports/cortex_m33/gnu/src/tx_thread_secure_stack.c @@ -40,6 +40,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 +62,7 @@ typedef struct TX_THREAD_SECURE_STACK_INFO_STRUCT /* FUNCTION RELEASE */ /* */ /* _tx_thread_secure_stack_initialize Cortex-M33/GNU */ -/* 6.1 */ +/* 6.1.1 */ /* AUTHOR */ /* */ /* Scott Larson, Microsoft Corporation */ @@ -90,7 +94,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)) @@ -118,7 +124,7 @@ void _tx_thread_secure_stack_initialize(void) /* FUNCTION RELEASE */ /* */ /* _tx_thread_secure_mode_stack_allocate Cortex-M33/GNU */ -/* 6.1 */ +/* 6.1.1 */ /* AUTHOR */ /* */ /* Scott Larson, Microsoft Corporation */ @@ -156,7 +162,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)) @@ -194,8 +203,8 @@ ULONG psplim_ns; 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) { @@ -205,6 +214,9 @@ ULONG psplim_ns; 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; @@ -242,7 +254,7 @@ ULONG psplim_ns; /* FUNCTION RELEASE */ /* */ /* _tx_thread_secure_mode_stack_free Cortex-M33/GNU */ -/* 6.1 */ +/* 6.1.1 */ /* AUTHOR */ /* */ /* Scott Larson, Microsoft Corporation */ @@ -274,7 +286,9 @@ ULONG psplim_ns; /* */ /* 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)) @@ -325,7 +339,7 @@ ULONG ipsr; /* FUNCTION RELEASE */ /* */ /* _tx_thread_secure_stack_context_save Cortex-M33/GNU */ -/* 6.1 */ +/* 6.1.1 */ /* AUTHOR */ /* */ /* Scott Larson, Microsoft Corporation */ @@ -357,7 +371,9 @@ ULONG ipsr; /* */ /* 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)) @@ -409,7 +425,7 @@ ULONG ipsr; /* FUNCTION RELEASE */ /* */ /* _tx_thread_secure_stack_context_restore Cortex-M33/GNU */ -/* 6.1 */ +/* 6.1.1 */ /* AUTHOR */ /* */ /* Scott Larson, Microsoft Corporation */ @@ -440,7 +456,9 @@ ULONG ipsr; /* */ /* 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)) |
