blob: b7af452978ca8d478ee070c84c9191d52a1ef511 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * S390 version
Heiko Carstensa53c8fa2012-07-20 11:15:04 +02003 * Copyright IBM Corp. 1999, 2000
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
5 * Thomas Spatzier (tspat@de.ibm.com)
6 *
7 * Derived from "arch/i386/kernel/sys_i386.c"
8 *
9 * This file contains various random system calls that
10 * have a non-standard calling sequence on the Linux/s390
11 * platform.
12 */
13
14#include <linux/errno.h>
15#include <linux/sched.h>
16#include <linux/mm.h>
Alexey Dobriyan4e950f62007-07-30 02:36:13 +040017#include <linux/fs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include <linux/smp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#include <linux/sem.h>
20#include <linux/msg.h>
21#include <linux/shm.h>
22#include <linux/stat.h>
23#include <linux/syscalls.h>
24#include <linux/mman.h>
25#include <linux/file.h>
26#include <linux/utsname.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070027#include <linux/personality.h>
Arnd Bergmannfe742902006-10-02 02:18:34 -070028#include <linux/unistd.h>
Adrian Bunkcba4fbb2007-10-16 23:29:24 -070029#include <linux/ipc.h>
Linus Torvalds7c0f6ba2016-12-24 11:46:01 -080030#include <linux/uaccess.h>
Heiko Carstensa8061702008-04-17 07:46:26 +020031#include "entry.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
Linus Torvalds1da177e2005-04-16 15:20:36 -070033/*
Christoph Hellwiga4679372010-03-10 15:21:15 -080034 * Perform the mmap() system call. Linux for S/390 isn't able to handle more
35 * than 5 system call parameters, so this system call uses a memory block
36 * for parameter passing.
Linus Torvalds1da177e2005-04-16 15:20:36 -070037 */
38
Christoph Hellwiga4679372010-03-10 15:21:15 -080039struct s390_mmap_arg_struct {
Linus Torvalds1da177e2005-04-16 15:20:36 -070040 unsigned long addr;
41 unsigned long len;
42 unsigned long prot;
43 unsigned long flags;
44 unsigned long fd;
45 unsigned long offset;
46};
47
Christoph Hellwiga4679372010-03-10 15:21:15 -080048SYSCALL_DEFINE1(mmap2, struct s390_mmap_arg_struct __user *, arg)
Linus Torvalds1da177e2005-04-16 15:20:36 -070049{
Christoph Hellwiga4679372010-03-10 15:21:15 -080050 struct s390_mmap_arg_struct a;
Linus Torvalds1da177e2005-04-16 15:20:36 -070051 int error = -EFAULT;
52
53 if (copy_from_user(&a, arg, sizeof(a)))
54 goto out;
Al Virof8b72562009-11-30 17:37:04 -050055 error = sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd, a.offset);
Linus Torvalds1da177e2005-04-16 15:20:36 -070056out:
57 return error;
58}
59
Linus Torvalds1da177e2005-04-16 15:20:36 -070060/*
Heiko Carstens3a3954c2011-12-27 11:27:21 +010061 * sys_ipc() is the de-multiplexer for the SysV IPC calls.
Linus Torvalds1da177e2005-04-16 15:20:36 -070062 */
Christoph Hellwigbaed7fc2010-03-10 15:21:18 -080063SYSCALL_DEFINE5(s390_ipc, uint, call, int, first, unsigned long, second,
Heiko Carstens26689452009-01-14 14:14:36 +010064 unsigned long, third, void __user *, ptr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070065{
Heiko Carstens3a3954c2011-12-27 11:27:21 +010066 if (call >> 16)
67 return -EINVAL;
68 /* The s390 sys_ipc variant has only five parameters instead of six
69 * like the generic variant. The only difference is the handling of
70 * the SEMTIMEDOP subcall where on s390 the third parameter is used
71 * as a pointer to a struct timespec where the generic variant uses
72 * the fifth parameter.
73 * Therefore we can call the generic variant by simply passing the
74 * third parameter also as fifth parameter.
75 */
76 return sys_ipc(call, first, second, third, ptr, third);
Linus Torvalds1da177e2005-04-16 15:20:36 -070077}
78
Heiko Carstens3a110372010-08-13 10:06:39 +020079SYSCALL_DEFINE1(s390_personality, unsigned int, personality)
Linus Torvalds1da177e2005-04-16 15:20:36 -070080{
Heiko Carstens3a110372010-08-13 10:06:39 +020081 unsigned int ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -070082
Jiri Kosina5ab37e12012-08-02 09:11:23 +020083 if (personality(current->personality) == PER_LINUX32 &&
84 personality(personality) == PER_LINUX)
85 personality |= PER_LINUX32;
Linus Torvalds1da177e2005-04-16 15:20:36 -070086 ret = sys_personality(personality);
Jiri Kosina5ab37e12012-08-02 09:11:23 +020087 if (personality(ret) == PER_LINUX32)
88 ret &= ~PER_LINUX32;
Linus Torvalds1da177e2005-04-16 15:20:36 -070089
90 return ret;
91}