Skip to content

Commit 2dfccdf

Browse files
aineoae86-sysrawalexe
authored andcommitted
Fix MicroBlaze stack protection context layout
Account for MicroBlaze stack protection registers when sizing the saved context and assigning SLR/SHR offsets for 32-bit and 64-bit builds. Signed-off-by: Old-Ding <ai.neo.ae86@gmail.com>
1 parent 78069a7 commit 2dfccdf

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

portable/GCC/MicroBlazeV9/portasm.S

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,32 @@
3737
/* The context is oversized to allow functions called from the ISR to write
3838
back into the caller stack. */
3939
#if defined (__arch64__)
40+
#if( XPAR_MICROBLAZE_USE_STACK_PROTECTION )
41+
#if( XPAR_MICROBLAZE_USE_FPU != 0 )
42+
#define portCONTEXT_SIZE 288
43+
#define portMINUS_CONTEXT_SIZE -288
44+
#else
45+
#define portCONTEXT_SIZE 280
46+
#define portMINUS_CONTEXT_SIZE -280
47+
#endif
48+
#else
4049
#if( XPAR_MICROBLAZE_USE_FPU != 0 )
4150
#define portCONTEXT_SIZE 272
4251
#define portMINUS_CONTEXT_SIZE -272
4352
#else
4453
#define portCONTEXT_SIZE 264
4554
#define portMINUS_CONTEXT_SIZE -264
4655
#endif
56+
#endif
57+
#else
58+
#if( XPAR_MICROBLAZE_USE_STACK_PROTECTION )
59+
#if( XPAR_MICROBLAZE_USE_FPU != 0 )
60+
#define portCONTEXT_SIZE 144
61+
#define portMINUS_CONTEXT_SIZE -144
62+
#else
63+
#define portCONTEXT_SIZE 140
64+
#define portMINUS_CONTEXT_SIZE -140
65+
#endif
4766
#else
4867
#if( XPAR_MICROBLAZE_USE_FPU != 0 )
4968
#define portCONTEXT_SIZE 136
@@ -53,6 +72,7 @@ back into the caller stack. */
5372
#define portMINUS_CONTEXT_SIZE -132
5473
#endif
5574
#endif
75+
#endif
5676

5777
/* Offsets from the stack pointer at which saved registers are placed. */
5878
#if defined (__arch64__)
@@ -88,7 +108,16 @@ back into the caller stack. */
88108
#define portR2_OFFSET 240
89109
#define portCRITICAL_NESTING_OFFSET 248
90110
#define portMSR_OFFSET 256
111+
#if( XPAR_MICROBLAZE_USE_FPU != 0 )
91112
#define portFSR_OFFSET 264
113+
#if( XPAR_MICROBLAZE_USE_STACK_PROTECTION )
114+
#define portSLR_OFFSET 272
115+
#define portSHR_OFFSET 280
116+
#endif
117+
#elif( XPAR_MICROBLAZE_USE_STACK_PROTECTION )
118+
#define portSLR_OFFSET 264
119+
#define portSHR_OFFSET 272
120+
#endif
92121
#else
93122
#define portR31_OFFSET 4
94123
#define portR30_OFFSET 8
@@ -122,7 +151,16 @@ back into the caller stack. */
122151
#define portR2_OFFSET 120
123152
#define portCRITICAL_NESTING_OFFSET 124
124153
#define portMSR_OFFSET 128
154+
#if( XPAR_MICROBLAZE_USE_FPU != 0 )
125155
#define portFSR_OFFSET 132
156+
#if( XPAR_MICROBLAZE_USE_STACK_PROTECTION )
157+
#define portSLR_OFFSET 136
158+
#define portSHR_OFFSET 140
159+
#endif
160+
#elif( XPAR_MICROBLAZE_USE_STACK_PROTECTION )
161+
#define portSLR_OFFSET 132
162+
#define portSHR_OFFSET 136
163+
#endif
126164

127165
#endif
128166

0 commit comments

Comments
 (0)