2 * arch/s390/kernel/sys_s390.c
5 * Copyright (C) 1999,2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
7 * Thomas Spatzier (tspat@de.ibm.com)
9 * Derived from "arch/i386/kernel/sys_i386.c"
11 * This file contains various random system calls that
12 * have a non-standard calling sequence on the Linux/s390
16 #include <linux/errno.h>
17 #include <linux/sched.h>
19 #include <linux/smp.h>
20 #include <linux/smp_lock.h>
21 #include <linux/sem.h>
22 #include <linux/msg.h>
23 #include <linux/shm.h>
24 #include <linux/stat.h>
25 #include <linux/syscalls.h>
26 #include <linux/mman.h>
27 #include <linux/file.h>
28 #include <linux/utsname.h>
29 #ifdef CONFIG_ARCH_S390X
30 #include <linux/personality.h>
31 #endif /* CONFIG_ARCH_S390X */
33 #include <asm/uaccess.h>
37 * sys_pipe() is the normal C calling standard for creating
38 * a pipe. It's not the way Unix traditionally does this, though.
40 asmlinkage long sys_pipe(unsigned long * fildes)
47 if (copy_to_user(fildes, fd, 2*sizeof(int)))
53 /* common code for old and new mmaps */
54 static inline long do_mmap2(
55 unsigned long addr, unsigned long len,
56 unsigned long prot, unsigned long flags,
57 unsigned long fd, unsigned long pgoff)
60 struct file * file = NULL;
62 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
63 if (!(flags & MAP_ANONYMOUS)) {
69 down_write(¤t->mm->mmap_sem);
70 error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
71 up_write(¤t->mm->mmap_sem);
80 * Perform the select(nd, in, out, ex, tv) and mmap() system
81 * calls. Linux for S/390 isn't able to handle more than 5
82 * system call parameters, so these system calls used a memory
83 * block for parameter passing..
86 struct mmap_arg_struct {
95 asmlinkage long sys_mmap2(struct mmap_arg_struct *arg)
97 struct mmap_arg_struct a;
100 if (copy_from_user(&a, arg, sizeof(a)))
102 error = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset);
107 asmlinkage long old_mmap(struct mmap_arg_struct *arg)
109 struct mmap_arg_struct a;
110 long error = -EFAULT;
112 if (copy_from_user(&a, arg, sizeof(a)))
116 if (a.offset & ~PAGE_MASK)
119 error = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset >> PAGE_SHIFT);
124 #ifndef CONFIG_ARCH_S390X
125 struct sel_arg_struct {
127 fd_set *inp, *outp, *exp;
131 asmlinkage long old_select(struct sel_arg_struct *arg)
133 struct sel_arg_struct a;
135 if (copy_from_user(&a, arg, sizeof(a)))
137 /* sys_select() does the appropriate kernel locking */
138 return sys_select(a.n, a.inp, a.outp, a.exp, a.tvp);
141 #else /* CONFIG_ARCH_S390X */
143 arch_get_unmapped_area(struct file *filp, unsigned long addr,
144 unsigned long len, unsigned long pgoff,
147 struct vm_area_struct *vma;
150 if (test_thread_flag(TIF_31BIT)) {
156 addr = TASK_SIZE / 2;
162 addr = PAGE_ALIGN(addr);
164 for (vma = find_vma(current->mm, addr); ; vma = vma->vm_next) {
165 /* At this point: (!vma || addr < vma->vm_end). */
166 if (end - len < addr)
168 if (!vma || addr + len <= vma->vm_start)
173 #endif /* CONFIG_ARCH_S390X */
176 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
178 * This is really horribly ugly.
180 asmlinkage long sys_ipc (uint call, int first, int second,
181 unsigned long third, void *ptr)
183 struct ipc_kludge tmp;
188 return sys_semtimedop (first, (struct sembuf *) ptr, second,
191 return sys_semtimedop (first, (struct sembuf *) ptr, second,
192 (const struct timespec *) third);
194 return sys_semget (first, second, third);
199 if (get_user(fourth.__pad, (void **) ptr))
201 return sys_semctl (first, second, third, fourth);
204 return sys_msgsnd (first, (struct msgbuf *) ptr,
210 if (copy_from_user (&tmp, (struct ipc_kludge *) ptr,
211 sizeof (struct ipc_kludge)))
213 return sys_msgrcv (first, tmp.msgp,
214 second, tmp.msgtyp, third);
216 return sys_msgget ((key_t) first, second);
218 return sys_msgctl (first, second, (struct msqid_ds *) ptr);
222 ret = do_shmat (first, (char *) ptr, second, &raddr);
225 return put_user (raddr, (ulong *) third);
229 return sys_shmdt ((char *)ptr);
231 return sys_shmget (first, second, third);
233 return sys_shmctl (first, second,
234 (struct shmid_ds *) ptr);
243 #ifdef CONFIG_ARCH_S390X
244 asmlinkage long s390x_newuname(struct new_utsname * name)
246 int ret = sys_newuname(name);
248 if (current->personality == PER_LINUX32 && !ret) {
249 ret = copy_to_user(name->machine, "s390\0\0\0\0", 8);
250 if (ret) ret = -EFAULT;
255 asmlinkage long s390x_personality(unsigned long personality)
259 if (current->personality == PER_LINUX32 && personality == PER_LINUX)
260 personality = PER_LINUX32;
261 ret = sys_personality(personality);
262 if (ret == PER_LINUX32)
267 #endif /* CONFIG_ARCH_S390X */
270 * Wrapper function for sys_fadvise64/fadvise64_64
272 #ifndef CONFIG_ARCH_S390X
275 s390_fadvise64(int fd, u32 offset_high, u32 offset_low, size_t len, int advice)
277 return sys_fadvise64(fd, (u64) offset_high << 32 | offset_low,
283 struct fadvise64_64_args {
291 s390_fadvise64_64(struct fadvise64_64_args *args)
293 struct fadvise64_64_args a;
295 if ( copy_from_user(&a, args, sizeof(a)) )
297 return sys_fadvise64_64(a.fd, a.offset, a.len, a.advice);