arm64: kaslr: use callee saved register to preserve SCTLR across C call
The KASLR code incorrectly expects the contents of x18 to be preserved across a call into C code, and uses it to stash the contents of SCTLR_EL1 before enabling the MMU. If the MMU needs to be disabled again to create the randomized kernel mapping, x18 is written back to SCTLR_EL1, which is likely to crash the system if x18 has been clobbered by kasan_early_init() or kaslr_early_init(). So use x22 instead, which is not in use so far in head.S Change-Id: I6a79b0c3b2e2306d080406c7f617483f6f1519b0 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> Git-commit: d5e5743797adc26e09db262e7a4b6b81d8c0f45c Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git [neeraju@codeaurora.org: resolve trivial merge conflicts] Signed-off-by: Neeraj Upadhyay <neeraju@codeaurora.org>
This commit is contained in:
parent
c1ef16be6d
commit
9fcccba399
1 changed files with 2 additions and 2 deletions
|
@ -664,7 +664,7 @@ ENDPROC(__secondary_switched)
|
||||||
*/
|
*/
|
||||||
.section ".idmap.text", "ax"
|
.section ".idmap.text", "ax"
|
||||||
ENTRY(__enable_mmu)
|
ENTRY(__enable_mmu)
|
||||||
mrs x18, sctlr_el1 // preserve old SCTLR_EL1 value
|
mrs x22, sctlr_el1 // preserve old SCTLR_EL1 value
|
||||||
mrs x1, ID_AA64MMFR0_EL1
|
mrs x1, ID_AA64MMFR0_EL1
|
||||||
ubfx x2, x1, #ID_AA64MMFR0_TGRAN_SHIFT, 4
|
ubfx x2, x1, #ID_AA64MMFR0_TGRAN_SHIFT, 4
|
||||||
cmp x2, #ID_AA64MMFR0_TGRAN_SUPPORTED
|
cmp x2, #ID_AA64MMFR0_TGRAN_SUPPORTED
|
||||||
|
@ -691,7 +691,7 @@ ENTRY(__enable_mmu)
|
||||||
* to take into account by discarding the current kernel mapping and
|
* to take into account by discarding the current kernel mapping and
|
||||||
* creating a new one.
|
* creating a new one.
|
||||||
*/
|
*/
|
||||||
msr sctlr_el1, x18 // disable the MMU
|
msr sctlr_el1, x22 // disable the MMU
|
||||||
isb
|
isb
|
||||||
bl __create_page_tables // recreate kernel mapping
|
bl __create_page_tables // recreate kernel mapping
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue