Linux Audio

Check our new training course

Loading...
v4.6
 
  1/*
  2 * Conversion between 32-bit and 64-bit native system calls.
  3 *
  4 * Copyright (C) 2000 Silicon Graphics, Inc.
  5 * Written by Ulf Carlsson (ulfc@engr.sgi.com)
  6 */
  7#include <linux/compiler.h>
  8#include <linux/mm.h>
  9#include <linux/errno.h>
 10#include <linux/file.h>
 11#include <linux/highuid.h>
 12#include <linux/resource.h>
 13#include <linux/highmem.h>
 14#include <linux/time.h>
 15#include <linux/times.h>
 16#include <linux/poll.h>
 17#include <linux/skbuff.h>
 18#include <linux/filter.h>
 19#include <linux/shm.h>
 20#include <linux/sem.h>
 21#include <linux/msg.h>
 22#include <linux/icmpv6.h>
 23#include <linux/syscalls.h>
 24#include <linux/sysctl.h>
 25#include <linux/utime.h>
 26#include <linux/utsname.h>
 27#include <linux/personality.h>
 28#include <linux/dnotify.h>
 29#include <linux/module.h>
 30#include <linux/binfmts.h>
 31#include <linux/security.h>
 32#include <linux/compat.h>
 33#include <linux/vfs.h>
 34#include <linux/ipc.h>
 35#include <linux/slab.h>
 36
 37#include <net/sock.h>
 38#include <net/scm.h>
 39
 40#include <asm/compat-signal.h>
 41#include <asm/sim.h>
 42#include <asm/uaccess.h>
 43#include <asm/mmu_context.h>
 44#include <asm/mman.h>
 45
 46/* Use this to get at 32-bit user passed pointers. */
 47/* A() macro should be used for places where you e.g.
 48   have some internal variable u32 and just want to get
 49   rid of a compiler warning. AA() has to be used in
 50   places where you want to convert a function argument
 51   to 32bit pointer or when you e.g. access pt_regs
 52   structure and want to consider 32bit registers only.
 53 */
 54#define A(__x) ((unsigned long)(__x))
 55#define AA(__x) ((unsigned long)((int)__x))
 56
 57#ifdef __MIPSEB__
 58#define merge_64(r1, r2) ((((r1) & 0xffffffffUL) << 32) + ((r2) & 0xffffffffUL))
 59#endif
 60#ifdef __MIPSEL__
 61#define merge_64(r1, r2) ((((r2) & 0xffffffffUL) << 32) + ((r1) & 0xffffffffUL))
 62#endif
 63
 64SYSCALL_DEFINE6(32_mmap2, unsigned long, addr, unsigned long, len,
 65	unsigned long, prot, unsigned long, flags, unsigned long, fd,
 66	unsigned long, pgoff)
 67{
 68	unsigned long error;
 69
 70	error = -EINVAL;
 71	if (pgoff & (~PAGE_MASK >> 12))
 72		goto out;
 73	error = sys_mmap_pgoff(addr, len, prot, flags, fd,
 74			       pgoff >> (PAGE_SHIFT-12));
 75out:
 76	return error;
 77}
 78
 79#define RLIM_INFINITY32 0x7fffffff
 80#define RESOURCE32(x) ((x > RLIM_INFINITY32) ? RLIM_INFINITY32 : x)
 81
 82struct rlimit32 {
 83	int	rlim_cur;
 84	int	rlim_max;
 85};
 86
 87SYSCALL_DEFINE4(32_truncate64, const char __user *, path,
 88	unsigned long, __dummy, unsigned long, a2, unsigned long, a3)
 89{
 90	return sys_truncate(path, merge_64(a2, a3));
 91}
 92
 93SYSCALL_DEFINE4(32_ftruncate64, unsigned long, fd, unsigned long, __dummy,
 94	unsigned long, a2, unsigned long, a3)
 95{
 96	return sys_ftruncate(fd, merge_64(a2, a3));
 97}
 98
 99SYSCALL_DEFINE5(32_llseek, unsigned int, fd, unsigned int, offset_high,
100		unsigned int, offset_low, loff_t __user *, result,
101		unsigned int, origin)
102{
103	return sys_llseek(fd, offset_high, offset_low, result, origin);
104}
105
106/* From the Single Unix Spec: pread & pwrite act like lseek to pos + op +
107   lseek back to original location.  They fail just like lseek does on
108   non-seekable files.	*/
109
110SYSCALL_DEFINE6(32_pread, unsigned long, fd, char __user *, buf, size_t, count,
111	unsigned long, unused, unsigned long, a4, unsigned long, a5)
112{
113	return sys_pread64(fd, buf, count, merge_64(a4, a5));
114}
115
116SYSCALL_DEFINE6(32_pwrite, unsigned int, fd, const char __user *, buf,
117	size_t, count, u32, unused, u64, a4, u64, a5)
118{
119	return sys_pwrite64(fd, buf, count, merge_64(a4, a5));
120}
121
122SYSCALL_DEFINE1(32_personality, unsigned long, personality)
123{
124	unsigned int p = personality & 0xffffffff;
125	int ret;
126
127	if (personality(current->personality) == PER_LINUX32 &&
128	    personality(p) == PER_LINUX)
129		p = (p & ~PER_MASK) | PER_LINUX32;
130	ret = sys_personality(p);
131	if (ret != -1 && personality(ret) == PER_LINUX32)
132		ret = (ret & ~PER_MASK) | PER_LINUX;
133	return ret;
134}
135
136asmlinkage ssize_t sys32_readahead(int fd, u32 pad0, u64 a2, u64 a3,
137				   size_t count)
138{
139	return sys_readahead(fd, merge_64(a2, a3), count);
140}
141
142asmlinkage long sys32_sync_file_range(int fd, int __pad,
143	unsigned long a2, unsigned long a3,
144	unsigned long a4, unsigned long a5,
145	int flags)
146{
147	return sys_sync_file_range(fd,
148			merge_64(a2, a3), merge_64(a4, a5),
149			flags);
150}
151
152asmlinkage long sys32_fadvise64_64(int fd, int __pad,
153	unsigned long a2, unsigned long a3,
154	unsigned long a4, unsigned long a5,
155	int flags)
156{
157	return sys_fadvise64_64(fd,
158			merge_64(a2, a3), merge_64(a4, a5),
159			flags);
160}
161
162asmlinkage long sys32_fallocate(int fd, int mode, unsigned offset_a2,
163	unsigned offset_a3, unsigned len_a4, unsigned len_a5)
164{
165	return sys_fallocate(fd, mode, merge_64(offset_a2, offset_a3),
166			     merge_64(len_a4, len_a5));
167}
v6.8
  1// SPDX-License-Identifier: GPL-2.0
  2/*
  3 * Conversion between 32-bit and 64-bit native system calls.
  4 *
  5 * Copyright (C) 2000 Silicon Graphics, Inc.
  6 * Written by Ulf Carlsson (ulfc@engr.sgi.com)
  7 */
  8#include <linux/compiler.h>
  9#include <linux/mm.h>
 10#include <linux/errno.h>
 11#include <linux/file.h>
 12#include <linux/highuid.h>
 13#include <linux/resource.h>
 14#include <linux/highmem.h>
 15#include <linux/time.h>
 16#include <linux/times.h>
 17#include <linux/poll.h>
 18#include <linux/skbuff.h>
 19#include <linux/filter.h>
 20#include <linux/shm.h>
 21#include <linux/sem.h>
 22#include <linux/msg.h>
 23#include <linux/icmpv6.h>
 24#include <linux/syscalls.h>
 25#include <linux/sysctl.h>
 26#include <linux/utime.h>
 27#include <linux/utsname.h>
 28#include <linux/personality.h>
 29#include <linux/dnotify.h>
 
 30#include <linux/binfmts.h>
 31#include <linux/security.h>
 32#include <linux/compat.h>
 33#include <linux/vfs.h>
 34#include <linux/ipc.h>
 35#include <linux/slab.h>
 36
 37#include <net/sock.h>
 38#include <net/scm.h>
 39
 40#include <asm/compat-signal.h>
 41#include <asm/sim.h>
 42#include <linux/uaccess.h>
 43#include <asm/mmu_context.h>
 44#include <asm/mman.h>
 45#include <asm/syscalls.h>
 
 
 
 
 
 
 
 
 
 
 46
 47#ifdef __MIPSEB__
 48#define merge_64(r1, r2) ((((r1) & 0xffffffffUL) << 32) + ((r2) & 0xffffffffUL))
 49#endif
 50#ifdef __MIPSEL__
 51#define merge_64(r1, r2) ((((r2) & 0xffffffffUL) << 32) + ((r1) & 0xffffffffUL))
 52#endif
 53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 54SYSCALL_DEFINE4(32_truncate64, const char __user *, path,
 55	unsigned long, __dummy, unsigned long, a2, unsigned long, a3)
 56{
 57	return ksys_truncate(path, merge_64(a2, a3));
 58}
 59
 60SYSCALL_DEFINE4(32_ftruncate64, unsigned long, fd, unsigned long, __dummy,
 61	unsigned long, a2, unsigned long, a3)
 62{
 63	return ksys_ftruncate(fd, merge_64(a2, a3));
 64}
 65
 66SYSCALL_DEFINE5(32_llseek, unsigned int, fd, unsigned int, offset_high,
 67		unsigned int, offset_low, loff_t __user *, result,
 68		unsigned int, origin)
 69{
 70	return sys_llseek(fd, offset_high, offset_low, result, origin);
 71}
 72
 73/* From the Single Unix Spec: pread & pwrite act like lseek to pos + op +
 74   lseek back to original location.  They fail just like lseek does on
 75   non-seekable files.	*/
 76
 77SYSCALL_DEFINE6(32_pread, unsigned long, fd, char __user *, buf, size_t, count,
 78	unsigned long, unused, unsigned long, a4, unsigned long, a5)
 79{
 80	return ksys_pread64(fd, buf, count, merge_64(a4, a5));
 81}
 82
 83SYSCALL_DEFINE6(32_pwrite, unsigned int, fd, const char __user *, buf,
 84	size_t, count, u32, unused, u64, a4, u64, a5)
 85{
 86	return ksys_pwrite64(fd, buf, count, merge_64(a4, a5));
 87}
 88
 89SYSCALL_DEFINE1(32_personality, unsigned long, personality)
 90{
 91	unsigned int p = personality & 0xffffffff;
 92	int ret;
 93
 94	if (personality(current->personality) == PER_LINUX32 &&
 95	    personality(p) == PER_LINUX)
 96		p = (p & ~PER_MASK) | PER_LINUX32;
 97	ret = sys_personality(p);
 98	if (ret != -1 && personality(ret) == PER_LINUX32)
 99		ret = (ret & ~PER_MASK) | PER_LINUX;
100	return ret;
101}
102
103asmlinkage ssize_t sys32_readahead(int fd, u32 pad0, u64 a2, u64 a3,
104				   size_t count)
105{
106	return ksys_readahead(fd, merge_64(a2, a3), count);
107}
108
109asmlinkage long sys32_sync_file_range(int fd, int __pad,
110	unsigned long a2, unsigned long a3,
111	unsigned long a4, unsigned long a5,
112	int flags)
113{
114	return ksys_sync_file_range(fd,
115			merge_64(a2, a3), merge_64(a4, a5),
116			flags);
117}
118
119asmlinkage long sys32_fadvise64_64(int fd, int __pad,
120	unsigned long a2, unsigned long a3,
121	unsigned long a4, unsigned long a5,
122	int flags)
123{
124	return ksys_fadvise64_64(fd,
125			merge_64(a2, a3), merge_64(a4, a5),
126			flags);
127}
128
129asmlinkage long sys32_fallocate(int fd, int mode, unsigned offset_a2,
130	unsigned offset_a3, unsigned len_a4, unsigned len_a5)
131{
132	return ksys_fallocate(fd, mode, merge_64(offset_a2, offset_a3),
133			      merge_64(len_a4, len_a5));
134}