Merge "arm64: SW PAN: Point saved ttbr0 at the zero page when switching to init_mm"
This commit is contained in:
commit
a4f5f7d5ee
2 changed files with 14 additions and 12 deletions
|
@ -87,10 +87,8 @@ static inline void efi_set_pgd(struct mm_struct *mm)
|
||||||
* Defer the switch to the current thread's TTBR0_EL1
|
* Defer the switch to the current thread's TTBR0_EL1
|
||||||
* until uaccess_enable(). Restore the current
|
* until uaccess_enable(). Restore the current
|
||||||
* thread's saved ttbr0 corresponding to its active_mm
|
* thread's saved ttbr0 corresponding to its active_mm
|
||||||
* (if different from init_mm).
|
|
||||||
*/
|
*/
|
||||||
cpu_set_reserved_ttbr0();
|
cpu_set_reserved_ttbr0();
|
||||||
if (current->active_mm != &init_mm)
|
|
||||||
update_saved_ttbr0(current, current->active_mm);
|
update_saved_ttbr0(current, current->active_mm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,11 +183,17 @@ enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
|
||||||
static inline void update_saved_ttbr0(struct task_struct *tsk,
|
static inline void update_saved_ttbr0(struct task_struct *tsk,
|
||||||
struct mm_struct *mm)
|
struct mm_struct *mm)
|
||||||
{
|
{
|
||||||
if (system_uses_ttbr0_pan()) {
|
u64 ttbr;
|
||||||
BUG_ON(mm->pgd == swapper_pg_dir);
|
|
||||||
task_thread_info(tsk)->ttbr0 =
|
if (!system_uses_ttbr0_pan())
|
||||||
virt_to_phys(mm->pgd) | ASID(mm) << 48;
|
return;
|
||||||
}
|
|
||||||
|
if (mm == &init_mm)
|
||||||
|
ttbr = __pa_symbol(empty_zero_page);
|
||||||
|
else
|
||||||
|
ttbr = virt_to_phys(mm->pgd) | ASID(mm) << 48;
|
||||||
|
|
||||||
|
task_thread_info(tsk)->ttbr0 = ttbr;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static inline void update_saved_ttbr0(struct task_struct *tsk,
|
static inline void update_saved_ttbr0(struct task_struct *tsk,
|
||||||
|
@ -223,10 +229,8 @@ switch_mm(struct mm_struct *prev, struct mm_struct *next,
|
||||||
* Update the saved TTBR0_EL1 of the scheduled-in task as the previous
|
* Update the saved TTBR0_EL1 of the scheduled-in task as the previous
|
||||||
* value may have not been initialised yet (activate_mm caller) or the
|
* value may have not been initialised yet (activate_mm caller) or the
|
||||||
* ASID has changed since the last run (following the context switch
|
* ASID has changed since the last run (following the context switch
|
||||||
* of another thread of the same process). Avoid setting the reserved
|
* of another thread of the same process).
|
||||||
* TTBR0_EL1 to swapper_pg_dir (init_mm; e.g. via idle_task_exit).
|
|
||||||
*/
|
*/
|
||||||
if (next != &init_mm)
|
|
||||||
update_saved_ttbr0(tsk, next);
|
update_saved_ttbr0(tsk, next);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue