xref: /linux/arch/powerpc/kernel/sys_ppc32.c (revision 81895a65ec63ee1daec3255dc1a06675d2fbe915)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * sys_ppc32.c: Conversion between 32bit and 64bit native syscalls.
4  *
5  * Copyright (C) 2001 IBM
6  * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
7  * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
8  *
9  * These routines maintain argument size conversion between 32bit and 64bit
10  * environment.
11  */
12 
13 #include <linux/kernel.h>
14 #include <linux/sched.h>
15 #include <linux/fs.h>
16 #include <linux/mm.h>
17 #include <linux/file.h>
18 #include <linux/signal.h>
19 #include <linux/resource.h>
20 #include <linux/times.h>
21 #include <linux/smp.h>
22 #include <linux/sem.h>
23 #include <linux/msg.h>
24 #include <linux/shm.h>
25 #include <linux/poll.h>
26 #include <linux/personality.h>
27 #include <linux/stat.h>
28 #include <linux/in.h>
29 #include <linux/syscalls.h>
30 #include <linux/unistd.h>
31 #include <linux/sysctl.h>
32 #include <linux/binfmts.h>
33 #include <linux/security.h>
34 #include <linux/compat.h>
35 #include <linux/ptrace.h>
36 #include <linux/elf.h>
37 #include <linux/ipc.h>
38 #include <linux/slab.h>
39 
40 #include <asm/ptrace.h>
41 #include <asm/types.h>
42 #include <linux/uaccess.h>
43 #include <asm/unistd.h>
44 #include <asm/time.h>
45 #include <asm/mmu_context.h>
46 #include <asm/ppc-pci.h>
47 #include <asm/syscalls.h>
48 #include <asm/switch_to.h>
49 
50 COMPAT_SYSCALL_DEFINE6(ppc_pread64,
51 		       unsigned int, fd,
52 		       char __user *, ubuf, compat_size_t, count,
53 		       u32, reg6, u32, pos1, u32, pos2)
54 {
55 	return ksys_pread64(fd, ubuf, count, merge_64(pos1, pos2));
56 }
57 
58 COMPAT_SYSCALL_DEFINE6(ppc_pwrite64,
59 		       unsigned int, fd,
60 		       const char __user *, ubuf, compat_size_t, count,
61 		       u32, reg6, u32, pos1, u32, pos2)
62 {
63 	return ksys_pwrite64(fd, ubuf, count, merge_64(pos1, pos2));
64 }
65 
66 COMPAT_SYSCALL_DEFINE5(ppc_readahead,
67 		       int, fd, u32, r4,
68 		       u32, offset1, u32, offset2, u32, count)
69 {
70 	return ksys_readahead(fd, merge_64(offset1, offset2), count);
71 }
72 
73 COMPAT_SYSCALL_DEFINE4(ppc_truncate64,
74 		       const char __user *, path, u32, reg4,
75 		       unsigned long, len1, unsigned long, len2)
76 {
77 	return ksys_truncate(path, merge_64(len1, len2));
78 }
79 
80 COMPAT_SYSCALL_DEFINE4(ppc_ftruncate64,
81 		       unsigned int, fd, u32, reg4,
82 		       unsigned long, len1, unsigned long, len2)
83 {
84 	return ksys_ftruncate(fd, merge_64(len1, len2));
85 }
86 
87 COMPAT_SYSCALL_DEFINE6(ppc32_fadvise64,
88 		       int, fd, u32, unused, u32, offset1, u32, offset2,
89 		       size_t, len, int, advice)
90 {
91 	return ksys_fadvise64_64(fd, merge_64(offset1, offset2), len,
92 				 advice);
93 }
94 
95 COMPAT_SYSCALL_DEFINE6(ppc_sync_file_range2,
96 		       int, fd, unsigned int, flags,
97 		       unsigned int, offset1, unsigned int, offset2,
98 		       unsigned int, nbytes1, unsigned int, nbytes2)
99 {
100 	loff_t offset = merge_64(offset1, offset2);
101 	loff_t nbytes = merge_64(nbytes1, nbytes2);
102 
103 	return ksys_sync_file_range(fd, offset, nbytes, flags);
104 }
105