diff options
author | Eugene Syromyatnikov <evgsyr@gmail.com> | 2023-04-30 15:53:58 +0200 |
---|---|---|
committer | Dmitry V. Levin <ldv@strace.io> | 2023-04-30 14:41:13 +0000 |
commit | 5bfbcdc03ba59c03c13e0241ee9bad3e411aca0c (patch) | |
tree | 434a7fb57724fae784cfea5c280fe7a7a9a30e8a /src/xlat | |
parent | afa50399904c71460bc8ca9f2446b58265b72b12 (diff) | |
download | strace-5bfbcdc03ba59c03c13e0241ee9bad3e411aca0c.tar.gz |
mem: handle hppa MADV_* UAPI breakage
Linux commit v6.2-rc1~39^2~7 has broken UAPI on PA-RISC by changing
the values of some MADV_* constants; that forces some special handling
for them, since we cannot have any assumptions about the version
of the kernel headers and/or kernel both strace and tracees are built
and/or being run on.
* src/mem.c: Include "xlat/madvise_hppa_generic_cmds.h".
[HPPA]: Include "xlat/madvise_hppa_old_cmds.h".
(SYS_FUNC(madvise)) <advice>: New local variable, set to tcp->u_arg[2].
[HPPA] (SYS_FUNC(madvise)): Check madvise_hppa_old_cmds for the advice
value and print it appropriately if it is there; then check
madvise_hppa_generic_cmds and print it appropriately if it is there;
then fallback to printing advice as madvise_cmds xval.
[!HPPA] (SYS_FUNC(madvise)): Print advice as madvise_cmds
and madvise_hppa_generic_cmds xval.
* src/xlat/madvise_cmds.in: Add sorted; remove "Generated ..." comment;
move hppa-specific values to madvise_hppa_old_cmds.in and their generic
counterparts to madvise_hppa_generic_cmds.in.
* src/xlat/madvise_hppa_generic_cmds.in: New file.
* src/xlat/madvise_hppa_old_cmds.in: Likewise.
* tests/.gitignore: Add madvise-Xabbrev, madvise-Xraw,
and madvise-Xverbose.
* tests/pure_executables.list: Likewise.
* tests/gen_tests.in (advise-Xabbrev, madvise-Xraw, madvise-Xverbos):
New tests.
* tests/madvise.c: Add checks for the advice argument decoding.
* tests/madvise-Xabbrev.c: New file.
* tests/madvise-Xraw.c: Likewise.
* tests/madvise-Xverbose.c: Likewise.
* NEWS: Mention it.
Reported-by: Matoro Mahri <matoro@users.noreply.github.com>
Closes: https://github.com/strace/strace/issues/241
Diffstat (limited to 'src/xlat')
-rw-r--r-- | src/xlat/madvise_cmds.in | 111 | ||||
-rw-r--r-- | src/xlat/madvise_hppa_generic_cmds.in | 16 | ||||
-rw-r--r-- | src/xlat/madvise_hppa_old_cmds.in | 12 |
3 files changed, 54 insertions, 85 deletions
diff --git a/src/xlat/madvise_cmds.in b/src/xlat/madvise_cmds.in index 8a1f9d8e2..decae9bf5 100644 --- a/src/xlat/madvise_cmds.in +++ b/src/xlat/madvise_cmds.in @@ -1,91 +1,32 @@ -/* Generated by maint/gen_xlat_defs.sh -f 'd' -p 'MADV_' -c 'asm-generic/mman-common.h' -a 'asm/mman.h' */ - -MADV_NORMAL 0 - -MADV_RANDOM 1 - -MADV_SEQUENTIAL 2 - -MADV_WILLNEED 3 +#sorted +MADV_NORMAL 0 +MADV_RANDOM 1 +MADV_SEQUENTIAL 2 +MADV_WILLNEED 3 #if defined __alpha__ -MADV_DONTNEED 6 -#else -MADV_DONTNEED 4 -#endif - -MADV_FREE 8 - -MADV_REMOVE 9 - -MADV_DONTFORK 10 - -MADV_DOFORK 11 - -#if defined __hppa__ -MADV_MERGEABLE 65 -#else -MADV_MERGEABLE 12 -#endif - -#if defined __hppa__ -MADV_UNMERGEABLE 66 -#else -MADV_UNMERGEABLE 13 -#endif - -#if defined __hppa__ -MADV_HUGEPAGE 67 -#else -MADV_HUGEPAGE 14 -#endif - -#if defined __hppa__ -MADV_NOHUGEPAGE 68 -#else -MADV_NOHUGEPAGE 15 -#endif - -#if defined __hppa__ -MADV_DONTDUMP 69 -#else -MADV_DONTDUMP 16 -#endif - -#if defined __hppa__ -MADV_DODUMP 70 -#else -MADV_DODUMP 17 -#endif - -#if defined __hppa__ -MADV_WIPEONFORK 71 -#else -MADV_WIPEONFORK 18 -#endif - -#if defined __hppa__ -MADV_KEEPONFORK 72 -#else -MADV_KEEPONFORK 19 -#endif - -MADV_COLD 20 - -MADV_PAGEOUT 21 - +MADV_DONTNEED 6 +#else +MADV_DONTNEED 4 +#endif + +MADV_FREE 8 +MADV_REMOVE 9 +MADV_DONTFORK 10 +MADV_DOFORK 11 +/* MADV_MERGEABLE 12 - see madvise_hppa_generic_cmds */ +/* MADV_UNMERGEABLE 13 - see madvise_hppa_generic_cmds */ +/* MADV_HUGEPAGE 14 - see madvise_hppa_generic_cmds */ +/* MADV_NOHUGEPAGE 15 - see madvise_hppa_generic_cmds */ +/* MADV_DONTDUMP 16 - see madvise_hppa_generic_cmds */ +/* MADV_DODUMP 17 - see madvise_hppa_generic_cmds */ +/* MADV_WIPEONFORK 18 - see madvise_hppa_generic_cmds */ +/* MADV_KEEPONFORK 19 - see madvise_hppa_generic_cmds */ +MADV_COLD 20 +MADV_PAGEOUT 21 MADV_POPULATE_READ 22 - MADV_POPULATE_WRITE 23 - MADV_DONTNEED_LOCKED 24 - -#if defined __hppa__ -MADV_COLLAPSE 73 -#else -MADV_COLLAPSE 25 -#endif - -MADV_HWPOISON 100 - +/* MADV_COLLAPSE 25 - see madvise_hppa_generic_cmds */ +MADV_HWPOISON 100 MADV_SOFT_OFFLINE 101 diff --git a/src/xlat/madvise_hppa_generic_cmds.in b/src/xlat/madvise_hppa_generic_cmds.in new file mode 100644 index 000000000..9740cab9b --- /dev/null +++ b/src/xlat/madvise_hppa_generic_cmds.in @@ -0,0 +1,16 @@ +#unconditional +#nocheckval +/* + * These values are used on hppa since v6.2-rc1~39^2~7 + * and on other architectures since their introduction; + * see madvise_hppa_old_cmds for the old values. + */ +MADV_MERGEABLE 12 +MADV_UNMERGEABLE 13 +MADV_HUGEPAGE 14 +MADV_NOHUGEPAGE 15 +MADV_DONTDUMP 16 +MADV_DODUMP 17 +MADV_WIPEONFORK 18 +MADV_KEEPONFORK 19 +MADV_COLLAPSE 25 diff --git a/src/xlat/madvise_hppa_old_cmds.in b/src/xlat/madvise_hppa_old_cmds.in new file mode 100644 index 000000000..b939fbba6 --- /dev/null +++ b/src/xlat/madvise_hppa_old_cmds.in @@ -0,0 +1,12 @@ +#unconditional +#nocheckval +/* These values were used on hppa before v6.2-rc1~39^2~7. */ +MADV_MERGEABLE 65 +MADV_UNMERGEABLE 66 +MADV_HUGEPAGE 67 +MADV_NOHUGEPAGE 68 +MADV_DONTDUMP 69 +MADV_DODUMP 70 +MADV_WIPEONFORK 71 +MADV_KEEPONFORK 72 +MADV_COLLAPSE 73 |