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