Skip to content

Commit f87aa12

Browse files
James Hogangregkh
authored andcommitted
MIPS: Save static registers before sysmips
commit 49955d84cd9ccdca5a16a495e448e1a06fad9e49 upstream. 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: f1e39a4 ("MIPS: Rewrite sysmips(MIPS_ATOMIC_SET, ...) in C with inline assembler") Signed-off-by: James Hogan <james.hogan@imgtec.com> Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/16149/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent a0ee412 commit f87aa12

5 files changed

Lines changed: 10 additions & 4 deletions

File tree

arch/mips/kernel/scall32-o32.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ EXPORT(sys_call_table)
372372
PTR sys_writev
373373
PTR sys_cacheflush
374374
PTR sys_cachectl
375-
PTR sys_sysmips
375+
PTR __sys_sysmips
376376
PTR sys_ni_syscall /* 4150 */
377377
PTR sys_getsid
378378
PTR sys_fdatasync

arch/mips/kernel/scall64-64.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ EXPORT(sys_call_table)
312312
PTR sys_sched_getaffinity
313313
PTR sys_cacheflush
314314
PTR sys_cachectl
315-
PTR sys_sysmips
315+
PTR __sys_sysmips
316316
PTR sys_io_setup /* 5200 */
317317
PTR sys_io_destroy
318318
PTR sys_io_getevents

arch/mips/kernel/scall64-n32.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ EXPORT(sysn32_call_table)
298298
PTR compat_sys_sched_getaffinity
299299
PTR sys_cacheflush
300300
PTR sys_cachectl
301-
PTR sys_sysmips
301+
PTR __sys_sysmips
302302
PTR compat_sys_io_setup /* 6200 */
303303
PTR sys_io_destroy
304304
PTR compat_sys_io_getevents

arch/mips/kernel/scall64-o32.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ EXPORT(sys32_call_table)
367367
PTR compat_sys_writev
368368
PTR sys_cacheflush
369369
PTR sys_cachectl
370-
PTR sys_sysmips
370+
PTR __sys_sysmips
371371
PTR sys_ni_syscall /* 4150 */
372372
PTR sys_getsid
373373
PTR sys_fdatasync

arch/mips/kernel/syscall.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,12 @@ static inline int mips_atomic_set(unsigned long addr, unsigned long new)
202202
unreachable();
203203
}
204204

205+
/*
206+
* mips_atomic_set() normally returns directly via syscall_exit potentially
207+
* clobbering static registers, so be sure to preserve them.
208+
*/
209+
save_static_function(sys_sysmips);
210+
205211
SYSCALL_DEFINE3(sysmips, long, cmd, long, arg1, long, arg2)
206212
{
207213
switch (cmd) {

0 commit comments

Comments
 (0)