x86: fix logic for thread wrappers
If we enable CONFIG_DEBUG_INFO, then we need to fixup the stack on thread entry so that the EFLAGS value in the EBP slot doesn't confuse the debugger or any runtime stack unwinding code. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
c49d176c35
commit
e00564d15d
3 changed files with 18 additions and 18 deletions
|
@ -393,7 +393,7 @@ time_read_not_needed:
|
|||
#endif
|
||||
ret
|
||||
|
||||
#if defined(CONFIG_X86_IAMCU)
|
||||
#ifdef _THREAD_WRAPPER_REQUIRED
|
||||
/**
|
||||
*
|
||||
* @brief Adjust stack/parameters before invoking thread entry function
|
||||
|
@ -465,5 +465,6 @@ SECTION_FUNC(TEXT, _x86_thread_entry_wrapper)
|
|||
pop %ecx
|
||||
push $0 /* Null return address */
|
||||
#endif
|
||||
movl $0, (%esp)
|
||||
jmp *%edi
|
||||
#endif
|
||||
#endif /* _THREAD_WRAPPER_REQUIRED */
|
||||
|
|
|
@ -25,19 +25,6 @@
|
|||
|
||||
/* forward declaration */
|
||||
|
||||
/* Some configurations require that the stack/registers be adjusted before
|
||||
* _thread_entry. See discussion in swap.S for _x86_thread_entry_wrapper()
|
||||
*/
|
||||
#if defined(CONFIG_X86_IAMCU)
|
||||
#define WRAPPER_REQUIRED
|
||||
#endif
|
||||
|
||||
#ifdef WRAPPER_REQUIRED
|
||||
extern void _x86_thread_entry_wrapper(k_thread_entry_t entry,
|
||||
void *p1, void *p2, void *p3);
|
||||
#endif /* WRAPPER_REQUIRED */
|
||||
|
||||
|
||||
/* Initial thread stack frame, such that everything is laid out as expected
|
||||
* for when _Swap() switches to it for the first time.
|
||||
*/
|
||||
|
@ -113,16 +100,16 @@ void _new_thread(struct k_thread *thread, k_thread_stack_t *stack,
|
|||
initial_frame->eflags = (EflagsGet() & ~EFLAGS_MASK) | EFLAGS_INITIAL;
|
||||
#ifdef CONFIG_X86_USERSPACE
|
||||
if (options & K_USER) {
|
||||
#ifdef WRAPPER_REQUIRED
|
||||
#ifdef _THREAD_WRAPPER_REQUIRED
|
||||
initial_frame->edi = (u32_t)_arch_user_mode_enter;
|
||||
initial_frame->_thread_entry = _x86_thread_entry_wrapper;
|
||||
#else
|
||||
initial_frame->_thread_entry = _arch_user_mode_enter;
|
||||
#endif /* WRAPPER_REQUIRED */
|
||||
#endif /* _THREAD_WRAPPER_REQUIRED */
|
||||
} else
|
||||
#endif /* CONFIG_X86_USERSPACE */
|
||||
{
|
||||
#ifdef WRAPPER_REQUIRED
|
||||
#ifdef _THREAD_WRAPPER_REQUIRED
|
||||
initial_frame->edi = (u32_t)_thread_entry;
|
||||
initial_frame->_thread_entry = _x86_thread_entry_wrapper;
|
||||
#else
|
||||
|
|
|
@ -39,6 +39,13 @@
|
|||
#include <misc/dlist.h>
|
||||
#endif
|
||||
|
||||
/* Some configurations require that the stack/registers be adjusted before
|
||||
* _thread_entry. See discussion in swap.S for _x86_thread_entry_wrapper()
|
||||
*/
|
||||
#if defined(CONFIG_X86_IAMCU) || defined(CONFIG_DEBUG_INFO)
|
||||
#define _THREAD_WRAPPER_REQUIRED
|
||||
#endif
|
||||
|
||||
|
||||
/* increase to 16 bytes (or more?) to support SSE/SSE2 instructions? */
|
||||
|
||||
|
@ -388,6 +395,11 @@
|
|||
|
||||
#include <misc/util.h>
|
||||
|
||||
#ifdef _THREAD_WRAPPER_REQUIRED
|
||||
extern void _x86_thread_entry_wrapper(k_thread_entry_t entry,
|
||||
void *p1, void *p2, void *p3);
|
||||
#endif /* _THREAD_WRAPPER_REQUIRED */
|
||||
|
||||
#ifdef DEBUG
|
||||
#include <misc/printk.h>
|
||||
#define PRINTK(...) printk(__VA_ARGS__)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue