Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * S390 version |
Heiko Carstens | a53c8fa | 2012-07-20 11:15:04 +0200 | [diff] [blame] | 4 | * Copyright IBM Corp. 1999, 2000 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> |
Alexey Dobriyan | 4e950f6 | 2007-07-30 02:36:13 +0400 | [diff] [blame] | 18 | #include <linux/fs.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #include <linux/smp.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | #include <linux/personality.h> |
Arnd Bergmann | fe74290 | 2006-10-02 02:18:34 -0700 | [diff] [blame] | 29 | #include <linux/unistd.h> |
Adrian Bunk | cba4fbb | 2007-10-16 23:29:24 -0700 | [diff] [blame] | 30 | #include <linux/ipc.h> |
Linus Torvalds | 7c0f6ba | 2016-12-24 11:46:01 -0800 | [diff] [blame] | 31 | #include <linux/uaccess.h> |
Heiko Carstens | a806170 | 2008-04-17 07:46:26 +0200 | [diff] [blame] | 32 | #include "entry.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | /* |
Christoph Hellwig | a467937 | 2010-03-10 15:21:15 -0800 | [diff] [blame] | 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. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | */ |
| 39 | |
Christoph Hellwig | a467937 | 2010-03-10 15:21:15 -0800 | [diff] [blame] | 40 | struct s390_mmap_arg_struct { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Christoph Hellwig | a467937 | 2010-03-10 15:21:15 -0800 | [diff] [blame] | 49 | SYSCALL_DEFINE1(mmap2, struct s390_mmap_arg_struct __user *, arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | { |
Christoph Hellwig | a467937 | 2010-03-10 15:21:15 -0800 | [diff] [blame] | 51 | struct s390_mmap_arg_struct a; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | int error = -EFAULT; |
| 53 | |
| 54 | if (copy_from_user(&a, arg, sizeof(a))) |
| 55 | goto out; |
Dominik Brodowski | a90f590 | 2018-03-11 11:34:46 +0100 | [diff] [blame] | 56 | error = ksys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd, a.offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | out: |
| 58 | return error; |
| 59 | } |
| 60 | |
Arnd Bergmann | 58fa4a4 | 2019-01-16 14:15:20 +0100 | [diff] [blame] | 61 | #ifdef CONFIG_SYSVIPC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | /* |
Heiko Carstens | 3a3954c | 2011-12-27 11:27:21 +0100 | [diff] [blame] | 63 | * sys_ipc() is the de-multiplexer for the SysV IPC calls. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | */ |
Christoph Hellwig | baed7fc | 2010-03-10 15:21:18 -0800 | [diff] [blame] | 65 | SYSCALL_DEFINE5(s390_ipc, uint, call, int, first, unsigned long, second, |
Heiko Carstens | 2668945 | 2009-01-14 14:14:36 +0100 | [diff] [blame] | 66 | unsigned long, third, void __user *, ptr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | { |
Heiko Carstens | 3a3954c | 2011-12-27 11:27:21 +0100 | [diff] [blame] | 68 | if (call >> 16) |
| 69 | return -EINVAL; |
| 70 | /* The s390 sys_ipc variant has only five parameters instead of six |
| 71 | * like the generic variant. The only difference is the handling of |
| 72 | * the SEMTIMEDOP subcall where on s390 the third parameter is used |
| 73 | * as a pointer to a struct timespec where the generic variant uses |
| 74 | * the fifth parameter. |
| 75 | * Therefore we can call the generic variant by simply passing the |
| 76 | * third parameter also as fifth parameter. |
| 77 | */ |
Arnd Bergmann | 58fa4a4 | 2019-01-16 14:15:20 +0100 | [diff] [blame] | 78 | return ksys_ipc(call, first, second, third, ptr, third); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | } |
Arnd Bergmann | 58fa4a4 | 2019-01-16 14:15:20 +0100 | [diff] [blame] | 80 | #endif /* CONFIG_SYSVIPC */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | |
Heiko Carstens | 3a11037 | 2010-08-13 10:06:39 +0200 | [diff] [blame] | 82 | SYSCALL_DEFINE1(s390_personality, unsigned int, personality) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | { |
Arnd Bergmann | 1ecff5e | 2019-01-16 14:15:19 +0100 | [diff] [blame] | 84 | unsigned int ret = current->personality; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | |
Jiri Kosina | 5ab37e1 | 2012-08-02 09:11:23 +0200 | [diff] [blame] | 86 | if (personality(current->personality) == PER_LINUX32 && |
| 87 | personality(personality) == PER_LINUX) |
| 88 | personality |= PER_LINUX32; |
Arnd Bergmann | 1ecff5e | 2019-01-16 14:15:19 +0100 | [diff] [blame] | 89 | |
| 90 | if (personality != 0xffffffff) |
| 91 | set_personality(personality); |
| 92 | |
Jiri Kosina | 5ab37e1 | 2012-08-02 09:11:23 +0200 | [diff] [blame] | 93 | if (personality(ret) == PER_LINUX32) |
| 94 | ret &= ~PER_LINUX32; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | |
| 96 | return ret; |
| 97 | } |
Arnd Bergmann | aa0d6e7 | 2019-01-16 14:15:22 +0100 | [diff] [blame] | 98 | |
| 99 | SYSCALL_DEFINE0(ni_syscall) |
| 100 | { |
| 101 | return -ENOSYS; |
| 102 | } |