Commit 2c8951ab authored by Will Deacon's avatar Will Deacon

ARM: idmap: use idmap_pgd when setting up mm for reboot

For soft-rebooting a system, it is necessary to map the MMU-off code
with an identity mapping so that execution can continue safely once the
MMU has been switched off.

Currently, switch_mm_for_reboot takes out a 1:1 mapping from 0x0 to
TASK_SIZE during reboot in the hope that the reset code lives at a
physical address corresponding to a userspace virtual address.

This patch modifies the code so that we switch to the idmap_pgd tables,
which contain a 1:1 mapping of the cpu_reset code. This has the
advantage of only remapping the code that we need and also means we
don't need to worry about allocating a pgd from an atomic context in the
case that the physical address of the cpu_reset code aliases with the
virtual space used by the kernel.
Acked-by: default avatarDave Martin <dave.martin@linaro.org>
Reviewed-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
parent 1a4baafa
...@@ -100,17 +100,18 @@ static int __init init_static_idmap(void) ...@@ -100,17 +100,18 @@ static int __init init_static_idmap(void)
arch_initcall(init_static_idmap); arch_initcall(init_static_idmap);
/* /*
* In order to soft-boot, we need to insert a 1:1 mapping in place of * In order to soft-boot, we need to switch to a 1:1 mapping for the
* the user-mode pages. This will then ensure that we have predictable * cpu_reset functions. This will then ensure that we have predictable
* results when turning the mmu off * results when turning off the mmu.
*/ */
void setup_mm_for_reboot(void) void setup_mm_for_reboot(void)
{ {
/* /* Clean and invalidate L1. */
* We need to access to user-mode page tables here. For kernel threads flush_cache_all();
* we don't have any user-mode mappings so we use the context that we
* "borrowed". /* Switch to the identity mapping. */
*/ cpu_switch_mm(idmap_pgd, &init_mm);
identity_mapping_add(current->active_mm->pgd, 0, TASK_SIZE);
/* Flush the TLB. */
local_flush_tlb_all(); local_flush_tlb_all();
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment