u-boot-brain/arch/mips
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
..
cpu mips: start.S: avoid overwriting outside gd when clearing global data in stack 2020-04-27 20:29:33 +02:00
dts dts: mtmips: add default pinctrl to eth nodes for all boards 2019-10-25 17:20:44 +02:00
include/asm mips: add support to restore exception vector base before booting linux 2020-04-27 20:29:33 +02:00
lib mips: add support to restore exception vector base before booting linux 2020-04-27 20:29:33 +02:00
mach-ath79 common: Move hang() to the same header as panic() 2020-01-17 17:53:40 -05:00
mach-bmips bmips: swapping IO space isn't required 2018-12-10 18:46:45 +01:00
mach-jz47xx common: Move hang() to the same header as panic() 2020-01-17 17:53:40 -05:00
mach-mscc mips: vcoreiii: Fix cache coherency issues 2020-04-09 18:55:59 +02:00
mach-mtmips mips: mtmips: add predefined i-cache/d-cache size and linesize 2020-04-27 20:29:33 +02:00
mach-pic32 dm: core: Create a new header file for 'compat' features 2020-02-05 19:33:46 -07:00
config.mk kconfig / kbuild: Re-sync with Linux 4.19 2020-04-10 11:18:32 -04:00
Kconfig mips: add support to restore exception vector base before booting linux 2020-04-27 20:29:33 +02:00
Makefile mips: rename mach-mt7620 to mach-mtmips 2019-05-03 16:43:11 +02:00
Makefile.postlink SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00