Implement MicroBlazeV9 stack protection (#523)

* Implement stack protection for MicroBlaze (without MPU wrappers)
This commit is contained in:
Gavin Lambert 2022-08-03 18:31:18 +12:00 committed by GitHub
parent bfe057367d
commit 63f86fc7a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 75 additions and 11 deletions

View file

@ -105,7 +105,11 @@ static XIntc xInterruptControllerInstance;
*
* See the portable.h header file.
*/
#if ( portHAS_STACK_OVERFLOW_CHECKING == 1 )
StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters )
#else
StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters )
#endif
{
extern void *_SDA2_BASE_, *_SDA_BASE_;
const uint32_t ulR2 = ( uint32_t ) &_SDA2_BASE_;
@ -122,6 +126,14 @@ extern void _start1( void );
*pxTopOfStack = ( StackType_t ) 0x00000000;
pxTopOfStack--;
#if ( portHAS_STACK_OVERFLOW_CHECKING == 1 )
/* Store the stack limits. */
*pxTopOfStack = (StackType_t) (pxTopOfStack + 3);
pxTopOfStack--;
*pxTopOfStack = (StackType_t) pxEndOfStack;
pxTopOfStack--;
#endif
#if( XPAR_MICROBLAZE_USE_FPU != 0 )
/* The FSR value placed in the initial task context is just 0. */
*pxTopOfStack = portINITIAL_FSR;