Mark Wielaard ff4eb7
commit 67e7b20eb256baec225b3d7df1f03d731bf5e939
Mark Wielaard 6a8a0b
Author: Mark Wielaard <mark@klomp.org>
Mark Wielaard 6a8a0b
Date:   Fri Dec 10 17:41:59 2021 +0100
Mark Wielaard 6a8a0b
Mark Wielaard 6a8a0b
    Implement linux rseq syscall as ENOSYS
Mark Wielaard 6a8a0b
    
Mark Wielaard 6a8a0b
    This implements rseq for amd64, arm, arm64, ppc32, ppc64,
Mark Wielaard 6a8a0b
    s390x and x86 linux as ENOSYS (without warning).
Mark Wielaard 6a8a0b
    
Mark Wielaard 6a8a0b
    glibc will start using rseq to accelerate sched_getcpu, if
Mark Wielaard 6a8a0b
    available. This would cause a warning from valgrind every
Mark Wielaard 6a8a0b
    time a new thread is started.
Mark Wielaard 6a8a0b
    
Mark Wielaard 6a8a0b
    Real rseq (restartable sequences) support is pretty hard, so
Mark Wielaard 6a8a0b
    for now just explicitly return ENOSYS (just like we do for clone3).
Mark Wielaard 6a8a0b
    
Mark Wielaard 6a8a0b
    https://sourceware.org/pipermail/libc-alpha/2021-December/133656.html
Mark Wielaard 6a8a0b
Mark Wielaard 6a8a0b
diff --git a/coregrind/m_syswrap/syswrap-amd64-linux.c b/coregrind/m_syswrap/syswrap-amd64-linux.c
Mark Wielaard 6a8a0b
index 5062324a1..18b25f80a 100644
Mark Wielaard 6a8a0b
--- a/coregrind/m_syswrap/syswrap-amd64-linux.c
Mark Wielaard 6a8a0b
+++ b/coregrind/m_syswrap/syswrap-amd64-linux.c
Mark Wielaard 6a8a0b
@@ -862,6 +862,8 @@ static SyscallTableEntry syscall_table[] = {
Mark Wielaard 6a8a0b
 
Mark Wielaard 6a8a0b
    LINXY(__NR_statx,             sys_statx),             // 332
Mark Wielaard 6a8a0b
 
Mark Wielaard 6a8a0b
+   GENX_(__NR_rseq,              sys_ni_syscall),        // 334
Mark Wielaard 6a8a0b
+
Mark Wielaard 6a8a0b
    LINX_(__NR_membarrier,        sys_membarrier),        // 324
Mark Wielaard 6a8a0b
 
Mark Wielaard 6a8a0b
    LINX_(__NR_copy_file_range,   sys_copy_file_range),   // 326
Mark Wielaard 6a8a0b
diff --git a/coregrind/m_syswrap/syswrap-arm-linux.c b/coregrind/m_syswrap/syswrap-arm-linux.c
Mark Wielaard 6a8a0b
index 556dd844b..d583cef0c 100644
Mark Wielaard 6a8a0b
--- a/coregrind/m_syswrap/syswrap-arm-linux.c
Mark Wielaard 6a8a0b
+++ b/coregrind/m_syswrap/syswrap-arm-linux.c
Mark Wielaard 6a8a0b
@@ -1024,6 +1024,7 @@ static SyscallTableEntry syscall_main_table[] = {
Mark Wielaard 6a8a0b
    LINX_(__NR_pwritev2,          sys_pwritev2),         // 393
Mark Wielaard 6a8a0b
 
Mark Wielaard 6a8a0b
    LINXY(__NR_statx,             sys_statx),            // 397
Mark Wielaard 6a8a0b
+   GENX_(__NR_rseq,              sys_ni_syscall),       // 398
Mark Wielaard 6a8a0b
 
Mark Wielaard 6a8a0b
    LINXY(__NR_clock_gettime64,   sys_clock_gettime64),  // 403
Mark Wielaard 6a8a0b
    LINX_(__NR_clock_settime64,   sys_clock_settime64),  // 404
Mark Wielaard 6a8a0b
diff --git a/coregrind/m_syswrap/syswrap-arm64-linux.c b/coregrind/m_syswrap/syswrap-arm64-linux.c
Mark Wielaard 6a8a0b
index b87107727..2066a38ea 100644
Mark Wielaard 6a8a0b
--- a/coregrind/m_syswrap/syswrap-arm64-linux.c
Mark Wielaard 6a8a0b
+++ b/coregrind/m_syswrap/syswrap-arm64-linux.c
Mark Wielaard 6a8a0b
@@ -823,8 +823,9 @@ static SyscallTableEntry syscall_main_table[] = {
Mark Wielaard 6a8a0b
    //   (__NR_pkey_mprotect,     sys_ni_syscall),        // 288
Mark Wielaard 6a8a0b
    //   (__NR_pkey_alloc,        sys_ni_syscall),        // 289
Mark Wielaard 6a8a0b
    //   (__NR_pkey_free,         sys_ni_syscall),        // 290
Mark Wielaard 6a8a0b
+   LINXY(__NR_statx,             sys_statx),             // 291
Mark Wielaard 6a8a0b
 
Mark Wielaard 6a8a0b
-   LINXY(__NR_statx,             sys_statx),             // 397
Mark Wielaard 6a8a0b
+   GENX_(__NR_rseq,              sys_ni_syscall),        // 293
Mark Wielaard 6a8a0b
 
Mark Wielaard 6a8a0b
    LINXY(__NR_io_uring_setup,    sys_io_uring_setup),    // 425
Mark Wielaard 6a8a0b
    LINXY(__NR_io_uring_enter,    sys_io_uring_enter),    // 426
Mark Wielaard 6a8a0b
diff --git a/coregrind/m_syswrap/syswrap-ppc32-linux.c b/coregrind/m_syswrap/syswrap-ppc32-linux.c
Mark Wielaard 6a8a0b
index 6263ab845..637b2504e 100644
Mark Wielaard 6a8a0b
--- a/coregrind/m_syswrap/syswrap-ppc32-linux.c
Mark Wielaard 6a8a0b
+++ b/coregrind/m_syswrap/syswrap-ppc32-linux.c
Mark Wielaard 6a8a0b
@@ -1028,6 +1028,8 @@ static SyscallTableEntry syscall_table[] = {
Mark Wielaard 6a8a0b
 
Mark Wielaard 6a8a0b
    LINXY(__NR_statx,             sys_statx),            // 383
Mark Wielaard 6a8a0b
 
Mark Wielaard 6a8a0b
+   GENX_(__NR_rseq,              sys_ni_syscall),       // 387
Mark Wielaard 6a8a0b
+
Mark Wielaard 6a8a0b
    LINXY(__NR_clock_gettime64,   sys_clock_gettime64),  // 403
Mark Wielaard 6a8a0b
    LINX_(__NR_clock_settime64,   sys_clock_settime64),  // 404
Mark Wielaard 6a8a0b
 
Mark Wielaard 6a8a0b
diff --git a/coregrind/m_syswrap/syswrap-ppc64-linux.c b/coregrind/m_syswrap/syswrap-ppc64-linux.c
Mark Wielaard 6a8a0b
index a26b41c32..93956d3cc 100644
Mark Wielaard 6a8a0b
--- a/coregrind/m_syswrap/syswrap-ppc64-linux.c
Mark Wielaard 6a8a0b
+++ b/coregrind/m_syswrap/syswrap-ppc64-linux.c
Mark Wielaard 6a8a0b
@@ -1019,6 +1019,8 @@ static SyscallTableEntry syscall_table[] = {
Mark Wielaard 6a8a0b
 
Mark Wielaard 6a8a0b
    LINXY(__NR_statx,             sys_statx),            // 383
Mark Wielaard 6a8a0b
 
Mark Wielaard 6a8a0b
+   GENX_(__NR_rseq,              sys_ni_syscall),       // 387
Mark Wielaard 6a8a0b
+
Mark Wielaard 6a8a0b
    LINXY(__NR_io_uring_setup,    sys_io_uring_setup),    // 425
Mark Wielaard 6a8a0b
    LINXY(__NR_io_uring_enter,    sys_io_uring_enter),    // 426
Mark Wielaard 6a8a0b
    LINXY(__NR_io_uring_register, sys_io_uring_register), // 427
Mark Wielaard 6a8a0b
diff --git a/coregrind/m_syswrap/syswrap-s390x-linux.c b/coregrind/m_syswrap/syswrap-s390x-linux.c
Mark Wielaard 6a8a0b
index 5c9209859..73f9684c4 100644
Mark Wielaard 6a8a0b
--- a/coregrind/m_syswrap/syswrap-s390x-linux.c
Mark Wielaard 6a8a0b
+++ b/coregrind/m_syswrap/syswrap-s390x-linux.c
Mark Wielaard 6a8a0b
@@ -860,6 +860,8 @@ static SyscallTableEntry syscall_table[] = {
Mark Wielaard 6a8a0b
 
Mark Wielaard 6a8a0b
    LINXY(__NR_statx, sys_statx),                                      // 379
Mark Wielaard 6a8a0b
 
Mark Wielaard 6a8a0b
+   GENX_(__NR_rseq, sys_ni_syscall),                                  // 381
Mark Wielaard 6a8a0b
+
Mark Wielaard 6a8a0b
    LINXY(__NR_io_uring_setup, sys_io_uring_setup),                    // 425
Mark Wielaard 6a8a0b
    LINXY(__NR_io_uring_enter, sys_io_uring_enter),                    // 426
Mark Wielaard 6a8a0b
    LINXY(__NR_io_uring_register, sys_io_uring_register),              // 427
Mark Wielaard 6a8a0b
diff --git a/coregrind/m_syswrap/syswrap-x86-linux.c b/coregrind/m_syswrap/syswrap-x86-linux.c
Mark Wielaard 6a8a0b
index 1d8f45d33..8662ff501 100644
Mark Wielaard 6a8a0b
--- a/coregrind/m_syswrap/syswrap-x86-linux.c
Mark Wielaard 6a8a0b
+++ b/coregrind/m_syswrap/syswrap-x86-linux.c
Mark Wielaard 6a8a0b
@@ -1619,6 +1619,8 @@ static SyscallTableEntry syscall_table[] = {
Mark Wielaard 6a8a0b
    /* Explicitly not supported on i386 yet. */
Mark Wielaard 6a8a0b
    GENX_(__NR_arch_prctl,        sys_ni_syscall),       // 384
Mark Wielaard 6a8a0b
 
Mark Wielaard 6a8a0b
+   GENX_(__NR_rseq,              sys_ni_syscall),       // 386
Mark Wielaard 6a8a0b
+
Mark Wielaard 6a8a0b
    LINXY(__NR_clock_gettime64,   sys_clock_gettime64),  // 403
Mark Wielaard 6a8a0b
    LINX_(__NR_clock_settime64,   sys_clock_settime64),  // 404
Mark Wielaard 6a8a0b
 
Mark Wielaard 6a8a0b
diff --git a/include/vki/vki-scnums-arm-linux.h b/include/vki/vki-scnums-arm-linux.h
Mark Wielaard 6a8a0b
index ff560e19d..485db8b26 100644
Mark Wielaard 6a8a0b
--- a/include/vki/vki-scnums-arm-linux.h
Mark Wielaard 6a8a0b
+++ b/include/vki/vki-scnums-arm-linux.h
Mark Wielaard 6a8a0b
@@ -432,6 +432,7 @@
Mark Wielaard 6a8a0b
 #define __NR_pkey_alloc                 395
Mark Wielaard 6a8a0b
 #define __NR_pkey_free                  396
Mark Wielaard 6a8a0b
 #define __NR_statx                      397
Mark Wielaard 6a8a0b
+#define __NR_rseq                       398
Mark Wielaard 6a8a0b
 
Mark Wielaard 6a8a0b
 
Mark Wielaard 6a8a0b
 
Mark Wielaard 6a8a0b
diff --git a/include/vki/vki-scnums-arm64-linux.h b/include/vki/vki-scnums-arm64-linux.h
Mark Wielaard 6a8a0b
index 9aa3b2b5f..acdfb39c6 100644
Mark Wielaard 6a8a0b
--- a/include/vki/vki-scnums-arm64-linux.h
Mark Wielaard 6a8a0b
+++ b/include/vki/vki-scnums-arm64-linux.h
Mark Wielaard 6a8a0b
@@ -323,9 +323,11 @@
Mark Wielaard 6a8a0b
 #define __NR_pkey_alloc 289
Mark Wielaard 6a8a0b
 #define __NR_pkey_free 290
Mark Wielaard 6a8a0b
 #define __NR_statx 291
Mark Wielaard 6a8a0b
+#define __NR_io_pgetevents 291
Mark Wielaard 6a8a0b
+#define __NR_rseq 293
Mark Wielaard 6a8a0b
 
Mark Wielaard 6a8a0b
 #undef __NR_syscalls
Mark Wielaard 6a8a0b
-#define __NR_syscalls 292
Mark Wielaard 6a8a0b
+#define __NR_syscalls 294
Mark Wielaard 6a8a0b
 
Mark Wielaard 6a8a0b
 ///*
Mark Wielaard 6a8a0b
 // * All syscalls below here should go away really,
Mark Wielaard 6a8a0b
diff --git a/include/vki/vki-scnums-ppc32-linux.h b/include/vki/vki-scnums-ppc32-linux.h
Mark Wielaard 6a8a0b
index 6987ad941..08fa77df0 100644
Mark Wielaard 6a8a0b
--- a/include/vki/vki-scnums-ppc32-linux.h
Mark Wielaard 6a8a0b
+++ b/include/vki/vki-scnums-ppc32-linux.h
Mark Wielaard 6a8a0b
@@ -415,6 +415,7 @@
Mark Wielaard 6a8a0b
 #define __NR_pkey_alloc		384
Mark Wielaard 6a8a0b
 #define __NR_pkey_free		385
Mark Wielaard 6a8a0b
 #define __NR_pkey_mprotect	386
Mark Wielaard 6a8a0b
+#define __NR_rseq		387
Mark Wielaard 6a8a0b
 
Mark Wielaard 6a8a0b
 #endif /* __VKI_SCNUMS_PPC32_LINUX_H */
Mark Wielaard 6a8a0b
 
Mark Wielaard 6a8a0b
diff --git a/include/vki/vki-scnums-ppc64-linux.h b/include/vki/vki-scnums-ppc64-linux.h
Mark Wielaard ff4eb7
index 6827964fd..a76fa6d32 100644
Mark Wielaard 6a8a0b
--- a/include/vki/vki-scnums-ppc64-linux.h
Mark Wielaard 6a8a0b
+++ b/include/vki/vki-scnums-ppc64-linux.h
Mark Wielaard 6a8a0b
@@ -407,6 +407,7 @@
Mark Wielaard 6a8a0b
 #define __NR_pkey_alloc		384
Mark Wielaard 6a8a0b
 #define __NR_pkey_free		385
Mark Wielaard 6a8a0b
 #define __NR_pkey_mprotect	386
Mark Wielaard ff4eb7
+#define __NR_rseq		387
Mark Wielaard 6a8a0b
 
Mark Wielaard 6a8a0b
 #endif /* __VKI_SCNUMS_PPC64_LINUX_H */
Mark Wielaard 6a8a0b
 
Mark Wielaard 6a8a0b
diff --git a/include/vki/vki-scnums-s390x-linux.h b/include/vki/vki-scnums-s390x-linux.h
Mark Wielaard 6a8a0b
index 6487e20c9..869c04584 100644
Mark Wielaard 6a8a0b
--- a/include/vki/vki-scnums-s390x-linux.h
Mark Wielaard 6a8a0b
+++ b/include/vki/vki-scnums-s390x-linux.h
Mark Wielaard 6a8a0b
@@ -342,8 +342,11 @@
Mark Wielaard 6a8a0b
 #define __NR_s390_guarded_storage	378
Mark Wielaard 6a8a0b
 #define __NR_statx			379
Mark Wielaard 6a8a0b
 #define __NR_s390_sthyi			380
Mark Wielaard 6a8a0b
+#define __NR_kexec_file_load		381
Mark Wielaard 6a8a0b
+#define __NR_io_pgetevents		382
Mark Wielaard 6a8a0b
+#define __NR_rseq			383
Mark Wielaard 6a8a0b
 
Mark Wielaard 6a8a0b
-#define NR_syscalls 381
Mark Wielaard 6a8a0b
+#define NR_syscalls 384
Mark Wielaard 6a8a0b
 
Mark Wielaard 6a8a0b
 /* 
Mark Wielaard 6a8a0b
  * There are some system calls that are not present on 64 bit, some