aarch64: mmu: apply domain switching on all CPUs if SMP
It is apparently possible for one CPU to change the memory domain of a thread already being executed on another CPU. All CPUs must ensure they're using the appropriate mapping after a thread is newly added to a domain. Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
This commit is contained in:
parent
ec70b2bc7a
commit
a74f378cdc
|
@ -989,15 +989,21 @@ void arch_mem_domain_thread_add(struct k_thread *thread)
|
|||
}
|
||||
|
||||
thread->arch.ptables = domain_ptables;
|
||||
if (thread == _current) {
|
||||
if (!is_ptable_active(domain_ptables)) {
|
||||
z_arm64_swap_ptables(thread);
|
||||
}
|
||||
} else {
|
||||
#ifdef CONFIG_SMP
|
||||
/* the thread could be running on another CPU right now */
|
||||
arch_sched_ipi();
|
||||
#endif
|
||||
}
|
||||
|
||||
if (is_migration) {
|
||||
reset_map(old_ptables, __func__, thread->stack_info.start,
|
||||
thread->stack_info.size);
|
||||
}
|
||||
|
||||
if (thread == _current && !is_ptable_active(domain_ptables)) {
|
||||
z_arm64_swap_ptables(thread);
|
||||
}
|
||||
}
|
||||
|
||||
void arch_mem_domain_thread_remove(struct k_thread *thread)
|
||||
|
@ -1026,8 +1032,6 @@ void z_arm64_swap_ptables(struct k_thread *incoming)
|
|||
|
||||
if (!is_ptable_active(ptables)) {
|
||||
z_arm64_set_ttbr0((uintptr_t)ptables->base_xlat_table);
|
||||
} else {
|
||||
invalidate_tlb_all();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -98,6 +98,14 @@ void sched_ipi_handler(const void *unused)
|
|||
{
|
||||
ARG_UNUSED(unused);
|
||||
|
||||
#ifdef CONFIG_USERSPACE
|
||||
/*
|
||||
* Make sure a domain switch by another CPU is effective on this CPU.
|
||||
* This is a no-op if the page table is already the right one.
|
||||
*/
|
||||
z_arm64_swap_ptables(_current);
|
||||
#endif
|
||||
|
||||
z_sched_ipi();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue