From 6943d0c7591a5a383335669ac13af465e4d64b7b Mon Sep 17 00:00:00 2001 From: eabdullin Date: Mon, 30 Sep 2024 16:46:19 +0000 Subject: [PATCH] import CS valgrind-3.23.0-4.el9 --- .gitignore | 2 +- .valgrind.metadata | 2 +- ...1-Prepare-NEWS-for-branch-3.23-fixes.patch | 31 ++ ...uestArchState-has-no-member-named-gu.patch | 83 +++++ ...3-Bug-486293-memccpy-false-positives.patch | 96 ++++++ ...-inotify_init-syscall-wrapper-missin.patch | 138 ++++++++ ...rinta-and-frinta-vector-instructions.patch | 282 ++++++++++++++++ ...ng-shared-syscall-numbers-for-mips32.patch | 169 ++++++++++ ...ninitialized-err-in-handle_extension.patch | 45 +++ ...st_IP_AT_SYSCALL-in-handle_extension.patch | 31 ++ ...90x-Minor-fixes-in-extension-s390x.c.patch | 66 ++++ ...4-gbserver_tests-failures-in-aarch64.patch | 38 +++ ...-regtest-reallocarray-needs-malloc.h.patch | 56 +++ ...012-Bug-487439-SIGILL-in-JDK11-JDK17.patch | 184 ++++++++++ ...created-with-log-file-xml-file-or-lo.patch | 226 +++++++++++++ ...nal-pipe-fds-after-VG_-fork-in-paren.patch | 138 ++++++++ ...rams-calling-fnctl-on-valgrind-s-own.patch | 58 ++++ ...ng-shared-syscall-numbers-for-mips64.patch | 176 ++++++++++ ...filters-remove-python-rpm-module-loa.patch | 46 +++ .../0018-Implement-VMOVQ-xmm1-xmm2-m64.patch | 318 ++++++++++++++++++ .../0019-arm64-Fix-fcvtas-instruction.patch | 258 ++++++++++++++ ...filters-remove-more-verbose-python-r.patch | 52 +++ ...e-check-on-btrfs-with-sanity-level-3.patch | 74 ++++ SOURCES/valgrind-3.22.0-rodata.patch | 122 ------- SPECS/valgrind.spec | 119 ++++--- 25 files changed, 2648 insertions(+), 162 deletions(-) create mode 100644 SOURCES/0001-Prepare-NEWS-for-branch-3.23-fixes.patch create mode 100644 SOURCES/0002-486180-MIPS-VexGuestArchState-has-no-member-named-gu.patch create mode 100644 SOURCES/0003-Bug-486293-memccpy-false-positives.patch create mode 100644 SOURCES/0004-Bug-486569-linux-inotify_init-syscall-wrapper-missin.patch create mode 100644 SOURCES/0005-aarch64-frinta-and-frinta-vector-instructions.patch create mode 100644 SOURCES/0006-mips-skip-using-shared-syscall-numbers-for-mips32.patch create mode 100644 SOURCES/0007-Fix-uninitialized-err-in-handle_extension.patch create mode 100644 SOURCES/0008-Avoid-use-of-guest_IP_AT_SYSCALL-in-handle_extension.patch create mode 100644 SOURCES/0009-s390x-Minor-fixes-in-extension-s390x.c.patch create mode 100644 SOURCES/0010-Bug-453044-gbserver_tests-failures-in-aarch64.patch create mode 100644 SOURCES/0011-Linux-regtest-reallocarray-needs-malloc.h.patch create mode 100644 SOURCES/0012-Bug-487439-SIGILL-in-JDK11-JDK17.patch create mode 100644 SOURCES/0013-Don-t-leave-fds-created-with-log-file-xml-file-or-lo.patch create mode 100644 SOURCES/0014-Close-both-internal-pipe-fds-after-VG_-fork-in-paren.patch create mode 100644 SOURCES/0015-Don-t-allow-programs-calling-fnctl-on-valgrind-s-own.patch create mode 100644 SOURCES/0016-mips-skip-using-shared-syscall-numbers-for-mips64.patch create mode 100644 SOURCES/0017-gdbserver_tests-filters-remove-python-rpm-module-loa.patch create mode 100644 SOURCES/0018-Implement-VMOVQ-xmm1-xmm2-m64.patch create mode 100644 SOURCES/0019-arm64-Fix-fcvtas-instruction.patch create mode 100644 SOURCES/0020-gdbserver_tests-filters-remove-more-verbose-python-r.patch create mode 100644 SOURCES/0021-Avoid-dev-inode-check-on-btrfs-with-sanity-level-3.patch delete mode 100644 SOURCES/valgrind-3.22.0-rodata.patch diff --git a/.gitignore b/.gitignore index 49d7e90..357889f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -SOURCES/valgrind-3.22.0.tar.bz2 +SOURCES/valgrind-3.23.0.tar.bz2 diff --git a/.valgrind.metadata b/.valgrind.metadata index c2dab07..434db31 100644 --- a/.valgrind.metadata +++ b/.valgrind.metadata @@ -1 +1 @@ -60894cbf59d480c1794674da24a8406518a8df59 SOURCES/valgrind-3.22.0.tar.bz2 +ec410c75d3920d4f9249a5cfa2cac31e1bf6d586 SOURCES/valgrind-3.23.0.tar.bz2 diff --git a/SOURCES/0001-Prepare-NEWS-for-branch-3.23-fixes.patch b/SOURCES/0001-Prepare-NEWS-for-branch-3.23-fixes.patch new file mode 100644 index 0000000..327fb04 --- /dev/null +++ b/SOURCES/0001-Prepare-NEWS-for-branch-3.23-fixes.patch @@ -0,0 +1,31 @@ +From 2afcd730a10d61c318289bc4c39c42eebd4b35a6 Mon Sep 17 00:00:00 2001 +From: Mark Wielaard +Date: Mon, 29 Apr 2024 15:15:46 +0200 +Subject: [PATCH 01/11] Prepare NEWS for branch 3.23 fixes + +--- + NEWS | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +diff --git a/NEWS b/NEWS +index 11c67410fb6f..8bdd3753f7bb 100644 +--- a/NEWS ++++ b/NEWS +@@ -1,3 +1,14 @@ ++Branch 3.23 ++~~~~~~~~~~~ ++ ++* ==================== FIXED BUGS ==================== ++ ++The following bugs have been fixed or resolved on this branch. ++ ++To see details of a given bug, visit ++ https://bugs.kde.org/show_bug.cgi?id=XXXXXX ++where XXXXXX is the bug number as listed above. ++ + Release 3.23.0 (26 Apr 2024) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +-- +2.45.2 + diff --git a/SOURCES/0002-486180-MIPS-VexGuestArchState-has-no-member-named-gu.patch b/SOURCES/0002-486180-MIPS-VexGuestArchState-has-no-member-named-gu.patch new file mode 100644 index 0000000..b8ab417 --- /dev/null +++ b/SOURCES/0002-486180-MIPS-VexGuestArchState-has-no-member-named-gu.patch @@ -0,0 +1,83 @@ +From 2e26af756d69c53026bf2d6d61589f754796340d Mon Sep 17 00:00:00 2001 +From: Paul Floyd +Date: Sat, 27 Apr 2024 13:07:07 +0200 +Subject: [PATCH 02/11] 486180 [MIPS] 'VexGuestArchState' has no member named + 'guest_IP_AT_SYSCALL' + +(cherry picked from commit 7214886886bce9029f325214156c02dcfff760d5) +--- + NEWS | 2 ++ + VEX/priv/guest_mips_helpers.c | 4 ++++ + VEX/pub/libvex_guest_mips32.h | 6 +++--- + VEX/pub/libvex_guest_mips64.h | 2 ++ + 4 files changed, 11 insertions(+), 3 deletions(-) + +diff --git a/NEWS b/NEWS +index 8bdd3753f7bb..c40e00cce46b 100644 +--- a/NEWS ++++ b/NEWS +@@ -5,6 +5,8 @@ Branch 3.23 + + The following bugs have been fixed or resolved on this branch. + ++486180 [MIPS] 'VexGuestArchState' has no member named 'guest_IP_AT_SYSCALL' ++ + To see details of a given bug, visit + https://bugs.kde.org/show_bug.cgi?id=XXXXXX + where XXXXXX is the bug number as listed above. +diff --git a/VEX/priv/guest_mips_helpers.c b/VEX/priv/guest_mips_helpers.c +index 74cfb9c34caa..79197378cc74 100644 +--- a/VEX/priv/guest_mips_helpers.c ++++ b/VEX/priv/guest_mips_helpers.c +@@ -187,6 +187,8 @@ void LibVEX_GuestMIPS32_initialise( /*OUT*/ VexGuestMIPS32State * vex_state) + vex_state->guest_w1.w64[1] = 0; + vex_state->guest_w2.w64[0] = 0; + vex_state->guest_w2.w64[1] = 0; ++ ++ vex_state->guest_IP_AT_SYSCALL = 0; + } + + void LibVEX_GuestMIPS64_initialise ( /*OUT*/ VexGuestMIPS64State * vex_state ) +@@ -294,6 +296,8 @@ void LibVEX_GuestMIPS64_initialise ( /*OUT*/ VexGuestMIPS64State * vex_state ) + vex_state->guest_LLaddr = 0xFFFFFFFFFFFFFFFFULL; + vex_state->guest_LLdata = 0; + ++ vex_state->guest_IP_AT_SYSCALL = 0; ++ + vex_state->guest_MSACSR = 0; + } + +diff --git a/VEX/pub/libvex_guest_mips32.h b/VEX/pub/libvex_guest_mips32.h +index 214f63cdbe8c..e769819d75ae 100644 +--- a/VEX/pub/libvex_guest_mips32.h ++++ b/VEX/pub/libvex_guest_mips32.h +@@ -188,10 +188,10 @@ typedef + + /* 1016 */ UInt guest_MSACSR; + +- /* 1020 */ UInt _padding3; ++ /* 1020 */ UInt guest_IP_AT_SYSCALL; + +- /* 1020 */ ULong guest_LLdata64; +- /* 1028 */ ULong _padding4; ++ /* 1024 */ ULong guest_LLdata64; ++ /* 1032 */ ULong _padding3; + } VexGuestMIPS32State; + /*---------------------------------------------------------------*/ + /*--- Utility functions for MIPS32 guest stuff. ---*/ +diff --git a/VEX/pub/libvex_guest_mips64.h b/VEX/pub/libvex_guest_mips64.h +index 657fe6fa3343..a953f0ab86a2 100644 +--- a/VEX/pub/libvex_guest_mips64.h ++++ b/VEX/pub/libvex_guest_mips64.h +@@ -184,6 +184,8 @@ typedef + /* 1144 */ UInt guest_MSACSR; + + /* 1148 */ UInt _padding2; ++ /* 1152 */ ULong guest_IP_AT_SYSCALL; ++ /* 1160 */ ULong _padding3; + + } VexGuestMIPS64State; + +-- +2.45.2 + diff --git a/SOURCES/0003-Bug-486293-memccpy-false-positives.patch b/SOURCES/0003-Bug-486293-memccpy-false-positives.patch new file mode 100644 index 0000000..10c7d5e --- /dev/null +++ b/SOURCES/0003-Bug-486293-memccpy-false-positives.patch @@ -0,0 +1,96 @@ +From 14141bb4a6ea528b4c0b9295aa64348f7a675735 Mon Sep 17 00:00:00 2001 +From: Paul Floyd +Date: Wed, 1 May 2024 09:24:14 +0200 +Subject: [PATCH 03/11] Bug 486293 - memccpy false positives + +(cherry picked from commit 805c020c6e5161966e6eb0099ebe937a510cea9e) +--- + NEWS | 1 + + memcheck/tests/memccpy2.c | 20 ++++++++++++++++++++ + memcheck/tests/memccpy2.stderr.exp | 4 ++-- + shared/vg_replace_strmem.c | 4 ++-- + 4 files changed, 25 insertions(+), 4 deletions(-) + +diff --git a/NEWS b/NEWS +index c40e00cce46b..f674191a286a 100644 +--- a/NEWS ++++ b/NEWS +@@ -6,6 +6,7 @@ Branch 3.23 + The following bugs have been fixed or resolved on this branch. + + 486180 [MIPS] 'VexGuestArchState' has no member named 'guest_IP_AT_SYSCALL' ++486293 memccpy false positives + + To see details of a given bug, visit + https://bugs.kde.org/show_bug.cgi?id=XXXXXX +diff --git a/memcheck/tests/memccpy2.c b/memcheck/tests/memccpy2.c +index a5a1dfc9f0af..947324581715 100644 +--- a/memcheck/tests/memccpy2.c ++++ b/memcheck/tests/memccpy2.c +@@ -1,6 +1,8 @@ + #include + #include + #include ++#include ++#include + + int main(void) + { +@@ -9,5 +11,23 @@ int main(void) + memccpy(astring+10, astring, '#', len-10); + sprintf(astring, "this is a string # with something to seek"); + memccpy(astring, astring+10, '#', len); ++ ++ sprintf(astring, "this is a string # with something to seek"); ++ /* ++ * space is earlier than len, no overlap ++ * "this " gets copied (up to and including the first ' ') ++ * and it overwrites the destination starting with the 's' of "string" ++ * so res will point to the 'g' of "string" ++ */ ++ char* res = memccpy(astring+10, astring, ' ', len-10); ++ assert(res && *res == 'g'); ++ sprintf(astring, "this is a string # with something to seek"); ++ /* length is 0, nothing copied, returns NULL */ ++ res = memccpy(astring, "abcdefhhijklmnopqrstuvwxy", 'z', 0); ++ assert(NULL == res); ++ /* 'z' not found so 20 bytes copied, returns NULL */ ++ res = memccpy(astring, "abcdefhhijklmnopqrstuvwxy", 'z', 20); ++ assert(NULL == res); ++ free(astring); + } + +diff --git a/memcheck/tests/memccpy2.stderr.exp b/memcheck/tests/memccpy2.stderr.exp +index 0132ef06c56a..240ce925c182 100644 +--- a/memcheck/tests/memccpy2.stderr.exp ++++ b/memcheck/tests/memccpy2.stderr.exp +@@ -1,8 +1,8 @@ + Source and destination overlap in memccpy(0x........, 0x........, 31) + at 0x........: memccpy (vg_replace_strmem.c:...) +- by 0x........: main (memccpy2.c:9) ++ by 0x........: main (memccpy2.c:11) + + Source and destination overlap in memccpy(0x........, 0x........, 41) + at 0x........: memccpy (vg_replace_strmem.c:...) +- by 0x........: main (memccpy2.c:11) ++ by 0x........: main (memccpy2.c:13) + +diff --git a/shared/vg_replace_strmem.c b/shared/vg_replace_strmem.c +index 737abbf67898..ae13a2a5f87a 100644 +--- a/shared/vg_replace_strmem.c ++++ b/shared/vg_replace_strmem.c +@@ -2364,9 +2364,9 @@ static inline void my_exit ( int x ) + \ + while (i-- > 0) \ + if ((*d++ = *s++) == x) { \ +- SizeT srclen = (i < len) ? i : len; \ ++ SizeT srclen = len - i; \ + RECORD_COPY(srclen); \ +- if (is_overlap(dst, src, srclen, srclen)) \ ++ if (is_overlap(dst, src, len, srclen)) \ + RECORD_OVERLAP_ERROR("memccpy", dst, src, len); \ + return d; \ + } \ +-- +2.45.2 + diff --git a/SOURCES/0004-Bug-486569-linux-inotify_init-syscall-wrapper-missin.patch b/SOURCES/0004-Bug-486569-linux-inotify_init-syscall-wrapper-missin.patch new file mode 100644 index 0000000..0b34908 --- /dev/null +++ b/SOURCES/0004-Bug-486569-linux-inotify_init-syscall-wrapper-missin.patch @@ -0,0 +1,138 @@ +From 3795a011eeb9730cda9f0beadce70aab8aa71e68 Mon Sep 17 00:00:00 2001 +From: Paul Floyd +Date: Sat, 4 May 2024 15:03:11 +0200 +Subject: [PATCH 04/11] Bug 486569 - linux inotify_init syscall wrapper missing + POST entry in syscall_table + +(cherry picked from commit b38115cc6087f30f872c533f93c7c31a6d73eb24) +--- + NEWS | 1 + + coregrind/m_syswrap/syswrap-amd64-linux.c | 2 +- + coregrind/m_syswrap/syswrap-arm-linux.c | 2 +- + coregrind/m_syswrap/syswrap-mips32-linux.c | 2 +- + coregrind/m_syswrap/syswrap-mips64-linux.c | 2 +- + coregrind/m_syswrap/syswrap-ppc32-linux.c | 2 +- + coregrind/m_syswrap/syswrap-ppc64-linux.c | 2 +- + coregrind/m_syswrap/syswrap-s390x-linux.c | 2 +- + coregrind/m_syswrap/syswrap-x86-linux.c | 2 +- + 9 files changed, 9 insertions(+), 8 deletions(-) + +diff --git a/NEWS b/NEWS +index f674191a286a..b65f9206679b 100644 +--- a/NEWS ++++ b/NEWS +@@ -7,6 +7,7 @@ The following bugs have been fixed or resolved on this branch. + + 486180 [MIPS] 'VexGuestArchState' has no member named 'guest_IP_AT_SYSCALL' + 486293 memccpy false positives ++486569 linux inotify_init syscall wrapper missing POST entry in syscall_table + + To see details of a given bug, visit + https://bugs.kde.org/show_bug.cgi?id=XXXXXX +diff --git a/coregrind/m_syswrap/syswrap-amd64-linux.c b/coregrind/m_syswrap/syswrap-amd64-linux.c +index a59e01826ca2..86a47d9c2811 100644 +--- a/coregrind/m_syswrap/syswrap-amd64-linux.c ++++ b/coregrind/m_syswrap/syswrap-amd64-linux.c +@@ -773,7 +773,7 @@ static SyscallTableEntry syscall_table[] = { + LINXY(__NR_keyctl, sys_keyctl), // 250 + LINX_(__NR_ioprio_set, sys_ioprio_set), // 251 + LINX_(__NR_ioprio_get, sys_ioprio_get), // 252 +- LINX_(__NR_inotify_init, sys_inotify_init), // 253 ++ LINXY(__NR_inotify_init, sys_inotify_init), // 253 + LINX_(__NR_inotify_add_watch, sys_inotify_add_watch), // 254 + + LINX_(__NR_inotify_rm_watch, sys_inotify_rm_watch), // 255 +diff --git a/coregrind/m_syswrap/syswrap-arm-linux.c b/coregrind/m_syswrap/syswrap-arm-linux.c +index 217b1c49dc9d..7b536e52cb2e 100644 +--- a/coregrind/m_syswrap/syswrap-arm-linux.c ++++ b/coregrind/m_syswrap/syswrap-arm-linux.c +@@ -922,7 +922,7 @@ static SyscallTableEntry syscall_main_table[] = { + // LINX_(__NR_ioprio_set, sys_ioprio_set), // 289 + + // LINX_(__NR_ioprio_get, sys_ioprio_get), // 290 +- LINX_(__NR_inotify_init, sys_inotify_init), // 291 ++ LINXY(__NR_inotify_init, sys_inotify_init), // 291 + LINX_(__NR_inotify_add_watch, sys_inotify_add_watch), // 292 + LINX_(__NR_inotify_rm_watch, sys_inotify_rm_watch), // 293 + // LINX_(__NR_migrate_pages, sys_migrate_pages), // 294 +diff --git a/coregrind/m_syswrap/syswrap-mips32-linux.c b/coregrind/m_syswrap/syswrap-mips32-linux.c +index 3f991da0a18d..e2f499eb80f8 100644 +--- a/coregrind/m_syswrap/syswrap-mips32-linux.c ++++ b/coregrind/m_syswrap/syswrap-mips32-linux.c +@@ -1037,7 +1037,7 @@ static SyscallTableEntry syscall_main_table[] = { + LINXY (__NR_mq_timedreceive, sys_mq_timedreceive), // 274 + LINX_ (__NR_mq_notify, sys_mq_notify), // 275 + LINXY (__NR_mq_getsetattr, sys_mq_getsetattr), // 276 +- LINX_ (__NR_inotify_init, sys_inotify_init), // 275 ++ LINXY (__NR_inotify_init, sys_inotify_init), // 275 + LINX_ (__NR_inotify_add_watch, sys_inotify_add_watch), // 276 + LINX_ (__NR_inotify_rm_watch, sys_inotify_rm_watch), // 277 + LINXY (__NR_waitid, sys_waitid), // 278 +diff --git a/coregrind/m_syswrap/syswrap-mips64-linux.c b/coregrind/m_syswrap/syswrap-mips64-linux.c +index 9899a21cfa78..24f2bcc93956 100644 +--- a/coregrind/m_syswrap/syswrap-mips64-linux.c ++++ b/coregrind/m_syswrap/syswrap-mips64-linux.c +@@ -759,7 +759,7 @@ static SyscallTableEntry syscall_main_table[] = { + LINX_ (__NR_request_key, sys_request_key), + LINXY (__NR_keyctl, sys_keyctl), + PLAX_ (__NR_set_thread_area, sys_set_thread_area), +- LINX_ (__NR_inotify_init, sys_inotify_init), ++ LINXY (__NR_inotify_init, sys_inotify_init), + LINX_ (__NR_inotify_add_watch, sys_inotify_add_watch), + LINX_ (__NR_inotify_rm_watch, sys_inotify_rm_watch), + LINXY (__NR_openat, sys_openat), +diff --git a/coregrind/m_syswrap/syswrap-ppc32-linux.c b/coregrind/m_syswrap/syswrap-ppc32-linux.c +index 0aabfbb179ec..74ba68564cd8 100644 +--- a/coregrind/m_syswrap/syswrap-ppc32-linux.c ++++ b/coregrind/m_syswrap/syswrap-ppc32-linux.c +@@ -944,7 +944,7 @@ static SyscallTableEntry syscall_table[] = { + LINX_(__NR_ioprio_set, sys_ioprio_set), // 273 + LINX_(__NR_ioprio_get, sys_ioprio_get), // 274 + +- LINX_(__NR_inotify_init, sys_inotify_init), // 275 ++ LINXY(__NR_inotify_init, sys_inotify_init), // 275 + LINX_(__NR_inotify_add_watch, sys_inotify_add_watch), // 276 + LINX_(__NR_inotify_rm_watch, sys_inotify_rm_watch), // 277 + PLAXY(__NR_spu_run, sys_spu_run), // 278 +diff --git a/coregrind/m_syswrap/syswrap-ppc64-linux.c b/coregrind/m_syswrap/syswrap-ppc64-linux.c +index 35e3f8ec4ee4..4609e10df363 100644 +--- a/coregrind/m_syswrap/syswrap-ppc64-linux.c ++++ b/coregrind/m_syswrap/syswrap-ppc64-linux.c +@@ -928,7 +928,7 @@ static SyscallTableEntry syscall_table[] = { + LINX_(__NR_ioprio_set, sys_ioprio_set), // 273 + LINX_(__NR_ioprio_get, sys_ioprio_get), // 274 + +- LINX_(__NR_inotify_init, sys_inotify_init), // 275 ++ LINXY(__NR_inotify_init, sys_inotify_init), // 275 + LINX_(__NR_inotify_add_watch, sys_inotify_add_watch), // 276 + LINX_(__NR_inotify_rm_watch, sys_inotify_rm_watch), // 277 + +diff --git a/coregrind/m_syswrap/syswrap-s390x-linux.c b/coregrind/m_syswrap/syswrap-s390x-linux.c +index f941bdd1907a..9ed2fa46888f 100644 +--- a/coregrind/m_syswrap/syswrap-s390x-linux.c ++++ b/coregrind/m_syswrap/syswrap-s390x-linux.c +@@ -751,7 +751,7 @@ static SyscallTableEntry syscall_table[] = { + LINXY(__NR_waitid, sys_waitid), // 281 + LINX_(__NR_ioprio_set, sys_ioprio_set), // 282 + LINX_(__NR_ioprio_get, sys_ioprio_get), // 283 +- LINX_(__NR_inotify_init, sys_inotify_init), // 284 ++ LINXY(__NR_inotify_init, sys_inotify_init), // 284 + + LINX_(__NR_inotify_add_watch, sys_inotify_add_watch), // 285 + LINX_(__NR_inotify_rm_watch, sys_inotify_rm_watch), // 286 +diff --git a/coregrind/m_syswrap/syswrap-x86-linux.c b/coregrind/m_syswrap/syswrap-x86-linux.c +index c6cf682e797c..ea930bafe3ec 100644 +--- a/coregrind/m_syswrap/syswrap-x86-linux.c ++++ b/coregrind/m_syswrap/syswrap-x86-linux.c +@@ -1508,7 +1508,7 @@ static SyscallTableEntry syscall_table[] = { + LINX_(__NR_ioprio_set, sys_ioprio_set), // 289 + + LINX_(__NR_ioprio_get, sys_ioprio_get), // 290 +- LINX_(__NR_inotify_init, sys_inotify_init), // 291 ++ LINXY(__NR_inotify_init, sys_inotify_init), // 291 + LINX_(__NR_inotify_add_watch, sys_inotify_add_watch), // 292 + LINX_(__NR_inotify_rm_watch, sys_inotify_rm_watch), // 293 + // LINX_(__NR_migrate_pages, sys_migrate_pages), // 294 +-- +2.45.2 + diff --git a/SOURCES/0005-aarch64-frinta-and-frinta-vector-instructions.patch b/SOURCES/0005-aarch64-frinta-and-frinta-vector-instructions.patch new file mode 100644 index 0000000..9a9c7d9 --- /dev/null +++ b/SOURCES/0005-aarch64-frinta-and-frinta-vector-instructions.patch @@ -0,0 +1,282 @@ +From f5d1c336e9276dd5947ef94c9831d9d53673b75b Mon Sep 17 00:00:00 2001 +From: Paul Floyd +Date: Thu, 9 May 2024 21:01:52 +0200 +Subject: [PATCH 05/11] aarch64 frinta and frinta vector instructions + +The initial fix for Bug 484426 only corrected frinta and frintn +scalar instructions. This adds support for the vector variants. + +(cherry picked from commit 7b66a5b58219ac1a4865da8e371edbdb8d765f32) +--- + NEWS | 1 + + VEX/priv/guest_arm64_toIR.c | 47 ++++++---- + none/tests/arm64/frinta_frintn.cpp | 141 +++++++++++++++++++++++++++++ + 3 files changed, 171 insertions(+), 18 deletions(-) + +diff --git a/NEWS b/NEWS +index b65f9206679b..adb52169dd87 100644 +--- a/NEWS ++++ b/NEWS +@@ -8,6 +8,7 @@ The following bugs have been fixed or resolved on this branch. + 486180 [MIPS] 'VexGuestArchState' has no member named 'guest_IP_AT_SYSCALL' + 486293 memccpy false positives + 486569 linux inotify_init syscall wrapper missing POST entry in syscall_table ++n-i-bz aarch64 frinta and frinta vector instructions + + To see details of a given bug, visit + https://bugs.kde.org/show_bug.cgi?id=XXXXXX +diff --git a/VEX/priv/guest_arm64_toIR.c b/VEX/priv/guest_arm64_toIR.c +index c7e395b4b63d..27d945d6328d 100644 +--- a/VEX/priv/guest_arm64_toIR.c ++++ b/VEX/priv/guest_arm64_toIR.c +@@ -13821,46 +13821,57 @@ Bool dis_AdvSIMD_two_reg_misc(/*MB_OUT*/DisResult* dres, UInt insn) + /* -------- 1,1x,11000 (apparently unassigned) (7) -------- */ + /* -------- 1,1x,11001 FRINTI 2d_2d, 4s_4s, 2s_2s (8) -------- */ + /* rm plan: +- FRINTN: tieeven -- !! FIXME KLUDGED !! ++ FRINTN: tieeven + FRINTM: -inf + FRINTP: +inf + FRINTZ: zero +- FRINTA: tieaway -- !! FIXME KLUDGED !! ++ FRINTA: tieaway + FRINTX: per FPCR + "exact = TRUE" + FRINTI: per FPCR + */ + Bool isD = (size & 1) == 1; + if (bitQ == 0 && isD) return False; // implied 1d case + +- IRTemp irrmRM = mk_get_IR_rounding_mode(); +- +- UChar ch = '?'; +- IRTemp irrm = newTemp(Ity_I32); ++ UChar ch = '?'; ++ IROp op = isD ? Iop_RoundF64toInt : Iop_RoundF32toInt; ++ Bool isBinop = True; ++ IRExpr* irrmE = NULL; + switch (ix) { +- case 1: ch = 'n'; assign(irrm, mkU32(Irrm_NEAREST)); break; +- case 2: ch = 'm'; assign(irrm, mkU32(Irrm_NegINF)); break; +- case 3: ch = 'p'; assign(irrm, mkU32(Irrm_PosINF)); break; +- case 4: ch = 'z'; assign(irrm, mkU32(Irrm_ZERO)); break; ++ case 1: ch = 'n'; isBinop = False; op = isD ? Iop_RoundF64toIntE : Iop_RoundF32toIntE; break; ++ case 2: ch = 'm'; irrmE = mkU32(Irrm_NegINF); break; ++ case 3: ch = 'p'; irrmE = mkU32(Irrm_PosINF); break; ++ case 4: ch = 'z'; irrmE = mkU32(Irrm_ZERO); break; + // The following is a kludge. Should be: Irrm_NEAREST_TIE_AWAY_0 +- case 5: ch = 'a'; assign(irrm, mkU32(Irrm_NEAREST)); break; ++ case 5: ch = 'a'; isBinop = False; op = isD ? Iop_RoundF64toIntA0 : Iop_RoundF32toIntA0; break; + // I am unsure about the following, due to the "integral exact" + // description in the manual. What does it mean? (frintx, that is) +- case 6: ch = 'x'; assign(irrm, mkexpr(irrmRM)); break; +- case 8: ch = 'i'; assign(irrm, mkexpr(irrmRM)); break; ++ case 6: ch = 'x'; irrmE = mkexpr(mk_get_IR_rounding_mode()); break; ++ case 8: ch = 'i'; irrmE = mkexpr(mk_get_IR_rounding_mode()); break; + default: vassert(0); + } + +- IROp opRND = isD ? Iop_RoundF64toInt : Iop_RoundF32toInt; + if (isD) { + for (UInt i = 0; i < 2; i++) { +- putQRegLane(dd, i, binop(opRND, mkexpr(irrm), +- getQRegLane(nn, i, Ity_F64))); ++ if (isBinop) { ++ IRTemp irrm = newTemp(Ity_I32); ++ assign(irrm, irrmE); ++ putQRegLane(dd, i, binop(op, mkexpr(irrm), ++ getQRegLane(nn, i, Ity_F64))); ++ } else { ++ putQRegLane(dd, i, unop(op, getQRegLane(nn, i, Ity_F64))); ++ } + } + } else { + UInt n = bitQ==1 ? 4 : 2; + for (UInt i = 0; i < n; i++) { +- putQRegLane(dd, i, binop(opRND, mkexpr(irrm), +- getQRegLane(nn, i, Ity_F32))); ++ if (isBinop) { ++ IRTemp irrm = newTemp(Ity_I32); ++ assign(irrm, irrmE); ++ putQRegLane(dd, i, binop(op, mkexpr(irrm), ++ getQRegLane(nn, i, Ity_F32))); ++ } else { ++ putQRegLane(dd, i, unop(op, getQRegLane(nn, i, Ity_F32))); ++ } + } + if (bitQ == 0) + putQRegLane(dd, 1, mkU64(0)); // zero out lanes 2 and 3 +diff --git a/none/tests/arm64/frinta_frintn.cpp b/none/tests/arm64/frinta_frintn.cpp +index 8e13761eb966..c0803688f698 100644 +--- a/none/tests/arm64/frinta_frintn.cpp ++++ b/none/tests/arm64/frinta_frintn.cpp +@@ -36,6 +36,55 @@ void test_frinta(T input, T expected) + } + } + ++template ++void test_frinta_fullvec(T* input, T* expected) ++{ ++ T result[2*sizeof(double)/sizeof(T)]; ++ T* rp = result; ++ if constexpr (std::is_same_v == true) ++ { ++ __asm__ __volatile__( ++ "ldr q23, [%1];\n" ++ "frinta v22.2d, v23.2d;\n" ++ "str q22, [%0];\n" ++ : "+rm" (rp) ++ : "r" (input) ++ : "memory", "v22", "v23"); ++ assert(result[0] == expected[0]); ++ assert(result[1] == expected[1]); ++ } ++ else ++ { ++ __asm__ __volatile__( ++ "ldr q23, [%1];\n" ++ "frinta v22.4s, v23.4s;\n" ++ "str q22, [%0];\n" ++ : "+rm" (rp) ++ : "r" (input) ++ : "memory", "v22", "v23"); ++ assert(result[0] == expected[0]); ++ assert(result[1] == expected[1]); ++ assert(result[2] == expected[2]); ++ assert(result[3] == expected[3]); ++ } ++} ++ ++void test_frinta_halfvec(float* input, float* expected) ++{ ++ float result[2]; ++ float* rp = result; ++ __asm__ __volatile__( ++ "ldr d23, [%1];\n" ++ "frinta v22.2s, v23.2s;\n" ++ "str d22, [%0];\n" ++ : "+rm" (rp) ++ : "r" (input) ++ : "memory", "v22", "v23"); ++ assert(result[0] == expected[0]); ++ assert(result[1] == expected[1]); ++} ++ ++ + template + void test_frintn(T input, T expected) + { +@@ -66,6 +115,54 @@ void test_frintn(T input, T expected) + } + } + ++template ++void test_frintn_fullvec(T* input, T* expected) ++{ ++ T result[2*sizeof(double)/sizeof(T)]; ++ T* rp = result; ++ if constexpr (std::is_same_v == true) ++ { ++ __asm__ __volatile__( ++ "ldr q23, [%1];\n" ++ "frintn v22.2d, v23.2d;\n" ++ "str q22, [%0];\n" ++ : "+rm" (rp) ++ : "r" (input) ++ : "memory", "v22", "v23"); ++ assert(result[0] == expected[0]); ++ assert(result[1] == expected[1]); ++ } ++ else ++ { ++ __asm__ __volatile__( ++ "ldr q23, [%1];\n" ++ "frintn v22.4s, v23.4s;\n" ++ "str q22, [%0];\n" ++ : "+rm" (rp) ++ : "r" (input) ++ : "memory", "v22", "v23"); ++ assert(result[0] == expected[0]); ++ assert(result[1] == expected[1]); ++ assert(result[2] == expected[2]); ++ assert(result[3] == expected[3]); ++ } ++} ++ ++void test_frintn_halfvec(float* input, float* expected) ++{ ++ float result[2]; ++ float* rp = result; ++ __asm__ __volatile__( ++ "ldr d23, [%1];\n" ++ "frintn v22.2s, v23.2s;\n" ++ "str d22, [%0];\n" ++ : "+rm" (rp) ++ : "r" (input) ++ : "memory", "v22", "v23"); ++ assert(result[0] == expected[0]); ++ assert(result[1] == expected[1]); ++} ++ + int main() + { + // round "away from zero" +@@ -78,6 +175,36 @@ int main() + test_frinta(-1.5F, -2.0F); + test_frinta(-2.5F, -3.0F); + ++ double in1[] = {1.5, 1.5}; ++ double out1[] = {2.0, 2,0}; ++ test_frinta_fullvec(in1, out1); ++ double in2[] = {2.5, 2.5}; ++ double out2[] = {3.0, 3,0}; ++ test_frinta_fullvec(in2, out2); ++ double in3[] = {-1.5, -1.5}; ++ double out3[] = {-2.0, -2,0}; ++ test_frinta_fullvec(in3, out3); ++ double in4[] = {-2.5, -2.5}; ++ double out4[] = {-3.0, -3,0}; ++ test_frinta_fullvec(in4, out4); ++ ++ float in1f[] = {1.5F, 1.5F, 1.5F, 1.5F}; ++ float out1f[] = {2.0F, 2.0F, 2.0F, 2.0F}; ++ test_frinta_fullvec(in1f, out1f); ++ test_frinta_halfvec(in1f, out1f); ++ float in2f[] = {2.5F, 2.5F, 2.5F, 2.5F}; ++ float out2f[] = {3.0F, 3.0F, 3.0F, 3.0F}; ++ test_frinta_fullvec(in2f, out2f); ++ test_frinta_halfvec(in2f, out2f); ++ float in3f[] = {-1.5F, -1.5F, -1.5F, -1.5F}; ++ float out3f[] = {-2.0F, -2.0F, -2.0F, -2.0F}; ++ test_frinta_fullvec(in3f, out3f); ++ test_frinta_halfvec(in3f, out3f); ++ float in4f[] = {-2.5F, -2.5F, -2.5F, -2.5F}; ++ float out4f[] = {-3.0F, -3.0F, -3.0F, -3.0F}; ++ test_frinta_fullvec(in4f, out4f); ++ test_frinta_halfvec(in4f, out4f); ++ + // round "to even" + test_frintn(1.5, 2.0); + test_frintn(2.5, 2.0); +@@ -87,5 +214,19 @@ int main() + test_frintn(2.5F, 2.0F); + test_frintn(-1.5F, -2.0F); + test_frintn(-2.5F, -2.0F); ++ ++ test_frintn_fullvec(in1, out1); ++ test_frintn_fullvec(in2, out1); ++ test_frintn_fullvec(in3, out3); ++ test_frintn_fullvec(in4, out3); ++ ++ test_frintn_fullvec(in1f, out1f); ++ test_frintn_halfvec(in1f, out1f); ++ test_frintn_fullvec(in2f, out1f); ++ test_frintn_halfvec(in2f, out1f); ++ test_frintn_fullvec(in3f, out3f); ++ test_frintn_halfvec(in3f, out3f); ++ test_frintn_fullvec(in4f, out3f); ++ test_frintn_halfvec(in4f, out3f); + } + +-- +2.45.2 + diff --git a/SOURCES/0006-mips-skip-using-shared-syscall-numbers-for-mips32.patch b/SOURCES/0006-mips-skip-using-shared-syscall-numbers-for-mips32.patch new file mode 100644 index 0000000..d393c9c --- /dev/null +++ b/SOURCES/0006-mips-skip-using-shared-syscall-numbers-for-mips32.patch @@ -0,0 +1,169 @@ +From 726f930355ca74b4aa4c656979224c9b7a706244 Mon Sep 17 00:00:00 2001 +From: Aleksandar Rikalo +Date: Fri, 10 May 2024 17:59:28 +0200 +Subject: [PATCH 06/11] mips: skip using shared syscall numbers for mips32 + +mips does not use shared syscall numbers, so we can not use +vki-scnums-shared-linux.h. + +This partially fixes KDE #444781. + +Signed-off-by: Hauke Mehrtens +Signed-off-by: Aleksandar Rikalo +(cherry picked from commit 54d6ad3348fb50f5b972fe9c05d0d8757bfe73ba) +--- + coregrind/m_syswrap/syswrap-mips32-linux.c | 1 + + include/pub_tool_vkiscnums_asm.h | 2 - + include/vki/vki-scnums-mips32-linux.h | 105 ++++++++++++++++----- + 3 files changed, 83 insertions(+), 25 deletions(-) + +diff --git a/coregrind/m_syswrap/syswrap-mips32-linux.c b/coregrind/m_syswrap/syswrap-mips32-linux.c +index e2f499eb80f8..e3498cd96f9b 100644 +--- a/coregrind/m_syswrap/syswrap-mips32-linux.c ++++ b/coregrind/m_syswrap/syswrap-mips32-linux.c +@@ -1110,6 +1110,7 @@ static SyscallTableEntry syscall_main_table[] = { + LINX_ (__NR_pwritev2, sys_pwritev2), // 362 + //.. + LINXY(__NR_statx, sys_statx), // 366 ++ GENX_(__NR_rseq, sys_ni_syscall), // 367 + + LINXY(__NR_clock_gettime64, sys_clock_gettime64), // 403 + LINX_(__NR_clock_settime64, sys_clock_settime64), // 404 +diff --git a/include/pub_tool_vkiscnums_asm.h b/include/pub_tool_vkiscnums_asm.h +index 8a26f834a93e..d3d7dc19be9d 100644 +--- a/include/pub_tool_vkiscnums_asm.h ++++ b/include/pub_tool_vkiscnums_asm.h +@@ -63,8 +63,6 @@ + # include "vki/vki-scnums-arm64-linux.h" + + #elif defined(VGP_mips32_linux) +-# include "vki/vki-scnums-shared-linux.h" +-# include "vki/vki-scnums-32bit-linux.h" + # include "vki/vki-scnums-mips32-linux.h" + + #elif defined(VGP_nanomips_linux) +diff --git a/include/vki/vki-scnums-mips32-linux.h b/include/vki/vki-scnums-mips32-linux.h +index e452a2e6c8d0..d4f8de15aac7 100644 +--- a/include/vki/vki-scnums-mips32-linux.h ++++ b/include/vki/vki-scnums-mips32-linux.h +@@ -380,35 +380,94 @@ + #define __NR_setns (__NR_Linux + 343) + #define __NR_process_vm_readv (__NR_Linux + 345) + #define __NR_process_vm_writev (__NR_Linux + 346) +-#define __NR_kcmp (__NR_Linux + 347) +-#define __NR_finit_module (__NR_Linux + 348) +-#define __NR_sched_setattr (__NR_Linux + 349) +-#define __NR_sched_getattr (__NR_Linux + 350) +-#define __NR_renameat2 (__NR_Linux + 351) +-#define __NR_seccomp (__NR_Linux + 352) +-#define __NR_getrandom (__NR_Linux + 353) +-#define __NR_memfd_create (__NR_Linux + 354) +-#define __NR_bpf (__NR_Linux + 355) +-#define __NR_execveat (__NR_Linux + 356) +-#define __NR_userfaultfd (__NR_Linux + 357) +-#define __NR_membarrier (__NR_Linux + 358) +-#define __NR_mlock2 (__NR_Linux + 359) +-#define __NR_copy_file_range (__NR_Linux + 360) +-#define __NR_preadv2 (__NR_Linux + 361) +-#define __NR_pwritev2 (__NR_Linux + 362) +-#define __NR_pkey_mprotect (__NR_Linux + 363) +-#define __NR_pkey_alloc (__NR_Linux + 364) +-#define __NR_pkey_free (__NR_Linux + 365) +-#define __NR_statx (__NR_Linux + 366) +- ++#define __NR_kcmp (__NR_Linux + 347) ++#define __NR_finit_module (__NR_Linux + 348) ++#define __NR_sched_setattr (__NR_Linux + 349) ++#define __NR_sched_getattr (__NR_Linux + 350) ++#define __NR_renameat2 (__NR_Linux + 351) ++#define __NR_seccomp (__NR_Linux + 352) ++#define __NR_getrandom (__NR_Linux + 353) ++#define __NR_memfd_create (__NR_Linux + 354) ++#define __NR_bpf (__NR_Linux + 355) ++#define __NR_execveat (__NR_Linux + 356) ++#define __NR_userfaultfd (__NR_Linux + 357) ++#define __NR_membarrier (__NR_Linux + 358) ++#define __NR_mlock2 (__NR_Linux + 359) ++#define __NR_copy_file_range (__NR_Linux + 360) ++#define __NR_preadv2 (__NR_Linux + 361) ++#define __NR_pwritev2 (__NR_Linux + 362) ++#define __NR_pkey_mprotect (__NR_Linux + 363) ++#define __NR_pkey_alloc (__NR_Linux + 364) ++#define __NR_pkey_free (__NR_Linux + 365) ++#define __NR_statx (__NR_Linux + 366) ++#define __NR_rseq (__NR_Linux + 367) ++#define __NR_io_pgetevents (__NR_Linux + 368) ++#define __NR_semget (__NR_Linux + 393) ++#define __NR_semctl (__NR_Linux + 394) ++#define __NR_shmget (__NR_Linux + 395) ++#define __NR_shmctl (__NR_Linux + 396) ++#define __NR_shmat (__NR_Linux + 397) ++#define __NR_shmdt (__NR_Linux + 398) ++#define __NR_msgget (__NR_Linux + 399) ++#define __NR_msgsnd (__NR_Linux + 400) ++#define __NR_msgrcv (__NR_Linux + 401) ++#define __NR_msgctl (__NR_Linux + 402) ++#define __NR_clock_gettime64 (__NR_Linux + 403) ++#define __NR_clock_settime64 (__NR_Linux + 404) ++#define __NR_clock_adjtime64 (__NR_Linux + 405) ++#define __NR_clock_getres_time64 (__NR_Linux + 406) ++#define __NR_clock_nanosleep_time64 (__NR_Linux + 407) ++#define __NR_timer_gettime64 (__NR_Linux + 408) ++#define __NR_timer_settime64 (__NR_Linux + 409) ++#define __NR_timerfd_gettime64 (__NR_Linux + 410) ++#define __NR_timerfd_settime64 (__NR_Linux + 411) ++#define __NR_utimensat_time64 (__NR_Linux + 412) ++#define __NR_pselect6_time64 (__NR_Linux + 413) ++#define __NR_ppoll_time64 (__NR_Linux + 414) ++#define __NR_io_pgetevents_time64 (__NR_Linux + 416) ++#define __NR_recvmmsg_time64 (__NR_Linux + 417) ++#define __NR_mq_timedsend_time64 (__NR_Linux + 418) ++#define __NR_mq_timedreceive_time64 (__NR_Linux + 419) ++#define __NR_semtimedop_time64 (__NR_Linux + 420) ++#define __NR_rt_sigtimedwait_time64 (__NR_Linux + 421) ++#define __NR_futex_time64 (__NR_Linux + 422) ++#define __NR_sched_rr_get_interval_time64 (__NR_Linux + 423) ++#define __NR_pidfd_send_signal (__NR_Linux + 424) ++#define __NR_io_uring_setup (__NR_Linux + 425) ++#define __NR_io_uring_enter (__NR_Linux + 426) ++#define __NR_io_uring_register (__NR_Linux + 427) ++#define __NR_open_tree (__NR_Linux + 428) ++#define __NR_move_mount (__NR_Linux + 429) ++#define __NR_fsopen (__NR_Linux + 430) ++#define __NR_fsconfig (__NR_Linux + 431) ++#define __NR_fsmount (__NR_Linux + 432) ++#define __NR_fspick (__NR_Linux + 433) ++#define __NR_pidfd_open (__NR_Linux + 434) ++#define __NR_clone3 (__NR_Linux + 435) ++#define __NR_close_range (__NR_Linux + 436) ++#define __NR_openat2 (__NR_Linux + 437) ++#define __NR_pidfd_getfd (__NR_Linux + 438) ++#define __NR_faccessat2 (__NR_Linux + 439) ++#define __NR_process_madvise (__NR_Linux + 440) ++#define __NR_epoll_pwait2 (__NR_Linux + 441) ++#define __NR_mount_setattr (__NR_Linux + 442) ++#define __NR_quotactl_fd (__NR_Linux + 443) ++#define __NR_landlock_create_ruleset (__NR_Linux + 444) ++#define __NR_landlock_add_rule (__NR_Linux + 445) ++#define __NR_landlock_restrict_self (__NR_Linux + 446) ++#define __NR_process_mrelease (__NR_Linux + 448) ++#define __NR_futex_waitv (__NR_Linux + 449) ++#define __NR_set_mempolicy_home_node (__NR_Linux + 450) ++#define __NR_cachestat (__NR_Linux + 451) ++#define __NR_fchmodat2 (__NR_Linux + 452) + /* + * Offset of the last Linux o32 flavoured syscall + */ +-#define __NR_Linux_syscalls 366 ++#define __NR_Linux_syscalls 366 + + + #define __NR_O32_Linux 4000 +-#define __NR_O32_Linux_syscalls 366 ++#define __NR_O32_Linux_syscalls 366 + + + #endif /* __VKI_SCNUMS_MIPS32_LINUX_H */ +-- +2.45.2 + diff --git a/SOURCES/0007-Fix-uninitialized-err-in-handle_extension.patch b/SOURCES/0007-Fix-uninitialized-err-in-handle_extension.patch new file mode 100644 index 0000000..84efe6f --- /dev/null +++ b/SOURCES/0007-Fix-uninitialized-err-in-handle_extension.patch @@ -0,0 +1,45 @@ +From 468933f9765449c1e353c38e88555a2f1603b9ce Mon Sep 17 00:00:00 2001 +From: Andreas Arnez +Date: Wed, 15 May 2024 14:32:42 +0200 +Subject: [PATCH 07/11] Fix uninitialized `err' in handle_extension() + +In handle_extension(), in the case of a second return from SCHEDSETJMP the +variable `err' would be used uninitialized. Fix this by avoiding any +access to `err' in this case. + +(cherry picked from commit 94c2e5c6be23c6323f24deacdad5f98fb9f0b1c2) +--- + coregrind/m_scheduler/scheduler.c | 10 ++++------ + 1 file changed, 4 insertions(+), 6 deletions(-) + +diff --git a/coregrind/m_scheduler/scheduler.c b/coregrind/m_scheduler/scheduler.c +index fc8cf7c9cb1d..29751bb28283 100644 +--- a/coregrind/m_scheduler/scheduler.c ++++ b/coregrind/m_scheduler/scheduler.c +@@ -1233,7 +1233,10 @@ static void handle_extension(ThreadId tid) + SCHEDSETJMP(tid, jumped, err = VG_(client_extension)(tid)); + vg_assert(VG_(is_running_thread)(tid)); + +- if (err != ExtErr_OK) { ++ if (jumped != (UWord)0) { ++ block_signals(); ++ VG_(poll_signals)(tid); ++ } else if (err != ExtErr_OK) { + ThreadState* tst = VG_(get_ThreadState)(tid); + Addr addr = tst->arch.vex.guest_IP_AT_SYSCALL; + switch (err) { +@@ -1244,11 +1247,6 @@ static void handle_extension(ThreadId tid) + VG_(core_panic)("scheduler: bad return code from extension"); + } + } +- +- if (jumped != (UWord)0) { +- block_signals(); +- VG_(poll_signals)(tid); +- } + } + + /* tid just requested a jump to the noredir version of its current +-- +2.45.2 + diff --git a/SOURCES/0008-Avoid-use-of-guest_IP_AT_SYSCALL-in-handle_extension.patch b/SOURCES/0008-Avoid-use-of-guest_IP_AT_SYSCALL-in-handle_extension.patch new file mode 100644 index 0000000..8e5f4ae --- /dev/null +++ b/SOURCES/0008-Avoid-use-of-guest_IP_AT_SYSCALL-in-handle_extension.patch @@ -0,0 +1,31 @@ +From 40b68ae8d6c869f098493e3a31d66f09170592e3 Mon Sep 17 00:00:00 2001 +From: Andreas Arnez +Date: Wed, 15 May 2024 14:32:42 +0200 +Subject: [PATCH 08/11] Avoid use of guest_IP_AT_SYSCALL in handle_extension() + +The guest state field guest_IP_AT_SYSCALL is referenced in +handle_extension(), even though it may not be defined by all +architectures. Avoid its use altogether. + +(cherry picked from commit 16249b21456d681b5d98400287b8dbd926050c75) +--- + coregrind/m_scheduler/scheduler.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/coregrind/m_scheduler/scheduler.c b/coregrind/m_scheduler/scheduler.c +index 29751bb28283..cc8d070b7930 100644 +--- a/coregrind/m_scheduler/scheduler.c ++++ b/coregrind/m_scheduler/scheduler.c +@@ -1237,8 +1237,7 @@ static void handle_extension(ThreadId tid) + block_signals(); + VG_(poll_signals)(tid); + } else if (err != ExtErr_OK) { +- ThreadState* tst = VG_(get_ThreadState)(tid); +- Addr addr = tst->arch.vex.guest_IP_AT_SYSCALL; ++ Addr addr = VG_(get_IP)(tid); + switch (err) { + case ExtErr_Illop: + VG_(synth_sigill)(tid, addr); +-- +2.45.2 + diff --git a/SOURCES/0009-s390x-Minor-fixes-in-extension-s390x.c.patch b/SOURCES/0009-s390x-Minor-fixes-in-extension-s390x.c.patch new file mode 100644 index 0000000..3bb1df0 --- /dev/null +++ b/SOURCES/0009-s390x-Minor-fixes-in-extension-s390x.c.patch @@ -0,0 +1,66 @@ +From ebe5fd9c0aae97767a4418d2f26f3281065b3e6a Mon Sep 17 00:00:00 2001 +From: Andreas Arnez +Date: Wed, 15 May 2024 14:32:42 +0200 +Subject: [PATCH 09/11] s390x: Minor fixes in extension-s390x.c + +Some tracker names for registers are not consistent with the naming +scheme. Also, there is a dead assignment to orig_addr2 and orig_len2. +Fix both. + +(cherry picked from commit 76f2218924f85547f670969b1a0b59e5200e22ec) +--- + coregrind/m_extension/extension-s390x.c | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +diff --git a/coregrind/m_extension/extension-s390x.c b/coregrind/m_extension/extension-s390x.c +index fd45c7ee948f..735406e6e4c5 100644 +--- a/coregrind/m_extension/extension-s390x.c ++++ b/coregrind/m_extension/extension-s390x.c +@@ -37,9 +37,9 @@ + + #undef SYSNO + +-#define READ_FUNCTION_CODE(tst) \ ++#define READ_FUNCTION_CODE(tst, extname) \ + ({ \ +- PRE_REG_READ(tst, "func_code", r0, 7, sizeof(UChar)); \ ++ PRE_REG_READ(tst, extname "(func_code)", r0, 7, sizeof(UChar)); \ + tst->arch.vex.guest_r0 & 0xff; \ + }) + +@@ -141,10 +141,10 @@ static enum ExtensionError do_extension_PRNO(ThreadState* tst, ULong variant) + { + UChar r1 = variant & 0xf; + UChar r2 = (variant >> 4) & 0xf; +- UChar func = READ_FUNCTION_CODE(tst); ++ UChar func = READ_FUNCTION_CODE(tst, "PRNO"); + UChar fc = func & 0x7f; + UChar mflag = func & 128; +- ULong parms = READ_GPR(tst, "r1", 1); ++ ULong parms = READ_GPR(tst, "PRNO(r1)", 1); + ULong parms_len; + Int cc = 0; + ULong orig_addr1 = 0, orig_len1 = 0, orig_addr2 = 0, orig_len2 = 0; +@@ -175,8 +175,8 @@ static enum ExtensionError do_extension_PRNO(ThreadState* tst, ULong variant) + PRE_MEM_WRITE(tst, "PRNO(op1)", addr1, len1); + } else { + // Seed operation +- addr2 = orig_addr2 = READ_GPR(tst, "PRNO(op2_addr)", r2); +- len2 = orig_len2 = READ_GPR(tst, "PRNO(op2_len)", r2 + 1); ++ addr2 = READ_GPR(tst, "PRNO(op2_addr)", r2); ++ len2 = READ_GPR(tst, "PRNO(op2_len)", r2 + 1); + PRE_MEM_READ(tst, "PRNO(op2)", addr2, len2); + } + PRE_MEM_WRITE(tst, "PRNO(parms)", parms, parms_len); +@@ -474,7 +474,7 @@ static enum ExtensionError do_extension_NNPA(ThreadState* tst, ULong variant) + { + ULong gpr0 = READ_GPR(tst, "NNPA(r0)", 0); + UChar fc = gpr0 & 0x7f; +- ULong parms_addr = READ_GPR(tst, "r1", 1); ++ ULong parms_addr = READ_GPR(tst, "NNPA(r1)", 1); + Int cc = 0; + ULong parms_len; + +-- +2.45.2 + diff --git a/SOURCES/0010-Bug-453044-gbserver_tests-failures-in-aarch64.patch b/SOURCES/0010-Bug-453044-gbserver_tests-failures-in-aarch64.patch new file mode 100644 index 0000000..7cc4012 --- /dev/null +++ b/SOURCES/0010-Bug-453044-gbserver_tests-failures-in-aarch64.patch @@ -0,0 +1,38 @@ +From 70d765faa162f2f12e7771db51877649637f2c12 Mon Sep 17 00:00:00 2001 +From: Jesus Checa +Date: Sat, 25 May 2024 12:40:30 +0200 +Subject: [PATCH 10/11] Bug 453044 - gbserver_tests failures in aarch64 + +(cherry picked from commit 790abdf7d3f3df0c968605b68ca765310689b7ce) +--- + NEWS | 1 + + gdbserver_tests/filter_gdb.in | 1 + + 2 files changed, 2 insertions(+) + +diff --git a/NEWS b/NEWS +index adb52169dd87..c2ad6a207d96 100644 +--- a/NEWS ++++ b/NEWS +@@ -5,6 +5,7 @@ Branch 3.23 + + The following bugs have been fixed or resolved on this branch. + ++453044 gbserver_tests failures in aarch64 + 486180 [MIPS] 'VexGuestArchState' has no member named 'guest_IP_AT_SYSCALL' + 486293 memccpy false positives + 486569 linux inotify_init syscall wrapper missing POST entry in syscall_table +diff --git a/gdbserver_tests/filter_gdb.in b/gdbserver_tests/filter_gdb.in +index 4118063f6bc6..497171732b25 100755 +--- a/gdbserver_tests/filter_gdb.in ++++ b/gdbserver_tests/filter_gdb.in +@@ -152,6 +152,7 @@ s/in _select ()/in syscall .../ + /sysv\/linux\/generic\/select.c/d + /return SYSCALL_CANCEL /d + /r = SYSCALL_CANCEL /d ++/result = SYSCALL_CANCEL /d + + # a more specialised system call select stack trace part + # (on 32 bits, we have an int_80, on 64 bits, directly select) +-- +2.45.2 + diff --git a/SOURCES/0011-Linux-regtest-reallocarray-needs-malloc.h.patch b/SOURCES/0011-Linux-regtest-reallocarray-needs-malloc.h.patch new file mode 100644 index 0000000..85f4415 --- /dev/null +++ b/SOURCES/0011-Linux-regtest-reallocarray-needs-malloc.h.patch @@ -0,0 +1,56 @@ +From 1c2cdfd790b3e26f47e709770bdefd456d83a7cb Mon Sep 17 00:00:00 2001 +From: Paul Floyd +Date: Tue, 4 Jun 2024 12:49:33 +0200 +Subject: [PATCH 11/11] Linux regtest: reallocarray needs malloc.h + +Seen on Rocky 8.9 + +(cherry picked from commit a015ad2e0db40076b4841220c7ab6d6853798936) +--- + memcheck/tests/amd64-linux/reallocarray.c | 1 + + memcheck/tests/amd64-linux/reallocarray.stderr.exp | 8 ++++---- + 2 files changed, 5 insertions(+), 4 deletions(-) + +diff --git a/memcheck/tests/amd64-linux/reallocarray.c b/memcheck/tests/amd64-linux/reallocarray.c +index 8765ca4997cb..ce63b80100da 100644 +--- a/memcheck/tests/amd64-linux/reallocarray.c ++++ b/memcheck/tests/amd64-linux/reallocarray.c +@@ -2,6 +2,7 @@ + #include + #include + #include ++#include + #include "../../memcheck.h" + + int main(void) +diff --git a/memcheck/tests/amd64-linux/reallocarray.stderr.exp b/memcheck/tests/amd64-linux/reallocarray.stderr.exp +index a1c8439cc9ef..20a1c4e8b4f9 100644 +--- a/memcheck/tests/amd64-linux/reallocarray.stderr.exp ++++ b/memcheck/tests/amd64-linux/reallocarray.stderr.exp +@@ -12,19 +12,19 @@ To see them, rerun with: --leak-check=full --show-leak-kinds=all + + realloc() with size 0 + at 0x........: reallocarray (vg_replace_malloc.c:...) +- by 0x........: main (reallocarray.c:13) ++ by 0x........: main (reallocarray.c:14) + Address 0x........ is 0 bytes inside a block of size 40 alloc'd + at 0x........: reallocarray (vg_replace_malloc.c:...) +- by 0x........: main (reallocarray.c:11) ++ by 0x........: main (reallocarray.c:12) + + All heap blocks were freed -- no leaks are possible + + realloc() with size 0 + at 0x........: reallocarray (vg_replace_malloc.c:...) +- by 0x........: main (reallocarray.c:16) ++ by 0x........: main (reallocarray.c:17) + Address 0x........ is 0 bytes inside a block of size 10 alloc'd + at 0x........: malloc (vg_replace_malloc.c:...) +- by 0x........: main (reallocarray.c:15) ++ by 0x........: main (reallocarray.c:16) + + All heap blocks were freed -- no leaks are possible + +-- +2.45.2 + diff --git a/SOURCES/0012-Bug-487439-SIGILL-in-JDK11-JDK17.patch b/SOURCES/0012-Bug-487439-SIGILL-in-JDK11-JDK17.patch new file mode 100644 index 0000000..5254b37 --- /dev/null +++ b/SOURCES/0012-Bug-487439-SIGILL-in-JDK11-JDK17.patch @@ -0,0 +1,184 @@ +From e62c7b4f9ee0a8c20c7211a92ad512f925e9515c Mon Sep 17 00:00:00 2001 +From: Paul Floyd +Date: Sun, 16 Jun 2024 09:25:51 +0200 +Subject: [PATCH 12/15] Bug 487439 - SIGILL in JDK11, JDK17 + +(cherry picked from commit c19d19d34a6dadaf4a9d590f516f813e9cbacdd0) +--- + .gitignore | 1 + + NEWS | 1 + + VEX/priv/guest_amd64_toIR.c | 2 +- + none/tests/amd64/Makefile.am | 3 + + none/tests/amd64/bug487439.cpp | 83 +++++++++++++++++++++++++++ + none/tests/amd64/bug487439.stderr.exp | 0 + none/tests/amd64/bug487439.stdout.exp | 1 + + none/tests/amd64/bug487439.vgtest | 2 + + 8 files changed, 92 insertions(+), 1 deletion(-) + create mode 100644 none/tests/amd64/bug487439.cpp + create mode 100644 none/tests/amd64/bug487439.stderr.exp + create mode 100644 none/tests/amd64/bug487439.stdout.exp + create mode 100644 none/tests/amd64/bug487439.vgtest + +diff --git a/NEWS b/NEWS +index c2ad6a207d96..fbe0f012ef0c 100644 +--- a/NEWS ++++ b/NEWS +@@ -9,6 +9,7 @@ The following bugs have been fixed or resolved on this branch. + 486180 [MIPS] 'VexGuestArchState' has no member named 'guest_IP_AT_SYSCALL' + 486293 memccpy false positives + 486569 linux inotify_init syscall wrapper missing POST entry in syscall_table ++487439 SIGILL in JDK11, JDK17 + n-i-bz aarch64 frinta and frinta vector instructions + + To see details of a given bug, visit +diff --git a/VEX/priv/guest_amd64_toIR.c b/VEX/priv/guest_amd64_toIR.c +index f0b1c5516267..28c37f092211 100644 +--- a/VEX/priv/guest_amd64_toIR.c ++++ b/VEX/priv/guest_amd64_toIR.c +@@ -14138,7 +14138,7 @@ Long dis_ESC_0F__SSE2 ( Bool* decode_OK, + goto decode_success; + } + /* 66 0F 73 /6 ib = PSLLQ by immediate */ +- if (have66noF2noF3(pfx) && sz == 2 ++ if (have66noF2noF3(pfx) && (sz == 2 || /* ignore redundant REX.W */ sz == 8) + && epartIsReg(getUChar(delta)) + && gregLO3ofRM(getUChar(delta)) == 6) { + delta = dis_SSE_shiftE_imm( pfx, delta, "psllq", Iop_ShlN64x2 ); +diff --git a/none/tests/amd64/Makefile.am b/none/tests/amd64/Makefile.am +index dc0498018209..83029c15590c 100644 +--- a/none/tests/amd64/Makefile.am ++++ b/none/tests/amd64/Makefile.am +@@ -44,6 +44,7 @@ EXTRA_DIST = \ + bug156404-amd64.vgtest bug156404-amd64.stdout.exp \ + bug156404-amd64.stderr.exp \ + bug485148.vgtest bug485148.stdout.exp bug485148.stderr.exp \ ++ bug487439.vgtest bug487439.stdout.exp bug487439.stderr.exp \ + cet_nops.vgtest cet_nops.stdout.exp cet_nops.stderr.exp \ + clc.vgtest clc.stdout.exp clc.stderr.exp \ + crc32.vgtest crc32.stdout.exp crc32.stderr.exp \ +@@ -107,6 +108,7 @@ check_PROGRAMS = \ + amd64locked \ + bt_flags \ + bug127521-64 bug132813-amd64 bug132918 bug137714-amd64 \ ++ bug487439 \ + cet_nops \ + clc \ + cmpxchg \ +@@ -204,6 +206,7 @@ amd64locked_CFLAGS = $(AM_CFLAGS) -O + bug132918_LDADD = -lm + bug485148_CXXFLAGS = ${AM_CXXFLAGS} -mfma + bug485148_SOURCES = bug485148.cpp ++bug487439_SOURCES = bug487439.cpp + cmpxchg_CFLAGS = $(AM_CFLAGS) @FLAG_NO_PIE@ + fb_test_amd64_CFLAGS = $(AM_CFLAGS) -O -fno-strict-aliasing + fb_test_amd64_LDADD = -lm +diff --git a/none/tests/amd64/bug487439.cpp b/none/tests/amd64/bug487439.cpp +new file mode 100644 +index 000000000000..f86bb65ce9eb +--- /dev/null ++++ b/none/tests/amd64/bug487439.cpp +@@ -0,0 +1,83 @@ ++// This is more or less a copy/paste from the generated insn_sse2.c ++// I didn't want to mess with the perl generator because ++// GCC and clang don't agree on the asm syntax ++// Using the rex prefix looks like a bug or misfeature in OpenJDK ++// so I'm assuming that this is a one-off and not a general issue ++ ++#include ++#include ++#include ++ ++union reg128_t { ++ char sb[16]; ++ unsigned char ub[16]; ++ short sw[8]; ++ unsigned short uw[8]; ++ int sd[4]; ++ unsigned int ud[4]; ++ long long int sq[2]; ++ unsigned long long int uq[2]; ++ float ps[4]; ++ double pd[2]; ++} __attribute__ ((aligned (16))); ++ ++static sigjmp_buf catchpoint; ++ ++static void handle_sigill(int signum) ++{ ++ siglongjmp(catchpoint, 1); ++} ++ ++/* with redundant rex.W */ ++static void psllq_4(void) ++{ ++ reg128_t arg1 = { .uq = { 0x0123456789abcdefULL, 0x0123456789abcdefULL } }; ++ reg128_t result0; ++ char state[108]; ++ ++ if (sigsetjmp(catchpoint, 1) == 0) ++ { ++ asm( ++ "ffree %%st(7)\n" ++ "ffree %%st(6)\n" ++ "ffree %%st(5)\n" ++ "ffree %%st(4)\n" ++ "movlps %2, %%xmm1\n" ++ "movhps %3, %%xmm1\n" ++ // only GCC ++ //".rex.W psllq $12, %%xmm1\n" ++ // only clang ++ //"data16 rex64 psllq $12, %mm1\n" ++ ".byte 0x66,0x48,0x0f,0x73,0xf1,0x0c\n" ++ "movlps %%xmm1, %0\n" ++ "movhps %%xmm1, %1\n" ++ "cld\n" ++ : "=m" (result0.uq[0]), "=m" (result0.uq[1]) ++ : "m" (arg1.uq[0]), "m" (arg1.uq[1]), "m" (state[0]) ++ : "xmm1" ++ ); ++ ++ if (result0.uq[0] == 0x3456789abcdef000ULL && result0.uq[1] == 0x3456789abcdef000ULL ) ++ { ++ std::cout << "psllq_4 ... ok\n"; ++ } ++ else ++ { ++ std::cout << "psllq_4 ... not ok\n"; ++ std::cout << " result0.uq[0] = " << result0.uq[0] << " (expected " << 0x3456789abcdef000ULL << ")\n"; ++ std::cout << " result0.uq[1] = " << result0.uq[1] << " (expected " << 0x3456789abcdef000ULL << ")\n"; ++ } ++ } ++ else ++ { ++ std::cout << "psllq_4 ... failed\n"; ++ } ++ ++ return; ++} ++ ++int main() ++{ ++ signal(SIGILL, handle_sigill); ++ psllq_4(); ++} +diff --git a/none/tests/amd64/bug487439.stderr.exp b/none/tests/amd64/bug487439.stderr.exp +new file mode 100644 +index 000000000000..e69de29bb2d1 +diff --git a/none/tests/amd64/bug487439.stdout.exp b/none/tests/amd64/bug487439.stdout.exp +new file mode 100644 +index 000000000000..065b518a27d7 +--- /dev/null ++++ b/none/tests/amd64/bug487439.stdout.exp +@@ -0,0 +1 @@ ++psllq_4 ... ok +diff --git a/none/tests/amd64/bug487439.vgtest b/none/tests/amd64/bug487439.vgtest +new file mode 100644 +index 000000000000..3faa1ed6b014 +--- /dev/null ++++ b/none/tests/amd64/bug487439.vgtest +@@ -0,0 +1,2 @@ ++prog: bug487439 ++vgopts: -q +-- +2.45.2 + diff --git a/SOURCES/0013-Don-t-leave-fds-created-with-log-file-xml-file-or-lo.patch b/SOURCES/0013-Don-t-leave-fds-created-with-log-file-xml-file-or-lo.patch new file mode 100644 index 0000000..bdabc23 --- /dev/null +++ b/SOURCES/0013-Don-t-leave-fds-created-with-log-file-xml-file-or-lo.patch @@ -0,0 +1,226 @@ +From 14cefe7c645a3148165f4b2fa6095d9446e378c7 Mon Sep 17 00:00:00 2001 +From: Mark Wielaard +Date: Sun, 16 Jun 2024 21:23:08 +0200 +Subject: [PATCH 13/15] Don't leave fds created with --log-file, --xml-file or + --log-socket open +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +prepare_sink_fd and prepare_sink_socket will create a new file +descriptor for the output sink. finalize_sink_fd then copies the fd +to the safe range, so it doesn't conflict with any application fds. + +If we created the original fd ourselves, it was a VgLogTo_File or +VgLogTo_Socket, not VgLogTo_Fd, finalize_sink_fd should close it. + +Also close socket when connecting fails in VG_(connect_via_socket). + +Add a testcase for --log-file and --xml-file which prints output to +/dev/stderr + +https://bugs.kde.org/show_bug.cgi?id=202770 +https://bugs.kde.org/show_bug.cgi?id=311655 +https://bugs.kde.org/show_bug.cgi?id=488379 + +Co-authored-by: Alexandra Hájková fd = safe_fd; ++ /* If we created the new_fd (VgLogTo_File or VgLogTo_Socket), then we ++ don't need the original file descriptor open anymore. We only need ++ to keep it open if it was an existing fd given by the user (or ++ stderr). */ ++ if (sink->type != VgLogTo_Fd) ++ VG_(close)(new_fd); + } + } + +diff --git a/none/tests/Makefile.am b/none/tests/Makefile.am +index 185993f204bb..532cc7632a8f 100644 +--- a/none/tests/Makefile.am ++++ b/none/tests/Makefile.am +@@ -86,6 +86,7 @@ dist_noinst_SCRIPTS = \ + filter_none_discards \ + filter_stderr \ + filter_timestamp \ ++ filter_xml \ + allexec_prepare_prereq + + noinst_HEADERS = fdleak.h +@@ -229,7 +230,9 @@ EXTRA_DIST = \ + sigprocmask.stderr.exp sigprocmask.vgtest \ + socket_close.stderr.exp socket_close.vgtest \ + file_dclose.stderr.exp file_dclose.vgtest \ +- double_close_range.stderr.exp double_close_range.vgtest ++ double_close_range.stderr.exp double_close_range.vgtest \ ++ log-track-fds.stderr.exp log-track-fds.vgtest \ ++ xml-track-fds.stderr.exp xml-track-fds.vgtest + + + check_PROGRAMS = \ +diff --git a/none/tests/filter_xml b/none/tests/filter_xml +new file mode 100755 +index 000000000000..d1ef570a05b0 +--- /dev/null ++++ b/none/tests/filter_xml +@@ -0,0 +1,25 @@ ++#! /bin/sh ++ ++dir=`dirname $0` ++ ++# FreeBSD adds this one extra line ++# but after filter_xml_frames it will just be ...<\/path> ++# which matches other lines, so get rid of it while we can ++# uniquely match it ++sed "/internet<\/path>/d" | ++ ++$dir/../../tests/filter_xml_frames | ++perl -p -e "s/