Re: k_thread_user_mode_enter() usage
Boie, Andrew P
Andy,toggle quoted messageShow quoted text
Can you take a look at this? Seems to be rooted in the privileged stack mechanism..
From: Vakul Garg [mailto:firstname.lastname@example.org]
Sent: Tuesday, March 20, 2018 11:26 PM
To: Boie, Andrew P <email@example.com>; firstname.lastname@example.org
Cc: Andy Gross <email@example.com>
Subject: RE: k_thread_user_mode_enter() usage
I am using nxp frdm_k64f (has cortex M4 core).
In my application, I have a printf() at beginning. This is causing bus fault.
Replacing it with an infinite while(1) loop hides the bus fault but stack check still remains.
Further I tried running zephyr/tests/kernel/mem_protect/userspace.
It passes successfully.
However if I introduce a printf() in function userspace/src/main.c: umode_enter_func() under the condition when is_user_context is true, it also crashes.
But here it is different exception !!
***** USAGE FAULT *****
Executing thread ID (thread): 0x200002ec
Faulting instruction address: 0x61a0
Attempt to execute undefined instruction Caught system error -- reason 0
Further decoding faulting instruction address 0x61a0 using 'addr2line' takes me to userspace/build/frdm_k64f/zephyr/priv_stacks_hash.gperf:32
The given line number is inside following function (at the location where variable map is being dereferenced to get priv_stack_addr).
u8_t *_k_priv_stack_find(void *obj)
const struct _k_priv_stack_map *map =
_k_priv_stack_map_lookup((const char *)obj, sizeof(void *));
I tried increasing MAIN/PREVILEDGED stack sizes in project config, but result is same.