sys_s390.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * S390 version
  4. * Copyright IBM Corp. 1999, 2000
  5. * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
  6. * Thomas Spatzier (tspat@de.ibm.com)
  7. *
  8. * Derived from "arch/i386/kernel/sys_i386.c"
  9. *
  10. * This file contains various random system calls that
  11. * have a non-standard calling sequence on the Linux/s390
  12. * platform.
  13. */
  14. #include <linux/errno.h>
  15. #include <linux/sched.h>
  16. #include <linux/mm.h>
  17. #include <linux/fs.h>
  18. #include <linux/smp.h>
  19. #include <linux/sem.h>
  20. #include <linux/msg.h>
  21. #include <linux/shm.h>
  22. #include <linux/stat.h>
  23. #include <linux/syscalls.h>
  24. #include <linux/mman.h>
  25. #include <linux/file.h>
  26. #include <linux/utsname.h>
  27. #include <linux/personality.h>
  28. #include <linux/unistd.h>
  29. #include <linux/ipc.h>
  30. #include <linux/uaccess.h>
  31. #include "entry.h"
  32. /*
  33. * Perform the mmap() system call. Linux for S/390 isn't able to handle more
  34. * than 5 system call parameters, so this system call uses a memory block
  35. * for parameter passing.
  36. */
  37. struct s390_mmap_arg_struct {
  38. unsigned long addr;
  39. unsigned long len;
  40. unsigned long prot;
  41. unsigned long flags;
  42. unsigned long fd;
  43. unsigned long offset;
  44. };
  45. SYSCALL_DEFINE1(mmap2, struct s390_mmap_arg_struct __user *, arg)
  46. {
  47. struct s390_mmap_arg_struct a;
  48. int error = -EFAULT;
  49. if (copy_from_user(&a, arg, sizeof(a)))
  50. goto out;
  51. error = ksys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd, a.offset);
  52. out:
  53. return error;
  54. }
  55. /*
  56. * sys_ipc() is the de-multiplexer for the SysV IPC calls.
  57. */
  58. SYSCALL_DEFINE5(s390_ipc, uint, call, int, first, unsigned long, second,
  59. unsigned long, third, void __user *, ptr)
  60. {
  61. if (call >> 16)
  62. return -EINVAL;
  63. /* The s390 sys_ipc variant has only five parameters instead of six
  64. * like the generic variant. The only difference is the handling of
  65. * the SEMTIMEDOP subcall where on s390 the third parameter is used
  66. * as a pointer to a struct timespec where the generic variant uses
  67. * the fifth parameter.
  68. * Therefore we can call the generic variant by simply passing the
  69. * third parameter also as fifth parameter.
  70. */
  71. return sys_ipc(call, first, second, third, ptr, third);
  72. }
  73. SYSCALL_DEFINE1(s390_personality, unsigned int, personality)
  74. {
  75. unsigned int ret;
  76. if (personality(current->personality) == PER_LINUX32 &&
  77. personality(personality) == PER_LINUX)
  78. personality |= PER_LINUX32;
  79. ret = sys_personality(personality);
  80. if (personality(ret) == PER_LINUX32)
  81. ret &= ~PER_LINUX32;
  82. return ret;
  83. }