linux-user: Do not treat madvise()'s advice as a bitmask
PATCH 1/1 linux-user: Do not treat madvise()'s advice as a bitmask
Advice is enum, not flags. Doing (advice & MADV_DONTNEED) also matches e.g. MADV_MERGEABLE.
Signed-off-by Ilya Leoshkevich <[email protected]>
--- linux-user/mmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/mmap.c +1 -1
@@ -891,7 +891,7 @@ abi_long target_madvise(abi_ulong start, abi_ulong len_in, int advice)* anonymous mappings. In this case passthrough is safe, so do it. */ mmap_lock (); -if ((advice &MADV_DONTNEED ) && +if (advice ==MADV_DONTNEED &&can_passthrough_madv_dontneed (start, end)) { ret =get_errno (madvise (g2h_untagged (start), len,MADV_DONTNEED )); }
Signature · 1 line
2.35.3
Le 25/07/2022 à 15:41, Ilya Leoshkevich a écrit :
Quoted 13 lines
Advice is enum, not flags. Doing (advice &
MADV_DONTNEED) also matches e.g.MADV_MERGEABLE.Signed-off-by Ilya Leoshkevich <[email protected]>--- linux-user/mmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)linux-user/mmap.c +0
-0
linux-user/mmap.c abi_long target_madvise(abi_ulong start, abi_ulong len_in, int advice) · line 897
Quoted 8 lines
linux-user/mmap.c +1
-1@@ -891,7 +891,7 @@ abi_long target_madvise(abi_ulong start, abi_ulong len_in, int advice)* anonymous mappings. In this case passthrough is safe, so do it. */ mmap_lock (); -if ((advice &MADV_DONTNEED ) && +if (advice ==MADV_DONTNEED &&can_passthrough_madv_dontneed (start, end)) { ret =get_errno (madvise (g2h_untagged (start), len,MADV_DONTNEED )); }
Fixes 892a4f6a750a ("linux-user: Add partial support for MADV_DONTNEED")
Reviewed-by Laurent Vivier <[email protected]>
Laurent Vivier
AppliedLe 25/07/2022 à 15:41, Ilya Leoshkevich a écrit :
Quoted 13 lines
Advice is enum, not flags. Doing (advice &
MADV_DONTNEED) also matches e.g.MADV_MERGEABLE.Signed-off-by Ilya Leoshkevich <[email protected]>--- linux-user/mmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)linux-user/mmap.c +0
-0
linux-user/mmap.c abi_long target_madvise(abi_ulong start, abi_ulong len_in, int advice) · line 897
Quoted 8 lines
linux-user/mmap.c +1
-1@@ -891,7 +891,7 @@ abi_long target_madvise(abi_ulong start, abi_ulong len_in, int advice)* anonymous mappings. In this case passthrough is safe, so do it. */ mmap_lock (); -if ((advice &MADV_DONTNEED ) && +if (advice ==MADV_DONTNEED &&can_passthrough_madv_dontneed (start, end)) { ret =get_errno (madvise (g2h_untagged (start), len,MADV_DONTNEED )); }
Applied to my linux-user-for-7.1 branch.
Thanks,
Laurent