#include <linux/thread_info.h>
 
 /* ftrace syscalls requires exporting the sys_call_table */
-#ifdef CONFIG_FTRACE_SYSCALLS
 extern const unsigned long sys_call_table[];
-#endif /* CONFIG_FTRACE_SYSCALLS */
+extern const unsigned long compat_sys_call_table[];
 
 static inline int syscall_get_nr(struct task_struct *task, struct pt_regs *regs)
 {
 
 SYS_CALL_TABLE:
        .tc sys_call_table[TC],sys_call_table
 
+COMPAT_SYS_CALL_TABLE:
+       .tc compat_sys_call_table[TC],compat_sys_call_table
+
 /* This value is used to mark exception frames on the stack. */
 exception_marker:
        .tc     ID_EXC_MARKER[TC],STACK_FRAME_REGS_MARKER
        ld      r11,SYS_CALL_TABLE@toc(2)
        andis.  r10,r10,_TIF_32BIT@h
        beq     15f
-       addi    r11,r11,8       /* use 32-bit syscall entries */
+       ld      r11,COMPAT_SYS_CALL_TABLE@toc(2)
        clrldi  r3,r3,32
        clrldi  r4,r4,32
        clrldi  r5,r5,32
        clrldi  r7,r7,32
        clrldi  r8,r8,32
 15:
-       slwi    r0,r0,4
+       slwi    r0,r0,3
 
        barrier_nospec_asm
        /*
 
 #include <asm/ppc_asm.h>
 
 #ifdef CONFIG_PPC64
-#define SYSCALL(func)          .8byte  DOTSYM(sys_##func),DOTSYM(sys_##func)
-#define COMPAT_SYS(func)       .8byte  DOTSYM(sys_##func),DOTSYM(compat_sys_##func)
-#define PPC_SYS(func)          .8byte  DOTSYM(ppc_##func),DOTSYM(ppc_##func)
-#define OLDSYS(func)           .8byte  DOTSYM(sys_ni_syscall),DOTSYM(sys_ni_syscall)
-#define SYS32ONLY(func)                .8byte  DOTSYM(sys_ni_syscall),DOTSYM(compat_sys_##func)
-#define PPC64ONLY(func)                .8byte  DOTSYM(ppc_##func),DOTSYM(sys_ni_syscall)
-#define SYSX(f, f3264, f32)    .8byte  DOTSYM(f),DOTSYM(f3264)
+#define SYSCALL(func)          .8byte  DOTSYM(sys_##func)
+#define COMPAT_SYS(func)       .8byte  DOTSYM(sys_##func)
+#define PPC_SYS(func)          .8byte  DOTSYM(ppc_##func)
+#define OLDSYS(func)           .8byte  DOTSYM(sys_ni_syscall)
+#define SYS32ONLY(func)                .8byte  DOTSYM(sys_ni_syscall)
+#define PPC64ONLY(func)                .8byte  DOTSYM(ppc_##func)
+#define SYSX(f, f3264, f32)    .8byte  DOTSYM(f)
 #else
 #define SYSCALL(func)          .long   sys_##func
 #define COMPAT_SYS(func)       .long   sys_##func
 
 .globl sys_call_table
 sys_call_table:
+#include <asm/systbl.h>
+
+#undef SYSCALL
+#undef COMPAT_SYS
+#undef PPC_SYS
+#undef OLDSYS
+#undef SYS32ONLY
+#undef PPC64ONLY
+#undef SYSX
 
+#ifdef CONFIG_COMPAT
+#define SYSCALL(func)          .8byte  DOTSYM(sys_##func)
+#define COMPAT_SYS(func)       .8byte  DOTSYM(compat_sys_##func)
+#define PPC_SYS(func)          .8byte  DOTSYM(ppc_##func)
+#define OLDSYS(func)           .8byte  DOTSYM(sys_ni_syscall)
+#define SYS32ONLY(func)                .8byte  DOTSYM(compat_sys_##func)
+#define PPC64ONLY(func)                .8byte  DOTSYM(sys_ni_syscall)
+#define SYSX(f, f3264, f32)    .8byte  DOTSYM(f3264)
+
+.globl compat_sys_call_table
+compat_sys_call_table:
 #define compat_sys_sigsuspend  sys_sigsuspend
 #include <asm/systbl.h>
+#endif
 
 {
        unsigned int i;
        extern unsigned long *sys_call_table;
+#ifdef CONFIG_PPC64
+       extern unsigned long *compat_sys_call_table;
+#endif
        extern unsigned long sys_ni_syscall;
 
 
        for (i = 0; i < NR_syscalls; i++) {
 #ifdef CONFIG_PPC64
-               if (sys_call_table[i*2] != sys_ni_syscall)
+               if (sys_call_table[i] != sys_ni_syscall)
                        vdso_data->syscall_map_64[i >> 5] |=
                                0x80000000UL >> (i & 0x1f);
-               if (sys_call_table[i*2+1] != sys_ni_syscall)
+               if (compat_sys_call_table[i] != sys_ni_syscall)
                        vdso_data->syscall_map_32[i >> 5] |=
                                0x80000000UL >> (i & 0x1f);
 #else /* CONFIG_PPC64 */