x86: set stack guard page non-writable

This will trigger a page fault if the guard area
is written to. Since the exception itself will try
to write to the memory, a double fault will be triggered
and we will do an IA task switch to the df_tss and panic.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2017-07-14 17:41:24 -07:00 committed by Anas Nashif
commit 054d47b29c

View file

@ -20,6 +20,7 @@
#include <linker/sections.h>
#include <kernel_structs.h>
#include <wait_q.h>
#include <mmustructs.h>
/* forward declaration */
@ -204,6 +205,10 @@ void _new_thread(struct k_thread *thread, char *pStackMem, size_t stackSize,
unsigned long *pInitialThread;
#if CONFIG_X86_STACK_PROTECTION
_x86_mmu_set_flags(pStackMem, MMU_PAGE_SIZE, MMU_ENTRY_NOT_PRESENT,
MMU_PTE_P_MASK);
#endif
#if _STACK_GUARD_SIZE
pStackMem += _STACK_GUARD_SIZE;
#endif