From 959a54cb3a631bb61420f1784a0c8585af24349e Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 15 Jun 2018 08:24:53 -0700 Subject: [PATCH] Add support for the Linux membarrier() system call Signed-off-by: Bart Van Assche --- NEWS | 1 + coregrind/m_syswrap/priv_syswrap-linux.h | 2 ++ coregrind/m_syswrap/syswrap-amd64-linux.c | 4 +++- coregrind/m_syswrap/syswrap-arm64-linux.c | 2 +- coregrind/m_syswrap/syswrap-linux.c | 6 ++++++ 5 files changed, 13 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 2eea33498..004497199 100644 --- a/NEWS +++ b/NEWS @@ -117,6 +117,7 @@ n-i-bz fix bug in strspn replacement n-i-bz Add support for the Linux BLKFLSBUF ioctl n-i-bz Add support for the Linux BLKREPORTZONE and BLKRESETZONE ioctls n-i-bz Fix possible stack trashing by semctl syscall wrapping +n-i-bz Add support for the Linux membarrier() system call Release 3.13.0 (15 June 2017) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/coregrind/m_syswrap/priv_syswrap-linux.h b/coregrind/m_syswrap/priv_syswrap-linux.h index 5b5c8ef37..65704cd60 100644 --- a/coregrind/m_syswrap/priv_syswrap-linux.h +++ b/coregrind/m_syswrap/priv_syswrap-linux.h @@ -293,6 +293,8 @@ DECL_TEMPLATE(linux, sys_memfd_create); DECL_TEMPLATE(linux, sys_syncfs); +DECL_TEMPLATE(linux, sys_membarrier); + /* --------------------------------------------------------------------- Wrappers for sockets and ipc-ery. These are split into standalone procedures because x86-linux hides them inside multiplexors diff --git a/coregrind/m_syswrap/syswrap-amd64-linux.c b/coregrind/m_syswrap/syswrap-amd64-linux.c index 14ad6499e..0f2ad8c51 100644 --- a/coregrind/m_syswrap/syswrap-amd64-linux.c +++ b/coregrind/m_syswrap/syswrap-amd64-linux.c @@ -839,10 +839,12 @@ static SyscallTableEntry syscall_table[] = { LINX_(__NR_renameat2, sys_renameat2), // 316 // LIN__(__NR_seccomp, sys_ni_syscall), // 317 LINXY(__NR_getrandom, sys_getrandom), // 318 - LINXY(__NR_memfd_create, sys_memfd_create) // 319 + LINXY(__NR_memfd_create, sys_memfd_create), // 319 // LIN__(__NR_kexec_file_load, sys_ni_syscall), // 320 // LIN__(__NR_bpf, sys_ni_syscall) // 321 + + LINX_(__NR_membarrier, sys_membarrier), // 324 }; SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno ) diff --git a/coregrind/m_syswrap/syswrap-arm64-linux.c b/coregrind/m_syswrap/syswrap-arm64-linux.c index d2444590d..32b87bf25 100644 --- a/coregrind/m_syswrap/syswrap-arm64-linux.c +++ b/coregrind/m_syswrap/syswrap-arm64-linux.c @@ -880,7 +880,7 @@ static SyscallTableEntry syscall_main_table[] = { // (__NR_bpf, sys_ni_syscall) // 280 // (__NR_execveat, sys_ni_syscall), // 281 // (__NR_userfaultfd, sys_ni_syscall), // 282 - // (__NR_membarrier, sys_ni_syscall), // 283 + LINX_(__NR_membarrier, sys_membarrier), // 283 // (__NR_mlock2, sys_ni_syscall), // 284 // (__NR_copy_file_range, sys_ni_syscall), // 285 // (__NR_preadv2, sys_ni_syscall), // 286 diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c index 1d95489e8..2336c2978 100644 --- a/coregrind/m_syswrap/syswrap-linux.c +++ b/coregrind/m_syswrap/syswrap-linux.c @@ -3646,6 +3646,12 @@ POST(sys_memfd_create) } } +PRE(sys_membarrier) +{ + PRINT("sys_membarrier ( %#" FMT_REGWORD "x )", ARG1); + PRE_REG_READ1(int, "membarrier", int, flags); +} + PRE(sys_syncfs) { *flags |= SfMayBlock; -- 2.11.4.GIT