summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2024-03-28 22:50:32 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-03-30 22:22:19 +0000
commitb7df5bd45d62183e2785e7458675eb5962c743e6 (patch)
treeb620fb4583a35362c2f9f71a16ff9730ae39b38a
parent4a8b005afc580e682bef6653e44eecc4483a8990 (diff)
downloadpoky-b7df5bd45d62183e2785e7458675eb5962c743e6.tar.gz
valgrind: Backport fixes from 3.22 branch
These fixes are helping some ptests on musl and 6.6 kernel (From OE-Core rev: 151dfe7a7bb21cda213ae539f40d17008ad6ff3e) Signed-off-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/recipes-devtools/valgrind/valgrind/0001-valgrind-monitor.py-regular-expressions-should-use-r.patch64
-rw-r--r--meta/recipes-devtools/valgrind/valgrind/0002-Bug-476548-valgrind-3.22.0-fails-on-assertion-when-l.patch147
-rw-r--r--meta/recipes-devtools/valgrind/valgrind/0003-Add-fchmodat2-syscall-on-linux.patch221
-rw-r--r--meta/recipes-devtools/valgrind/valgrind/0004-Bug-478624-Valgrind-incompatibility-with-binutils-2..patch137
-rw-r--r--meta/recipes-devtools/valgrind/valgrind_3.22.0.bb4
5 files changed, 573 insertions, 0 deletions
diff --git a/meta/recipes-devtools/valgrind/valgrind/0001-valgrind-monitor.py-regular-expressions-should-use-r.patch b/meta/recipes-devtools/valgrind/valgrind/0001-valgrind-monitor.py-regular-expressions-should-use-r.patch
new file mode 100644
index 0000000000..80a8e3a10b
--- /dev/null
+++ b/meta/recipes-devtools/valgrind/valgrind/0001-valgrind-monitor.py-regular-expressions-should-use-r.patch
@@ -0,0 +1,64 @@
1From 027b649fdb831868e71be01cafdacc49a5f419ab Mon Sep 17 00:00:00 2001
2From: Mark Wielaard <mark@klomp.org>
3Date: Fri, 17 Nov 2023 14:01:21 +0100
4Subject: [PATCH 1/4] valgrind-monitor.py regular expressions should use raw
5 strings
6
7With python 3.12 gdb will produce the following SyntaxWarning when
8loading valgrind-monitor-def.py:
9
10 /usr/share/gdb/auto-load/valgrind-monitor-def.py:214:
11 SyntaxWarning: invalid escape sequence '\['
12 if re.fullmatch("^0x[0123456789ABCDEFabcdef]+\[[^\[\]]+\]$", arg_str):
13
14In a future python version this will become an SyntaxError.
15
16Use a raw strings for the regular expression.
17
18https://bugs.kde.org/show_bug.cgi?id=476708
19(cherry picked from commit 0fbfbe05028ad18efda786a256a2738d2c231ed4)
20
21Upstream-Status: Backport [https://sourceware.org/git/?p=valgrind.git;a=commit;h=027b649fdb831868e71be01cafdacc49a5f419ab]
22Signed-off-by: Khem Raj <raj.khem@gmail.com>
23---
24 NEWS | 13 +++++++++++++
25 coregrind/m_gdbserver/valgrind-monitor-def.py | 2 +-
26 2 files changed, 14 insertions(+), 1 deletion(-)
27
28diff --git a/NEWS b/NEWS
29index f11da4be8..ee5b4ff11 100644
30--- a/NEWS
31+++ b/NEWS
32@@ -1,3 +1,16 @@
33+Branch 3.22
34+~~~~~~~~~~~
35+
36+* ==================== FIXED BUGS ====================
37+
38+The following bugs have been fixed or resolved on this branch.
39+
40+476708 valgrind-monitor.py regular expressions should use raw strings
41+
42+To see details of a given bug, visit
43+ https://bugs.kde.org/show_bug.cgi?id=XXXXXX
44+where XXXXXX is the bug number as listed above.
45+
46 Release 3.22.0 (31 Oct 2023)
47 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
48
49diff --git a/coregrind/m_gdbserver/valgrind-monitor-def.py b/coregrind/m_gdbserver/valgrind-monitor-def.py
50index b4e7b992d..d74b1590c 100644
51--- a/coregrind/m_gdbserver/valgrind-monitor-def.py
52+++ b/coregrind/m_gdbserver/valgrind-monitor-def.py
53@@ -211,7 +211,7 @@ class Valgrind_ADDR_LEN_opt(Valgrind_Command):
54 For compatibility reason with the Valgrind gdbserver monitor command,
55 we detect and accept usages such as 0x1234ABCD[10]."""
56 def invoke(self, arg_str : str, from_tty : bool) -> None:
57- if re.fullmatch("^0x[0123456789ABCDEFabcdef]+\[[^\[\]]+\]$", arg_str):
58+ if re.fullmatch(r"^0x[0123456789ABCDEFabcdef]+\[[^\[\]]+\]$", arg_str):
59 arg_str = arg_str.replace("[", " ")
60 arg_str = arg_str.replace("]", " ")
61 eval_execute_2(self, arg_str,
62--
632.44.0
64
diff --git a/meta/recipes-devtools/valgrind/valgrind/0002-Bug-476548-valgrind-3.22.0-fails-on-assertion-when-l.patch b/meta/recipes-devtools/valgrind/valgrind/0002-Bug-476548-valgrind-3.22.0-fails-on-assertion-when-l.patch
new file mode 100644
index 0000000000..5759fa039a
--- /dev/null
+++ b/meta/recipes-devtools/valgrind/valgrind/0002-Bug-476548-valgrind-3.22.0-fails-on-assertion-when-l.patch
@@ -0,0 +1,147 @@
1From 1d00e5ce0fb069911c4b525ec38289fb5d9021b0 Mon Sep 17 00:00:00 2001
2From: Paul Floyd <pjfloyd@wanadoo.fr>
3Date: Sat, 18 Nov 2023 08:49:34 +0100
4Subject: [PATCH 2/4] Bug 476548 - valgrind 3.22.0 fails on assertion when
5 loading debuginfo file produced by mold
6
7(cherry picked from commit 9ea4ae66707a4dcc6f4328e11911652e4418c585)
8
9Upstream-Status: Backport [https://sourceware.org/git/?p=valgrind.git;a=commit;h=1d00e5ce0fb069911c4b525ec38289fb5d9021b0]
10Signed-off-by: Khem Raj <raj.khem@gmail.com>
11---
12 NEWS | 2 ++
13 coregrind/m_debuginfo/image.c | 14 +++++++++
14 coregrind/m_debuginfo/priv_image.h | 4 +++
15 coregrind/m_debuginfo/readelf.c | 49 ++++++++++++++++++++++++++++--
16 4 files changed, 66 insertions(+), 3 deletions(-)
17
18diff --git a/NEWS b/NEWS
19index ee5b4ff11..6cd13429a 100644
20--- a/NEWS
21+++ b/NEWS
22@@ -5,6 +5,8 @@ Branch 3.22
23
24 The following bugs have been fixed or resolved on this branch.
25
26+476548 valgrind 3.22.0 fails on assertion when loading debuginfo
27+ file produced by mold
28 476708 valgrind-monitor.py regular expressions should use raw strings
29
30 To see details of a given bug, visit
31diff --git a/coregrind/m_debuginfo/image.c b/coregrind/m_debuginfo/image.c
32index 02e509071..445f95555 100644
33--- a/coregrind/m_debuginfo/image.c
34+++ b/coregrind/m_debuginfo/image.c
35@@ -1221,6 +1221,20 @@ Int ML_(img_strcmp_c)(DiImage* img, DiOffT off1, const HChar* str2)
36 }
37 }
38
39+Int ML_(img_strcmp_n)(DiImage* img, DiOffT off1, const HChar* str2, Word n)
40+{
41+ ensure_valid(img, off1, 1, "ML_(img_strcmp_c)");
42+ while (n) {
43+ UChar c1 = get(img, off1);
44+ UChar c2 = *(const UChar*)str2;
45+ if (c1 < c2) return -1;
46+ if (c1 > c2) return 1;
47+ if (c1 == 0) return 0;
48+ off1++; str2++; --n;
49+ }
50+ return 0;
51+}
52+
53 UChar ML_(img_get_UChar)(DiImage* img, DiOffT offset)
54 {
55 ensure_valid(img, offset, 1, "ML_(img_get_UChar)");
56diff --git a/coregrind/m_debuginfo/priv_image.h b/coregrind/m_debuginfo/priv_image.h
57index a49846f14..c91e49f01 100644
58--- a/coregrind/m_debuginfo/priv_image.h
59+++ b/coregrind/m_debuginfo/priv_image.h
60@@ -115,6 +115,10 @@ Int ML_(img_strcmp)(DiImage* img, DiOffT off1, DiOffT off2);
61 cast to HChar before comparison. */
62 Int ML_(img_strcmp_c)(DiImage* img, DiOffT off1, const HChar* str2);
63
64+/* Do strncmp of a C string in the image vs a normal one. Chars are
65+ cast to HChar before comparison. */
66+Int ML_(img_strcmp_n)(DiImage* img, DiOffT off1, const HChar* str2, Word n);
67+
68 /* Do strlen of a C string in the image. */
69 SizeT ML_(img_strlen)(DiImage* img, DiOffT off);
70
71diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c
72index fb64ed976..46f8c8343 100644
73--- a/coregrind/m_debuginfo/readelf.c
74+++ b/coregrind/m_debuginfo/readelf.c
75@@ -2501,8 +2501,7 @@ Bool ML_(read_elf_object) ( struct _DebugInfo* di )
76 di->rodata_avma += inrw1->bias;
77 di->rodata_bias = inrw1->bias;
78 di->rodata_debug_bias = inrw1->bias;
79- }
80- else {
81+ } else {
82 BAD(".rodata"); /* should not happen? */
83 }
84 di->rodata_present = True;
85@@ -2977,6 +2976,46 @@ Bool ML_(read_elf_object) ( struct _DebugInfo* di )
86 return retval;
87 }
88
89+static void find_rodata(Word i, Word shnum, DiImage* dimg, struct _DebugInfo* di, DiOffT shdr_dioff,
90+ UWord shdr_dent_szB, DiOffT shdr_strtab_dioff, PtrdiffT rw_dbias)
91+{
92+ ElfXX_Shdr a_shdr;
93+ ElfXX_Shdr a_extra_shdr;
94+ ML_(img_get)(&a_shdr, dimg,
95+ INDEX_BIS(shdr_dioff, i, shdr_dent_szB),
96+ sizeof(a_shdr));
97+ if (di->rodata_present &&
98+ 0 == ML_(img_strcmp_c)(dimg, shdr_strtab_dioff
99+ + a_shdr.sh_name, ".rodata")) {
100+ Word sh_size = a_shdr.sh_size;
101+ Word j;
102+ Word next_addr = a_shdr.sh_addr + a_shdr.sh_size;
103+ for (j = i + 1; j < shnum; ++j) {
104+ ML_(img_get)(&a_extra_shdr, dimg,
105+ INDEX_BIS(shdr_dioff, j, shdr_dent_szB),
106+ sizeof(a_shdr));
107+ if (0 == ML_(img_strcmp_n)(dimg, shdr_strtab_dioff
108+ + a_extra_shdr.sh_name, ".rodata", 7)) {
109+ if (a_extra_shdr.sh_addr ==
110+ VG_ROUNDUP(next_addr, a_extra_shdr.sh_addralign)) {
111+ sh_size = VG_ROUNDUP(sh_size, a_extra_shdr.sh_addralign) + a_extra_shdr.sh_size;
112+ }
113+ next_addr = a_extra_shdr.sh_addr + a_extra_shdr.sh_size;
114+ } else {
115+ break;
116+ }
117+ }
118+ vg_assert(di->rodata_size == sh_size);
119+ vg_assert(di->rodata_avma + a_shdr.sh_addr + rw_dbias);
120+ di->rodata_debug_svma = a_shdr.sh_addr;
121+ di->rodata_debug_bias = di->rodata_bias +
122+ di->rodata_svma - di->rodata_debug_svma;
123+ TRACE_SYMTAB("acquiring .rodata debug svma = %#lx .. %#lx\n",
124+ di->rodata_debug_svma,
125+ di->rodata_debug_svma + di->rodata_size - 1);
126+ TRACE_SYMTAB("acquiring .rodata debug bias = %#lx\n", (UWord)di->rodata_debug_bias);
127+ }
128+}
129 Bool ML_(read_elf_debug) ( struct _DebugInfo* di )
130 {
131 Word i, j;
132@@ -3391,7 +3430,11 @@ Bool ML_(read_elf_debug) ( struct _DebugInfo* di )
133 FIND(text, rx)
134 FIND(data, rw)
135 FIND(sdata, rw)
136- FIND(rodata, rw)
137+ // https://bugs.kde.org/show_bug.cgi?id=476548
138+ // special handling for rodata as adjacent
139+ // rodata sections may have been merged in ML_(read_elf_object)
140+ //FIND(rodata, rw)
141+ find_rodata(i, ehdr_dimg.e_shnum, dimg, di, shdr_dioff, shdr_dent_szB, shdr_strtab_dioff, rw_dbias);
142 FIND(bss, rw)
143 FIND(sbss, rw)
144
145--
1462.44.0
147
diff --git a/meta/recipes-devtools/valgrind/valgrind/0003-Add-fchmodat2-syscall-on-linux.patch b/meta/recipes-devtools/valgrind/valgrind/0003-Add-fchmodat2-syscall-on-linux.patch
new file mode 100644
index 0000000000..2a09ca52b7
--- /dev/null
+++ b/meta/recipes-devtools/valgrind/valgrind/0003-Add-fchmodat2-syscall-on-linux.patch
@@ -0,0 +1,221 @@
1From a43e62dddcf51ec6578a90c5988a41e856b44b05 Mon Sep 17 00:00:00 2001
2From: Mark Wielaard <mark@klomp.org>
3Date: Sat, 18 Nov 2023 21:17:02 +0100
4Subject: [PATCH 3/4] Add fchmodat2 syscall on linux
5
6fchmodat2 is a new syscall on linux 6.6. It is a variant of fchmodat
7that takes an extra flags argument.
8
9https://bugs.kde.org/show_bug.cgi?id=477198
10
11(cherry picked from commit 372d09fd9a8d76847c81092ebff71c80fd6c145d)
12
13Upstream-Status: Backport [https://sourceware.org/git/?p=valgrind.git;a=commit;h=a43e62dddcf51ec6578a90c5988a41e856b44b05]
14Signed-off-by: Khem Raj <raj.khem@gmail.com>
15---
16 NEWS | 1 +
17 coregrind/m_syswrap/priv_syswrap-linux.h | 3 +++
18 coregrind/m_syswrap/syswrap-amd64-linux.c | 2 ++
19 coregrind/m_syswrap/syswrap-arm-linux.c | 2 ++
20 coregrind/m_syswrap/syswrap-arm64-linux.c | 2 ++
21 coregrind/m_syswrap/syswrap-linux.c | 11 +++++++++++
22 coregrind/m_syswrap/syswrap-mips32-linux.c | 2 ++
23 coregrind/m_syswrap/syswrap-mips64-linux.c | 1 +
24 coregrind/m_syswrap/syswrap-nanomips-linux.c | 1 +
25 coregrind/m_syswrap/syswrap-ppc32-linux.c | 2 ++
26 coregrind/m_syswrap/syswrap-ppc64-linux.c | 2 ++
27 coregrind/m_syswrap/syswrap-s390x-linux.c | 2 ++
28 coregrind/m_syswrap/syswrap-x86-linux.c | 2 ++
29 include/vki/vki-scnums-shared-linux.h | 2 ++
30 14 files changed, 35 insertions(+)
31
32diff --git a/NEWS b/NEWS
33index 6cd13429a..da0f8c1aa 100644
34--- a/NEWS
35+++ b/NEWS
36@@ -8,6 +8,7 @@ The following bugs have been fixed or resolved on this branch.
37 476548 valgrind 3.22.0 fails on assertion when loading debuginfo
38 file produced by mold
39 476708 valgrind-monitor.py regular expressions should use raw strings
40+477198 Add fchmodat2 syscall on linux
41
42 To see details of a given bug, visit
43 https://bugs.kde.org/show_bug.cgi?id=XXXXXX
44diff --git a/coregrind/m_syswrap/priv_syswrap-linux.h b/coregrind/m_syswrap/priv_syswrap-linux.h
45index 7c9decf5a..798c456c9 100644
46--- a/coregrind/m_syswrap/priv_syswrap-linux.h
47+++ b/coregrind/m_syswrap/priv_syswrap-linux.h
48@@ -331,6 +331,9 @@ DECL_TEMPLATE(linux, sys_openat2);
49 // Linux-specific (new in Linux 5.14)
50 DECL_TEMPLATE(linux, sys_memfd_secret);
51
52+// Since Linux 6.6
53+DECL_TEMPLATE(linux, sys_fchmodat2);
54+
55 /* ---------------------------------------------------------------------
56 Wrappers for sockets and ipc-ery. These are split into standalone
57 procedures because x86-linux hides them inside multiplexors
58diff --git a/coregrind/m_syswrap/syswrap-amd64-linux.c b/coregrind/m_syswrap/syswrap-amd64-linux.c
59index 008600798..fe17d118b 100644
60--- a/coregrind/m_syswrap/syswrap-amd64-linux.c
61+++ b/coregrind/m_syswrap/syswrap-amd64-linux.c
62@@ -886,6 +886,8 @@ static SyscallTableEntry syscall_table[] = {
63 LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441
64
65 LINXY(__NR_memfd_secret, sys_memfd_secret), // 447
66+
67+ LINX_(__NR_fchmodat2, sys_fchmodat2), // 452
68 };
69
70 SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno )
71diff --git a/coregrind/m_syswrap/syswrap-arm-linux.c b/coregrind/m_syswrap/syswrap-arm-linux.c
72index 9a7a1e0d2..811931d3b 100644
73--- a/coregrind/m_syswrap/syswrap-arm-linux.c
74+++ b/coregrind/m_syswrap/syswrap-arm-linux.c
75@@ -1059,6 +1059,8 @@ static SyscallTableEntry syscall_main_table[] = {
76 LINX_(__NR_faccessat2, sys_faccessat2), // 439
77
78 LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441
79+
80+ LINX_(__NR_fchmodat2, sys_fchmodat2), // 452
81 };
82
83
84diff --git a/coregrind/m_syswrap/syswrap-arm64-linux.c b/coregrind/m_syswrap/syswrap-arm64-linux.c
85index 6af7bab83..3307bc2ca 100644
86--- a/coregrind/m_syswrap/syswrap-arm64-linux.c
87+++ b/coregrind/m_syswrap/syswrap-arm64-linux.c
88@@ -840,6 +840,8 @@ static SyscallTableEntry syscall_main_table[] = {
89 LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441
90
91 LINXY(__NR_memfd_secret, sys_memfd_secret), // 447
92+
93+ LINX_(__NR_fchmodat2, sys_fchmodat2), // 452
94 };
95
96
97diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c
98index d571fc327..efa47f2e6 100644
99--- a/coregrind/m_syswrap/syswrap-linux.c
100+++ b/coregrind/m_syswrap/syswrap-linux.c
101@@ -6059,6 +6059,17 @@ PRE(sys_fchmodat)
102 PRE_MEM_RASCIIZ( "fchmodat(path)", ARG2 );
103 }
104
105+PRE(sys_fchmodat2)
106+{
107+ PRINT("sys_fchmodat2 ( %ld, %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u, %"
108+ FMT_REGWORD "u )",
109+ SARG1, ARG2, (HChar*)(Addr)ARG2, ARG3, ARG4);
110+ PRE_REG_READ4(long, "fchmodat2",
111+ int, dfd, const char *, path, vki_mode_t, mode,
112+ unsigned int, flags);
113+ PRE_MEM_RASCIIZ( "fchmodat2(pathname)", ARG2 );
114+}
115+
116 PRE(sys_faccessat)
117 {
118 PRINT("sys_faccessat ( %ld, %#" FMT_REGWORD "x(%s), %ld )",
119diff --git a/coregrind/m_syswrap/syswrap-mips32-linux.c b/coregrind/m_syswrap/syswrap-mips32-linux.c
120index 6268a00dd..74a1f6eac 100644
121--- a/coregrind/m_syswrap/syswrap-mips32-linux.c
122+++ b/coregrind/m_syswrap/syswrap-mips32-linux.c
123@@ -1143,6 +1143,8 @@ static SyscallTableEntry syscall_main_table[] = {
124 LINX_ (__NR_faccessat2, sys_faccessat2), // 439
125
126 LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441
127+
128+ LINX_(__NR_fchmodat2, sys_fchmodat2), // 452
129 };
130
131 SyscallTableEntry* ML_(get_linux_syscall_entry) (UInt sysno)
132diff --git a/coregrind/m_syswrap/syswrap-mips64-linux.c b/coregrind/m_syswrap/syswrap-mips64-linux.c
133index 6cdf25893..4e8508b7a 100644
134--- a/coregrind/m_syswrap/syswrap-mips64-linux.c
135+++ b/coregrind/m_syswrap/syswrap-mips64-linux.c
136@@ -820,6 +820,7 @@ static SyscallTableEntry syscall_main_table[] = {
137 LINXY (__NR_close_range, sys_close_range),
138 LINX_ (__NR_faccessat2, sys_faccessat2),
139 LINXY(__NR_epoll_pwait2, sys_epoll_pwait2),
140+ LINX_ (__NR_fchmodat2, sys_fchmodat2),
141 };
142
143 SyscallTableEntry * ML_(get_linux_syscall_entry) ( UInt sysno )
144diff --git a/coregrind/m_syswrap/syswrap-nanomips-linux.c b/coregrind/m_syswrap/syswrap-nanomips-linux.c
145index d724cde74..7859900c1 100644
146--- a/coregrind/m_syswrap/syswrap-nanomips-linux.c
147+++ b/coregrind/m_syswrap/syswrap-nanomips-linux.c
148@@ -829,6 +829,7 @@ static SyscallTableEntry syscall_main_table[] = {
149 LINXY (__NR_close_range, sys_close_range),
150 LINX_ (__NR_faccessat2, sys_faccessat2),
151 LINXY (__NR_epoll_pwait2, sys_epoll_pwait2),
152+ LINX_ (__NR_fchmodat2, sys_fchmodat2),
153 };
154
155 SyscallTableEntry* ML_(get_linux_syscall_entry) (UInt sysno)
156diff --git a/coregrind/m_syswrap/syswrap-ppc32-linux.c b/coregrind/m_syswrap/syswrap-ppc32-linux.c
157index c0cfef235..1e19116ee 100644
158--- a/coregrind/m_syswrap/syswrap-ppc32-linux.c
159+++ b/coregrind/m_syswrap/syswrap-ppc32-linux.c
160@@ -1063,6 +1063,8 @@ static SyscallTableEntry syscall_table[] = {
161 LINX_(__NR_faccessat2, sys_faccessat2), // 439
162
163 LINXY (__NR_epoll_pwait2, sys_epoll_pwait2), // 441
164+
165+ LINX_ (__NR_fchmodat2, sys_fchmodat2), // 452
166 };
167
168 SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno )
169diff --git a/coregrind/m_syswrap/syswrap-ppc64-linux.c b/coregrind/m_syswrap/syswrap-ppc64-linux.c
170index f5976f30c..1097212a4 100644
171--- a/coregrind/m_syswrap/syswrap-ppc64-linux.c
172+++ b/coregrind/m_syswrap/syswrap-ppc64-linux.c
173@@ -1032,6 +1032,8 @@ static SyscallTableEntry syscall_table[] = {
174 LINX_(__NR_faccessat2, sys_faccessat2), // 439
175
176 LINXY (__NR_epoll_pwait2, sys_epoll_pwait2), // 441
177+
178+ LINX_ (__NR_fchmodat2, sys_fchmodat2), // 452
179 };
180
181 SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno )
182diff --git a/coregrind/m_syswrap/syswrap-s390x-linux.c b/coregrind/m_syswrap/syswrap-s390x-linux.c
183index afba154e7..3588672c7 100644
184--- a/coregrind/m_syswrap/syswrap-s390x-linux.c
185+++ b/coregrind/m_syswrap/syswrap-s390x-linux.c
186@@ -873,6 +873,8 @@ static SyscallTableEntry syscall_table[] = {
187 LINX_(__NR_faccessat2, sys_faccessat2), // 439
188
189 LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441
190+
191+ LINX_ (__NR_fchmodat2, sys_fchmodat2), // 452
192 };
193
194 SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno )
195diff --git a/coregrind/m_syswrap/syswrap-x86-linux.c b/coregrind/m_syswrap/syswrap-x86-linux.c
196index da4fd8fa2..58badc6b0 100644
197--- a/coregrind/m_syswrap/syswrap-x86-linux.c
198+++ b/coregrind/m_syswrap/syswrap-x86-linux.c
199@@ -1658,6 +1658,8 @@ static SyscallTableEntry syscall_table[] = {
200 LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441
201
202 LINXY(__NR_memfd_secret, sys_memfd_secret), // 447
203+
204+ LINX_(__NR_fchmodat2, sys_fchmodat2), // 452
205 };
206
207 SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno )
208diff --git a/include/vki/vki-scnums-shared-linux.h b/include/vki/vki-scnums-shared-linux.h
209index 542382b53..a4cd87149 100644
210--- a/include/vki/vki-scnums-shared-linux.h
211+++ b/include/vki/vki-scnums-shared-linux.h
212@@ -50,4 +50,6 @@
213
214 #define __NR_memfd_secret 447
215
216+#define __NR_fchmodat2 452
217+
218 #endif
219--
2202.44.0
221
diff --git a/meta/recipes-devtools/valgrind/valgrind/0004-Bug-478624-Valgrind-incompatibility-with-binutils-2..patch b/meta/recipes-devtools/valgrind/valgrind/0004-Bug-478624-Valgrind-incompatibility-with-binutils-2..patch
new file mode 100644
index 0000000000..4e9185508a
--- /dev/null
+++ b/meta/recipes-devtools/valgrind/valgrind/0004-Bug-478624-Valgrind-incompatibility-with-binutils-2..patch
@@ -0,0 +1,137 @@
1From 41ff9aa49f6c54c66d0e6b37f265fd9cb0176057 Mon Sep 17 00:00:00 2001
2From: Paul Floyd <pjfloyd@wanadoo.fr>
3Date: Sun, 17 Dec 2023 14:18:51 +0100
4Subject: [PATCH 4/4] Bug 478624 - Valgrind incompatibility with binutils-2.42
5 on x86 with new nop patterns (unhandled instruction bytes: 0x2E 0x8D 0xB4
6 0x26)
7
8It was a bit of a struggle to get the testcase to build
9with both clang and gcc (oddly enough gcc was more difficult) so
10I just resorted to using .byte arrays.
11
12(cherry picked from commit d35005cef8ad8207542738812705ceabf137d7e0)
13
14Upstream-Status: Backport [https://sourceware.org/git/?p=valgrind.git;a=commit;h=41ff9aa49f6c54c66d0e6b37f265fd9cb0176057]
15Signed-off-by: Khem Raj <raj.khem@gmail.com>
16---
17 .gitignore | 1 +
18 NEWS | 2 ++
19 VEX/priv/guest_x86_toIR.c | 22 +++++++++++++-
20 none/tests/x86/Makefile.am | 2 ++
21 none/tests/x86/gnu_binutils_nop.c | 34 ++++++++++++++++++++++
22 none/tests/x86/gnu_binutils_nop.stderr.exp | 0
23 none/tests/x86/gnu_binutils_nop.vgtest | 2 ++
24 7 files changed, 62 insertions(+), 1 deletion(-)
25 create mode 100644 none/tests/x86/gnu_binutils_nop.c
26 create mode 100644 none/tests/x86/gnu_binutils_nop.stderr.exp
27 create mode 100644 none/tests/x86/gnu_binutils_nop.vgtest
28
29--- a/NEWS
30+++ b/NEWS
31@@ -9,6 +9,8 @@ The following bugs have been fixed or re
32 file produced by mold
33 476708 valgrind-monitor.py regular expressions should use raw strings
34 477198 Add fchmodat2 syscall on linux
35+478624 Valgrind incompatibility with binutils-2.42 on x86 with new nop patterns
36+ (unhandled instruction bytes: 0x2E 0x8D 0xB4 0x26)
37
38 To see details of a given bug, visit
39 https://bugs.kde.org/show_bug.cgi?id=XXXXXX
40--- a/VEX/priv/guest_x86_toIR.c
41+++ b/VEX/priv/guest_x86_toIR.c
42@@ -8198,7 +8198,7 @@ DisResult disInstr_X86_WRK (
43 delta += 5;
44 goto decode_success;
45 }
46- /* Don't barf on recent binutils padding,
47+ /* Don't barf on recent (2010) binutils padding,
48 all variants of which are: nopw %cs:0x0(%eax,%eax,1)
49 66 2e 0f 1f 84 00 00 00 00 00
50 66 66 2e 0f 1f 84 00 00 00 00 00
51@@ -8222,6 +8222,26 @@ DisResult disInstr_X86_WRK (
52 goto decode_success;
53 }
54 }
55+
56+ /* bug478624 GNU binutils uses a leal of esi into itself with
57+ a zero offset and CS prefix as an 8 byte no-op (Dec 2023).
58+ Since the CS prefix is hardly ever used we don't do much
59+ to decode it, just a few cases for conditional branches.
60+ So add handling here with other pseudo-no-ops.
61+ */
62+ if (code[0] == 0x2E && code[1] == 0x8D) {
63+ if (code[2] == 0x74 && code[3] == 0x26 && code[4] == 0x00) {
64+ DIP("leal %%cs:0(%%esi,%%eiz,1),%%esi\n");
65+ delta += 5;
66+ goto decode_success;
67+ }
68+ if (code[2] == 0xB4 && code[3] == 0x26 && code[4] == 0x00
69+ && code[5] == 0x00 && code[6] == 0x00 && code[7] == 0x00) {
70+ DIP("leal %%cs:0(%%esi,%%eiz,1),%%esi\n");
71+ delta += 8;
72+ goto decode_success;
73+ }
74+ }
75
76 // Intel CET requires the following opcodes to be treated as NOPs
77 // with any prefix and ModRM, SIB and disp combination:
78--- a/none/tests/x86/Makefile.am
79+++ b/none/tests/x86/Makefile.am
80@@ -52,6 +52,7 @@ EXTRA_DIST = \
81 fxtract.stdout.exp fxtract.stderr.exp fxtract.vgtest \
82 fxtract.stdout.exp-older-glibc \
83 getseg.stdout.exp getseg.stderr.exp getseg.vgtest \
84+ gnu_binutils_nop.stderr.exp gnu_binutils_nop.vgtest \
85 incdec_alt.stdout.exp incdec_alt.stderr.exp incdec_alt.vgtest \
86 int.stderr.exp int.stdout.exp int.disabled \
87 $(addsuffix .stderr.exp,$(INSN_TESTS)) \
88@@ -100,6 +101,7 @@ check_PROGRAMS = \
89 fpu_lazy_eflags \
90 fxtract \
91 getseg \
92+ gnu_binutils_nop \
93 incdec_alt \
94 $(INSN_TESTS) \
95 int \
96--- /dev/null
97+++ b/none/tests/x86/gnu_binutils_nop.c
98@@ -0,0 +1,34 @@
99+int main(void)
100+{
101+ // GNU binutils uses various opcodes as alternatives for nop
102+ // the idea is that it is faster to execute one large opcode
103+ // with no side-effects than multiple repetitions of the
104+ // single byte 'nop'. This gives more choice when code
105+ // needs to be padded.
106+
107+ // the following is based on
108+ // https://sourceware.org/cgit/binutils-gdb/tree/gas/config/tc-i386.c#n1256
109+
110+ // one byte
111+ __asm__ __volatile__("nop");
112+ // two bytes
113+ __asm__ __volatile__("xchg %ax,%ax");
114+ // three bytes
115+ //__asm__ __volatile__("leal 0(%esi),%esi");
116+ __asm__ __volatile__(".byte 0x8d,0x76,0x00");
117+ // four bytes
118+ //__asm__ __volatile__("leal 0(%esi,%eiz),%esi");
119+ __asm__ __volatile__(".byte 0x8d,0x74,0x26,0x00");
120+ // five bytes
121+ //__asm__ __volatile__("leal %cs:0(%esi,%eiz),%esi");
122+ __asm__ __volatile__(".byte 0x2e,0x8d,0x74,0x26,0x00");
123+ // six bytes
124+ //__asm__ __volatile__("leal 0L(%esi),%esi");
125+ __asm__ __volatile__(".byte 0x8d,0xb6,0x00,0x00,0x00,0x00");
126+ // seven bytes
127+ //__asm__ __volatile__("leal 0L(%esi,%eiz),%esi");
128+ __asm__ __volatile__(".byte 0x8d,0xb4,0x26,0x00,0x00,0x00,0x00");
129+ // eight bytes
130+ //__asm__ __volatile__("leal %cs:0L(%esi,%eiz),%esi");
131+ __asm__ __volatile__(".byte 0x2e,0x8d,0xb4,0x26,0x00,0x00,0x00,0x00");
132+}
133--- /dev/null
134+++ b/none/tests/x86/gnu_binutils_nop.vgtest
135@@ -0,0 +1,2 @@
136+prog: gnu_binutils_nop
137+vgopts: -q
diff --git a/meta/recipes-devtools/valgrind/valgrind_3.22.0.bb b/meta/recipes-devtools/valgrind/valgrind_3.22.0.bb
index 74ac7ec9d5..563d99f0e2 100644
--- a/meta/recipes-devtools/valgrind/valgrind_3.22.0.bb
+++ b/meta/recipes-devtools/valgrind/valgrind_3.22.0.bb
@@ -33,6 +33,10 @@ SRC_URI = "https://sourceware.org/pub/valgrind/valgrind-${PV}.tar.bz2 \
33 file://0001-none-tests-fdleak_cmsg.stderr.exp-adjust-tmp-paths.patch \ 33 file://0001-none-tests-fdleak_cmsg.stderr.exp-adjust-tmp-paths.patch \
34 file://0001-memcheck-tests-Fix-timerfd-syscall-test.patch \ 34 file://0001-memcheck-tests-Fix-timerfd-syscall-test.patch \
35 file://0001-docs-Disable-manual-validation.patch \ 35 file://0001-docs-Disable-manual-validation.patch \
36 file://0001-valgrind-monitor.py-regular-expressions-should-use-r.patch \
37 file://0002-Bug-476548-valgrind-3.22.0-fails-on-assertion-when-l.patch \
38 file://0003-Add-fchmodat2-syscall-on-linux.patch \
39 file://0004-Bug-478624-Valgrind-incompatibility-with-binutils-2..patch \
36 " 40 "
37SRC_URI[sha256sum] = "c811db5add2c5f729944caf47c4e7a65dcaabb9461e472b578765dd7bf6d2d4c" 41SRC_URI[sha256sum] = "c811db5add2c5f729944caf47c4e7a65dcaabb9461e472b578765dd7bf6d2d4c"
38UPSTREAM_CHECK_REGEX = "valgrind-(?P<pver>\d+(\.\d+)+)\.tar" 42UPSTREAM_CHECK_REGEX = "valgrind-(?P<pver>\d+(\.\d+)+)\.tar"