Skip to content

Commit c33f8e7

Browse files
author
Nicolas Pitre
committed
arch: arm64: Fix SMP TLB invalidation on SMP systems
Use Inner Shareable (IS) TLB invalidation instructions in SMP configurations to broadcast TLB invalidations to all CPUs. Use TLBI VMALLE1IS instead of VMALLE1 in invalidate_tlb_all(). While at it, implement proper page-specific invalidation using TLBI VAE1IS in invalidate_tlb_page() instead of falling back to full invalidation. This fixes many SMP test failures with userspace enabled. Signed-off-by: Nicolas Pitre <[email protected]>
1 parent c524cec commit c33f8e7

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

arch/arm64/core/mmu.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -778,15 +778,30 @@ static void remove_map(struct arm_mmu_ptables *ptables, const char *name,
778778

779779
static void invalidate_tlb_all(void)
780780
{
781+
#ifdef CONFIG_SMP
782+
/* Use IS variant to broadcast to all CPUs in Inner Shareable domain */
783+
__asm__ volatile (
784+
"dsb ishst; tlbi vmalle1is; dsb ish; isb"
785+
: : : "memory");
786+
#else
781787
__asm__ volatile (
782788
"dsb ishst; tlbi vmalle1; dsb ish; isb"
783789
: : : "memory");
790+
#endif
784791
}
785792

786793
static inline void invalidate_tlb_page(uintptr_t virt)
787794
{
788-
/* to be refined */
789-
invalidate_tlb_all();
795+
#ifdef CONFIG_SMP
796+
/* Use IS variant to broadcast to all CPUs in Inner Shareable domain */
797+
__asm__ volatile (
798+
"dsb ishst; tlbi vae1is, %0; dsb ish; isb"
799+
: : "r" (virt >> PAGE_SIZE_SHIFT) : "memory");
800+
#else
801+
__asm__ volatile (
802+
"dsb ishst; tlbi vae1, %0; dsb ish; isb"
803+
: : "r" (virt >> PAGE_SIZE_SHIFT) : "memory");
804+
#endif
790805
}
791806

792807
/* zephyr execution regions with appropriate attributes */

0 commit comments

Comments
 (0)