ARM v7: Fix register corruption in v7_mmu_cache_off
v7_mmu_cache_flush stores registers on the stack and restores
them afterwards. Additionally v7_mmu_cache_flush is called
from v7_mmu_cache_off *after* disabling the MMU. With this
the following can happen:

- v7_mmu_cache_off disables the MMU. From now on no new values
  go to the data cache.
- v7_mmu_cache_off calls v7_mmu_cache_flush which in turn puts
  registers on the stack. Due to the MMU being disabled they
  do not go into the data cache.
- In v7_mmu_cache_flush the memory the stack is pointing to is
  overwritten with the values currently being in the cache.
- v7_mmu_cache_flush restores the registers from the stack with
  values from the cache and not the memory where the values have
  previously been written to.

Fix this by storing the registers on the stack *before* we disable
the MMU and restore them after we have called v7_mmu_cache_flush.
This way v7_mmu_cache_flush still restores corrupt register values
for the case when the MMU has been disabled, but we will restore
correct values afterwards.

This has been first observed when switching to gcc-4.7.2 when compiling
in Thumb2 mode, but could explain earlier problems also. The result
here was that the register holding the kernel address in start_linux()
was corrupted so that the kernel could not be started.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
WIP_next-LS master next stable/v2013.05 stable/v2013.06 stable/v2013.07 stable/v2013.08 stable/v2013.10 stable/v2014.05 stable/v2014.06 stable/v2014.07 stable/v2014.08 stable/v2014.09 stable/v2014.10 stable/v2014.11 stable/v2014.12 stable/v2015.01 stable/v2015.02 stable/v2017.05 stable/v2017.06 stable/v2017.07 stable/v2017.11 stable/v2018.07 stable/v2018.09 stable/v2018.12 work/fit-support v2020.07.0 v2020.06.0 v2020.05.0 v2020.04.0 v2020.03.0 v2020.02.0 v2020.01.0 v2019.12.0 v2019.11.0 v2019.10.0 v2019.09.0 v2019.08.1 v2019.08.0 v2019.07.0 v2019.06.1 v2019.06.0 v2019.05.0 v2019.04.0 v2019.03.0 v2019.02.0 v2019.01.0 v2018.12.0 v2018.11.0 v2018.10.0 v2018.09.1 v2018.09.0 v2018.08.1 v2018.08.0 v2018.07.2 v2018.07.1 v2018.07.0 v2018.06.0 v2018.05.0 v2018.04.0 v2018.03.0 v2018.02.0 v2018.01.0 v2017.12.0 v2017.11.0 v2017.10.0 v2017.09.0 v2017.08.0 v2017.07.1 v2017.07.0 v2017.06.2 v2017.06.1 v2017.06.0 v2017.05.4 v2017.05.3 v2017.05.2 v2017.05.1 v2017.05.0 v2017.04.0 v2017.03.0 v2017.02.0 v2017.01.0 v2016.11.0 v2016.10.0 v2016.09.0 v2016.08.0 v2016.07.0 v2016.06.0 v2016.05.0 v2016.04.0 v2016.03.0 v2016.02.0 v2016.01.0 v2015.12.0 v2015.11.0 v2015.10.0 v2015.09.0 v2015.08.0 v2015.07.0 v2015.06.0 v2015.05.0 v2015.04.0 v2015.03.0 v2015.02.0 v2015.01.0 v2014.12.0 v2014.11.0 v2014.10.0 v2014.09.0 v2014.08.0 v2014.07.0 v2014.06.0 v2014.05.0 v2014.04.0 v2014.03.0 v2014.02.0 v2014.01.0 v2013.12.0 v2013.11.0 v2013.10.1 v2013.10.0 v2013.09.0 v2013.08.1 v2013.08.0 v2013.07.0 v2013.06.1 v2013.06.0 v2013.05.1 v2013.05.0 v2013.04.0 v2013.03.0 v2013.02.0
1 parent a25d919 commit 50d1b2de8ea0f3b8d89fe3a97ce64315996ed4cb
@Sascha Hauer Sascha Hauer authored on 23 Jan 2013
Showing 1 changed file
View
arch/arm/cpu/cache-armv7.S