couple of sparc 32 mm fixes
cover couple of sparc 32 mm fixes
I was able to test patch 2 in SMP qemu and verify there were cases where a cpu's active_mm does not have that CPU set in the mm_cpumask before the patch, and do not observe it afterwards.
I haven't observed any actual corruption from the bugs, but I didn't stress it much, and only what qemu can do.
Thanks,
Nick
Nicholas Piggin (2):
sparc32: remove mm_cpumask clearing to fix kthread_use_mm race
sparc32: fix mm_cpumask maintenance causing missing TLB flushing
arch/sparc/include/asm/switch_to_32.h | 1 - arch/sparc/mm/srmmu.c | 9 ++++----- 2 files changed, 4 insertions(+), 6 deletions(-)
Signature · 1 line
2.23.0
PATCH 1/2 sparc32: remove mm_cpumask clearing to fix kthread_use_mm race
Commit bafb056ce279 ("sparc64: remove mm_cpumask clearing to fix kthread_use_mm race") fixed this for sparc64, but missed the same bug in sparc32. Fix it similarly.
--- arch/sparc/mm/srmmu.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
arch/sparc/mm/srmmu.c +1 -5
@@ -1670,12 +1670,8 @@ static void smp_flush_tlb_mm(struct mm_struct *mm)cpumask_t cpu_mask;cpumask_copy (&cpu_mask,mm_cpumask (mm));cpumask_clear_cpu (smp_processor_id (), &cpu_mask); -if (!cpumask_empty (&cpu_mask)) { +if (!cpumask_empty (&cpu_mask))xc1 ((smpfunc_t ) local_ops->tlb_mm, (unsigned long ) mm); -if (atomic_read (&mm->mm_users) ==1 && current->active_mm == mm) -cpumask_copy (mm_cpumask (mm), -cpumask_of (smp_processor_id ())); - } local_ops->tlb_mm (mm); } }
Signature · 1 line
2.23.0
PATCH 2/2 sparc32: fix mm_cpumask maintenance causing missing TLB flushing
In reply to Nicholas PigginFix a bug in mm_cpumask maintenance where a CPU can have switched to an mm but it's not present in the cpumask, resulting in possible lost TLB flushes. switch_mm() can be called without switching thread (exec(2), kthread_use_mm()). Move mm_cpumask setting there, matching sparc64.
--- arch/sparc/include/asm/switch_to_32.h | 1 - arch/sparc/mm/srmmu.c | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-)
arch/sparc/include/asm/switch_to_32.h +0 -1
@@ -58,7 +58,6 @@ extern struct thread_info *current_set[NR_CPUS];#define switch_to (prev, next, last) do { \ SWITCH_ENTER(prev); \ SWITCH_DO_LAZY_FPU(next); \ - cpumask_set_cpu(smp_processor_id(), mm_cpumask(next->active_mm)); \ __asm__ __volatile__( \ "sethi %%hi(here - 0x8), %%o7\n\t" \ "mov %%g6, %%g3\n\t" \
arch/sparc/mm/srmmu.c +3 -0
@@ -473,6 +473,9 @@ void switch_mm(struct mm_struct *old_mm, struct mm_struct *mm, {unsigned long flags; +if (!cpumask_test_cpu (smp_processor_id (),mm_cpumask (mm))) +cpumask_set_cpu (smp_processor_id (),mm_cpumask (mm)); +if (mm->context ==NO_CONTEXT ) {spin_lock_irqsave (&srmmu_context_spinlock, flags);alloc_context (old_mm, mm);
Signature · 1 line
2.23.0