OSDN Git Service

UPSTREAM: MIPS: c-r4k: Fix sigtramp SMP call to use kmap
authorJames Hogan <james.hogan@imgtec.com>
Wed, 13 Jul 2016 13:12:48 +0000 (14:12 +0100)
committerGreg Kroah-Hartman <gregkh@google.com>
Mon, 5 Feb 2018 16:58:31 +0000 (08:58 -0800)
commit98561f4928838a8ab828a660d0d013db1dd50958
treebcacce92d4f8b4b79e95256c49ed418d4efd1d3d
parentaff62c8fadd7789f87c9a7b856db2f3168b298d7
UPSTREAM: MIPS: c-r4k: Fix sigtramp SMP call to use kmap

Fix r4k_flush_cache_sigtramp() and local_r4k_flush_cache_sigtramp() to
flush the delay slot emulation trampoline cacheline through a kmap
rather than directly when the active_mm doesn't match that of the task
initiating the flush, a bit like local_r4k_flush_cache_page() does.

This would fix a corner case on SMP systems without hardware globalized
hit cache ops, where a migration to another CPU after the flush, where
that CPU did not have the same mm active at the time of the flush, could
result in stale icache content being executed instead of the trampoline,
e.g. from a previous delay slot emulation with a similar stack pointer.

This case was artificially triggered by replacing the icache flush with
a full indexed flush (not globalized on CM systems) and forcing the SMP
call to take place, with a test program that alternated two FPU delay
slots with a parent process repeatedly changing scheduler affinity.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Paul Burton <paul.burton@imgtec.com>
Cc: Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/13797/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
(cherry picked from commit e523f289fe4d18d509f8827f8a293e8c5e4f51a1)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
arch/mips/mm/c-r4k.c