Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

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