Commit 49955d84 authored by James Hogan's avatar James Hogan Committed by Ralf Baechle

MIPS: Save static registers before sysmips

The MIPS sysmips system call handler may return directly from the
MIPS_ATOMIC_SET case (mips_atomic_set()) to syscall_exit. This path
restores the static (callee saved) registers, however they won't have
been saved on entry to the system call.

Use the save_static_function() macro to create a __sys_sysmips wrapper
function which saves the static registers before calling sys_sysmips, so
that the correct static register state is restored by syscall_exit.

Fixes: f1e39a4a ("MIPS: Rewrite sysmips(MIPS_ATOMIC_SET, ...) in C with inline assembler")
Signed-off-by: default avatarJames Hogan <james.hogan@imgtec.com>
Cc: linux-mips@linux-mips.org
Cc: stable@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/16149/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent 2ec420b2
...@@ -371,7 +371,7 @@ EXPORT(sys_call_table) ...@@ -371,7 +371,7 @@ EXPORT(sys_call_table)
PTR sys_writev PTR sys_writev
PTR sys_cacheflush PTR sys_cacheflush
PTR sys_cachectl PTR sys_cachectl
PTR sys_sysmips PTR __sys_sysmips
PTR sys_ni_syscall /* 4150 */ PTR sys_ni_syscall /* 4150 */
PTR sys_getsid PTR sys_getsid
PTR sys_fdatasync PTR sys_fdatasync
......
...@@ -311,7 +311,7 @@ EXPORT(sys_call_table) ...@@ -311,7 +311,7 @@ EXPORT(sys_call_table)
PTR sys_sched_getaffinity PTR sys_sched_getaffinity
PTR sys_cacheflush PTR sys_cacheflush
PTR sys_cachectl PTR sys_cachectl
PTR sys_sysmips PTR __sys_sysmips
PTR sys_io_setup /* 5200 */ PTR sys_io_setup /* 5200 */
PTR sys_io_destroy PTR sys_io_destroy
PTR sys_io_getevents PTR sys_io_getevents
......
...@@ -302,7 +302,7 @@ EXPORT(sysn32_call_table) ...@@ -302,7 +302,7 @@ EXPORT(sysn32_call_table)
PTR compat_sys_sched_getaffinity PTR compat_sys_sched_getaffinity
PTR sys_cacheflush PTR sys_cacheflush
PTR sys_cachectl PTR sys_cachectl
PTR sys_sysmips PTR __sys_sysmips
PTR compat_sys_io_setup /* 6200 */ PTR compat_sys_io_setup /* 6200 */
PTR sys_io_destroy PTR sys_io_destroy
PTR compat_sys_io_getevents PTR compat_sys_io_getevents
......
...@@ -371,7 +371,7 @@ EXPORT(sys32_call_table) ...@@ -371,7 +371,7 @@ EXPORT(sys32_call_table)
PTR compat_sys_writev PTR compat_sys_writev
PTR sys_cacheflush PTR sys_cacheflush
PTR sys_cachectl PTR sys_cachectl
PTR sys_sysmips PTR __sys_sysmips
PTR sys_ni_syscall /* 4150 */ PTR sys_ni_syscall /* 4150 */
PTR sys_getsid PTR sys_getsid
PTR sys_fdatasync PTR sys_fdatasync
......
...@@ -192,6 +192,12 @@ static inline int mips_atomic_set(unsigned long addr, unsigned long new) ...@@ -192,6 +192,12 @@ static inline int mips_atomic_set(unsigned long addr, unsigned long new)
unreachable(); unreachable();
} }
/*
* mips_atomic_set() normally returns directly via syscall_exit potentially
* clobbering static registers, so be sure to preserve them.
*/
save_static_function(sys_sysmips);
SYSCALL_DEFINE3(sysmips, long, cmd, long, arg1, long, arg2) SYSCALL_DEFINE3(sysmips, long, cmd, long, arg1, long, arg2)
{ {
switch (cmd) { switch (cmd) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment