x86: enable stack overflow detection on 64-bit
CONFIG_HW_STACK_PROTECTION is now available. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
9fb89ccf32
commit
7d1ae023f8
4 changed files with 30 additions and 3 deletions
|
@ -15,10 +15,22 @@ void z_arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
|
|||
void *parameter1, void *parameter2, void *parameter3,
|
||||
int priority, unsigned int options)
|
||||
{
|
||||
#if defined(CONFIG_X86_USERSPACE) || defined(CONFIG_X86_STACK_PROTECTION)
|
||||
struct z_x86_thread_stack_header *header =
|
||||
(struct z_x86_thread_stack_header *)stack;
|
||||
#endif
|
||||
|
||||
Z_ASSERT_VALID_PRIO(priority, entry);
|
||||
z_new_thread_init(thread, Z_THREAD_STACK_BUFFER(stack),
|
||||
stack_size, priority, options);
|
||||
|
||||
#if CONFIG_X86_STACK_PROTECTION
|
||||
/* Set guard area to read-only to catch stack overflows */
|
||||
z_x86_mmu_set_flags(&z_x86_kernel_ptables, &header->guard_page,
|
||||
MMU_PAGE_SIZE, MMU_ENTRY_READ, Z_X86_MMU_RW,
|
||||
true);
|
||||
#endif
|
||||
|
||||
thread->callee_saved.rsp = (long) Z_THREAD_STACK_BUFFER(stack);
|
||||
thread->callee_saved.rsp += (stack_size - 8); /* fake RIP for ABI */
|
||||
thread->callee_saved.rip = (long) z_thread_entry;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue