Skip to content

Commit ceabf6e

Browse files
committed
Merge tag 'linux-user-for-8.0-pull-request' of https://gitlab.com/laurent_vivier/qemu into staging
linux-user branch pull request 20230204 Implement execveat() un-parent OBJECT(cpu) when closing thread Revert fix for glibc >= 2.36 sys/mount.h Fix/update strace move target_flat.h to target subdirs Fix SO_ERROR return code of getsockopt() Fix /proc/cpuinfo output for hppa Add emulation for MADV_WIPEONFORK and MADV_KEEPONFORK in madvise() Implement SOL_ALG encryption support linux-user: Allow sendmsg() without IOV # -----BEGIN PGP SIGNATURE----- # # iQJGBAABCAAwFiEEzS913cjjpNwuT1Fz8ww4vT8vvjwFAmPeguUSHGxhdXJlbnRA # dml2aWVyLmV1AAoJEPMMOL0/L748tnQP/1A4eu33pLe4+tjBuDGt2zcGAVuz+wN9 # rcwN5BQgjILwfECfRsy9QIkC8+M496tLk4W7pNkW9x/GSpzBp9x0+066uUghsa1Q # c0bFU0FM8xpywEXvOrz3LvEWaWqeBV/R+XYMqKFaiBQXf/5kmmteei9guH42L3gV # a+d0s1cWT48TslTaga9ECbiPD9lK+yfW879+wRhex1/BetkJPzLU1hZB4vfC5YQo # XagcmLWiseT4U8uCysikOgKQE4g2bv1oJXUuYjBxW15s5/llg8e57dEboO7MFEPK # a9P3Hl1qiA5Ol3scF1I7WURmGP6UVfdhTYe1aKYHhKY7QVBVjbU7r/NkdQ3dR6Nv # db58Lkurnrf5dMksZk8+25F/fvJT0nZpnbipunZejetNjrDVPk19XK5E6kJf91hk # 3W3vOeWMp4QjThpqghnlQ3gm2XfVmCGSMIOywTKZ4/M/TP28+9zY7GZqQXQXCBMy # nJFahfVTCfiYaGAYGjlMe5CMOQ6tJ6lwxuTCl9O1X565ifMBNUj3rcte1FvO/i24 # Rk0/lQVO+tD9ImxHJrei0Y2C0xzo7V8kaB9+foAf6Ku91SY1X1FIOm81DEyAhK61 # Biv2zlNwUV0aCierrn3oLuDkviVaAg6FkLO9snPG+lQy2uxgyJJ2/Pv0OCZhniWI # 9WifjYZKAXDa # =AcC6 # -----END PGP SIGNATURE----- # gpg: Signature made Sat 04 Feb 2023 16:08:05 GMT # gpg: using RSA key CD2F75DDC8E3A4DC2E4F5173F30C38BD3F2FBE3C # gpg: issuer "[email protected]" # gpg: Good signature from "Laurent Vivier <[email protected]>" [full] # gpg: aka "Laurent Vivier <[email protected]>" [full] # gpg: aka "Laurent Vivier (Red Hat) <[email protected]>" [full] # Primary key fingerprint: CD2F 75DD C8E3 A4DC 2E4F 5173 F30C 38BD 3F2F BE3C * tag 'linux-user-for-8.0-pull-request' of https://gitlab.com/laurent_vivier/qemu: (22 commits) linux-user: Allow sendmsg() without IOV linux-user: Implement SOL_ALG encryption support linux-user: Enhance strace output for various syscalls linux-user: Show 4th argument of rt_sigprocmask() in strace linux-user: Add emulation for MADV_WIPEONFORK and MADV_KEEPONFORK in madvise() linux-user: Improve strace output of personality() and sysinfo() linux-user: Fix /proc/cpuinfo output for hppa linux-user: Fix SO_ERROR return code of getsockopt() linux-user: move target_flat.h to target subdirs linux-user: Improve strace output of getgroups() and setgroups() linux-user: Add strace output for clock_getres_time64() and futex_time64() Revert "linux-user: fix compat with glibc >= 2.36 sys/mount.h" Revert "linux-user: add more compat ioctl definitions" linux-user: add more netlink protocol constants linux-user: fix strace build w/out munlockall linux-user: un-parent OBJECT(cpu) when closing thread linux-user: Add missing MAP_HUGETLB and MAP_STACK flags in strace linux-user/syscall: Implement execveat() linux-user/syscall: Extract do_execve() from do_syscall1() linux-user/strace: Add output for execveat() syscall ... Signed-off-by: Peter Maydell <[email protected]>
2 parents 025274a + 3f0744f commit ceabf6e

File tree

11 files changed

+378
-250
lines changed

11 files changed

+378
-250
lines changed

linux-user/aarch64/target_flat.h

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include "../generic/target_flat.h"

linux-user/arm/target_flat.h

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include "../generic/target_flat.h"
File renamed without changes.

linux-user/m68k/target_flat.h

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include "../generic/target_flat.h"

linux-user/microblaze/target_flat.h

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include "../generic/target_flat.h"

linux-user/mmap.c

+43-13
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size,
857857
return new_addr;
858858
}
859859

860-
static bool can_passthrough_madv_dontneed(abi_ulong start, abi_ulong end)
860+
static bool can_passthrough_madvise(abi_ulong start, abi_ulong end)
861861
{
862862
ulong addr;
863863

@@ -901,23 +901,53 @@ abi_long target_madvise(abi_ulong start, abi_ulong len_in, int advice)
901901
return -TARGET_EINVAL;
902902
}
903903

904+
/* Translate for some architectures which have different MADV_xxx values */
905+
switch (advice) {
906+
case TARGET_MADV_DONTNEED: /* alpha */
907+
advice = MADV_DONTNEED;
908+
break;
909+
case TARGET_MADV_WIPEONFORK: /* parisc */
910+
advice = MADV_WIPEONFORK;
911+
break;
912+
case TARGET_MADV_KEEPONFORK: /* parisc */
913+
advice = MADV_KEEPONFORK;
914+
break;
915+
/* we do not care about the other MADV_xxx values yet */
916+
}
917+
904918
/*
905-
* A straight passthrough may not be safe because qemu sometimes turns
906-
* private file-backed mappings into anonymous mappings.
919+
* Most advice values are hints, so ignoring and returning success is ok.
920+
*
921+
* However, some advice values such as MADV_DONTNEED, MADV_WIPEONFORK and
922+
* MADV_KEEPONFORK are not hints and need to be emulated.
907923
*
908-
* This is a hint, so ignoring and returning success is ok.
924+
* A straight passthrough for those may not be safe because qemu sometimes
925+
* turns private file-backed mappings into anonymous mappings.
926+
* can_passthrough_madvise() helps to check if a passthrough is possible by
927+
* comparing mappings that are known to have the same semantics in the host
928+
* and the guest. In this case passthrough is safe.
909929
*
910-
* This breaks MADV_DONTNEED, completely implementing which is quite
911-
* complicated. However, there is one low-hanging fruit: mappings that are
912-
* known to have the same semantics in the host and the guest. In this case
913-
* passthrough is safe, so do it.
930+
* We pass through MADV_WIPEONFORK and MADV_KEEPONFORK if possible and
931+
* return failure if not.
932+
*
933+
* MADV_DONTNEED is passed through as well, if possible.
934+
* If passthrough isn't possible, we nevertheless (wrongly!) return
935+
* success, which is broken but some userspace programs fail to work
936+
* otherwise. Completely implementing such emulation is quite complicated
937+
* though.
914938
*/
915939
mmap_lock();
916-
if (advice == TARGET_MADV_DONTNEED &&
917-
can_passthrough_madv_dontneed(start, end)) {
918-
ret = get_errno(madvise(g2h_untagged(start), len, MADV_DONTNEED));
919-
if (ret == 0) {
920-
page_reset_target_data(start, start + len);
940+
switch (advice) {
941+
case MADV_WIPEONFORK:
942+
case MADV_KEEPONFORK:
943+
ret = -EINVAL;
944+
/* fall through */
945+
case MADV_DONTNEED:
946+
if (can_passthrough_madvise(start, end)) {
947+
ret = get_errno(madvise(g2h_untagged(start), len, advice));
948+
if ((advice == MADV_DONTNEED) && (ret == 0)) {
949+
page_reset_target_data(start, start + len);
950+
}
921951
}
922952
}
923953
mmap_unlock();

linux-user/sh4/target_flat.h

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include "../generic/target_flat.h"

0 commit comments

Comments
 (0)