spu_callbacks.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * System call callback functions for SPUs
  3. */
  4. #undef DEBUG
  5. #include <linux/kallsyms.h>
  6. #include <linux/export.h>
  7. #include <linux/syscalls.h>
  8. #include <asm/spu.h>
  9. #include <asm/syscalls.h>
  10. #include <asm/unistd.h>
  11. /*
  12. * This table defines the system calls that an SPU can call.
  13. * It is currently a subset of the 64 bit powerpc system calls,
  14. * with the exact semantics.
  15. *
  16. * The reasons for disabling some of the system calls are:
  17. * 1. They interact with the way SPU syscalls are handled
  18. * and we can't let them execute ever:
  19. * restart_syscall, exit, for, execve, ptrace, ...
  20. * 2. They are deprecated and replaced by other means:
  21. * uselib, pciconfig_*, sysfs, ...
  22. * 3. They are somewhat interacting with the system in a way
  23. * we don't want an SPU to:
  24. * reboot, init_module, mount, kexec_load
  25. * 4. They are optional and we can't rely on them being
  26. * linked into the kernel. Unfortunately, the cond_syscall
  27. * helper does not work here as it does not add the necessary
  28. * opd symbols:
  29. * mbind, mq_open, ipc, ...
  30. */
  31. static void *spu_syscall_table[] = {
  32. #define SYSCALL(func) sys_ni_syscall,
  33. #define COMPAT_SYS(func) sys_ni_syscall,
  34. #define PPC_SYS(func) sys_ni_syscall,
  35. #define OLDSYS(func) sys_ni_syscall,
  36. #define SYS32ONLY(func) sys_ni_syscall,
  37. #define PPC64ONLY(func) sys_ni_syscall,
  38. #define SYSX(f, f3264, f32) sys_ni_syscall,
  39. #define SYSCALL_SPU(func) sys_##func,
  40. #define COMPAT_SYS_SPU(func) sys_##func,
  41. #define PPC_SYS_SPU(func) ppc_##func,
  42. #define SYSX_SPU(f, f3264, f32) f,
  43. #include <asm/systbl.h>
  44. };
  45. long spu_sys_callback(struct spu_syscall_block *s)
  46. {
  47. long (*syscall)(u64 a1, u64 a2, u64 a3, u64 a4, u64 a5, u64 a6);
  48. if (s->nr_ret >= ARRAY_SIZE(spu_syscall_table)) {
  49. pr_debug("%s: invalid syscall #%lld", __func__, s->nr_ret);
  50. return -ENOSYS;
  51. }
  52. syscall = spu_syscall_table[s->nr_ret];
  53. pr_debug("SPU-syscall "
  54. "%pSR:syscall%lld(%llx, %llx, %llx, %llx, %llx, %llx)\n",
  55. syscall,
  56. s->nr_ret,
  57. s->parm[0], s->parm[1], s->parm[2],
  58. s->parm[3], s->parm[4], s->parm[5]);
  59. return syscall(s->parm[0], s->parm[1], s->parm[2],
  60. s->parm[3], s->parm[4], s->parm[5]);
  61. }
  62. EXPORT_SYMBOL_GPL(spu_sys_callback);