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>
20 #include <linux/smp.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>
31 #include <linux/ipc.h>
32 #include <asm/uaccess.h>
35 /* common code for old and new mmaps */
36 static inline long do_mmap2(
37 unsigned long addr
, unsigned long len
,
38 unsigned long prot
, unsigned long flags
,
39 unsigned long fd
, unsigned long pgoff
)
42 struct file
* file
= NULL
;
44 flags
&= ~(MAP_EXECUTABLE
| MAP_DENYWRITE
);
45 if (!(flags
& MAP_ANONYMOUS
)) {
51 down_write(¤t
->mm
->mmap_sem
);
52 error
= do_mmap_pgoff(file
, addr
, len
, prot
, flags
, pgoff
);
53 up_write(¤t
->mm
->mmap_sem
);
62 * Perform the select(nd, in, out, ex, tv) and mmap() system
63 * calls. Linux for S/390 isn't able to handle more than 5
64 * system call parameters, so these system calls used a memory
65 * block for parameter passing..
68 struct mmap_arg_struct
{
77 asmlinkage
long sys_mmap2(struct mmap_arg_struct __user
*arg
)
79 struct mmap_arg_struct a
;
82 if (copy_from_user(&a
, arg
, sizeof(a
)))
84 error
= do_mmap2(a
.addr
, a
.len
, a
.prot
, a
.flags
, a
.fd
, a
.offset
);
89 asmlinkage
long old_mmap(struct mmap_arg_struct __user
*arg
)
91 struct mmap_arg_struct a
;
94 if (copy_from_user(&a
, arg
, sizeof(a
)))
98 if (a
.offset
& ~PAGE_MASK
)
101 error
= do_mmap2(a
.addr
, a
.len
, a
.prot
, a
.flags
, a
.fd
, a
.offset
>> PAGE_SHIFT
);
107 struct sel_arg_struct
{
109 fd_set __user
*inp
, *outp
, *exp
;
110 struct timeval __user
*tvp
;
113 asmlinkage
long old_select(struct sel_arg_struct __user
*arg
)
115 struct sel_arg_struct a
;
117 if (copy_from_user(&a
, arg
, sizeof(a
)))
119 /* sys_select() does the appropriate kernel locking */
120 return sys_select(a
.n
, a
.inp
, a
.outp
, a
.exp
, a
.tvp
);
123 #endif /* CONFIG_64BIT */
126 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
128 * This is really horribly ugly.
130 asmlinkage
long sys_ipc(uint call
, int first
, unsigned long second
,
131 unsigned long third
, void __user
*ptr
)
133 struct ipc_kludge tmp
;
138 return sys_semtimedop(first
, (struct sembuf __user
*)ptr
,
139 (unsigned)second
, NULL
);
141 return sys_semtimedop(first
, (struct sembuf __user
*)ptr
,
143 (const struct timespec __user
*) third
);
145 return sys_semget(first
, (int)second
, third
);
150 if (get_user(fourth
.__pad
, (void __user
* __user
*) ptr
))
152 return sys_semctl(first
, (int)second
, third
, fourth
);
155 return sys_msgsnd (first
, (struct msgbuf __user
*) ptr
,
156 (size_t)second
, third
);
161 if (copy_from_user (&tmp
, (struct ipc_kludge __user
*) ptr
,
162 sizeof (struct ipc_kludge
)))
164 return sys_msgrcv (first
, tmp
.msgp
,
165 (size_t)second
, tmp
.msgtyp
, third
);
167 return sys_msgget((key_t
)first
, (int)second
);
169 return sys_msgctl(first
, (int)second
,
170 (struct msqid_ds __user
*)ptr
);
174 ret
= do_shmat(first
, (char __user
*)ptr
,
175 (int)second
, &raddr
);
178 return put_user (raddr
, (ulong __user
*) third
);
182 return sys_shmdt ((char __user
*)ptr
);
184 return sys_shmget(first
, (size_t)second
, third
);
186 return sys_shmctl(first
, (int)second
,
187 (struct shmid_ds __user
*) ptr
);
197 asmlinkage
long s390x_newuname(struct new_utsname __user
*name
)
199 int ret
= sys_newuname(name
);
201 if (personality(current
->personality
) == PER_LINUX32
&& !ret
) {
202 ret
= copy_to_user(name
->machine
, "s390\0\0\0\0", 8);
203 if (ret
) ret
= -EFAULT
;
208 asmlinkage
long s390x_personality(unsigned long personality
)
212 if (current
->personality
== PER_LINUX32
&& personality
== PER_LINUX
)
213 personality
= PER_LINUX32
;
214 ret
= sys_personality(personality
);
215 if (ret
== PER_LINUX32
)
220 #endif /* CONFIG_64BIT */
223 * Wrapper function for sys_fadvise64/fadvise64_64
228 s390_fadvise64(int fd
, u32 offset_high
, u32 offset_low
, size_t len
, int advice
)
230 return sys_fadvise64(fd
, (u64
) offset_high
<< 32 | offset_low
,
236 struct fadvise64_64_args
{
244 s390_fadvise64_64(struct fadvise64_64_args __user
*args
)
246 struct fadvise64_64_args a
;
248 if ( copy_from_user(&a
, args
, sizeof(a
)) )
250 return sys_fadvise64_64(a
.fd
, a
.offset
, a
.len
, a
.advice
);
255 * This is a wrapper to call sys_fallocate(). For 31 bit s390 the last
256 * 64 bit argument "len" is split into the upper and lower 32 bits. The
257 * system call wrapper in the user space loads the value to %r6/%r7.
258 * The code in entry.S keeps the values in %r2 - %r6 where they are and
259 * stores %r7 to 96(%r15). But the standard C linkage requires that
260 * the whole 64 bit value for len is stored on the stack and doesn't
261 * use %r6 at all. So s390_fallocate has to convert the arguments from
262 * %r2: fd, %r3: mode, %r4/%r5: offset, %r6/96(%r15)-99(%r15): len
264 * %r2: fd, %r3: mode, %r4/%r5: offset, 96(%r15)-103(%r15): len
266 asmlinkage
long s390_fallocate(int fd
, int mode
, loff_t offset
,
267 u32 len_high
, u32 len_low
)
269 return sys_fallocate(fd
, mode
, offset
, ((u64
)len_high
<< 32) | len_low
);