1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * sys_ppc32.c: 32-bit system calls with complex calling conventions.
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)
9 * 32-bit system calls with 64-bit arguments pass those in register pairs.
10 * This must be specially dealt with on 64-bit kernels. The compat_arg_u64_dual
11 * in generic compat syscalls is not always usable because the register
12 * pairing is constrained depending on preceding arguments.
14 * An analogous problem exists on 32-bit kernels with ARCH_HAS_SYSCALL_WRAPPER,
15 * the defined system call functions take the pt_regs as an argument, and there
16 * is a mapping macro which maps registers to arguments
17 * (SC_POWERPC_REGS_TO_ARGS) which also does not deal with these 64-bit
20 * This file contains these system calls.
23 #include <linux/kernel.h>
24 #include <linux/sched.h>
27 #include <linux/file.h>
28 #include <linux/signal.h>
29 #include <linux/resource.h>
30 #include <linux/times.h>
31 #include <linux/smp.h>
32 #include <linux/sem.h>
33 #include <linux/msg.h>
34 #include <linux/shm.h>
35 #include <linux/poll.h>
36 #include <linux/personality.h>
37 #include <linux/stat.h>
39 #include <linux/syscalls.h>
40 #include <linux/unistd.h>
41 #include <linux/sysctl.h>
42 #include <linux/binfmts.h>
43 #include <linux/security.h>
44 #include <linux/compat.h>
45 #include <linux/ptrace.h>
46 #include <linux/elf.h>
47 #include <linux/ipc.h>
48 #include <linux/slab.h>
50 #include <asm/ptrace.h>
51 #include <asm/types.h>
52 #include <linux/uaccess.h>
53 #include <asm/unistd.h>
55 #include <asm/mmu_context.h>
56 #include <asm/ppc-pci.h>
57 #include <asm/syscalls.h>
58 #include <asm/switch_to.h>
61 #define PPC32_SYSCALL_DEFINE4 SYSCALL_DEFINE4
62 #define PPC32_SYSCALL_DEFINE5 SYSCALL_DEFINE5
63 #define PPC32_SYSCALL_DEFINE6 SYSCALL_DEFINE6
65 #define PPC32_SYSCALL_DEFINE4 COMPAT_SYSCALL_DEFINE4
66 #define PPC32_SYSCALL_DEFINE5 COMPAT_SYSCALL_DEFINE5
67 #define PPC32_SYSCALL_DEFINE6 COMPAT_SYSCALL_DEFINE6
70 PPC32_SYSCALL_DEFINE6(ppc_pread64
,
72 char __user
*, ubuf
, compat_size_t
, count
,
73 u32
, reg6
, u32
, pos1
, u32
, pos2
)
75 return ksys_pread64(fd
, ubuf
, count
, merge_64(pos1
, pos2
));
78 PPC32_SYSCALL_DEFINE6(ppc_pwrite64
,
80 const char __user
*, ubuf
, compat_size_t
, count
,
81 u32
, reg6
, u32
, pos1
, u32
, pos2
)
83 return ksys_pwrite64(fd
, ubuf
, count
, merge_64(pos1
, pos2
));
86 PPC32_SYSCALL_DEFINE5(ppc_readahead
,
88 u32
, offset1
, u32
, offset2
, u32
, count
)
90 return ksys_readahead(fd
, merge_64(offset1
, offset2
), count
);
93 PPC32_SYSCALL_DEFINE4(ppc_truncate64
,
94 const char __user
*, path
, u32
, reg4
,
95 unsigned long, len1
, unsigned long, len2
)
97 return ksys_truncate(path
, merge_64(len1
, len2
));
100 PPC32_SYSCALL_DEFINE4(ppc_ftruncate64
,
101 unsigned int, fd
, u32
, reg4
,
102 unsigned long, len1
, unsigned long, len2
)
104 return ksys_ftruncate(fd
, merge_64(len1
, len2
));
107 PPC32_SYSCALL_DEFINE6(ppc32_fadvise64
,
108 int, fd
, u32
, unused
, u32
, offset1
, u32
, offset2
,
109 size_t, len
, int, advice
)
111 return ksys_fadvise64_64(fd
, merge_64(offset1
, offset2
), len
,
115 PPC32_SYSCALL_DEFINE6(ppc_sync_file_range2
,
116 int, fd
, unsigned int, flags
,
117 unsigned int, offset1
, unsigned int, offset2
,
118 unsigned int, nbytes1
, unsigned int, nbytes2
)
120 loff_t offset
= merge_64(offset1
, offset2
);
121 loff_t nbytes
= merge_64(nbytes1
, nbytes2
);
123 return ksys_sync_file_range(fd
, offset
, nbytes
, flags
);
127 SYSCALL_DEFINE6(ppc_fallocate
,
129 u32
, offset1
, u32
, offset2
, u32
, len1
, u32
, len2
)
131 return ksys_fallocate(fd
, mode
,
132 merge_64(offset1
, offset2
),
133 merge_64(len1
, len2
));