Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-2.6-block.git] / arch / s390 / kernel / sys_s390.c
CommitLineData
b2441318 1// SPDX-License-Identifier: GPL-2.0
1da177e4 2/*
1da177e4 3 * S390 version
a53c8fab 4 * Copyright IBM Corp. 1999, 2000
1da177e4
LT
5 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
6 * Thomas Spatzier (tspat@de.ibm.com)
7 *
8 * Derived from "arch/i386/kernel/sys_i386.c"
9 *
10 * This file contains various random system calls that
11 * have a non-standard calling sequence on the Linux/s390
12 * platform.
13 */
14
15#include <linux/errno.h>
16#include <linux/sched.h>
17#include <linux/mm.h>
4e950f6f 18#include <linux/fs.h>
1da177e4 19#include <linux/smp.h>
1da177e4
LT
20#include <linux/sem.h>
21#include <linux/msg.h>
22#include <linux/shm.h>
23#include <linux/stat.h>
24#include <linux/syscalls.h>
25#include <linux/mman.h>
26#include <linux/file.h>
27#include <linux/utsname.h>
1da177e4 28#include <linux/personality.h>
fe74290d 29#include <linux/unistd.h>
cba4fbbf 30#include <linux/ipc.h>
7c0f6ba6 31#include <linux/uaccess.h>
a806170e 32#include "entry.h"
1da177e4 33
1da177e4 34/*
a4679373
CH
35 * Perform the mmap() system call. Linux for S/390 isn't able to handle more
36 * than 5 system call parameters, so this system call uses a memory block
37 * for parameter passing.
1da177e4
LT
38 */
39
a4679373 40struct s390_mmap_arg_struct {
1da177e4
LT
41 unsigned long addr;
42 unsigned long len;
43 unsigned long prot;
44 unsigned long flags;
45 unsigned long fd;
46 unsigned long offset;
47};
48
a4679373 49SYSCALL_DEFINE1(mmap2, struct s390_mmap_arg_struct __user *, arg)
1da177e4 50{
a4679373 51 struct s390_mmap_arg_struct a;
1da177e4
LT
52 int error = -EFAULT;
53
54 if (copy_from_user(&a, arg, sizeof(a)))
55 goto out;
a90f590a 56 error = ksys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd, a.offset);
1da177e4
LT
57out:
58 return error;
59}
60
1da177e4 61/*
3a3954ce 62 * sys_ipc() is the de-multiplexer for the SysV IPC calls.
1da177e4 63 */
baed7fc9 64SYSCALL_DEFINE5(s390_ipc, uint, call, int, first, unsigned long, second,
26689452 65 unsigned long, third, void __user *, ptr)
1da177e4 66{
3a3954ce
HC
67 if (call >> 16)
68 return -EINVAL;
69 /* The s390 sys_ipc variant has only five parameters instead of six
70 * like the generic variant. The only difference is the handling of
71 * the SEMTIMEDOP subcall where on s390 the third parameter is used
72 * as a pointer to a struct timespec where the generic variant uses
73 * the fifth parameter.
74 * Therefore we can call the generic variant by simply passing the
75 * third parameter also as fifth parameter.
76 */
77 return sys_ipc(call, first, second, third, ptr, third);
1da177e4
LT
78}
79
3a110370 80SYSCALL_DEFINE1(s390_personality, unsigned int, personality)
1da177e4 81{
3a110370 82 unsigned int ret;
1da177e4 83
5ab37e1b
JK
84 if (personality(current->personality) == PER_LINUX32 &&
85 personality(personality) == PER_LINUX)
86 personality |= PER_LINUX32;
1da177e4 87 ret = sys_personality(personality);
5ab37e1b
JK
88 if (personality(ret) == PER_LINUX32)
89 ret &= ~PER_LINUX32;
1da177e4
LT
90
91 return ret;
92}