1From 1024237358f01009fe233cb1294f3b8211304eaa Mon Sep 17 00:00:00 2001 2From: Mark Wielaard <mark@klomp.org> 3Date: Fri, 10 Dec 2021 17:41:59 +0100 4Subject: [PATCH] Implement linux rseq syscall as ENOSYS 5 6This implements rseq for amd64, arm, arm64, ppc32, ppc64, 7s390x and x86 linux as ENOSYS (without warning). 8 9glibc will start using rseq to accelerate sched_getcpu, if 10available. This would cause a warning from valgrind every 11time a new thread is started. 12 13Real rseq (restartable sequences) support is pretty hard, so 14for now just explicitly return ENOSYS (just like we do for clone3). 15 16Upstream-Status: Backport [ 1024237358f01009fe233cb1294f3b8211304eaa ] 17 18https://sourceware.org/pipermail/libc-alpha/2021-December/133656.html 19--- 20 coregrind/m_syswrap/syswrap-amd64-linux.c | 2 ++ 21 coregrind/m_syswrap/syswrap-arm-linux.c | 1 + 22 coregrind/m_syswrap/syswrap-arm64-linux.c | 3 ++- 23 coregrind/m_syswrap/syswrap-ppc32-linux.c | 2 ++ 24 coregrind/m_syswrap/syswrap-ppc64-linux.c | 2 ++ 25 coregrind/m_syswrap/syswrap-s390x-linux.c | 2 ++ 26 coregrind/m_syswrap/syswrap-x86-linux.c | 2 ++ 27 include/vki/vki-scnums-arm-linux.h | 1 + 28 include/vki/vki-scnums-arm64-linux.h | 4 +++- 29 include/vki/vki-scnums-ppc32-linux.h | 1 + 30 include/vki/vki-scnums-ppc64-linux.h | 1 + 31 include/vki/vki-scnums-s390x-linux.h | 5 ++++- 32 12 files changed, 23 insertions(+), 3 deletions(-) 33 34diff --git a/coregrind/m_syswrap/syswrap-amd64-linux.c b/coregrind/m_syswrap/syswrap-amd64-linux.c 35index 5062324a1..18b25f80a 100644 36--- a/coregrind/m_syswrap/syswrap-amd64-linux.c 37+++ b/coregrind/m_syswrap/syswrap-amd64-linux.c 38@@ -862,6 +862,8 @@ static SyscallTableEntry syscall_table[] = { 39 40 LINXY(__NR_statx, sys_statx), // 332 41 42+ GENX_(__NR_rseq, sys_ni_syscall), // 334 43+ 44 LINX_(__NR_membarrier, sys_membarrier), // 324 45 46 LINX_(__NR_copy_file_range, sys_copy_file_range), // 326 47diff --git a/coregrind/m_syswrap/syswrap-arm-linux.c b/coregrind/m_syswrap/syswrap-arm-linux.c 48index 556dd844b..d583cef0c 100644 49--- a/coregrind/m_syswrap/syswrap-arm-linux.c 50+++ b/coregrind/m_syswrap/syswrap-arm-linux.c 51@@ -1024,6 +1024,7 @@ static SyscallTableEntry syscall_main_table[] = { 52 LINX_(__NR_pwritev2, sys_pwritev2), // 393 53 54 LINXY(__NR_statx, sys_statx), // 397 55+ GENX_(__NR_rseq, sys_ni_syscall), // 398 56 57 LINXY(__NR_clock_gettime64, sys_clock_gettime64), // 403 58 LINX_(__NR_clock_settime64, sys_clock_settime64), // 404 59diff --git a/coregrind/m_syswrap/syswrap-arm64-linux.c b/coregrind/m_syswrap/syswrap-arm64-linux.c 60index b87107727..2066a38ea 100644 61--- a/coregrind/m_syswrap/syswrap-arm64-linux.c 62+++ b/coregrind/m_syswrap/syswrap-arm64-linux.c 63@@ -823,8 +823,9 @@ static SyscallTableEntry syscall_main_table[] = { 64 // (__NR_pkey_mprotect, sys_ni_syscall), // 288 65 // (__NR_pkey_alloc, sys_ni_syscall), // 289 66 // (__NR_pkey_free, sys_ni_syscall), // 290 67+ LINXY(__NR_statx, sys_statx), // 291 68 69- LINXY(__NR_statx, sys_statx), // 397 70+ GENX_(__NR_rseq, sys_ni_syscall), // 293 71 72 LINXY(__NR_io_uring_setup, sys_io_uring_setup), // 425 73 LINXY(__NR_io_uring_enter, sys_io_uring_enter), // 426 74diff --git a/coregrind/m_syswrap/syswrap-ppc32-linux.c b/coregrind/m_syswrap/syswrap-ppc32-linux.c 75index 6263ab845..637b2504e 100644 76--- a/coregrind/m_syswrap/syswrap-ppc32-linux.c 77+++ b/coregrind/m_syswrap/syswrap-ppc32-linux.c 78@@ -1028,6 +1028,8 @@ static SyscallTableEntry syscall_table[] = { 79 80 LINXY(__NR_statx, sys_statx), // 383 81 82+ GENX_(__NR_rseq, sys_ni_syscall), // 387 83+ 84 LINXY(__NR_clock_gettime64, sys_clock_gettime64), // 403 85 LINX_(__NR_clock_settime64, sys_clock_settime64), // 404 86 87diff --git a/coregrind/m_syswrap/syswrap-ppc64-linux.c b/coregrind/m_syswrap/syswrap-ppc64-linux.c 88index a26b41c32..93956d3cc 100644 89--- a/coregrind/m_syswrap/syswrap-ppc64-linux.c 90+++ b/coregrind/m_syswrap/syswrap-ppc64-linux.c 91@@ -1019,6 +1019,8 @@ static SyscallTableEntry syscall_table[] = { 92 93 LINXY(__NR_statx, sys_statx), // 383 94 95+ GENX_(__NR_rseq, sys_ni_syscall), // 387 96+ 97 LINXY(__NR_io_uring_setup, sys_io_uring_setup), // 425 98 LINXY(__NR_io_uring_enter, sys_io_uring_enter), // 426 99 LINXY(__NR_io_uring_register, sys_io_uring_register), // 427 100diff --git a/coregrind/m_syswrap/syswrap-s390x-linux.c b/coregrind/m_syswrap/syswrap-s390x-linux.c 101index 5c9209859..73f9684c4 100644 102--- a/coregrind/m_syswrap/syswrap-s390x-linux.c 103+++ b/coregrind/m_syswrap/syswrap-s390x-linux.c 104@@ -860,6 +860,8 @@ static SyscallTableEntry syscall_table[] = { 105 106 LINXY(__NR_statx, sys_statx), // 379 107 108+ GENX_(__NR_rseq, sys_ni_syscall), // 381 109+ 110 LINXY(__NR_io_uring_setup, sys_io_uring_setup), // 425 111 LINXY(__NR_io_uring_enter, sys_io_uring_enter), // 426 112 LINXY(__NR_io_uring_register, sys_io_uring_register), // 427 113diff --git a/coregrind/m_syswrap/syswrap-x86-linux.c b/coregrind/m_syswrap/syswrap-x86-linux.c 114index 1d8f45d33..8662ff501 100644 115--- a/coregrind/m_syswrap/syswrap-x86-linux.c 116+++ b/coregrind/m_syswrap/syswrap-x86-linux.c 117@@ -1619,6 +1619,8 @@ static SyscallTableEntry syscall_table[] = { 118 /* Explicitly not supported on i386 yet. */ 119 GENX_(__NR_arch_prctl, sys_ni_syscall), // 384 120 121+ GENX_(__NR_rseq, sys_ni_syscall), // 386 122+ 123 LINXY(__NR_clock_gettime64, sys_clock_gettime64), // 403 124 LINX_(__NR_clock_settime64, sys_clock_settime64), // 404 125 126diff --git a/include/vki/vki-scnums-arm-linux.h b/include/vki/vki-scnums-arm-linux.h 127index ff560e19d..485db8b26 100644 128--- a/include/vki/vki-scnums-arm-linux.h 129+++ b/include/vki/vki-scnums-arm-linux.h 130@@ -432,6 +432,7 @@ 131 #define __NR_pkey_alloc 395 132 #define __NR_pkey_free 396 133 #define __NR_statx 397 134+#define __NR_rseq 398 135 136 137 138diff --git a/include/vki/vki-scnums-arm64-linux.h b/include/vki/vki-scnums-arm64-linux.h 139index 9aa3b2b5f..acdfb39c6 100644 140--- a/include/vki/vki-scnums-arm64-linux.h 141+++ b/include/vki/vki-scnums-arm64-linux.h 142@@ -323,9 +323,11 @@ 143 #define __NR_pkey_alloc 289 144 #define __NR_pkey_free 290 145 #define __NR_statx 291 146+#define __NR_io_pgetevents 291 147+#define __NR_rseq 293 148 149 #undef __NR_syscalls 150-#define __NR_syscalls 292 151+#define __NR_syscalls 294 152 153 ///* 154 // * All syscalls below here should go away really, 155diff --git a/include/vki/vki-scnums-ppc32-linux.h b/include/vki/vki-scnums-ppc32-linux.h 156index 6987ad941..08fa77df0 100644 157--- a/include/vki/vki-scnums-ppc32-linux.h 158+++ b/include/vki/vki-scnums-ppc32-linux.h 159@@ -415,6 +415,7 @@ 160 #define __NR_pkey_alloc 384 161 #define __NR_pkey_free 385 162 #define __NR_pkey_mprotect 386 163+#define __NR_rseq 387 164 165 #endif /* __VKI_SCNUMS_PPC32_LINUX_H */ 166 167diff --git a/include/vki/vki-scnums-ppc64-linux.h b/include/vki/vki-scnums-ppc64-linux.h 168index 6827964fd..a76fa6d32 100644 169--- a/include/vki/vki-scnums-ppc64-linux.h 170+++ b/include/vki/vki-scnums-ppc64-linux.h 171@@ -407,6 +407,7 @@ 172 #define __NR_pkey_alloc 384 173 #define __NR_pkey_free 385 174 #define __NR_pkey_mprotect 386 175+#define __NR_rseq 387 176 177 #endif /* __VKI_SCNUMS_PPC64_LINUX_H */ 178 179diff --git a/include/vki/vki-scnums-s390x-linux.h b/include/vki/vki-scnums-s390x-linux.h 180index 6487e20c9..869c04584 100644 181--- a/include/vki/vki-scnums-s390x-linux.h 182+++ b/include/vki/vki-scnums-s390x-linux.h 183@@ -342,8 +342,11 @@ 184 #define __NR_s390_guarded_storage 378 185 #define __NR_statx 379 186 #define __NR_s390_sthyi 380 187+#define __NR_kexec_file_load 381 188+#define __NR_io_pgetevents 382 189+#define __NR_rseq 383 190 191-#define NR_syscalls 381 192+#define NR_syscalls 384 193 194 /* 195 * There are some system calls that are not present on 64 bit, some 196-- 1972.30.2 198 199