diff --git a/fel-sdboot.c b/fel-sdboot.c index 3767ae338f..d3b0917128 100644 --- a/fel-sdboot.c +++ b/fel-sdboot.c @@ -39,16 +39,21 @@ void _start(void) unsigned int sctlr; /* - * FEL mode fails to activate in an unpredictable way without - * this NOP padding. Minor changes in the code, such as checking - * the PC register (PC >= 0x10000) instead of SCTLR.V or doing - * jump instead of call to the FEL handler in the BROM sometimes - * break on A64 and sometimes break on A10/A13/A20. Trying to - * add DSB & ISB instructions and/or invalidating caches and - * BTB do not seem to make any difference. Only adding a bunch - * of NOP instructions in the beginning helps. + * In cases where insufficient padding is added by an old mksunxiboot, + * the _start entry point may be 0x20, which means that the instruction + * at 0x28 could get corrupted by the BROM - see + * https://patchwork.ozlabs.org/patch/622173/ + * + * Apply a workaround to avoid (= skip over) that memory location. + * _main would be 0x30 in that particular case. With newer (properly + * fixed) versions of mksunxiboot, this code ends up at higher addresses + * and will be moot, but harmless. */ - asm volatile(".rept 32 \n nop \n .endr"); + asm volatile("b _main \n" + "nop \n" + "nop \n" + "nop \n" + "_main:"); asm volatile("mrc p15, 0, %0, c1, c0, 0" : "=r" (sctlr));