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 __user *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 __user *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 __user *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 __user *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 #endif /* CONFIG_ARCH_S390X */
144 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
146 * This is really horribly ugly.
148 asmlinkage long sys_ipc(uint call, int first, unsigned long second,
149 unsigned long third, void __user *ptr)
151 struct ipc_kludge tmp;
156 return sys_semtimedop(first, (struct sembuf __user *)ptr,
157 (unsigned)second, NULL);
159 return sys_semtimedop(first, (struct sembuf __user *)ptr,
161 (const struct timespec __user *) third);
163 return sys_semget(first, (int)second, third);
168 if (get_user(fourth.__pad, (void __user * __user *) ptr))
170 return sys_semctl(first, (int)second, third, fourth);
173 return sys_msgsnd (first, (struct msgbuf __user *) ptr,
174 (size_t)second, third);
179 if (copy_from_user (&tmp, (struct ipc_kludge __user *) ptr,
180 sizeof (struct ipc_kludge)))
182 return sys_msgrcv (first, tmp.msgp,
183 (size_t)second, tmp.msgtyp, third);
185 return sys_msgget((key_t)first, (int)second);
187 return sys_msgctl(first, (int)second,
188 (struct msqid_ds __user *)ptr);
192 ret = do_shmat(first, (char __user *)ptr,
193 (int)second, &raddr);
196 return put_user (raddr, (ulong __user *) third);
200 return sys_shmdt ((char __user *)ptr);
202 return sys_shmget(first, (size_t)second, third);
204 return sys_shmctl(first, (int)second,
205 (struct shmid_ds __user *) ptr);
214 #ifdef CONFIG_ARCH_S390X
215 asmlinkage long s390x_newuname(struct new_utsname __user *name)
217 int ret = sys_newuname(name);
219 if (current->personality == PER_LINUX32 && !ret) {
220 ret = copy_to_user(name->machine, "s390\0\0\0\0", 8);
221 if (ret) ret = -EFAULT;
226 asmlinkage long s390x_personality(unsigned long personality)
230 if (current->personality == PER_LINUX32 && personality == PER_LINUX)
231 personality = PER_LINUX32;
232 ret = sys_personality(personality);
233 if (ret == PER_LINUX32)
238 #endif /* CONFIG_ARCH_S390X */
241 * Wrapper function for sys_fadvise64/fadvise64_64
243 #ifndef CONFIG_ARCH_S390X
246 s390_fadvise64(int fd, u32 offset_high, u32 offset_low, size_t len, int advice)
248 return sys_fadvise64(fd, (u64) offset_high << 32 | offset_low,
254 struct fadvise64_64_args {
262 s390_fadvise64_64(struct fadvise64_64_args __user *args)
264 struct fadvise64_64_args a;
266 if ( copy_from_user(&a, args, sizeof(a)) )
268 return sys_fadvise64_64(a.fd, a.offset, a.len, a.advice);