Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * Conversion between 32-bit and 64-bit native system calls.
0004  *
0005  * Copyright (C) 2000 Silicon Graphics, Inc.
0006  * Written by Ulf Carlsson (ulfc@engr.sgi.com)
0007  */
0008 #include <linux/compiler.h>
0009 #include <linux/mm.h>
0010 #include <linux/errno.h>
0011 #include <linux/file.h>
0012 #include <linux/highuid.h>
0013 #include <linux/resource.h>
0014 #include <linux/highmem.h>
0015 #include <linux/time.h>
0016 #include <linux/times.h>
0017 #include <linux/poll.h>
0018 #include <linux/skbuff.h>
0019 #include <linux/filter.h>
0020 #include <linux/shm.h>
0021 #include <linux/sem.h>
0022 #include <linux/msg.h>
0023 #include <linux/icmpv6.h>
0024 #include <linux/syscalls.h>
0025 #include <linux/sysctl.h>
0026 #include <linux/utime.h>
0027 #include <linux/utsname.h>
0028 #include <linux/personality.h>
0029 #include <linux/dnotify.h>
0030 #include <linux/binfmts.h>
0031 #include <linux/security.h>
0032 #include <linux/compat.h>
0033 #include <linux/vfs.h>
0034 #include <linux/ipc.h>
0035 #include <linux/slab.h>
0036 
0037 #include <net/sock.h>
0038 #include <net/scm.h>
0039 
0040 #include <asm/compat-signal.h>
0041 #include <asm/sim.h>
0042 #include <linux/uaccess.h>
0043 #include <asm/mmu_context.h>
0044 #include <asm/mman.h>
0045 
0046 #ifdef __MIPSEB__
0047 #define merge_64(r1, r2) ((((r1) & 0xffffffffUL) << 32) + ((r2) & 0xffffffffUL))
0048 #endif
0049 #ifdef __MIPSEL__
0050 #define merge_64(r1, r2) ((((r2) & 0xffffffffUL) << 32) + ((r1) & 0xffffffffUL))
0051 #endif
0052 
0053 SYSCALL_DEFINE4(32_truncate64, const char __user *, path,
0054     unsigned long, __dummy, unsigned long, a2, unsigned long, a3)
0055 {
0056     return ksys_truncate(path, merge_64(a2, a3));
0057 }
0058 
0059 SYSCALL_DEFINE4(32_ftruncate64, unsigned long, fd, unsigned long, __dummy,
0060     unsigned long, a2, unsigned long, a3)
0061 {
0062     return ksys_ftruncate(fd, merge_64(a2, a3));
0063 }
0064 
0065 SYSCALL_DEFINE5(32_llseek, unsigned int, fd, unsigned int, offset_high,
0066         unsigned int, offset_low, loff_t __user *, result,
0067         unsigned int, origin)
0068 {
0069     return sys_llseek(fd, offset_high, offset_low, result, origin);
0070 }
0071 
0072 /* From the Single Unix Spec: pread & pwrite act like lseek to pos + op +
0073    lseek back to original location.  They fail just like lseek does on
0074    non-seekable files.  */
0075 
0076 SYSCALL_DEFINE6(32_pread, unsigned long, fd, char __user *, buf, size_t, count,
0077     unsigned long, unused, unsigned long, a4, unsigned long, a5)
0078 {
0079     return ksys_pread64(fd, buf, count, merge_64(a4, a5));
0080 }
0081 
0082 SYSCALL_DEFINE6(32_pwrite, unsigned int, fd, const char __user *, buf,
0083     size_t, count, u32, unused, u64, a4, u64, a5)
0084 {
0085     return ksys_pwrite64(fd, buf, count, merge_64(a4, a5));
0086 }
0087 
0088 SYSCALL_DEFINE1(32_personality, unsigned long, personality)
0089 {
0090     unsigned int p = personality & 0xffffffff;
0091     int ret;
0092 
0093     if (personality(current->personality) == PER_LINUX32 &&
0094         personality(p) == PER_LINUX)
0095         p = (p & ~PER_MASK) | PER_LINUX32;
0096     ret = sys_personality(p);
0097     if (ret != -1 && personality(ret) == PER_LINUX32)
0098         ret = (ret & ~PER_MASK) | PER_LINUX;
0099     return ret;
0100 }
0101 
0102 asmlinkage ssize_t sys32_readahead(int fd, u32 pad0, u64 a2, u64 a3,
0103                    size_t count)
0104 {
0105     return ksys_readahead(fd, merge_64(a2, a3), count);
0106 }
0107 
0108 asmlinkage long sys32_sync_file_range(int fd, int __pad,
0109     unsigned long a2, unsigned long a3,
0110     unsigned long a4, unsigned long a5,
0111     int flags)
0112 {
0113     return ksys_sync_file_range(fd,
0114             merge_64(a2, a3), merge_64(a4, a5),
0115             flags);
0116 }
0117 
0118 asmlinkage long sys32_fadvise64_64(int fd, int __pad,
0119     unsigned long a2, unsigned long a3,
0120     unsigned long a4, unsigned long a5,
0121     int flags)
0122 {
0123     return ksys_fadvise64_64(fd,
0124             merge_64(a2, a3), merge_64(a4, a5),
0125             flags);
0126 }
0127 
0128 asmlinkage long sys32_fallocate(int fd, int mode, unsigned offset_a2,
0129     unsigned offset_a3, unsigned len_a4, unsigned len_a5)
0130 {
0131     return ksys_fallocate(fd, mode, merge_64(offset_a2, offset_a3),
0132                   merge_64(len_a4, len_a5));
0133 }