|
1 | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
2 | 2 | /* |
3 | | - * sys_ppc32.c: Conversion between 32bit and 64bit native syscalls. |
| 3 | + * sys_ppc32.c: 32-bit system calls with complex calling conventions. |
4 | 4 | * |
5 | 5 | * Copyright (C) 2001 IBM |
6 | 6 | * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz) |
7 | 7 | * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu) |
8 | 8 | * |
9 | | - * These routines maintain argument size conversion between 32bit and 64bit |
10 | | - * environment. |
| 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. |
| 13 | + * |
| 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 |
| 18 | + * arguments. |
| 19 | + * |
| 20 | + * This file contains these system calls. |
11 | 21 | */ |
12 | 22 |
|
13 | 23 | #include <linux/kernel.h> |
|
47 | 57 | #include <asm/syscalls.h> |
48 | 58 | #include <asm/switch_to.h> |
49 | 59 |
|
50 | | -COMPAT_SYSCALL_DEFINE6(ppc_pread64, |
| 60 | +#ifdef CONFIG_PPC32 |
| 61 | +#define PPC32_SYSCALL_DEFINE4 SYSCALL_DEFINE4 |
| 62 | +#define PPC32_SYSCALL_DEFINE5 SYSCALL_DEFINE5 |
| 63 | +#define PPC32_SYSCALL_DEFINE6 SYSCALL_DEFINE6 |
| 64 | +#else |
| 65 | +#define PPC32_SYSCALL_DEFINE4 COMPAT_SYSCALL_DEFINE4 |
| 66 | +#define PPC32_SYSCALL_DEFINE5 COMPAT_SYSCALL_DEFINE5 |
| 67 | +#define PPC32_SYSCALL_DEFINE6 COMPAT_SYSCALL_DEFINE6 |
| 68 | +#endif |
| 69 | + |
| 70 | +PPC32_SYSCALL_DEFINE6(ppc_pread64, |
51 | 71 | unsigned int, fd, |
52 | 72 | char __user *, ubuf, compat_size_t, count, |
53 | 73 | u32, reg6, u32, pos1, u32, pos2) |
54 | 74 | { |
55 | 75 | return ksys_pread64(fd, ubuf, count, merge_64(pos1, pos2)); |
56 | 76 | } |
57 | 77 |
|
58 | | -COMPAT_SYSCALL_DEFINE6(ppc_pwrite64, |
| 78 | +PPC32_SYSCALL_DEFINE6(ppc_pwrite64, |
59 | 79 | unsigned int, fd, |
60 | 80 | const char __user *, ubuf, compat_size_t, count, |
61 | 81 | u32, reg6, u32, pos1, u32, pos2) |
62 | 82 | { |
63 | 83 | return ksys_pwrite64(fd, ubuf, count, merge_64(pos1, pos2)); |
64 | 84 | } |
65 | 85 |
|
66 | | -COMPAT_SYSCALL_DEFINE5(ppc_readahead, |
| 86 | +PPC32_SYSCALL_DEFINE5(ppc_readahead, |
67 | 87 | int, fd, u32, r4, |
68 | 88 | u32, offset1, u32, offset2, u32, count) |
69 | 89 | { |
70 | 90 | return ksys_readahead(fd, merge_64(offset1, offset2), count); |
71 | 91 | } |
72 | 92 |
|
73 | | -COMPAT_SYSCALL_DEFINE4(ppc_truncate64, |
| 93 | +PPC32_SYSCALL_DEFINE4(ppc_truncate64, |
74 | 94 | const char __user *, path, u32, reg4, |
75 | 95 | unsigned long, len1, unsigned long, len2) |
76 | 96 | { |
77 | 97 | return ksys_truncate(path, merge_64(len1, len2)); |
78 | 98 | } |
79 | 99 |
|
80 | | -COMPAT_SYSCALL_DEFINE4(ppc_ftruncate64, |
| 100 | +PPC32_SYSCALL_DEFINE4(ppc_ftruncate64, |
81 | 101 | unsigned int, fd, u32, reg4, |
82 | 102 | unsigned long, len1, unsigned long, len2) |
83 | 103 | { |
84 | 104 | return ksys_ftruncate(fd, merge_64(len1, len2)); |
85 | 105 | } |
86 | 106 |
|
87 | | -COMPAT_SYSCALL_DEFINE6(ppc32_fadvise64, |
| 107 | +PPC32_SYSCALL_DEFINE6(ppc32_fadvise64, |
88 | 108 | int, fd, u32, unused, u32, offset1, u32, offset2, |
89 | 109 | size_t, len, int, advice) |
90 | 110 | { |
|
0 commit comments