diff options
Diffstat (limited to 'meta/recipes-devtools/qemu/qemu/0009-linux-user-Replace-use-of-lfs64-related-functions-an.patch')
-rw-r--r-- | meta/recipes-devtools/qemu/qemu/0009-linux-user-Replace-use-of-lfs64-related-functions-an.patch | 358 |
1 files changed, 358 insertions, 0 deletions
diff --git a/meta/recipes-devtools/qemu/qemu/0009-linux-user-Replace-use-of-lfs64-related-functions-an.patch b/meta/recipes-devtools/qemu/qemu/0009-linux-user-Replace-use-of-lfs64-related-functions-an.patch new file mode 100644 index 0000000000..7577249d39 --- /dev/null +++ b/meta/recipes-devtools/qemu/qemu/0009-linux-user-Replace-use-of-lfs64-related-functions-an.patch | |||
@@ -0,0 +1,358 @@ | |||
1 | From 23de30079dbf47a8026faddd550a9e181d609c8f Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Sat, 17 Dec 2022 08:37:46 -0800 | ||
4 | Subject: [PATCH 09/11] linux-user: Replace use of lfs64 related functions and | ||
5 | macros | ||
6 | |||
7 | Builds defines -D_FILE_OFFSET_BITS=64 which makes the original functions | ||
8 | anf macros behave same as their 64 suffixed counterparts. This also | ||
9 | helps in compiling with latest musl C library, where these macros and | ||
10 | functions are no more available under _GNU_SOURCE feature macro | ||
11 | |||
12 | Upstream-Status: Submitted [https://lists.gnu.org/archive/html/qemu-devel/2022-12/msg02841.html] | ||
13 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
14 | Cc: Laurent Vivier <laurent@vivier.eu> | ||
15 | --- | ||
16 | linux-user/syscall.c | 153 +++++++++++-------------------------------- | ||
17 | 1 file changed, 39 insertions(+), 114 deletions(-) | ||
18 | |||
19 | diff --git a/linux-user/syscall.c b/linux-user/syscall.c | ||
20 | index 18f09f1f07..1b7c50a2a7 100644 | ||
21 | --- a/linux-user/syscall.c | ||
22 | +++ b/linux-user/syscall.c | ||
23 | @@ -761,8 +761,8 @@ safe_syscall6(ssize_t, copy_file_range, int, infd, loff_t *, pinoff, | ||
24 | */ | ||
25 | #define safe_ioctl(...) safe_syscall(__NR_ioctl, __VA_ARGS__) | ||
26 | /* Similarly for fcntl. Note that callers must always: | ||
27 | - * pass the F_GETLK64 etc constants rather than the unsuffixed F_GETLK | ||
28 | - * use the flock64 struct rather than unsuffixed flock | ||
29 | + * pass the F_GETLK etc constants rather than the unsuffixed F_GETLK | ||
30 | + * use the flock struct rather than unsuffixed flock | ||
31 | * This will then work and use a 64-bit offset for both 32-bit and 64-bit hosts. | ||
32 | */ | ||
33 | #ifdef __NR_fcntl64 | ||
34 | @@ -6739,13 +6739,13 @@ static int target_to_host_fcntl_cmd(int cmd) | ||
35 | ret = cmd; | ||
36 | break; | ||
37 | case TARGET_F_GETLK: | ||
38 | - ret = F_GETLK64; | ||
39 | + ret = F_GETLK; | ||
40 | break; | ||
41 | case TARGET_F_SETLK: | ||
42 | - ret = F_SETLK64; | ||
43 | + ret = F_SETLK; | ||
44 | break; | ||
45 | case TARGET_F_SETLKW: | ||
46 | - ret = F_SETLKW64; | ||
47 | + ret = F_SETLKW; | ||
48 | break; | ||
49 | case TARGET_F_GETOWN: | ||
50 | ret = F_GETOWN; | ||
51 | @@ -6759,17 +6759,6 @@ static int target_to_host_fcntl_cmd(int cmd) | ||
52 | case TARGET_F_SETSIG: | ||
53 | ret = F_SETSIG; | ||
54 | break; | ||
55 | -#if TARGET_ABI_BITS == 32 | ||
56 | - case TARGET_F_GETLK64: | ||
57 | - ret = F_GETLK64; | ||
58 | - break; | ||
59 | - case TARGET_F_SETLK64: | ||
60 | - ret = F_SETLK64; | ||
61 | - break; | ||
62 | - case TARGET_F_SETLKW64: | ||
63 | - ret = F_SETLKW64; | ||
64 | - break; | ||
65 | -#endif | ||
66 | case TARGET_F_SETLEASE: | ||
67 | ret = F_SETLEASE; | ||
68 | break; | ||
69 | @@ -6821,8 +6810,8 @@ static int target_to_host_fcntl_cmd(int cmd) | ||
70 | * them to 5, 6 and 7 before making the syscall(). Since we make the | ||
71 | * syscall directly, adjust to what is supported by the kernel. | ||
72 | */ | ||
73 | - if (ret >= F_GETLK64 && ret <= F_SETLKW64) { | ||
74 | - ret -= F_GETLK64 - 5; | ||
75 | + if (ret >= F_GETLK && ret <= F_SETLKW) { | ||
76 | + ret -= F_GETLK - 5; | ||
77 | } | ||
78 | #endif | ||
79 | |||
80 | @@ -6855,55 +6844,11 @@ static int host_to_target_flock(int type) | ||
81 | return type; | ||
82 | } | ||
83 | |||
84 | -static inline abi_long copy_from_user_flock(struct flock64 *fl, | ||
85 | - abi_ulong target_flock_addr) | ||
86 | -{ | ||
87 | - struct target_flock *target_fl; | ||
88 | - int l_type; | ||
89 | - | ||
90 | - if (!lock_user_struct(VERIFY_READ, target_fl, target_flock_addr, 1)) { | ||
91 | - return -TARGET_EFAULT; | ||
92 | - } | ||
93 | - | ||
94 | - __get_user(l_type, &target_fl->l_type); | ||
95 | - l_type = target_to_host_flock(l_type); | ||
96 | - if (l_type < 0) { | ||
97 | - return l_type; | ||
98 | - } | ||
99 | - fl->l_type = l_type; | ||
100 | - __get_user(fl->l_whence, &target_fl->l_whence); | ||
101 | - __get_user(fl->l_start, &target_fl->l_start); | ||
102 | - __get_user(fl->l_len, &target_fl->l_len); | ||
103 | - __get_user(fl->l_pid, &target_fl->l_pid); | ||
104 | - unlock_user_struct(target_fl, target_flock_addr, 0); | ||
105 | - return 0; | ||
106 | -} | ||
107 | - | ||
108 | -static inline abi_long copy_to_user_flock(abi_ulong target_flock_addr, | ||
109 | - const struct flock64 *fl) | ||
110 | -{ | ||
111 | - struct target_flock *target_fl; | ||
112 | - short l_type; | ||
113 | - | ||
114 | - if (!lock_user_struct(VERIFY_WRITE, target_fl, target_flock_addr, 0)) { | ||
115 | - return -TARGET_EFAULT; | ||
116 | - } | ||
117 | - | ||
118 | - l_type = host_to_target_flock(fl->l_type); | ||
119 | - __put_user(l_type, &target_fl->l_type); | ||
120 | - __put_user(fl->l_whence, &target_fl->l_whence); | ||
121 | - __put_user(fl->l_start, &target_fl->l_start); | ||
122 | - __put_user(fl->l_len, &target_fl->l_len); | ||
123 | - __put_user(fl->l_pid, &target_fl->l_pid); | ||
124 | - unlock_user_struct(target_fl, target_flock_addr, 1); | ||
125 | - return 0; | ||
126 | -} | ||
127 | - | ||
128 | -typedef abi_long from_flock64_fn(struct flock64 *fl, abi_ulong target_addr); | ||
129 | -typedef abi_long to_flock64_fn(abi_ulong target_addr, const struct flock64 *fl); | ||
130 | +typedef abi_long from_flock_fn(struct flock *fl, abi_ulong target_addr); | ||
131 | +typedef abi_long to_flock_fn(abi_ulong target_addr, const struct flock *fl); | ||
132 | |||
133 | #if defined(TARGET_ARM) && TARGET_ABI_BITS == 32 | ||
134 | -struct target_oabi_flock64 { | ||
135 | +struct target_oabi_flock { | ||
136 | abi_short l_type; | ||
137 | abi_short l_whence; | ||
138 | abi_llong l_start; | ||
139 | @@ -6911,10 +6856,10 @@ struct target_oabi_flock64 { | ||
140 | abi_int l_pid; | ||
141 | } QEMU_PACKED; | ||
142 | |||
143 | -static inline abi_long copy_from_user_oabi_flock64(struct flock64 *fl, | ||
144 | +static inline abi_long copy_from_user_oabi_flock(struct flock *fl, | ||
145 | abi_ulong target_flock_addr) | ||
146 | { | ||
147 | - struct target_oabi_flock64 *target_fl; | ||
148 | + struct target_oabi_flock *target_fl; | ||
149 | int l_type; | ||
150 | |||
151 | if (!lock_user_struct(VERIFY_READ, target_fl, target_flock_addr, 1)) { | ||
152 | @@ -6935,10 +6880,10 @@ static inline abi_long copy_from_user_oabi_flock64(struct flock64 *fl, | ||
153 | return 0; | ||
154 | } | ||
155 | |||
156 | -static inline abi_long copy_to_user_oabi_flock64(abi_ulong target_flock_addr, | ||
157 | - const struct flock64 *fl) | ||
158 | +static inline abi_long copy_to_user_oabi_flock(abi_ulong target_flock_addr, | ||
159 | + const struct flock *fl) | ||
160 | { | ||
161 | - struct target_oabi_flock64 *target_fl; | ||
162 | + struct target_oabi_flock *target_fl; | ||
163 | short l_type; | ||
164 | |||
165 | if (!lock_user_struct(VERIFY_WRITE, target_fl, target_flock_addr, 0)) { | ||
166 | @@ -6956,10 +6901,10 @@ static inline abi_long copy_to_user_oabi_flock64(abi_ulong target_flock_addr, | ||
167 | } | ||
168 | #endif | ||
169 | |||
170 | -static inline abi_long copy_from_user_flock64(struct flock64 *fl, | ||
171 | +static inline abi_long copy_from_user_flock(struct flock *fl, | ||
172 | abi_ulong target_flock_addr) | ||
173 | { | ||
174 | - struct target_flock64 *target_fl; | ||
175 | + struct target_flock *target_fl; | ||
176 | int l_type; | ||
177 | |||
178 | if (!lock_user_struct(VERIFY_READ, target_fl, target_flock_addr, 1)) { | ||
179 | @@ -6980,10 +6925,10 @@ static inline abi_long copy_from_user_flock64(struct flock64 *fl, | ||
180 | return 0; | ||
181 | } | ||
182 | |||
183 | -static inline abi_long copy_to_user_flock64(abi_ulong target_flock_addr, | ||
184 | - const struct flock64 *fl) | ||
185 | +static inline abi_long copy_to_user_flock(abi_ulong target_flock_addr, | ||
186 | + const struct flock *fl) | ||
187 | { | ||
188 | - struct target_flock64 *target_fl; | ||
189 | + struct target_flock *target_fl; | ||
190 | short l_type; | ||
191 | |||
192 | if (!lock_user_struct(VERIFY_WRITE, target_fl, target_flock_addr, 0)) { | ||
193 | @@ -7002,7 +6947,7 @@ static inline abi_long copy_to_user_flock64(abi_ulong target_flock_addr, | ||
194 | |||
195 | static abi_long do_fcntl(int fd, int cmd, abi_ulong arg) | ||
196 | { | ||
197 | - struct flock64 fl64; | ||
198 | + struct flock fl64; | ||
199 | #ifdef F_GETOWN_EX | ||
200 | struct f_owner_ex fox; | ||
201 | struct target_f_owner_ex *target_fox; | ||
202 | @@ -7015,6 +6960,7 @@ static abi_long do_fcntl(int fd, int cmd, abi_ulong arg) | ||
203 | |||
204 | switch(cmd) { | ||
205 | case TARGET_F_GETLK: | ||
206 | + case TARGET_F_OFD_GETLK: | ||
207 | ret = copy_from_user_flock(&fl64, arg); | ||
208 | if (ret) { | ||
209 | return ret; | ||
210 | @@ -7024,32 +6970,11 @@ static abi_long do_fcntl(int fd, int cmd, abi_ulong arg) | ||
211 | ret = copy_to_user_flock(arg, &fl64); | ||
212 | } | ||
213 | break; | ||
214 | - | ||
215 | case TARGET_F_SETLK: | ||
216 | case TARGET_F_SETLKW: | ||
217 | - ret = copy_from_user_flock(&fl64, arg); | ||
218 | - if (ret) { | ||
219 | - return ret; | ||
220 | - } | ||
221 | - ret = get_errno(safe_fcntl(fd, host_cmd, &fl64)); | ||
222 | - break; | ||
223 | - | ||
224 | - case TARGET_F_GETLK64: | ||
225 | - case TARGET_F_OFD_GETLK: | ||
226 | - ret = copy_from_user_flock64(&fl64, arg); | ||
227 | - if (ret) { | ||
228 | - return ret; | ||
229 | - } | ||
230 | - ret = get_errno(safe_fcntl(fd, host_cmd, &fl64)); | ||
231 | - if (ret == 0) { | ||
232 | - ret = copy_to_user_flock64(arg, &fl64); | ||
233 | - } | ||
234 | - break; | ||
235 | - case TARGET_F_SETLK64: | ||
236 | - case TARGET_F_SETLKW64: | ||
237 | case TARGET_F_OFD_SETLK: | ||
238 | case TARGET_F_OFD_SETLKW: | ||
239 | - ret = copy_from_user_flock64(&fl64, arg); | ||
240 | + ret = copy_from_user_flock(&fl64, arg); | ||
241 | if (ret) { | ||
242 | return ret; | ||
243 | } | ||
244 | @@ -7278,7 +7203,7 @@ static inline abi_long target_truncate64(CPUArchState *cpu_env, const char *arg1 | ||
245 | arg2 = arg3; | ||
246 | arg3 = arg4; | ||
247 | } | ||
248 | - return get_errno(truncate64(arg1, target_offset64(arg2, arg3))); | ||
249 | + return get_errno(truncate(arg1, target_offset64(arg2, arg3))); | ||
250 | } | ||
251 | #endif | ||
252 | |||
253 | @@ -7292,7 +7217,7 @@ static inline abi_long target_ftruncate64(CPUArchState *cpu_env, abi_long arg1, | ||
254 | arg2 = arg3; | ||
255 | arg3 = arg4; | ||
256 | } | ||
257 | - return get_errno(ftruncate64(arg1, target_offset64(arg2, arg3))); | ||
258 | + return get_errno(ftruncate(arg1, target_offset64(arg2, arg3))); | ||
259 | } | ||
260 | #endif | ||
261 | |||
262 | @@ -8667,7 +8592,7 @@ static int do_getdents(abi_long dirfd, abi_long arg2, abi_long count) | ||
263 | void *tdirp; | ||
264 | int hlen, hoff, toff; | ||
265 | int hreclen, treclen; | ||
266 | - off64_t prev_diroff = 0; | ||
267 | + off_t prev_diroff = 0; | ||
268 | |||
269 | hdirp = g_try_malloc(count); | ||
270 | if (!hdirp) { | ||
271 | @@ -8720,7 +8645,7 @@ static int do_getdents(abi_long dirfd, abi_long arg2, abi_long count) | ||
272 | * Return what we have, resetting the file pointer to the | ||
273 | * location of the first record not returned. | ||
274 | */ | ||
275 | - lseek64(dirfd, prev_diroff, SEEK_SET); | ||
276 | + lseek(dirfd, prev_diroff, SEEK_SET); | ||
277 | break; | ||
278 | } | ||
279 | |||
280 | @@ -8754,7 +8679,7 @@ static int do_getdents64(abi_long dirfd, abi_long arg2, abi_long count) | ||
281 | void *tdirp; | ||
282 | int hlen, hoff, toff; | ||
283 | int hreclen, treclen; | ||
284 | - off64_t prev_diroff = 0; | ||
285 | + off_t prev_diroff = 0; | ||
286 | |||
287 | hdirp = g_try_malloc(count); | ||
288 | if (!hdirp) { | ||
289 | @@ -8796,7 +8721,7 @@ static int do_getdents64(abi_long dirfd, abi_long arg2, abi_long count) | ||
290 | * Return what we have, resetting the file pointer to the | ||
291 | * location of the first record not returned. | ||
292 | */ | ||
293 | - lseek64(dirfd, prev_diroff, SEEK_SET); | ||
294 | + lseek(dirfd, prev_diroff, SEEK_SET); | ||
295 | break; | ||
296 | } | ||
297 | |||
298 | @@ -11527,7 +11452,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, | ||
299 | return -TARGET_EFAULT; | ||
300 | } | ||
301 | } | ||
302 | - ret = get_errno(pread64(arg1, p, arg3, target_offset64(arg4, arg5))); | ||
303 | + ret = get_errno(pread(arg1, p, arg3, target_offset64(arg4, arg5))); | ||
304 | unlock_user(p, arg2, ret); | ||
305 | return ret; | ||
306 | case TARGET_NR_pwrite64: | ||
307 | @@ -11544,7 +11469,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, | ||
308 | return -TARGET_EFAULT; | ||
309 | } | ||
310 | } | ||
311 | - ret = get_errno(pwrite64(arg1, p, arg3, target_offset64(arg4, arg5))); | ||
312 | + ret = get_errno(pwrite(arg1, p, arg3, target_offset64(arg4, arg5))); | ||
313 | unlock_user(p, arg2, 0); | ||
314 | return ret; | ||
315 | #endif | ||
316 | @@ -12404,14 +12329,14 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, | ||
317 | case TARGET_NR_fcntl64: | ||
318 | { | ||
319 | int cmd; | ||
320 | - struct flock64 fl; | ||
321 | - from_flock64_fn *copyfrom = copy_from_user_flock64; | ||
322 | - to_flock64_fn *copyto = copy_to_user_flock64; | ||
323 | + struct flock fl; | ||
324 | + from_flock_fn *copyfrom = copy_from_user_flock; | ||
325 | + to_flock_fn *copyto = copy_to_user_flock; | ||
326 | |||
327 | #ifdef TARGET_ARM | ||
328 | if (!cpu_env->eabi) { | ||
329 | - copyfrom = copy_from_user_oabi_flock64; | ||
330 | - copyto = copy_to_user_oabi_flock64; | ||
331 | + copyfrom = copy_from_user_oabi_flock; | ||
332 | + copyto = copy_to_user_oabi_flock; | ||
333 | } | ||
334 | #endif | ||
335 | |||
336 | @@ -12421,7 +12346,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, | ||
337 | } | ||
338 | |||
339 | switch(arg2) { | ||
340 | - case TARGET_F_GETLK64: | ||
341 | + case TARGET_F_GETLK: | ||
342 | ret = copyfrom(&fl, arg3); | ||
343 | if (ret) { | ||
344 | break; | ||
345 | @@ -12432,8 +12357,8 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, | ||
346 | } | ||
347 | break; | ||
348 | |||
349 | - case TARGET_F_SETLK64: | ||
350 | - case TARGET_F_SETLKW64: | ||
351 | + case TARGET_F_SETLK: | ||
352 | + case TARGET_F_SETLKW: | ||
353 | ret = copyfrom(&fl, arg3); | ||
354 | if (ret) { | ||
355 | break; | ||
356 | -- | ||
357 | 2.44.0 | ||
358 | |||