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 #include <linux/personality.h>
30 #include <linux/unistd.h>
32 #include <asm/uaccess.h>
36 * sys_pipe() is the normal C calling standard for creating
37 * a pipe. It's not the way Unix traditionally does this, though.
39 asmlinkage long sys_pipe(unsigned long __user *fildes)
46 if (copy_to_user(fildes, fd, 2*sizeof(int)))
52 /* common code for old and new mmaps */
53 static inline long do_mmap2(
54 unsigned long addr, unsigned long len,
55 unsigned long prot, unsigned long flags,
56 unsigned long fd, unsigned long pgoff)
59 struct file * file = NULL;
61 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
62 if (!(flags & MAP_ANONYMOUS)) {
68 down_write(¤t->mm->mmap_sem);
69 error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
70 up_write(¤t->mm->mmap_sem);
79 * Perform the select(nd, in, out, ex, tv) and mmap() system
80 * calls. Linux for S/390 isn't able to handle more than 5
81 * system call parameters, so these system calls used a memory
82 * block for parameter passing..
85 struct mmap_arg_struct {
94 asmlinkage long sys_mmap2(struct mmap_arg_struct __user *arg)
96 struct mmap_arg_struct a;
99 if (copy_from_user(&a, arg, sizeof(a)))
101 error = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset);
106 asmlinkage long old_mmap(struct mmap_arg_struct __user *arg)
108 struct mmap_arg_struct a;
109 long error = -EFAULT;
111 if (copy_from_user(&a, arg, sizeof(a)))
115 if (a.offset & ~PAGE_MASK)
118 error = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset >> PAGE_SHIFT);
124 struct sel_arg_struct {
126 fd_set __user *inp, *outp, *exp;
127 struct timeval __user *tvp;
130 asmlinkage long old_select(struct sel_arg_struct __user *arg)
132 struct sel_arg_struct a;
134 if (copy_from_user(&a, arg, sizeof(a)))
136 /* sys_select() does the appropriate kernel locking */
137 return sys_select(a.n, a.inp, a.outp, a.exp, a.tvp);
140 #endif /* CONFIG_64BIT */
143 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
145 * This is really horribly ugly.
147 asmlinkage long sys_ipc(uint call, int first, unsigned long second,
148 unsigned long third, void __user *ptr)
150 struct ipc_kludge tmp;
155 return sys_semtimedop(first, (struct sembuf __user *)ptr,
156 (unsigned)second, NULL);
158 return sys_semtimedop(first, (struct sembuf __user *)ptr,
160 (const struct timespec __user *) third);
162 return sys_semget(first, (int)second, third);
167 if (get_user(fourth.__pad, (void __user * __user *) ptr))
169 return sys_semctl(first, (int)second, third, fourth);
172 return sys_msgsnd (first, (struct msgbuf __user *) ptr,
173 (size_t)second, third);
178 if (copy_from_user (&tmp, (struct ipc_kludge __user *) ptr,
179 sizeof (struct ipc_kludge)))
181 return sys_msgrcv (first, tmp.msgp,
182 (size_t)second, tmp.msgtyp, third);
184 return sys_msgget((key_t)first, (int)second);
186 return sys_msgctl(first, (int)second,
187 (struct msqid_ds __user *)ptr);
191 ret = do_shmat(first, (char __user *)ptr,
192 (int)second, &raddr);
195 return put_user (raddr, (ulong __user *) third);
199 return sys_shmdt ((char __user *)ptr);
201 return sys_shmget(first, (size_t)second, third);
203 return sys_shmctl(first, (int)second,
204 (struct shmid_ds __user *) ptr);
214 asmlinkage long s390x_newuname(struct new_utsname __user *name)
216 int ret = sys_newuname(name);
218 if (current->personality == PER_LINUX32 && !ret) {
219 ret = copy_to_user(name->machine, "s390\0\0\0\0", 8);
220 if (ret) ret = -EFAULT;
225 asmlinkage long s390x_personality(unsigned long personality)
229 if (current->personality == PER_LINUX32 && personality == PER_LINUX)
230 personality = PER_LINUX32;
231 ret = sys_personality(personality);
232 if (ret == PER_LINUX32)
237 #endif /* CONFIG_64BIT */
240 * Wrapper function for sys_fadvise64/fadvise64_64
245 s390_fadvise64(int fd, u32 offset_high, u32 offset_low, size_t len, int advice)
247 return sys_fadvise64(fd, (u64) offset_high << 32 | offset_low,
253 struct fadvise64_64_args {
261 s390_fadvise64_64(struct fadvise64_64_args __user *args)
263 struct fadvise64_64_args a;
265 if ( copy_from_user(&a, args, sizeof(a)) )
267 return sys_fadvise64_64(a.fd, a.offset, a.len, a.advice);
271 * Do a system call from kernel instead of calling sys_execve so we
272 * end up with proper pt_regs.
274 int kernel_execve(const char *filename, char *const argv[], char *const envp[])
276 register const char *__arg1 asm("2") = filename;
277 register char *const*__arg2 asm("3") = argv;
278 register char *const*__arg3 asm("4") = envp;
279 register long __svcres asm("2");
286 "d" (__arg3) : "memory");