Skip to content

Commit 9a33c40

Browse files
Flavio Ceolincarlescufi
authored andcommitted
xtensa: mmu: Fix possible race condition on tlb shootdown
We need to use the mmu spin lock when invalidating the cache during tlb shootdown, otherwise it is possible that this happens when another thread is updating the page tables. Signed-off-by: Flavio Ceolin <[email protected]> Signed-off-by: Anas Nashif <[email protected]>
1 parent 156f1d4 commit 9a33c40

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

arch/xtensa/core/xtensa_mmu.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -828,11 +828,13 @@ void z_xtensa_mmu_tlb_shootdown(void)
828828
*/
829829
key = arch_irq_lock();
830830

831-
/* We don't have information on which page tables have changed,
832-
* so we just invalidate the cache for all L1 page tables.
833-
*/
834-
sys_cache_data_invd_range((void *)l1_page_table, sizeof(l1_page_table));
835-
sys_cache_data_invd_range((void *)l2_page_tables, sizeof(l2_page_tables));
831+
K_SPINLOCK(&xtensa_mmu_lock) {
832+
/* We don't have information on which page tables have changed,
833+
* so we just invalidate the cache for all L1 page tables.
834+
*/
835+
sys_cache_data_invd_range((void *)l1_page_table, sizeof(l1_page_table));
836+
sys_cache_data_invd_range((void *)l2_page_tables, sizeof(l2_page_tables));
837+
}
836838

837839
#ifdef CONFIG_USERSPACE
838840
struct k_thread *thread = _current_cpu->current;

0 commit comments

Comments
 (0)