cpu/esp: fix computation of coprocessor save area
`top_of_stack` isn't aligned down to the previous 16 byte aligned address. Furthermore, `top_of_stack` as well as `XT_CP_SIZE` are used unaligned in `cpu/esp_common/vendor/xtensa/portasm.S` in the address computation for the coprocessor save area, . Aligning pointer `p` down to the previous 16 byte aligned address results in a wrong address of the coprocessor save area during the initialization of the thread context. This leads to wrong values and wrong positions of these values in the coprocessor save area in inital thread context. Since ESP8266 doesn't have a coprocessor, this bug affects only ESP32.
This commit is contained in:
parent
8755a26716
commit
09a2a11dd7
@ -183,7 +183,7 @@ char* thread_stack_init(thread_task_func_t task_func, void *arg, void *stack_sta
|
|||||||
|
|
||||||
uint32_t *p;
|
uint32_t *p;
|
||||||
|
|
||||||
p = (uint32_t *)(((uint32_t)(top_of_stack + 1) - XT_CP_SIZE) & ~0xf);
|
p = (uint32_t *)(((uint32_t)(top_of_stack + 1) - XT_CP_SIZE));
|
||||||
p[0] = 0;
|
p[0] = 0;
|
||||||
p[1] = 0;
|
p[1] = 0;
|
||||||
p[2] = (((uint32_t) p) + 12 + XCHAL_TOTAL_SA_ALIGN - 1) & -XCHAL_TOTAL_SA_ALIGN;
|
p[2] = (((uint32_t) p) + 12 + XCHAL_TOTAL_SA_ALIGN - 1) & -XCHAL_TOTAL_SA_ALIGN;
|
||||||
|
|||||||
@ -174,7 +174,7 @@ char* thread_stack_init(thread_task_func_t task_func, void *arg, void *stack_sta
|
|||||||
*/
|
*/
|
||||||
uint32_t *p;
|
uint32_t *p;
|
||||||
|
|
||||||
p = (uint32_t *)(((uint32_t) pxTopOfStack - XT_CP_SIZE) & ~0xf);
|
p = (uint32_t *)(((uint32_t) pxTopOfStack - XT_CP_SIZE));
|
||||||
p[0] = 0;
|
p[0] = 0;
|
||||||
p[1] = 0;
|
p[1] = 0;
|
||||||
p[2] = (((uint32_t) p) + 12 + XCHAL_TOTAL_SA_ALIGN - 1) & -XCHAL_TOTAL_SA_ALIGN;
|
p[2] = (((uint32_t) p) + 12 + XCHAL_TOTAL_SA_ALIGN - 1) & -XCHAL_TOTAL_SA_ALIGN;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user