[U-Boot-Users] Why exceptions are enabled before exception vector code is copied

Dear Wolfgang.
Can I ask you why exceptions are enabled before exception vector code is copied to the low RAM pages ? (I am talking about U-Boot/PPC)
On my board, U-Boot crashes before relocation (when debugging) since Xilinx Microprocessor Debugger (XMD) makes a spurious "Machine Check Exception". For other reasons, such an exception could arrived before u-boot starts.
Finally, it is a bug or a very strange coding behaviour...
Cedric VINCENT.

In message c8f10050706004556bcca54@mail.gmail.com you wrote:
Can I ask you why exceptions are enabled before exception vector code is copied to the low RAM pages ? (I am talking about U-Boot/PPC)
No exceptions are supposed to happen until then.
On my board, U-Boot crashes before relocation (when debugging) since Xilinx Microprocessor Debugger (XMD) makes a spurious "Machine Check Exception". For other reasons, such an exception could arrived before u-boot starts.
Well, then fix this problem. What do you suggest hoiw such a situation should be handled while running from flash?
Finally, it is a bug or a very strange coding behaviour...
It does not happen on other systems.
Best regards,
Wolfgang Denk

No exceptions are supposed to happen until then.
What do you suggest hoiw such a situation should be handled while running from flash?
There is no reason to enable them before exception vector code is copied. So exceptions should be enabled *after* exception vector code is copied.
It does not happen on other systems.
The spurious "Machine Check Excpetion" is well known on Virtex/PPC. Most Xilinx FPGA boards are affected (tested on Virtex-II Pro and Virtex 4).
regards, Cedric VINCENT.

In message c8f1005070601532cb85bff@mail.gmail.com you wrote:
No exceptions are supposed to happen until then.
What do you suggest hoiw such a situation should be handled while running from flash?
There is no reason to enable them before exception vector code is copied. So exceptions should be enabled *after* exception vector code is copied.
Feel free to submit a patch.
But what would happen in your case of a Machine Check? What do you suggest to recover from that?
Best regards,
Wolfgang Denk

Feel free to submit a patch.
OK, maybe the next week.
But what would happen in your case of a Machine Check? What do you suggest to recover from that?
When this spurious "Machine Check Exception" occured, the MSR didn't contain any known causes. Maybe the function "MachineCheckException" (from cpu/ppc4xx/traps.c) may be modified with something like this : --------- #if (CONFIG_COMMANDS & CFG_CMD_KGDB) if (debugger_exception_handler && (*debugger_exception_handler)(regs)) return; #endif
+ #if defined(CONFIG_USE_XMD) + if( SPURIOUS_MCE == (regs->msr & 0x000F0000) ) + return; + #endif
printf("Machine check in kernel mode.\n"); printf("Caused by (from msr): "); printf("regs %p ",regs); switch( regs->msr & 0x000F0000) { --------- where CONFIG_USE_XMD is a macro (to use with care !) defined by user when he uses XMD (during debugging stage) and SPURIOUS_MCE is the MSR unknown cause.
This (ugly) stuff makes sense to enable exception after relocation. I didn't test this, since I disable Machine Check Exception when debugging my Virtex Board. Maybe it will not work (if this spurious exception occured more than once). I will try to test next week.
Regards, Cedric VINCENT.

Here comes a patch to enable exceptions after exceptions vector code is copied (i.e after relocation). I tested it with my board (PPC 405), I also changed 440 and IOP480 target but without testing...
I run the MAKEALL script : there are no errors, warnings was not due to this patch.
CHANGELOG : * cpu/ppc4xx/start.S : exceptions are enabled after relocation.
About XMD, as I thought the spurious exception comes infinitely... So there is no easy way to fix it. If you apply this patch (this is an easy way to detect this spurious exception), you should add at the end of doc/README.ml300 : ======================== 6. Warning ----------
It was reported that XMD makes (sometimes) a spurious "Machine Check Exception". When debugging, if you are sure that this exception doesn't come from your system, comment this line into cpu/ppc4xx/start.S :
addi r7,r0,0x1000 /* set ME bit (Machine Exceptions) */
========================
Regards, Cedric VINCENT

In message c8f1005070606506c278f6b@mail.gmail.com you wrote:
Here comes a patch to enable exceptions after exceptions vector code is copied (i.e after relocation). I tested it with my board (PPC 405), I also changed 440 and IOP480 target but without testing...
I run the MAKEALL script : there are no errors, warnings was not due to this patch.
CHANGELOG : * cpu/ppc4xx/start.S : exceptions are enabled after relocation.
Added, thanks.
Best regards,
Wolfgang Denk
participants (2)
-
Cedric VINCENT
-
Wolfgang Denk