compat_syscall_table.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. #define __SYSCALL_COMPAT
  3. #include <linux/compat.h>
  4. #include <linux/syscalls.h>
  5. #include <asm/cacheflush.h>
  6. #include <asm-generic/mman-common.h>
  7. SYSCALL_DEFINE6(mmap2, unsigned long, addr, unsigned long, len,
  8. unsigned long, prot, unsigned long, flags,
  9. unsigned long, fd, unsigned long, offset)
  10. {
  11. if ((prot & PROT_WRITE) && (prot & PROT_EXEC))
  12. if (unlikely(!(prot & PROT_READ)))
  13. return -EINVAL;
  14. return ksys_mmap_pgoff(addr, len, prot, flags, fd, offset);
  15. }
  16. #define arg_u32p(name) u32, name##_lo, u32, name##_hi
  17. #define arg_u64(name) (((u64)name##_hi << 32) | \
  18. ((u64)name##_lo & 0xffffffff))
  19. COMPAT_SYSCALL_DEFINE3(truncate64, const char __user *, pathname,
  20. arg_u32p(length))
  21. {
  22. return ksys_truncate(pathname, arg_u64(length));
  23. }
  24. COMPAT_SYSCALL_DEFINE3(ftruncate64, unsigned int, fd, arg_u32p(length))
  25. {
  26. return ksys_ftruncate(fd, arg_u64(length));
  27. }
  28. COMPAT_SYSCALL_DEFINE6(fallocate, int, fd, int, mode,
  29. arg_u32p(offset), arg_u32p(len))
  30. {
  31. return ksys_fallocate(fd, mode, arg_u64(offset), arg_u64(len));
  32. }
  33. COMPAT_SYSCALL_DEFINE5(pread64, unsigned int, fd, char __user *, buf,
  34. size_t, count, arg_u32p(pos))
  35. {
  36. return ksys_pread64(fd, buf, count, arg_u64(pos));
  37. }
  38. COMPAT_SYSCALL_DEFINE5(pwrite64, unsigned int, fd,
  39. const char __user *, buf, size_t, count, arg_u32p(pos))
  40. {
  41. return ksys_pwrite64(fd, buf, count, arg_u64(pos));
  42. }
  43. COMPAT_SYSCALL_DEFINE6(sync_file_range, int, fd, arg_u32p(offset),
  44. arg_u32p(nbytes), unsigned int, flags)
  45. {
  46. return ksys_sync_file_range(fd, arg_u64(offset), arg_u64(nbytes),
  47. flags);
  48. }
  49. COMPAT_SYSCALL_DEFINE4(readahead, int, fd, arg_u32p(offset),
  50. size_t, count)
  51. {
  52. return ksys_readahead(fd, arg_u64(offset), count);
  53. }
  54. COMPAT_SYSCALL_DEFINE6(fadvise64_64, int, fd, arg_u32p(offset),
  55. arg_u32p(len), int, advice)
  56. {
  57. return ksys_fadvise64_64(fd, arg_u64(offset), arg_u64(len), advice);
  58. }
  59. #undef __SYSCALL
  60. #define __SYSCALL(nr, call) [nr] = (call),
  61. asmlinkage long compat_sys_rt_sigreturn(void);
  62. asmlinkage long sys_riscv_flush_icache(uintptr_t, uintptr_t, uintptr_t);
  63. const void *compat_sys_call_table[__NR_syscalls] = {
  64. [0 ... __NR_syscalls - 1] = sys_ni_syscall,
  65. #include <asm/unistd.h>
  66. };