kernel-hacking-2024-linux-s.../arch/sparc
David S. Miller f9384d41c0 sparc64: Fix MM refcount check in smp_flush_tlb_pending().
As explained by Benjamin Herrenschmidt:

> CPU 0 is running the context, task->mm == task->active_mm == your
> context. The CPU is in userspace happily churning things.
>
> CPU 1 used to run it, not anymore, it's now running fancyfsd which
> is a kernel thread, but current->active_mm still points to that
> same context.
>
> Because there's only one "real" user, mm_users is 1 (but mm_count is
> elevated, it's just that the presence on CPU 1 as active_mm has no
> effect on mm_count().
>
> At this point, fancyfsd decides to invalidate a mapping currently mapped
> by that context, for example because a networked file has changed
> remotely or something like that, using unmap_mapping_ranges().
>
> So CPU 1 goes into the zapping code, which eventually ends up calling
> flush_tlb_pending(). Your test will succeed, as current->active_mm is
> indeed the target mm for the flush, and mm_users is indeed 1. So you
> will -not- send an IPI to the other CPU, and CPU 0 will continue happily
> accessing the pages that should have been unmapped.

To fix this problem, check ->mm instead of ->active_mm, and this
means:

> So if you test current->mm, you effectively account for mm_users == 1,
> so the only way the mm can be active on another processor is as a lazy
> mm for a kernel thread. So your test should work properly as long
> as you don't have a HW that will do speculative TLB reloads into the
> TLB on that other CPU (and even if you do, you flush-on-switch-in should
> get rid of any crap here).

And therefore we should be OK.

Signed-off-by: David S. Miller <davem@davemloft.net>
2009-03-27 01:09:17 -07:00
..
boot sparc,sparc64: unify boot/ 2008-12-04 09:17:21 -08:00
configs eeprom: More consistent symbol names 2009-01-26 21:19:57 +01:00
include/asm sparc64: Flush TLB before releasing pages. 2009-03-26 01:54:46 -07:00
kernel sparc64: Fix MM refcount check in smp_flush_tlb_pending(). 2009-03-27 01:09:17 -07:00
lib sparc64: Fix probe_kernel_{read,write}(). 2009-02-08 22:32:31 -08:00
math-emu sparc64: unify math-emu 2008-12-04 09:16:56 -08:00
mm sparc64: Reschedule KGDB capture to a software interrupt. 2009-03-18 23:51:57 -07:00
oprofile sparc64: Implement NMI watchdog on capable cpus. 2009-01-30 00:03:53 -08:00
prom sparc: Eliminate PROMLIB_INTERNAL as it does nothing 2009-01-08 16:59:01 -08:00
Kconfig [CVE-2009-0029] sparc: Enable syscall wrappers for 64-bit 2009-01-19 20:21:49 -08:00
Kconfig.debug sparc: unify Kconfig.debug 2008-12-04 09:16:48 -08:00
Makefile sparc: unify kernel/init_task 2008-12-04 13:28:09 -08:00