spu_callbacks.c 1.8 KB

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