From: Tom Hughes Date: Wed, 25 Nov 2009 11:29:14 +0000 (+0000) Subject: Clean up support for sync_file_range system call and add second version used X-Git-Tag: svn/VALGRIND_3_6_0~461 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=27f8eb0f4a6bf03233bec6bfeddd3766ab3a4867;p=thirdparty%2Fvalgrind.git Clean up support for sync_file_range system call and add second version used by ppc platforms based on patch from Dodji Seketeli. Part fix for #215973. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10952 --- diff --git a/coregrind/m_syswrap/priv_syswrap-linux.h b/coregrind/m_syswrap/priv_syswrap-linux.h index 6e914527ae..dcd39b7996 100644 --- a/coregrind/m_syswrap/priv_syswrap-linux.h +++ b/coregrind/m_syswrap/priv_syswrap-linux.h @@ -247,6 +247,7 @@ DECL_TEMPLATE(linux, sys_rt_sigsuspend); // Linux-specific? DECL_TEMPLATE(linux, sys_sync_file_range); +DECL_TEMPLATE(linux, sys_sync_file_range2); DECL_TEMPLATE(linux, sys_stime); /* maybe generic? I'm not sure */ // Linux specific (kernel modules) diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c index 29c11f5948..6416701610 100644 --- a/coregrind/m_syswrap/syswrap-linux.c +++ b/coregrind/m_syswrap/syswrap-linux.c @@ -2481,15 +2481,50 @@ POST(sys_waitid) PRE(sys_sync_file_range) { *flags |= SfMayBlock; - PRINT("sys_sync_file_range ( %ld, %ld, %ld, %ld )", - ARG1,ARG2,ARG3,ARG4); +#if VG_WORDSIZE == 4 + PRINT("sys_sync_file_range ( %ld, %lld, %lld, %ld )", + ARG1,MERGE64(ARG2,ARG3),MERGE64(ARG4,ARG5),ARG6); + PRE_REG_READ6(long, "sync_file_range", + int, fd, + unsigned, MERGE64_FIRST(offset), unsigned, MERGE64_SECOND(offset), + unsigned, MERGE64_FIRST(nbytes), unsigned, MERGE64_SECOND(nbytes), + unsigned int, flags); +#elif VG_WORDSIZE == 8 + PRINT("sys_sync_file_range ( %ld, %lld, %lld, %ld )", + ARG1,(Long)ARG2,(Long)ARG3,ARG4); PRE_REG_READ4(long, "sync_file_range", int, fd, vki_loff_t, offset, vki_loff_t, nbytes, unsigned int, flags); +#else +# error Unexpected word size +#endif if (!ML_(fd_allowed)(ARG1, "sync_file_range", tid, False)) SET_STATUS_Failure( VKI_EBADF ); } +PRE(sys_sync_file_range2) +{ + *flags |= SfMayBlock; +#if VG_WORDSIZE == 4 + PRINT("sys_sync_file_range2 ( %ld, %ld, %lld, %lld )", + ARG1,ARG2,MERGE64(ARG3,ARG4),MERGE64(ARG5,ARG6)); + PRE_REG_READ6(long, "sync_file_range2", + int, fd, unsigned int, flags, + unsigned, MERGE64_FIRST(offset), unsigned, MERGE64_SECOND(offset), + unsigned, MERGE64_FIRST(nbytes), unsigned, MERGE64_SECOND(nbytes)); +#elif VG_WORDSIZE == 8 + PRINT("sys_sync_file_range2 ( %ld, %ld, %lld, %lld )", + ARG1,ARG2,(Long)ARG3,(Long)ARG4); + PRE_REG_READ4(long, "sync_file_range2", + int, fd, unsigned int, flags, + vki_loff_t, offset, vki_loff_t, nbytes); +#else +# error Unexpected word size +#endif + if (!ML_(fd_allowed)(ARG1, "sync_file_range2", tid, False)) + SET_STATUS_Failure( VKI_EBADF ); +} + PRE(sys_stime) { PRINT("sys_stime ( %#lx )", ARG1); diff --git a/coregrind/m_syswrap/syswrap-ppc32-linux.c b/coregrind/m_syswrap/syswrap-ppc32-linux.c index 3d15f04cb9..3e67540d7d 100644 --- a/coregrind/m_syswrap/syswrap-ppc32-linux.c +++ b/coregrind/m_syswrap/syswrap-ppc32-linux.c @@ -1857,7 +1857,7 @@ const SyscallTableEntry ML_(syscall_table)[] = { LINXY(__NR_signalfd, sys_signalfd), // 305 LINXY(__NR_timerfd_create, sys_timerfd_create), // 306 LINX_(__NR_eventfd, sys_eventfd), // 307 -// LINX_(__NR_sync_file_range2, sys_ni_syscall), // 308 + LINX_(__NR_sync_file_range2, sys_sync_file_range2), // 308 // LINX_(__NR_fallocate, sys_fallocate), // 309 // LINXY(__NR_subpage_prot, sys_ni_syscall), // 310 LINXY(__NR_timerfd_settime, sys_timerfd_settime), // 311 diff --git a/coregrind/m_syswrap/syswrap-ppc64-linux.c b/coregrind/m_syswrap/syswrap-ppc64-linux.c index 12892a9da1..0ce1d823ee 100644 --- a/coregrind/m_syswrap/syswrap-ppc64-linux.c +++ b/coregrind/m_syswrap/syswrap-ppc64-linux.c @@ -1497,7 +1497,7 @@ const SyscallTableEntry ML_(syscall_table)[] = { LINXY(__NR_signalfd, sys_signalfd), // 305 LINXY(__NR_timerfd_create, sys_timerfd_create), // 306 LINX_(__NR_eventfd, sys_eventfd), // 307 -// LINX_(__NR_sync_file_range2, sys_ni_syscall), // 308 + LINX_(__NR_sync_file_range2, sys_sync_file_range2), // 308 LINX_(__NR_fallocate, sys_fallocate), // 309 // LINXY(__NR_subpage_prot, sys_ni_syscall), // 310 LINXY(__NR_timerfd_settime, sys_timerfd_settime), // 311