ARM: lib: add call_with_stack function for safely changing stack
authorWill Deacon <will.deacon@arm.com>
Wed, 8 Jun 2011 14:29:00 +0000 (15:29 +0100)
committerLeann Ogasawara <leann.ogasawara@canonical.com>
Mon, 2 Apr 2012 20:17:08 +0000 (13:17 -0700)
commitc00cdb8fe7858af4c91dfbca93a646baebc09d4d
tree3e85469e5f4a24d58b672664cbb8dbbe239e5165
parent50c2de23792facb40c93f97d9ba4b80fda73f8f3
ARM: lib: add call_with_stack function for safely changing stack

When disabling the MMU, it is necessary to take out a 1:1 identity map
of the reset code so that it can safely be executed with and without
the MMU active. To avoid the situation where the physical address of the
reset code aliases with the virtual address of the active stack (which
cannot be included in the 1:1 mapping), it is desirable to change to a
new stack at a location which is less likely to alias.

This code adds a new lib function, call_with_stack:

void call_with_stack(void (*fn)(void *), void *arg, void *sp);

which changes the stack to point at the sp parameter, before invoking
fn(arg) with the new stack selected.

Reviewed-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Dave Martin <dave.martin@linaro.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
(cherry picked from commit 2d81f1fe81b753a5744fd2deceafab3e62ba02d5)

Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
arch/arm/lib/Makefile
arch/arm/lib/call_with_stack.S [new file with mode: 0644]