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