diff options
author | Khem Raj <raj.khem@gmail.com> | 2022-12-21 09:55:51 -0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-12-22 23:05:50 +0000 |
commit | dfd4944fc15a713c9ca2dc35a94b5fc026a4f3b6 (patch) | |
tree | cf8719271b3c9e825bb78bd658cce42b6483d6db /meta/recipes-devtools/qemu/qemu | |
parent | 556f09df23ad77f91cd48757fb89980750d2c489 (diff) | |
download | poky-dfd4944fc15a713c9ca2dc35a94b5fc026a4f3b6.tar.gz |
qemu: Fix build with largefile support
drop using lfs64 specific functions and macros
(From OE-Core rev: 82fd98d6d8de17424ed9f129a1661645253ef7ae)
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/qemu/qemu')
2 files changed, 395 insertions, 0 deletions
diff --git a/meta/recipes-devtools/qemu/qemu/0001-contrib-vhost-user-blk-Replace-lseek64-with-lseek.patch b/meta/recipes-devtools/qemu/qemu/0001-contrib-vhost-user-blk-Replace-lseek64-with-lseek.patch new file mode 100644 index 0000000000..1838c88f0e --- /dev/null +++ b/meta/recipes-devtools/qemu/qemu/0001-contrib-vhost-user-blk-Replace-lseek64-with-lseek.patch | |||
@@ -0,0 +1,37 @@ | |||
1 | From 38f5c88bf296dbbc04dcd57f36d64695055a2d3f Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Fri, 16 Dec 2022 20:19:49 -0800 | ||
4 | Subject: [PATCH 1/2] contrib/vhost-user-blk: Replace lseek64 with lseek | ||
5 | |||
6 | 64bit off_t is already in use since build uses _FILE_OFFSET_BITS=64 | ||
7 | already. Using lseek/off_t also makes it work with latest must without | ||
8 | using _LARGEFILE64_SOURCE macro. This macro is implied with _GNU_SOURCE | ||
9 | when using glibc but not with musl. | ||
10 | |||
11 | Upstream-Status: Submitted [https://lists.gnu.org/archive/html/qemu-devel/2022-12/msg02840.html] | ||
12 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
13 | Cc: Michael S. Tsirkin <mst@redhat.com> | ||
14 | CC: Raphael Norwitz <raphael.norwitz@nutanix.com> | ||
15 | --- | ||
16 | contrib/vhost-user-blk/vhost-user-blk.c | 4 ++-- | ||
17 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
18 | |||
19 | diff --git a/contrib/vhost-user-blk/vhost-user-blk.c b/contrib/vhost-user-blk/vhost-user-blk.c | ||
20 | index aa99877fcd..7941694e53 100644 | ||
21 | --- a/contrib/vhost-user-blk/vhost-user-blk.c | ||
22 | +++ b/contrib/vhost-user-blk/vhost-user-blk.c | ||
23 | @@ -532,9 +532,9 @@ vub_get_blocksize(int fd) | ||
24 | static void | ||
25 | vub_initialize_config(int fd, struct virtio_blk_config *config) | ||
26 | { | ||
27 | - off64_t capacity; | ||
28 | + off_t capacity; | ||
29 | |||
30 | - capacity = lseek64(fd, 0, SEEK_END); | ||
31 | + capacity = lseek(fd, 0, SEEK_END); | ||
32 | config->capacity = capacity >> 9; | ||
33 | config->blk_size = vub_get_blocksize(fd); | ||
34 | config->size_max = 65536; | ||
35 | -- | ||
36 | 2.39.0 | ||
37 | |||
diff --git a/meta/recipes-devtools/qemu/qemu/0002-linux-user-Replace-use-of-lfs64-related-functions-an.patch b/meta/recipes-devtools/qemu/qemu/0002-linux-user-Replace-use-of-lfs64-related-functions-an.patch new file mode 100644 index 0000000000..14b5338eb2 --- /dev/null +++ b/meta/recipes-devtools/qemu/qemu/0002-linux-user-Replace-use-of-lfs64-related-functions-an.patch | |||
@@ -0,0 +1,358 @@ | |||
1 | From 71f14902256e3c3529710b713e1ea43100bf4c40 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 2/2] 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 1f8c10f8ef..30d83ed162 100644 | ||
21 | --- a/linux-user/syscall.c | ||
22 | +++ b/linux-user/syscall.c | ||
23 | @@ -795,8 +795,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 | @@ -6797,13 +6797,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 | @@ -6817,17 +6817,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 | @@ -6879,8 +6868,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 | @@ -6913,55 +6902,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 | @@ -6969,10 +6914,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 | @@ -6993,10 +6938,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 | @@ -7014,10 +6959,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 | @@ -7038,10 +6983,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 | @@ -7060,7 +7005,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 | @@ -7073,6 +7018,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 | @@ -7082,32 +7028,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 | @@ -7332,7 +7257,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 | @@ -7346,7 +7271,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 | @@ -8452,7 +8377,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 | @@ -8505,7 +8430,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 | @@ -8539,7 +8464,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 | @@ -8581,7 +8506,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 | @@ -11114,7 +11039,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 | @@ -11131,7 +11056,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 | @@ -11954,14 +11879,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 | @@ -11971,7 +11896,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 | @@ -11982,8 +11907,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.39.0 | ||
358 | |||