valgrind/valgrind-3.21.0-epoll_pwait2.patch
2023-05-17 13:27:22 +02:00

218 lines
8.6 KiB
Diff

From 17f56ab4c4fce7b4778251e1fab2bc50e5c6dbda Mon Sep 17 00:00:00 2001
From: Olli Vanhoja <olli.vanhoja@gmail.com>
Date: Mon, 10 Oct 2022 11:44:22 +0200
Subject: [PATCH] Add epoll_pwait2
The only difference between epoll_pwait and epoll_pwait2 is the
timeout argument. For epoll_pwait2 this is a timespec (which is
always 64bit).
https://bugs.kde.org/show_bug.cgi?id=460192
---
NEWS | 1 +
coregrind/m_syswrap/priv_syswrap-linux.h | 1 +
coregrind/m_syswrap/syswrap-amd64-linux.c | 2 ++
coregrind/m_syswrap/syswrap-arm-linux.c | 2 ++
coregrind/m_syswrap/syswrap-arm64-linux.c | 2 ++
coregrind/m_syswrap/syswrap-linux.c | 23 ++++++++++++++++++++
coregrind/m_syswrap/syswrap-mips32-linux.c | 2 ++
coregrind/m_syswrap/syswrap-mips64-linux.c | 1 +
coregrind/m_syswrap/syswrap-nanomips-linux.c | 1 +
coregrind/m_syswrap/syswrap-ppc32-linux.c | 2 ++
coregrind/m_syswrap/syswrap-ppc64-linux.c | 2 ++
coregrind/m_syswrap/syswrap-s390x-linux.c | 2 ++
coregrind/m_syswrap/syswrap-x86-linux.c | 2 ++
include/vki/vki-scnums-shared-linux.h | 2 ++
14 files changed, 45 insertions(+)
diff --git a/coregrind/m_syswrap/priv_syswrap-linux.h b/coregrind/m_syswrap/priv_syswrap-linux.h
index a73b6247e..7c9decf5a 100644
--- a/coregrind/m_syswrap/priv_syswrap-linux.h
+++ b/coregrind/m_syswrap/priv_syswrap-linux.h
@@ -105,6 +105,7 @@ DECL_TEMPLATE(linux, sys_epoll_create1);
DECL_TEMPLATE(linux, sys_epoll_ctl);
DECL_TEMPLATE(linux, sys_epoll_wait);
DECL_TEMPLATE(linux, sys_epoll_pwait);
+DECL_TEMPLATE(linux, sys_epoll_pwait2);
DECL_TEMPLATE(linux, sys_eventfd);
DECL_TEMPLATE(linux, sys_eventfd2);
diff --git a/coregrind/m_syswrap/syswrap-amd64-linux.c b/coregrind/m_syswrap/syswrap-amd64-linux.c
index 1aeebd274..008600798 100644
--- a/coregrind/m_syswrap/syswrap-amd64-linux.c
+++ b/coregrind/m_syswrap/syswrap-amd64-linux.c
@@ -883,6 +883,8 @@ static SyscallTableEntry syscall_table[] = {
LINX_(__NR_faccessat2, sys_faccessat2), // 439
+ LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441
+
LINXY(__NR_memfd_secret, sys_memfd_secret), // 447
};
diff --git a/coregrind/m_syswrap/syswrap-arm-linux.c b/coregrind/m_syswrap/syswrap-arm-linux.c
index bca509589..9a7a1e0d2 100644
--- a/coregrind/m_syswrap/syswrap-arm-linux.c
+++ b/coregrind/m_syswrap/syswrap-arm-linux.c
@@ -1057,6 +1057,8 @@ static SyscallTableEntry syscall_main_table[] = {
LINXY(__NR_close_range, sys_close_range), // 436
LINX_(__NR_faccessat2, sys_faccessat2), // 439
+
+ LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441
};
diff --git a/coregrind/m_syswrap/syswrap-arm64-linux.c b/coregrind/m_syswrap/syswrap-arm64-linux.c
index 953236000..6af7bab83 100644
--- a/coregrind/m_syswrap/syswrap-arm64-linux.c
+++ b/coregrind/m_syswrap/syswrap-arm64-linux.c
@@ -837,6 +837,8 @@ static SyscallTableEntry syscall_main_table[] = {
LINX_(__NR_faccessat2, sys_faccessat2), // 439
+ LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441
+
LINXY(__NR_memfd_secret, sys_memfd_secret), // 447
};
diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c
index 26f1fbee3..f8621f8f0 100644
--- a/coregrind/m_syswrap/syswrap-linux.c
+++ b/coregrind/m_syswrap/syswrap-linux.c
@@ -2165,6 +2165,29 @@ POST(sys_epoll_pwait)
epoll_post_helper (tid, arrghs, status);
}
+PRE(sys_epoll_pwait2)
+{
+ *flags |= SfMayBlock;
+ PRINT("sys_epoll_pwait2 ( %ld, %#" FMT_REGWORD "x, %ld, %#"
+ FMT_REGWORD "x, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )",
+ SARG1, ARG2, SARG3, ARG4, ARG5, ARG6);
+ PRE_REG_READ6(long, "epoll_pwait2",
+ int, epfd, struct vki_epoll_event *, events,
+ int, maxevents, const struct timespec64 *, timeout,
+ vki_sigset_t *, sigmask, vki_size_t, sigsetsize);
+ /* Assume all (maxevents) events records should be (fully) writable. */
+ PRE_MEM_WRITE( "epoll_pwait2(events)", ARG2, sizeof(struct vki_epoll_event)*ARG3);
+ /* epoll_pwait2 only supports 64bit timespec. */
+ if (ARG4)
+ pre_read_timespec64(tid, "epoll_pwait2(timeout)", ARG4);
+ if (ARG5)
+ PRE_MEM_READ( "epoll_pwait2(sigmask)", ARG5, sizeof(vki_sigset_t) );
+}
+POST(sys_epoll_pwait2)
+{
+ epoll_post_helper (tid, arrghs, status);
+}
+
PRE(sys_eventfd)
{
PRINT("sys_eventfd ( %" FMT_REGWORD "u )", ARG1);
diff --git a/coregrind/m_syswrap/syswrap-mips32-linux.c b/coregrind/m_syswrap/syswrap-mips32-linux.c
index de27998b3..6268a00dd 100644
--- a/coregrind/m_syswrap/syswrap-mips32-linux.c
+++ b/coregrind/m_syswrap/syswrap-mips32-linux.c
@@ -1141,6 +1141,8 @@ static SyscallTableEntry syscall_main_table[] = {
LINXY(__NR_close_range, sys_close_range), // 436
LINX_ (__NR_faccessat2, sys_faccessat2), // 439
+
+ LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441
};
SyscallTableEntry* ML_(get_linux_syscall_entry) (UInt sysno)
diff --git a/coregrind/m_syswrap/syswrap-mips64-linux.c b/coregrind/m_syswrap/syswrap-mips64-linux.c
index 67e7c2c2f..6cdf25893 100644
--- a/coregrind/m_syswrap/syswrap-mips64-linux.c
+++ b/coregrind/m_syswrap/syswrap-mips64-linux.c
@@ -819,6 +819,7 @@ static SyscallTableEntry syscall_main_table[] = {
GENX_ (__NR_clone3, sys_ni_syscall),
LINXY (__NR_close_range, sys_close_range),
LINX_ (__NR_faccessat2, sys_faccessat2),
+ LINXY(__NR_epoll_pwait2, sys_epoll_pwait2),
};
SyscallTableEntry * ML_(get_linux_syscall_entry) ( UInt sysno )
diff --git a/coregrind/m_syswrap/syswrap-nanomips-linux.c b/coregrind/m_syswrap/syswrap-nanomips-linux.c
index 9c535c68e..d724cde74 100644
--- a/coregrind/m_syswrap/syswrap-nanomips-linux.c
+++ b/coregrind/m_syswrap/syswrap-nanomips-linux.c
@@ -828,6 +828,7 @@ static SyscallTableEntry syscall_main_table[] = {
GENX_ (__NR_clone3, sys_ni_syscall),
LINXY (__NR_close_range, sys_close_range),
LINX_ (__NR_faccessat2, sys_faccessat2),
+ LINXY (__NR_epoll_pwait2, sys_epoll_pwait2),
};
SyscallTableEntry* ML_(get_linux_syscall_entry) (UInt sysno)
diff --git a/coregrind/m_syswrap/syswrap-ppc32-linux.c b/coregrind/m_syswrap/syswrap-ppc32-linux.c
index 12c073027..c0cfef235 100644
--- a/coregrind/m_syswrap/syswrap-ppc32-linux.c
+++ b/coregrind/m_syswrap/syswrap-ppc32-linux.c
@@ -1061,6 +1061,8 @@ static SyscallTableEntry syscall_table[] = {
LINXY(__NR_close_range, sys_close_range), // 436
LINX_(__NR_faccessat2, sys_faccessat2), // 439
+
+ LINXY (__NR_epoll_pwait2, sys_epoll_pwait2), // 441
};
SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno )
diff --git a/coregrind/m_syswrap/syswrap-ppc64-linux.c b/coregrind/m_syswrap/syswrap-ppc64-linux.c
index 3c33d1267..f5976f30c 100644
--- a/coregrind/m_syswrap/syswrap-ppc64-linux.c
+++ b/coregrind/m_syswrap/syswrap-ppc64-linux.c
@@ -1030,6 +1030,8 @@ static SyscallTableEntry syscall_table[] = {
LINXY(__NR_close_range, sys_close_range), // 436
LINX_(__NR_faccessat2, sys_faccessat2), // 439
+
+ LINXY (__NR_epoll_pwait2, sys_epoll_pwait2), // 441
};
SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno )
diff --git a/coregrind/m_syswrap/syswrap-s390x-linux.c b/coregrind/m_syswrap/syswrap-s390x-linux.c
index a377cb731..afba154e7 100644
--- a/coregrind/m_syswrap/syswrap-s390x-linux.c
+++ b/coregrind/m_syswrap/syswrap-s390x-linux.c
@@ -871,6 +871,8 @@ static SyscallTableEntry syscall_table[] = {
LINXY(__NR_close_range, sys_close_range), // 436
LINX_(__NR_faccessat2, sys_faccessat2), // 439
+
+ LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441
};
SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno )
diff --git a/coregrind/m_syswrap/syswrap-x86-linux.c b/coregrind/m_syswrap/syswrap-x86-linux.c
index a9ba15dfe..da4fd8fa2 100644
--- a/coregrind/m_syswrap/syswrap-x86-linux.c
+++ b/coregrind/m_syswrap/syswrap-x86-linux.c
@@ -1655,6 +1655,8 @@ static SyscallTableEntry syscall_table[] = {
LINX_(__NR_faccessat2, sys_faccessat2), // 439
+ LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441
+
LINXY(__NR_memfd_secret, sys_memfd_secret), // 447
};
diff --git a/include/vki/vki-scnums-shared-linux.h b/include/vki/vki-scnums-shared-linux.h
index d90cdd312..542382b53 100644
--- a/include/vki/vki-scnums-shared-linux.h
+++ b/include/vki/vki-scnums-shared-linux.h
@@ -46,6 +46,8 @@
#define __NR_faccessat2 439
+#define __NR_epoll_pwait2 441
+
#define __NR_memfd_secret 447
#endif
--
2.40.1