]> begriffs open source - freertos/commit
Xtensa: fix stack overlap coproc_area issue (#118)
authormagicse7en <magicse7en@outlook.com>
Mon, 26 Oct 2020 18:07:32 +0000 (02:07 +0800)
committerGitHub <noreply@github.com>
Mon, 26 Oct 2020 18:07:32 +0000 (11:07 -0700)
commitb9748e50eaafdb20a0c2438c0286a255c3f59e4c
tree200c902b187dfc7f540f0016f9d39c267d651bc7
parentf376c3bd71b87c532474aa204861028c577d6dab
Xtensa: fix stack overlap coproc_area issue (#118)

In function pxPortInitialiseStack of port.c:
sp = ( StackType_t * ) ( ( ( UBaseType_t ) ( pxTopOfStack + 1 )  - XT_CP_SIZE - XT_STK_FRMSZ ) & ~0xf );
We assume XT_CP_SIZE is 0xE4, XT_STK_FRMSZ is 0xA0, pxTopOfStack is 0xA0000000, sp is 0x9FFFFE80.
From port.c, we know the frame->a1 as below:
frame->a1 = ( UBaseType_t ) sp + XT_STK_FRMSZ;  /* physical top of stack frame    */
So frame->a1 is 0x9FFFFF20. Therefore the interrupt stack frame range is 0x9FFFFE80 ~ 0x9FFFFF20.

The coproc_area is: p = ( uint32_t * ) ( ( ( uint32_t ) pxTopOfStack - XT_CP_SIZE ) & ~0xf );
So its value is 0x9FFFFF10. Obviously, the interrupt stack frame overlaps the coproc_area.

Co-authored-by: Carl Lundin <53273776+lundinc2@users.noreply.github.com>
portable/ThirdParty/XCC/Xtensa/port.c