Commit 609116d2 authored by Mark Rutland's avatar Mark Rutland Committed by Catalin Marinas

arm64: add function to install the idmap

In some cases (e.g. when making invasive changes to the kernel page
tables) we will need to execute code from the idmap.

Add a new helper which may be used to install the idmap, complementing
the existing cpu_uninstall_idmap.
Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
Reviewed-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
Tested-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
Tested-by: default avatarJeremy Linton <jeremy.linton@arm.com>
Cc: Laura Abbott <labbott@fedoraproject.org>
Cc: Will Deacon <will.deacon@arm.com>
Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
parent 86ccce89
...@@ -74,7 +74,7 @@ static inline bool __cpu_uses_extended_idmap(void) ...@@ -74,7 +74,7 @@ static inline bool __cpu_uses_extended_idmap(void)
/* /*
* Set TCR.T0SZ to its default value (based on VA_BITS) * Set TCR.T0SZ to its default value (based on VA_BITS)
*/ */
static inline void cpu_set_default_tcr_t0sz(void) static inline void __cpu_set_tcr_t0sz(unsigned long t0sz)
{ {
unsigned long tcr; unsigned long tcr;
...@@ -87,9 +87,12 @@ static inline void cpu_set_default_tcr_t0sz(void) ...@@ -87,9 +87,12 @@ static inline void cpu_set_default_tcr_t0sz(void)
" msr tcr_el1, %0 ;" " msr tcr_el1, %0 ;"
" isb" " isb"
: "=&r" (tcr) : "=&r" (tcr)
: "r"(TCR_T0SZ(VA_BITS)), "I"(TCR_T0SZ_OFFSET), "I"(TCR_TxSZ_WIDTH)); : "r"(t0sz), "I"(TCR_T0SZ_OFFSET), "I"(TCR_TxSZ_WIDTH));
} }
#define cpu_set_default_tcr_t0sz() __cpu_set_tcr_t0sz(TCR_T0SZ(VA_BITS))
#define cpu_set_idmap_tcr_t0sz() __cpu_set_tcr_t0sz(idmap_t0sz)
/* /*
* Remove the idmap from TTBR0_EL1 and install the pgd of the active mm. * Remove the idmap from TTBR0_EL1 and install the pgd of the active mm.
* *
...@@ -114,6 +117,15 @@ static inline void cpu_uninstall_idmap(void) ...@@ -114,6 +117,15 @@ static inline void cpu_uninstall_idmap(void)
cpu_switch_mm(mm->pgd, mm); cpu_switch_mm(mm->pgd, mm);
} }
static inline void cpu_install_idmap(void)
{
cpu_set_reserved_ttbr0();
local_flush_tlb_all();
cpu_set_idmap_tcr_t0sz();
cpu_switch_mm(idmap_pg_dir, &init_mm);
}
/* /*
* It would be nice to return ASIDs back to the allocator, but unfortunately * It would be nice to return ASIDs back to the allocator, but unfortunately
* that introduces a race with a generation rollover where we could erroneously * that introduces a race with a generation rollover where we could erroneously
......
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