sys_s390.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*
  2. * S390 version
  3. * Copyright IBM Corp. 1999, 2000
  4. * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
  5. * Thomas Spatzier (tspat@de.ibm.com)
  6. *
  7. * Derived from "arch/i386/kernel/sys_i386.c"
  8. *
  9. * This file contains various random system calls that
  10. * have a non-standard calling sequence on the Linux/s390
  11. * platform.
  12. */
  13. #include <linux/errno.h>
  14. #include <linux/sched.h>
  15. #include <linux/mm.h>
  16. #include <linux/fs.h>
  17. #include <linux/smp.h>
  18. #include <linux/sem.h>
  19. #include <linux/msg.h>
  20. #include <linux/shm.h>
  21. #include <linux/stat.h>
  22. #include <linux/syscalls.h>
  23. #include <linux/mman.h>
  24. #include <linux/file.h>
  25. #include <linux/utsname.h>
  26. #include <linux/personality.h>
  27. #include <linux/unistd.h>
  28. #include <linux/ipc.h>
  29. #include <asm/uaccess.h>
  30. #include "entry.h"
  31. /*
  32. * Perform the mmap() system call. Linux for S/390 isn't able to handle more
  33. * than 5 system call parameters, so this system call uses a memory block
  34. * for parameter passing.
  35. */
  36. struct s390_mmap_arg_struct {
  37. unsigned long addr;
  38. unsigned long len;
  39. unsigned long prot;
  40. unsigned long flags;
  41. unsigned long fd;
  42. unsigned long offset;
  43. };
  44. SYSCALL_DEFINE1(mmap2, struct s390_mmap_arg_struct __user *, arg)
  45. {
  46. struct s390_mmap_arg_struct a;
  47. int error = -EFAULT;
  48. if (copy_from_user(&a, arg, sizeof(a)))
  49. goto out;
  50. error = sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd, a.offset);
  51. out:
  52. return error;
  53. }
  54. /*
  55. * sys_ipc() is the de-multiplexer for the SysV IPC calls.
  56. */
  57. SYSCALL_DEFINE5(s390_ipc, uint, call, int, first, unsigned long, second,
  58. unsigned long, third, void __user *, ptr)
  59. {
  60. if (call >> 16)
  61. return -EINVAL;
  62. /* The s390 sys_ipc variant has only five parameters instead of six
  63. * like the generic variant. The only difference is the handling of
  64. * the SEMTIMEDOP subcall where on s390 the third parameter is used
  65. * as a pointer to a struct timespec where the generic variant uses
  66. * the fifth parameter.
  67. * Therefore we can call the generic variant by simply passing the
  68. * third parameter also as fifth parameter.
  69. */
  70. return sys_ipc(call, first, second, third, ptr, third);
  71. }
  72. #ifdef CONFIG_64BIT
  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. }
  84. #endif /* CONFIG_64BIT */
  85. /*
  86. * Wrapper function for sys_fadvise64/fadvise64_64
  87. */
  88. #ifndef CONFIG_64BIT
  89. SYSCALL_DEFINE5(s390_fadvise64, int, fd, u32, offset_high, u32, offset_low,
  90. size_t, len, int, advice)
  91. {
  92. return sys_fadvise64(fd, (u64) offset_high << 32 | offset_low,
  93. len, advice);
  94. }
  95. struct fadvise64_64_args {
  96. int fd;
  97. long long offset;
  98. long long len;
  99. int advice;
  100. };
  101. SYSCALL_DEFINE1(s390_fadvise64_64, struct fadvise64_64_args __user *, args)
  102. {
  103. struct fadvise64_64_args a;
  104. if ( copy_from_user(&a, args, sizeof(a)) )
  105. return -EFAULT;
  106. return sys_fadvise64_64(a.fd, a.offset, a.len, a.advice);
  107. }
  108. /*
  109. * This is a wrapper to call sys_fallocate(). For 31 bit s390 the last
  110. * 64 bit argument "len" is split into the upper and lower 32 bits. The
  111. * system call wrapper in the user space loads the value to %r6/%r7.
  112. * The code in entry.S keeps the values in %r2 - %r6 where they are and
  113. * stores %r7 to 96(%r15). But the standard C linkage requires that
  114. * the whole 64 bit value for len is stored on the stack and doesn't
  115. * use %r6 at all. So s390_fallocate has to convert the arguments from
  116. * %r2: fd, %r3: mode, %r4/%r5: offset, %r6/96(%r15)-99(%r15): len
  117. * to
  118. * %r2: fd, %r3: mode, %r4/%r5: offset, 96(%r15)-103(%r15): len
  119. */
  120. SYSCALL_DEFINE(s390_fallocate)(int fd, int mode, loff_t offset,
  121. u32 len_high, u32 len_low)
  122. {
  123. return sys_fallocate(fd, mode, offset, ((u64)len_high << 32) | len_low);
  124. }
  125. #ifdef CONFIG_HAVE_SYSCALL_WRAPPERS
  126. asmlinkage long SyS_s390_fallocate(long fd, long mode, loff_t offset,
  127. long len_high, long len_low)
  128. {
  129. return SYSC_s390_fallocate((int) fd, (int) mode, offset,
  130. (u32) len_high, (u32) len_low);
  131. }
  132. SYSCALL_ALIAS(sys_s390_fallocate, SyS_s390_fallocate);
  133. #endif
  134. #endif