diff -Nru link/arch/mips/mm/tlb-sb1.c.orig link/arch/mips/mm/tlb-sb1.c --- link/arch/mips/mm/tlb-sb1.c.orig Tue Jan 21 13:54:59 2003 +++ link/arch/mips/mm/tlb-sb1.c Tue Jan 21 13:58:50 2003 @@ -172,9 +172,13 @@ } write_c0_entryhi(oldpid); } else { - get_new_mmu_context(mm, cpu); - if (mm == current->active_mm) + if (mm == current->active_mm) { + get_new_mmu_context(mm, cpu); write_c0_entryhi(cpu_asid(cpu, mm)); + } else { + /* drop the current context completely */ + CPU_CONTEXT(cpu, mm) = 0; + } } } __restore_flags(flags); @@ -258,9 +262,12 @@ __save_and_cli(flags); cpu = smp_processor_id(); if (cpu_context(cpu, mm) != 0) { - get_new_mmu_context(mm, smp_processor_id()); if (mm == current->active_mm) { + get_new_mmu_context(mm, smp_processor_id()); write_c0_entryhi(cpu_asid(cpu, mm)); + } else { + /* drop the current context completely */ + CPU_CONTEXT(cpu, mm) = 0; } } __restore_flags(flags); diff -Nru link/include/asm-mips/mmu_context.h.orig link/include/asm-mips/mmu_context.h --- link/include/asm-mips/mmu_context.h.orig Tue Jan 21 13:55:43 2003 +++ link/include/asm-mips/mmu_context.h Tue Jan 21 14:01:19 2003 @@ -89,12 +89,25 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, struct task_struct *tsk, unsigned cpu) { + unsigned long flags; + + __save_and_cli(flags); + /* Check if our ASID is of an older version and thus invalid */ if ((cpu_context(cpu, next) ^ asid_cache(cpu)) & ASID_VERSION_MASK) get_new_mmu_context(next, cpu); write_c0_entryhi(cpu_context(cpu, next)); TLBMISS_HANDLER_SETUP_PGD(next->pgd); + + /* + * Mark current->active_mm as not "active" anymore. + * We don't want to mislead possible IPI tlb flush routines. + */ + clear_bit(cpu, &prev->cpu_vm_mask); + set_bit(cpu, &next->cpu_vm_mask); + + __restore_flags(flags); } /* @@ -112,11 +125,17 @@ static inline void activate_mm(struct mm_struct *prev, struct mm_struct *next) { + unsigned long flags; + + __save_and_cli(flags); + /* Unconditionally get a new ASID. */ get_new_mmu_context(next, smp_processor_id()); write_c0_entryhi(cpu_context(smp_processor_id(), next)); TLBMISS_HANDLER_SETUP_PGD(next->pgd); + + __restore_flags(flags); } #endif /* _ASM_MMU_CONTEXT_H */