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. 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)  *               Gerhard Tonn (ton@de.ibm.com)   
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *               Thomas Spatzier (tspat@de.ibm.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *  Conversion between 31bit and 64bit native syscalls.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * Heavily inspired by the 32-bit Sparc compat code which is 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/fs.h> 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <linux/mm.h> 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <linux/file.h> 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <linux/signal.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #include <linux/resource.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #include <linux/times.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #include <linux/smp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #include <linux/sem.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #include <linux/msg.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #include <linux/shm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #include <linux/uio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #include <linux/quota.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #include <linux/poll.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #include <linux/personality.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #include <linux/stat.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #include <linux/filter.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #include <linux/highmem.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #include <linux/mman.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #include <linux/ipv6.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #include <linux/in.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #include <linux/icmpv6.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) #include <linux/syscalls.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #include <linux/sysctl.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) #include <linux/binfmts.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #include <linux/capability.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) #include <linux/compat.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) #include <linux/vfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) #include <linux/ptrace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) #include <linux/fadvise.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) #include <linux/ipc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) #include <asm/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) #include <net/scm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) #include <net/sock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) #include "compat_linux.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) #ifdef CONFIG_SYSVIPC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) COMPAT_SYSCALL_DEFINE5(s390_ipc, uint, call, int, first, compat_ulong_t, second,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 		compat_ulong_t, third, compat_uptr_t, ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	if (call >> 16)		/* hack for backward compatibility */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	return compat_ksys_ipc(call, first, second, third, ptr, third);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) COMPAT_SYSCALL_DEFINE3(s390_truncate64, const char __user *, path, u32, high, u32, low)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	return ksys_truncate(path, (unsigned long)high << 32 | low);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) COMPAT_SYSCALL_DEFINE3(s390_ftruncate64, unsigned int, fd, u32, high, u32, low)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	return ksys_ftruncate(fd, (unsigned long)high << 32 | low);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) COMPAT_SYSCALL_DEFINE5(s390_pread64, unsigned int, fd, char __user *, ubuf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 		       compat_size_t, count, u32, high, u32, low)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	if ((compat_ssize_t) count < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	return ksys_pread64(fd, ubuf, count, (unsigned long)high << 32 | low);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) COMPAT_SYSCALL_DEFINE5(s390_pwrite64, unsigned int, fd, const char __user *, ubuf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 		       compat_size_t, count, u32, high, u32, low)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	if ((compat_ssize_t) count < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	return ksys_pwrite64(fd, ubuf, count, (unsigned long)high << 32 | low);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) COMPAT_SYSCALL_DEFINE4(s390_readahead, int, fd, u32, high, u32, low, s32, count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	return ksys_readahead(fd, (unsigned long)high << 32 | low, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) struct stat64_emu31 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	unsigned long long  st_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	unsigned int    __pad1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) #define STAT64_HAS_BROKEN_ST_INO        1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	u32             __st_ino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	unsigned int    st_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	unsigned int    st_nlink;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	u32             st_uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	u32             st_gid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	unsigned long long  st_rdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	unsigned int    __pad3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	long            st_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	u32             st_blksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	unsigned char   __pad4[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	u32             __pad5;     /* future possible st_blocks high bits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	u32             st_blocks;  /* Number 512-byte blocks allocated. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	u32             st_atime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	u32             __pad6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	u32             st_mtime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	u32             __pad7;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	u32             st_ctime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	u32             __pad8;     /* will be high 32 bits of ctime someday */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	unsigned long   st_ino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) };	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) static int cp_stat64(struct stat64_emu31 __user *ubuf, struct kstat *stat)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	struct stat64_emu31 tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	memset(&tmp, 0, sizeof(tmp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	tmp.st_dev = huge_encode_dev(stat->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	tmp.st_ino = stat->ino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	tmp.__st_ino = (u32)stat->ino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	tmp.st_mode = stat->mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	tmp.st_nlink = (unsigned int)stat->nlink;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	tmp.st_uid = from_kuid_munged(current_user_ns(), stat->uid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	tmp.st_gid = from_kgid_munged(current_user_ns(), stat->gid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	tmp.st_rdev = huge_encode_dev(stat->rdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	tmp.st_size = stat->size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	tmp.st_blksize = (u32)stat->blksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	tmp.st_blocks = (u32)stat->blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	tmp.st_atime = (u32)stat->atime.tv_sec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	tmp.st_mtime = (u32)stat->mtime.tv_sec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	tmp.st_ctime = (u32)stat->ctime.tv_sec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	return copy_to_user(ubuf,&tmp,sizeof(tmp)) ? -EFAULT : 0; 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) COMPAT_SYSCALL_DEFINE2(s390_stat64, const char __user *, filename, struct stat64_emu31 __user *, statbuf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	struct kstat stat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	int ret = vfs_stat(filename, &stat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	if (!ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 		ret = cp_stat64(statbuf, &stat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) COMPAT_SYSCALL_DEFINE2(s390_lstat64, const char __user *, filename, struct stat64_emu31 __user *, statbuf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	struct kstat stat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	int ret = vfs_lstat(filename, &stat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	if (!ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 		ret = cp_stat64(statbuf, &stat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) COMPAT_SYSCALL_DEFINE2(s390_fstat64, unsigned int, fd, struct stat64_emu31 __user *, statbuf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	struct kstat stat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	int ret = vfs_fstat(fd, &stat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	if (!ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		ret = cp_stat64(statbuf, &stat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) COMPAT_SYSCALL_DEFINE4(s390_fstatat64, unsigned int, dfd, const char __user *, filename,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 		       struct stat64_emu31 __user *, statbuf, int, flag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	struct kstat stat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	error = vfs_fstatat(dfd, filename, &stat, flag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	return cp_stat64(statbuf, &stat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)  * Linux/i386 didn't use to be able to handle more than
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)  * 4 system call parameters, so these system calls used a memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)  * block for parameter passing..
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) struct mmap_arg_struct_emu31 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	compat_ulong_t addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	compat_ulong_t len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	compat_ulong_t prot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	compat_ulong_t flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	compat_ulong_t fd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	compat_ulong_t offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) COMPAT_SYSCALL_DEFINE1(s390_old_mmap, struct mmap_arg_struct_emu31 __user *, arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	struct mmap_arg_struct_emu31 a;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	if (copy_from_user(&a, arg, sizeof(a)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	if (a.offset & ~PAGE_MASK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	return ksys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 			       a.offset >> PAGE_SHIFT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) COMPAT_SYSCALL_DEFINE1(s390_mmap2, struct mmap_arg_struct_emu31 __user *, arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	struct mmap_arg_struct_emu31 a;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	if (copy_from_user(&a, arg, sizeof(a)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 		return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	return ksys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd, a.offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) COMPAT_SYSCALL_DEFINE3(s390_read, unsigned int, fd, char __user *, buf, compat_size_t, count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	if ((compat_ssize_t) count < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 		return -EINVAL; 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	return ksys_read(fd, buf, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) COMPAT_SYSCALL_DEFINE3(s390_write, unsigned int, fd, const char __user *, buf, compat_size_t, count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	if ((compat_ssize_t) count < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 		return -EINVAL; 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	return ksys_write(fd, buf, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)  * 31 bit emulation wrapper functions for sys_fadvise64/fadvise64_64.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)  * These need to rewrite the advise values for POSIX_FADV_{DONTNEED,NOREUSE}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)  * because the 31 bit values differ from the 64 bit values.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) COMPAT_SYSCALL_DEFINE5(s390_fadvise64, int, fd, u32, high, u32, low, compat_size_t, len, int, advise)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	if (advise == 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 		advise = POSIX_FADV_DONTNEED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	else if (advise == 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 		advise = POSIX_FADV_NOREUSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	return ksys_fadvise64_64(fd, (unsigned long)high << 32 | low, len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 				 advise);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) struct fadvise64_64_args {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	int fd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	long long offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	long long len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	int advice;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) COMPAT_SYSCALL_DEFINE1(s390_fadvise64_64, struct fadvise64_64_args __user *, args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	struct fadvise64_64_args a;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	if ( copy_from_user(&a, args, sizeof(a)) )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 		return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	if (a.advice == 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 		a.advice = POSIX_FADV_DONTNEED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	else if (a.advice == 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 		a.advice = POSIX_FADV_NOREUSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	return ksys_fadvise64_64(a.fd, a.offset, a.len, a.advice);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) COMPAT_SYSCALL_DEFINE6(s390_sync_file_range, int, fd, u32, offhigh, u32, offlow,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 		       u32, nhigh, u32, nlow, unsigned int, flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	return ksys_sync_file_range(fd, ((loff_t)offhigh << 32) + offlow,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 				   ((u64)nhigh << 32) + nlow, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) COMPAT_SYSCALL_DEFINE6(s390_fallocate, int, fd, int, mode, u32, offhigh, u32, offlow,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 		       u32, lenhigh, u32, lenlow)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	return ksys_fallocate(fd, mode, ((loff_t)offhigh << 32) + offlow,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 			      ((u64)lenhigh << 32) + lenlow);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) }