arch/intel64: fix stack alignment
The stack pointer must be aligned to 16 bytes, otherwise the system crash on the first unaligned data access with vector instruction. The problem is only observable with optimization enabled, when vector instructions are generated. Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com> Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
This commit is contained in:
parent
c3d41195c7
commit
16e47d6c8b
@ -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;
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user