Skip to content

Commit 19e2e17

Browse files
committed
MIPS: Provide arch_syscall_addr.
The generic version is wrong for MIPS. Signed-off-by: Ralf Baechle <[email protected]>
1 parent 403342a commit 19e2e17

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

arch/mips/include/asm/syscall.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* This file is subject to the terms and conditions of the GNU General Public
3+
* License. See the file "COPYING" in the main directory of this archive
4+
* for more details.
5+
*
6+
* Copyright (C) 2012 Ralf Baechle <[email protected]>
7+
*/
8+
9+
#ifndef __ASM_MIPS_SYSCALL_H
10+
#define __ASM_MIPS_SYSCALL_H
11+
12+
extern const unsigned long sys_call_table[];
13+
extern const unsigned long sys32_call_table[];
14+
extern const unsigned long sysn32_call_table[];
15+
16+
#endif /* __ASM_MIPS_SYSCALL_H */

arch/mips/kernel/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ obj-$(CONFIG_STACKTRACE) += stacktrace.o
3535
obj-$(CONFIG_MODULES) += mips_ksyms.o module.o
3636
obj-$(CONFIG_MODULES_USE_ELF_RELA) += module-rela.o
3737

38+
obj-$(CONFIG_FTRACE_SYSCALLS) += ftrace.o
3839
obj-$(CONFIG_FUNCTION_TRACER) += mcount.o ftrace.o
3940

4041
obj-$(CONFIG_CPU_R4K_FPU) += r4k_fpu.o r4k_switch.o

arch/mips/kernel/ftrace.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@
1111
#include <linux/uaccess.h>
1212
#include <linux/init.h>
1313
#include <linux/ftrace.h>
14+
#include <linux/syscalls.h>
1415

1516
#include <asm/asm.h>
1617
#include <asm/asm-offsets.h>
1718
#include <asm/cacheflush.h>
19+
#include <asm/syscall.h>
1820
#include <asm/uasm.h>
21+
#include <asm/unistd.h>
1922

2023
#include <asm-generic/sections.h>
2124

@@ -364,3 +367,33 @@ void prepare_ftrace_return(unsigned long *parent_ra_addr, unsigned long self_ra,
364367
WARN_ON(1);
365368
}
366369
#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
370+
371+
#ifdef CONFIG_FTRACE_SYSCALLS
372+
373+
#ifdef CONFIG_32BIT
374+
unsigned long __init arch_syscall_addr(int nr)
375+
{
376+
return (unsigned long)sys_call_table[nr - __NR_O32_Linux];
377+
}
378+
#endif
379+
380+
#ifdef CONFIG_64BIT
381+
382+
unsigned long __init arch_syscall_addr(int nr)
383+
{
384+
#ifdef CONFIG_MIPS32_N32
385+
if (nr >= __NR_N32_Linux && nr <= __NR_N32_Linux + __NR_N32_Linux_syscalls)
386+
return (unsigned long)sysn32_call_table[(nr - __NR_N32_Linux) * 2];
387+
#endif
388+
if (nr >= __NR_64_Linux && nr <= __NR_64_Linux + __NR_64_Linux_syscalls)
389+
return (unsigned long)sys_call_table[nr - __NR_64_Linux];
390+
#ifdef CONFIG_MIPS32_O32
391+
if (nr >= __NR_O32_Linux && nr <= __NR_O32_Linux + __NR_O32_Linux_syscalls)
392+
return (unsigned long)sys32_call_table[nr - __NR_O32_Linux];
393+
#endif
394+
395+
return (unsigned long) &sys_ni_syscall;
396+
}
397+
#endif
398+
399+
#endif /* CONFIG_FTRACE_SYSCALLS */

0 commit comments

Comments
 (0)