diff --git a/arch/x86_64/src/intel64/intel64_createstack.c b/arch/x86_64/src/intel64/intel64_createstack.c index f95086f5ff..f1c05da1fd 100644 --- a/arch/x86_64/src/intel64/intel64_createstack.c +++ b/arch/x86_64/src/intel64/intel64_createstack.c @@ -192,8 +192,9 @@ int up_create_stack(struct tcb_s *tcb, size_t stack_size, uint8_t ttype) /* The intel64 stack must be aligned at word (16 byte) boundaries. If * necessary top_of_stack must be rounded down to the next boundary. - * We intentionally align at 8 byte boundary, because at task_start, - * only frame pointer will be pushed, not instruction pointer. + * We intentionally align at 8 byte boundary (look at up_stack_frame()) + * , because at task_start, only frame pointer will be pushed, not + * instruction pointer. */ top_of_stack &= ~0x0f; diff --git a/arch/x86_64/src/intel64/intel64_stackframe.c b/arch/x86_64/src/intel64/intel64_stackframe.c index 2381aeef2f..a0c6909799 100644 --- a/arch/x86_64/src/intel64/intel64_stackframe.c +++ b/arch/x86_64/src/intel64/intel64_stackframe.c @@ -90,7 +90,7 @@ void *up_stack_frame(struct tcb_s *tcb, size_t frame_size) /* Save the adjusted stack values in the struct tcb_s */ tcb->stack_base_ptr = (uint8_t *)tcb->stack_base_ptr + frame_size; - tcb->adj_stack_size -= frame_size; + tcb->adj_stack_size -= frame_size + 8; /* And return the pointer to the allocated region */ diff --git a/arch/x86_64/src/intel64/intel64_usestack.c b/arch/x86_64/src/intel64/intel64_usestack.c index d05d89d1fd..386d7c77cd 100644 --- a/arch/x86_64/src/intel64/intel64_usestack.c +++ b/arch/x86_64/src/intel64/intel64_usestack.c @@ -110,8 +110,9 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) /* The intel64 stack must be aligned at word (16 byte) boundaries. If * necessary top_of_stack must be rounded down to the next boundary. - * We intentionally align at 8 byte boundary, because at task_start, only - * frame pointer will be pushed, not instruction pointer. + * We intentionally align at 8 byte boundary (look at up_stack_frame()), + * because at task_start, only frame pointer will be pushed, not + * instruction pointer. */ top_of_stack &= ~0x0f;