-
Notifications
You must be signed in to change notification settings - Fork 461
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Platform/ARM/ArmShellCmdRunAxf: switch to by-VA cache maintenance
Currently, the 'runaxf' shell command that exists only on ARM's own development platforms deals with the caches in an unsafe manner, as it relies on set/way maintenance to ensure that the ELF image it has put into memory, as well as the running image itself is visible in memory after the MMU and caches are disabled. So let's switch to by-VA maintenance for the currently running image, as well as the ELF image, and use a helper in assembly to ensure that we are not relying on the stack between the disabling of the MMU and the invocation of the ELF image. Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Leif Lindholm <leif@nuviainc.com>
- Loading branch information
Ard Biesheuvel
committed
Mar 6, 2020
1 parent
828fcbf
commit 9960476
Showing
4 changed files
with
130 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// | ||
// Copyright (c) 2020, ARM Limited. All rights reserved. | ||
// | ||
// SPDX-License-Identifier: BSD-2-Clause-Patent | ||
// | ||
|
||
#include <AsmMacroIoLibV8.h> | ||
|
||
// VOID | ||
// RunAxfPivot ( | ||
// IN ELF_ENTRYPOINT ElfEntry | ||
// IN UINTN Arg0, | ||
// IN UINTN Arg1, | ||
// IN UINTN Arg2, | ||
// IN UINTN Arg3 | ||
// ); | ||
ASM_FUNC(RunAxfPivot) | ||
// Preserve ElfEntry() and its arguments | ||
// Since we will not be returning from this function, we can clobber | ||
// callee preserved register instead. | ||
mov x19, x0 | ||
mov x20, x1 | ||
mov x21, x2 | ||
mov x22, x3 | ||
mov x23, x4 | ||
|
||
bl ArmDisableDataCache | ||
bl ArmDisableMmu | ||
|
||
// Load ElfEntry()'s arguments into x0...x3 | ||
mov x0, x20 | ||
mov x1, x21 | ||
mov x2, x22 | ||
mov x3, x23 | ||
|
||
// Call ElfEntry() | ||
blr x19 | ||
|
||
0:wfi | ||
wfe | ||
b 0b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// | ||
// Copyright (c) 2020, ARM Limited. All rights reserved. | ||
// | ||
// SPDX-License-Identifier: BSD-2-Clause-Patent | ||
// | ||
|
||
#include <AsmMacroIoLibV8.h> | ||
|
||
// VOID | ||
// RunAxfPivot ( | ||
// IN ELF_ENTRYPOINT ElfEntry | ||
// IN UINTN Arg0, | ||
// IN UINTN Arg1, | ||
// IN UINTN Arg2, | ||
// IN UINTN Arg3 | ||
// ); | ||
ASM_FUNC(RunAxfPivot) | ||
// Preserve ElfEntry() and its arguments without using the stack. | ||
// Since we will not be returning from this function, we can clobber | ||
// callee preserved register instead. | ||
mov r4, r0 | ||
mov r5, r1 | ||
mov r6, r2 | ||
mov r7, r3 | ||
pop {r8} | ||
|
||
bl ArmDisableDataCache | ||
bl ArmDisableMmu | ||
|
||
// Load ElfEntry()'s arguments into x0...x3 | ||
mov r0, r5 | ||
mov r1, r6 | ||
mov r2, r7 | ||
mov r3, r8 | ||
|
||
// Call ElfEntry() | ||
blx r4 | ||
|
||
0:wfi | ||
wfe | ||
b 0b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters