u-boot-brain/arch/mips/cpu
Weijie Gao 6e9281b559 mips: start.S: avoid overwriting outside gd when clearing global data in stack
When setting up initial stack, global data will also be put in the stack,
and being cleared.

The assembler instructions for clearing gd is as follows:

	move	t0, k0
1:
	PTR_S	zero, 0(t0)
	blt	t0, t1, 1b
	 PTR_ADDIU t0, PTRSIZE

t0 is the start address of gd, t1 is the end address of gd (t0 + GD_SIZE).

[PTR_ADDIU t0, PTRSIZE] is in the delay slot of [blt t0, t1, 1b], so it
will be executed before the branch operation.

However the comparison for the BLT instruction is done before executing the
delay slot. This means when the last word just before k1 is cleared, the
loop will continue to run once. This will clear an extra word at k1, which
is outside the global data.

Global data is placed at the top of the stack. If the initial stack is a
SRAM or locked cache, the area outside them may be inaccessible. A write
operation performed in this area may cause an exception.

To solve this, [PTR_ADDIU t0, PTRSIZE] should be placed before the BLT
instruction.

Reviewed-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
2020-04-27 20:29:33 +02:00
..
cm_init.S SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
cpu.c MIPS: move create_tlb() in an proper header: mipsregs.h 2018-12-19 15:23:01 +01:00
interrupts.c common: Move interrupt functions into a new header 2019-12-02 18:25:00 -05:00
Makefile SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
start.S mips: start.S: avoid overwriting outside gd when clearing global data in stack 2020-04-27 20:29:33 +02:00
time.c MIPS: allow override of get_tbclk() 2020-04-09 18:55:59 +02:00
u-boot-spl.lds linker: Modify linker scripts to be more generic 2019-01-26 22:55:53 -05:00
u-boot.lds MIPS: optimize and fix ELF sections 2019-01-16 13:56:43 +01:00