Skip to content

Commit 476a5bf

Browse files
committed
Set public box main stack non-secure guard protection for v8m
1 parent d80fc81 commit 476a5bf

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

api/src/uvisor-input.S

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ uvisor_config:
114114
/* Debug driver pointer */
115115
.long __uvisor_debug_driver
116116

117+
/* Stack limit for publix box MSPLIM_NS, accessed by public_box_stack_limit */
118+
.long __uvisor_public_box_stack_limit
119+
117120
/* uVisor mode of operation
118121
* Modes available: UVISOR_ENABLED, UVISOR_DISABLED, UVISOR_PERMISSIVE. */
119122
__uvisor_mode:
@@ -134,6 +137,9 @@ __uvisor_debug_driver:
134137
.long 0
135138
.long 0
136139

140+
__uvisor_public_box_stack_limit:
141+
.long __StackLimit
142+
137143
/* __uvisor_ps is written inside uvisor_init. It must not be
138144
* overwritten by libc init and therefore is placed in .uninitialized. */
139145
.section .uninitialized

core/system/inc/linker.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ typedef struct {
121121
UvisorLibHooks const * const lib_hooks;
122122

123123
TUvisorDebugDriver const * const debug_driver;
124+
125+
/* Stack limit for public box MSPNS_LIM, accessed by __uvisor_public_box_stack_limit*/
126+
uint32_t * public_box_stack_limit;
124127
} UVISOR_PACKED UvisorConfig;
125128

126129
extern UvisorConfig const __uvisor_config;

core/system/src/main.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ void main_init(void)
161161
/* NS P stack pointer, for the RTOS and the uVisor-ns. */
162162
__TZ_set_MSP_NS(original_sp);
163163

164+
/* NS P limit, for the RTOS and the uVisor-ns. */
165+
__TZ_set_MSPLIM_NS(*(__uvisor_config.public_box_stack_limit));
166+
164167
/* S NP stack pointer, for the SDSs and the transition gateways. */
165168
__set_PSP((uint32_t) &__uvisor_stack_top_np__);
166169
#else /* defined(ARCH_CORE_ARMv8M) */

0 commit comments

Comments
 (0)