05-19-2015 04:16 PM
I'm developing a project with SDK 14.3 and lwIP140 that contains a simple embedded webserver. Early on in the game I realized that a lot of the webserver functions involved dereferencing pointers in potentially unaligned byte streams. So I enabled the unaligned data exception on the microblaze, enabled exceptions in the BSP and for a while all was well.
Just recently, while testing with an obsolete version of IE, we noticed that connecting to our webserver caused the microblaze to hang dead.It's stuck at the ex_handler_unhandled label in hw_exception_handler.S. What's happening is that it's getting an unaligned data exception from register 17, and the table entry for register 17 doesn't fix the unaligned data acess but just instead just traps it and that's what hangs the microblaze.
sw_r14: SWREG_TO_R3 (14);
sw_r15: SWREG_TO_R3 (15);
sw_r16: SWREG_TO_R3 (16);
sw_r17: SWREG_NOP; // this is where the code gets sent to the unhandled exception trap
sw_r18: SWREG_TO_R3 (18);
sw_r19: SWREG_TO_R3 (19);
sw_r20: SWREG_TO_R3 (20);
The problem is that I have no idea what to do about this. I don't control the register allocation by the compiler so I don't even know where to start. But it's unacceptable to have the processor hang when the webserver gets accessed by a certain web browser, even obsolete IE.
05-20-2015 05:34 AM
There is something weird going around here since the compiler should never allocate R17 since it is used as the exception return address.
Do you have any code that uses R17?
05-21-2015 05:23 AM
Then the only other reason behind this is that MicroBlaze is execute something that isn't instruction code.
Stack or data corruption can lead to MicroBlaze executing random code and this code could use R17 and thus you experience this issue.