You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
(122) |
Nov
(152) |
Dec
(69) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(6) |
Feb
(25) |
Mar
(73) |
Apr
(82) |
May
(24) |
Jun
(25) |
Jul
(10) |
Aug
(11) |
Sep
(10) |
Oct
(54) |
Nov
(203) |
Dec
(182) |
| 2004 |
Jan
(307) |
Feb
(305) |
Mar
(430) |
Apr
(312) |
May
(187) |
Jun
(342) |
Jul
(487) |
Aug
(637) |
Sep
(336) |
Oct
(373) |
Nov
(441) |
Dec
(210) |
| 2005 |
Jan
(385) |
Feb
(480) |
Mar
(636) |
Apr
(544) |
May
(679) |
Jun
(625) |
Jul
(810) |
Aug
(838) |
Sep
(634) |
Oct
(521) |
Nov
(965) |
Dec
(543) |
| 2006 |
Jan
(494) |
Feb
(431) |
Mar
(546) |
Apr
(411) |
May
(406) |
Jun
(322) |
Jul
(256) |
Aug
(401) |
Sep
(345) |
Oct
(542) |
Nov
(308) |
Dec
(481) |
| 2007 |
Jan
(427) |
Feb
(326) |
Mar
(367) |
Apr
(255) |
May
(244) |
Jun
(204) |
Jul
(223) |
Aug
(231) |
Sep
(354) |
Oct
(374) |
Nov
(497) |
Dec
(362) |
| 2008 |
Jan
(322) |
Feb
(482) |
Mar
(658) |
Apr
(422) |
May
(476) |
Jun
(396) |
Jul
(455) |
Aug
(267) |
Sep
(280) |
Oct
(253) |
Nov
(232) |
Dec
(304) |
| 2009 |
Jan
(486) |
Feb
(470) |
Mar
(458) |
Apr
(423) |
May
(696) |
Jun
(461) |
Jul
(551) |
Aug
(575) |
Sep
(134) |
Oct
(110) |
Nov
(157) |
Dec
(102) |
| 2010 |
Jan
(226) |
Feb
(86) |
Mar
(147) |
Apr
(117) |
May
(107) |
Jun
(203) |
Jul
(193) |
Aug
(238) |
Sep
(300) |
Oct
(246) |
Nov
(23) |
Dec
(75) |
| 2011 |
Jan
(133) |
Feb
(195) |
Mar
(315) |
Apr
(200) |
May
(267) |
Jun
(293) |
Jul
(353) |
Aug
(237) |
Sep
(278) |
Oct
(611) |
Nov
(274) |
Dec
(260) |
| 2012 |
Jan
(303) |
Feb
(391) |
Mar
(417) |
Apr
(441) |
May
(488) |
Jun
(655) |
Jul
(590) |
Aug
(610) |
Sep
(526) |
Oct
(478) |
Nov
(359) |
Dec
(372) |
| 2013 |
Jan
(467) |
Feb
(226) |
Mar
(391) |
Apr
(281) |
May
(299) |
Jun
(252) |
Jul
(311) |
Aug
(352) |
Sep
(481) |
Oct
(571) |
Nov
(222) |
Dec
(231) |
| 2014 |
Jan
(185) |
Feb
(329) |
Mar
(245) |
Apr
(238) |
May
(281) |
Jun
(399) |
Jul
(382) |
Aug
(500) |
Sep
(579) |
Oct
(435) |
Nov
(487) |
Dec
(256) |
| 2015 |
Jan
(338) |
Feb
(357) |
Mar
(330) |
Apr
(294) |
May
(191) |
Jun
(108) |
Jul
(142) |
Aug
(261) |
Sep
(190) |
Oct
(54) |
Nov
(83) |
Dec
(22) |
| 2016 |
Jan
(49) |
Feb
(89) |
Mar
(33) |
Apr
(50) |
May
(27) |
Jun
(34) |
Jul
(53) |
Aug
(53) |
Sep
(98) |
Oct
(206) |
Nov
(93) |
Dec
(53) |
| 2017 |
Jan
(65) |
Feb
(82) |
Mar
(102) |
Apr
(86) |
May
(187) |
Jun
(67) |
Jul
(23) |
Aug
(93) |
Sep
(65) |
Oct
(45) |
Nov
(35) |
Dec
(17) |
| 2018 |
Jan
(26) |
Feb
(35) |
Mar
(38) |
Apr
(32) |
May
(8) |
Jun
(43) |
Jul
(27) |
Aug
(30) |
Sep
(43) |
Oct
(42) |
Nov
(38) |
Dec
(67) |
| 2019 |
Jan
(32) |
Feb
(37) |
Mar
(53) |
Apr
(64) |
May
(49) |
Jun
(18) |
Jul
(14) |
Aug
(53) |
Sep
(25) |
Oct
(30) |
Nov
(49) |
Dec
(31) |
| 2020 |
Jan
(87) |
Feb
(45) |
Mar
(37) |
Apr
(51) |
May
(99) |
Jun
(36) |
Jul
(11) |
Aug
(14) |
Sep
(20) |
Oct
(24) |
Nov
(40) |
Dec
(23) |
| 2021 |
Jan
(14) |
Feb
(53) |
Mar
(85) |
Apr
(15) |
May
(19) |
Jun
(3) |
Jul
(14) |
Aug
(1) |
Sep
(57) |
Oct
(73) |
Nov
(56) |
Dec
(22) |
| 2022 |
Jan
(3) |
Feb
(22) |
Mar
(6) |
Apr
(55) |
May
(46) |
Jun
(39) |
Jul
(15) |
Aug
(9) |
Sep
(11) |
Oct
(34) |
Nov
(20) |
Dec
(36) |
| 2023 |
Jan
(79) |
Feb
(41) |
Mar
(99) |
Apr
(169) |
May
(48) |
Jun
(16) |
Jul
(16) |
Aug
(57) |
Sep
(19) |
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
|
|
|
1
(2) |
2
(2) |
3
|
4
|
|
5
|
6
(3) |
7
(1) |
8
(1) |
9
(4) |
10
(1) |
11
(1) |
|
12
(2) |
13
(7) |
14
(3) |
15
(2) |
16
(7) |
17
(1) |
18
(2) |
|
19
|
20
|
21
|
22
|
23
|
24
|
25
|
|
26
|
27
|
28
|
29
|
30
|
|
|
|
From: Paul F. <pa...@so...> - 2022-06-06 20:38:09
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=3ce76737204b5f439324096d238674d52e7cd406 commit 3ce76737204b5f439324096d238674d52e7cd406 Author: Paul Floyd <pj...@wa...> Date: Mon Jun 6 22:32:53 2022 +0200 Add syscall wrappers for FreeBSD funlinkat and copy_file_range Aslo add a smoketest for /bin/cp, which uses copy_file_range Diff: --- coregrind/m_syswrap/priv_syswrap-freebsd.h | 4 +-- coregrind/m_syswrap/syswrap-freebsd.c | 51 ++++++++++++++++++++++++++++-- none/tests/freebsd/Makefile.am | 2 ++ none/tests/freebsd/cp.stderr.exp | 0 none/tests/freebsd/cp.vgtest | 7 ++++ 5 files changed, 59 insertions(+), 5 deletions(-) diff --git a/coregrind/m_syswrap/priv_syswrap-freebsd.h b/coregrind/m_syswrap/priv_syswrap-freebsd.h index 70fc431cc0..437047c533 100644 --- a/coregrind/m_syswrap/priv_syswrap-freebsd.h +++ b/coregrind/m_syswrap/priv_syswrap-freebsd.h @@ -526,8 +526,8 @@ DECL_TEMPLATE(freebsd, sys_fhreadlink) // 567 #if (FREEBSD_VERS >= FREEBSD_12_2) -// unimpl __NR_funlinkat 568 -// unimpl __NR_copy_file_range 569 +DECL_TEMPLATE(freebsd, sys_funlinkat) // 568 +DECL_TEMPLATE(freebsd, sys_copy_file_range) // 569 DECL_TEMPLATE(freebsd, sys___sysctlbyname) // 570 #if (FREEBSD_VERS >= FREEBSD_13_0) diff --git a/coregrind/m_syswrap/syswrap-freebsd.c b/coregrind/m_syswrap/syswrap-freebsd.c index b8f5250b94..20718badd6 100644 --- a/coregrind/m_syswrap/syswrap-freebsd.c +++ b/coregrind/m_syswrap/syswrap-freebsd.c @@ -5200,7 +5200,8 @@ PRE(sys_symlinkat) PRE(sys_unlinkat) { *flags |= SfMayBlock; - PRINT("sys_unlinkat ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x(%s) )", ARG1,ARG2,(char*)ARG2); + PRINT("sys_unlinkat ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u ", + ARG1, ARG2, (char*)ARG2, ARG3); PRE_REG_READ3(int, "unlinkat", int, fd, const char *, path, int, flag); PRE_MEM_RASCIIZ( "unlinkat(path)", ARG2 ); } @@ -6185,6 +6186,50 @@ POST(sys_fhreadlink) #if (FREEBSD_VERS >= FREEBSD_12_2) +// SYS_unlinkat 568 +// int funlinkat(int dfd, const char *path, int fd, int flag); +PRE(sys_funlinkat) +{ + *flags |= SfMayBlock; + PRINT("sys_funlinkat ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u, %" FMT_REGWORD"u )", + SARG1, ARG2, (char*)ARG2, ARG4, ARG5); + PRE_REG_READ4(int, "funlinkat", int, dfd, const char *, path, int, fd, int, flag); + PRE_MEM_RASCIIZ( "funlinkat(path)", ARG2 ); +} + +// SYS_copy_file_range 569 +// ssize_t copy_file_range(int infd, off_t *inoffp, int outfd, off_t *outoffp, +// size_t len, unsigned int flags); +PRE(sys_copy_file_range) +{ + PRINT("sys_copy_file_range (%" FMT_REGWORD"d, %#" FMT_REGWORD "x, %" FMT_REGWORD "d, %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "d, %" FMT_REGWORD "d)", + SARG1, ARG2, SARG3, ARG4, (char*)ARG4, SARG5, SARG6); + + PRE_REG_READ6(vki_ssize_t, "copy_file_range", + int, "infd", + vki_off_t *, "inoffp", + int, "outfd", + vki_off_t *, "outoffp", + vki_size_t, "len", + unsigned int, "flags"); + + /* File descriptors are "specially" tracked by valgrind. + valgrind itself uses some, so make sure someone didn't + put in one of our own... */ + if (!ML_(fd_allowed)(ARG1, "copy_file_range(infd)", tid, False) || + !ML_(fd_allowed)(ARG3, "copy_file_range(infd)", tid, False)) { + SET_STATUS_Failure( VKI_EBADF ); + } else { + /* Now see if the offsets are defined. PRE_MEM_READ will + double check it can dereference them. */ + if (ARG2 != 0) + PRE_MEM_READ( "copy_file_range(inoffp)", ARG2, sizeof(vki_off_t)); + if (ARG4 != 0) + PRE_MEM_READ( "copy_file_range(outoffp)", ARG4, sizeof(vki_off_t)); + } +} + + // SYS___sysctlbyname 570 // int sysctlbyname(const char *name, void *oldp, size_t *oldlenp, // const void *newp, size_t newlen); @@ -7031,8 +7076,8 @@ const SyscallTableEntry ML_(syscall_table)[] = { #endif // FREEBSD_VERS >= FREEBSD_12 #if (FREEBSD_VERS >= FREEBSD_12_2) - // unimpl __NR_funlinkat 568 - // unimpl __NR_copy_file_range 569 + BSDX_(__NR_funlinkat, sys_funlinkat), // 568 + BSDX_(__NR_copy_file_range, sys_copy_file_range), // 569 BSDXY(__NR___sysctlbyname, sys___sysctlbyname), // 570 #if (FREEBSD_VERS >= FREEBSD_13_0) diff --git a/none/tests/freebsd/Makefile.am b/none/tests/freebsd/Makefile.am index 4b94071b4b..4a29928238 100644 --- a/none/tests/freebsd/Makefile.am +++ b/none/tests/freebsd/Makefile.am @@ -8,6 +8,8 @@ EXTRA_DIST = \ auxv.stderr.exp-32on64 \ auxv.stderr.exp-freebsd13 \ auxv.stderr.exp-freebsd131 \ + cp.vgtest \ + cp.stderr.exp \ osrel.vgtest \ osrel.stderr.exp \ osrel.stdout.exp \ diff --git a/none/tests/freebsd/cp.stderr.exp b/none/tests/freebsd/cp.stderr.exp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/none/tests/freebsd/cp.vgtest b/none/tests/freebsd/cp.vgtest new file mode 100644 index 0000000000..931fffbf01 --- /dev/null +++ b/none/tests/freebsd/cp.vgtest @@ -0,0 +1,7 @@ +# basic smoke test, but even this can fail +# the copy_file_range syscall was added in FreeBSD 12 +# and then used in the cp command +prog: /bin/cp +args: cp.vgtest cp.out +vgopts: -q +cleanup: rm cp.out |
|
From: Paul F. <pa...@so...> - 2022-06-06 13:59:14
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=6cc2d94d93fa5350355b8cedb0d6b5309fcc588c commit 6cc2d94d93fa5350355b8cedb0d6b5309fcc588c Author: Paul Floyd <pj...@wa...> Date: Mon Jun 6 15:18:29 2022 +0200 Use a different way to tell where the syscall handler was interrupted on FreeBSD and macOS I was using a global variable. This would be set to '1' just before calling the function to save cflags and cleared just after, then using the variable to fill in the 'outside_rnage_ condition in VG_(fixup_guest_state_after_syscall_interrupted) Even though I haven't experienced any isseus with that, the comments just before do_syscall_for_client made me want to try an alternative. This code is very ugly and won't please the language lawyers. Functions aren't guaranteed to have an address and there is no guarantee that the binary layout will reflect the source layout. Sadly C doesn't have something like "sizeof(*function)" to give the size of a function in bytes. The next best that I could manage was to use dummy 'marker' functions just after the ones I want the end address of and then use the address of 'marker - 1' I did think of one other way to do this. That would be to generate a C file containing the function sizes. This would require 1. "put_flag_size.c" would depend on the VEX guest_(x86|amd64)_helpers object files 2. Extract the sizes, for instance echo -n "const size_t x86_put_eflag_c_size = 0x" > put_flag_size.c nm -F sysv libvex_x86_freebsd_a-guest_x86_helpers.o | awk -F\| '/LibVEX_GuestX86_put_eflag_c/{print $5}' >> put_flag_size.c echo ";" >> put_flag_size.c That seems fairly difficult to do in automake and I'm not sure if it would be robust. Diff: --- VEX/priv/guest_amd64_helpers.c | 28 ++++++++++++++++++++++++ VEX/priv/guest_x86_helpers.c | 23 +++++++++++++++++++ VEX/pub/libvex_guest_amd64.h | 7 ++++++ VEX/pub/libvex_guest_x86.h | 6 +++++ coregrind/m_syswrap/syscall-amd64-darwin.S | 5 ----- coregrind/m_syswrap/syscall-amd64-freebsd.S | 8 ------- coregrind/m_syswrap/syscall-x86-darwin.S | 4 ---- coregrind/m_syswrap/syscall-x86-freebsd.S | 7 ------ coregrind/m_syswrap/syswrap-main.c | 34 ++++++++++++++++++++++++----- 9 files changed, 93 insertions(+), 29 deletions(-) diff --git a/VEX/priv/guest_amd64_helpers.c b/VEX/priv/guest_amd64_helpers.c index ba71c1b62f..abd2a1e370 100644 --- a/VEX/priv/guest_amd64_helpers.c +++ b/VEX/priv/guest_amd64_helpers.c @@ -768,6 +768,25 @@ ULong amd64g_calculate_rflags_all_WRK ( ULong cc_op, } } +#if defined(VGO_freebsd) || defined(VGO_darwin) + +/* This dummy function is just used to have an address just after + amd64g_calculate_rflags_all_WRK */ + +static +void _______VVVVVVVV_amd64g_calculate_rflags_all_WRK_VVVVVVVV_______ (void) +{ +} + +/* Export addresses of amd64g_calculate_rflags_all_WRK and + _______VVVVVVVV_amd64g_calculate_rflags_all_WRK_VVVVVVVV_______ + Used in syswrap-main.c / VG_(post_syscall) in the case where + the above function was interrupted and we need to work out + what needs to be done for the resumption */ + +Addr addr_amd64g_calculate_rflags_all_WRK = (Addr)amd64g_calculate_rflags_all_WRK; +Addr addr________VVVVVVVV_amd64g_calculate_rflags_all_WRK_VVVVVVVV_______ = (Addr)_______VVVVVVVV_amd64g_calculate_rflags_all_WRK_VVVVVVVV_______; +#endif /* CALLED FROM GENERATED CODE: CLEAN HELPER */ /* Calculate all the 6 flags from the supplied thunk parameters. */ @@ -994,6 +1013,15 @@ LibVEX_GuestAMD64_put_rflag_c ( ULong new_carry_flag, vex_state->guest_CC_NDEP = 0; } +#if defined(VGO_freebsd) || defined(VGO_darwin) +/* Used in syswrap-main.c / VG_(post_syscall) in the case where + the above function was interrupted and we need to work out + what needs to be done for the resumption. These functions + are extern so no need for 'addr' global variables */ +void _______VVVVVVVV_after_GuestAMD64_put_rflag_c_VVVVVVVV_______ (void) +{ +} +#endif /*---------------------------------------------------------------*/ /*--- %rflags translation-time function specialisers. ---*/ diff --git a/VEX/priv/guest_x86_helpers.c b/VEX/priv/guest_x86_helpers.c index c0a4d33edc..7b229cb795 100644 --- a/VEX/priv/guest_x86_helpers.c +++ b/VEX/priv/guest_x86_helpers.c @@ -567,6 +567,20 @@ UInt x86g_calculate_eflags_all_WRK ( UInt cc_op, } } +#if defined(VGO_freebsd) || defined(VGO_darwin) + +/* see guest_amd64_helpers.c + Used in syswrap-main.c / VG_(post_syscall) for signal + resumption */ + +static void _______VVVVVVVV_after_x86g_calculate_eflags_all_WRK_VVVVVVVV_______ (void) +{ +} + +Addr addr_x86g_calculate_eflags_all_WRK = (Addr)x86g_calculate_eflags_all_WRK; +Addr addr________VVVVVVVV_x86g_calculate_eflags_all_WRK_VVVVVVVV_______ = (Addr)_______VVVVVVVV_after_x86g_calculate_eflags_all_WRK_VVVVVVVV_______; +#endif + /* CALLED FROM GENERATED CODE: CLEAN HELPER */ /* Calculate all the 6 flags from the supplied thunk parameters. */ @@ -790,6 +804,15 @@ LibVEX_GuestX86_put_eflag_c ( UInt new_carry_flag, vex_state->guest_CC_NDEP = 0; } +#if defined(VGO_freebsd) || defined(VGO_darwin) + +/* Used in syswrap-main.c / VG_(post_syscall) for signal resumption */ + +void _______VVVVVVVV_after_LibVEX_GuestX86_put_eflag_c_VVVVVVVV_______ (void) +{ +} +#endif + /*---------------------------------------------------------------*/ /*--- %eflags translation-time function specialisers. ---*/ diff --git a/VEX/pub/libvex_guest_amd64.h b/VEX/pub/libvex_guest_amd64.h index 1518ba304c..864b54b04e 100644 --- a/VEX/pub/libvex_guest_amd64.h +++ b/VEX/pub/libvex_guest_amd64.h @@ -203,6 +203,13 @@ void LibVEX_GuestAMD64_put_rflag_c ( ULong new_carry_flag, /*MOD*/VexGuestAMD64State* vex_state ); +#if defined(VGO_freebsd) || defined(VGO_darwin) +void _______VVVVVVVV_after_GuestAMD64_put_rflag_c_VVVVVVVV_______ (void); +extern Addr addr_amd64g_calculate_rflags_all_WRK; +extern Addr addr________VVVVVVVV_amd64g_calculate_rflags_all_WRK_VVVVVVVV_______; +#endif + + /* Do FXSAVE from the supplied VexGuestAMD64tate structure and store the result at the given address which represents a buffer of at least 416 bytes. */ diff --git a/VEX/pub/libvex_guest_x86.h b/VEX/pub/libvex_guest_x86.h index fabafe113c..53f72acb8c 100644 --- a/VEX/pub/libvex_guest_x86.h +++ b/VEX/pub/libvex_guest_x86.h @@ -292,6 +292,12 @@ void LibVEX_GuestX86_put_eflag_c ( UInt new_carry_flag, /*MOD*/VexGuestX86State* vex_state ); +#if defined(VGO_freebsd) || defined(VGO_darwin) +extern void _______VVVVVVVV_after_LibVEX_GuestX86_put_eflag_c_VVVVVVVV_______ (void); +extern Addr addr_x86g_calculate_eflags_all_WRK; +extern Addr addr________VVVVVVVV_x86g_calculate_eflags_all_WRK_VVVVVVVV_______; +#endif + /* Do x87 save from the supplied VexGuestX86State structure and store the result at the given address which represents a buffer of at least 108 bytes. */ diff --git a/coregrind/m_syswrap/syscall-amd64-darwin.S b/coregrind/m_syswrap/syscall-amd64-darwin.S index 8a970fa088..ed93a851eb 100644 --- a/coregrind/m_syswrap/syscall-amd64-darwin.S +++ b/coregrind/m_syswrap/syscall-amd64-darwin.S @@ -248,11 +248,6 @@ ML_(blksys_complete_UNIX): .quad MK_L_SCCLASS_N(UNIX,3) ML_(blksys_committed_UNIX): .quad MK_L_SCCLASS_N(UNIX,4) ML_(blksys_finished_UNIX): .quad MK_L_SCCLASS_N(UNIX,5) -.data -globl ML_(blksys_saving_cflag) -ML_(blksys_saving_cflag): .quad 0 -.previous - #endif // defined(VGP_amd64_darwin) /* Let the linker know we don't need an executable stack */ diff --git a/coregrind/m_syswrap/syscall-amd64-freebsd.S b/coregrind/m_syswrap/syscall-amd64-freebsd.S index 55d53f0b76..8f084c3e19 100644 --- a/coregrind/m_syswrap/syscall-amd64-freebsd.S +++ b/coregrind/m_syswrap/syscall-amd64-freebsd.S @@ -153,9 +153,7 @@ ML_(do_syscall_for_client_WRK): movq %rax, %rdi /* arg1 = new flag */ movq %r11, %rsi /* arg2 = vex state */ addq $24, %rsp /* remove syscall parameters */ - movq $0x1, ML_(blksys_saving_cflag) call LibVEX_GuestAMD64_put_rflag_c - movq $0x0, ML_(blksys_saving_cflag) 4: /* Re-block signals. If eip is in [4,5), then the syscall is complete and we needn't worry about it. */ @@ -208,12 +206,6 @@ ML_(blksys_committed): .quad 4b ML_(blksys_finished): .quad 5b .previous - .data - .globl ML_(blksys_saving_cflag) - ML_(blksys_saving_cflag): .quad 0 - .previous - - #endif /* defined(VGP_amd64_freebsd) */ /* Let the linker know we don't need an executable stack */ diff --git a/coregrind/m_syswrap/syscall-x86-darwin.S b/coregrind/m_syswrap/syscall-x86-darwin.S index cbeadc52f8..9032422685 100644 --- a/coregrind/m_syswrap/syscall-x86-darwin.S +++ b/coregrind/m_syswrap/syscall-x86-darwin.S @@ -246,10 +246,6 @@ ML_(blksys_complete_UNIX): .long MK_L_SCCLASS_N(UNIX,3) ML_(blksys_committed_UNIX): .long MK_L_SCCLASS_N(UNIX,4) ML_(blksys_finished_UNIX): .long MK_L_SCCLASS_N(UNIX,5) -.data -.globl ML_(blksys_saving_cflag) -ML_(blksys_saving_cflag): .long 0 -.previous #endif // defined(VGP_x86_darwin) /* Let the linker know we don't need an executable stack */ diff --git a/coregrind/m_syswrap/syscall-x86-freebsd.S b/coregrind/m_syswrap/syscall-x86-freebsd.S index 523d3d2e0d..1faa74c4d6 100644 --- a/coregrind/m_syswrap/syscall-x86-freebsd.S +++ b/coregrind/m_syswrap/syscall-x86-freebsd.S @@ -143,9 +143,7 @@ ML_(do_syscall_for_client_WRK): movl $0, 0(%esp) movb 12(%esp), %al movb %al, 0(%esp) - movl $0x1, ML_(blksys_saving_cflag) call LibVEX_GuestX86_put_eflag_c - movl $0x0, ML_(blksys_saving_cflag) addl $12, %esp 4: /* Re-block signals. If eip is in [4,5), then the syscall is @@ -193,11 +191,6 @@ ML_(blksys_committed): .long 4b ML_(blksys_finished): .long 5b .previous - .data - .globl ML_(blksys_saving_cflag) - ML_(blksys_saving_cflag): .long 0 - .previous - #endif // defined(VGP_x86_freebsd) /* Let the linker know we don't need an executable stack */ diff --git a/coregrind/m_syswrap/syswrap-main.c b/coregrind/m_syswrap/syswrap-main.c index 5824a1dbea..5077a7da73 100644 --- a/coregrind/m_syswrap/syswrap-main.c +++ b/coregrind/m_syswrap/syswrap-main.c @@ -2569,9 +2569,6 @@ void VG_(post_syscall) (ThreadId tid) extern const Addr ML_(blksys_complete); extern const Addr ML_(blksys_committed); extern const Addr ML_(blksys_finished); -#if defined(VGO_freebsd) - extern const Addr ML_(blksys_saving_cflag); -#endif #elif defined(VGO_darwin) /* Darwin requires extra uglyness */ extern const Addr ML_(blksys_setup_MACH); @@ -2589,7 +2586,6 @@ void VG_(post_syscall) (ThreadId tid) extern const Addr ML_(blksys_complete_UNIX); extern const Addr ML_(blksys_committed_UNIX); extern const Addr ML_(blksys_finished_UNIX); - extern const Addr ML_(blksys_saving_cflag); #elif defined(VGO_solaris) extern const Addr ML_(blksys_setup); extern const Addr ML_(blksys_complete); @@ -3123,7 +3119,35 @@ VG_(fixup_guest_state_after_syscall_interrupted)( ThreadId tid, #if defined(VGO_freebsd) || defined(VGO_darwin) if (outside_range) { - if (ML_(blksys_saving_cflag)) + /* This is not guaranteed to work since the compiler / link editor + could lay out the binary functions in a different order to + the source file. However, it seems to work. */ + +#if defined (VGA_amd64) + + vg_assert((Addr)_______VVVVVVVV_after_GuestAMD64_put_rflag_c_VVVVVVVV_______ > + (Addr)LibVEX_GuestAMD64_put_rflag_c ); + + vg_assert(addr________VVVVVVVV_amd64g_calculate_rflags_all_WRK_VVVVVVVV_______ > + addr_amd64g_calculate_rflags_all_WRK); + + if ((ip >= (Addr)LibVEX_GuestAMD64_put_rflag_c && + ip < (Addr)_______VVVVVVVV_after_GuestAMD64_put_rflag_c_VVVVVVVV_______) || + (ip >= addr_amd64g_calculate_rflags_all_WRK && + ip < addr________VVVVVVVV_amd64g_calculate_rflags_all_WRK_VVVVVVVV_______)) +#else + + vg_assert((Addr)_______VVVVVVVV_after_LibVEX_GuestX86_put_eflag_c_VVVVVVVV_______ > + (Addr)LibVEX_GuestX86_put_eflag_c); + + vg_assert(addr________VVVVVVVV_x86g_calculate_eflags_all_WRK_VVVVVVVV_______> + addr_x86g_calculate_eflags_all_WRK); + + if ((ip >= (Addr)LibVEX_GuestX86_put_eflag_c && + ip < (Addr)_______VVVVVVVV_after_LibVEX_GuestX86_put_eflag_c_VVVVVVVV_______) || + (ip >= addr_x86g_calculate_eflags_all_WRK && + ip < addr________VVVVVVVV_x86g_calculate_eflags_all_WRK_VVVVVVVV_______)) +#endif { outside_range = False; in_complete_to_committed = True; |
|
From: Paul F. <pa...@so...> - 2022-06-06 09:23:48
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=eeaf547e6c345834032c73f63595dc52a9fbf585 commit eeaf547e6c345834032c73f63595dc52a9fbf585 Author: Paul Floyd <pj...@wa...> Date: Mon Jun 6 11:20:39 2022 +0200 Fix FreeBSD x86 allocation of GDT for threads on x86 Also update README.freebsd This is about the last significant failure that is x86 FreeBSD specific. Diff: --- README.freebsd | 12 +++----- coregrind/m_syswrap/syswrap-x86-freebsd.c | 50 +++++++++++++++++++++---------- 2 files changed, 39 insertions(+), 23 deletions(-) diff --git a/README.freebsd b/README.freebsd index 8a8981439c..f33ba2f9b6 100644 --- a/README.freebsd +++ b/README.freebsd @@ -21,7 +21,7 @@ $ ./configure --prefix=/where/ever $ gmake $ gmake install -Known Limitations (December 2020) +Known Limitations (June 2022) 0. Be aware that if you use a wrapper script and run Valgrind on the wrapper script Valgrind may hit restrictions if the wrapper script runs any @@ -31,13 +31,9 @@ Known Limitations (December 2020) application. 1. There are some limitations when running Valgrind on code that was compiled with clang. These issues are not present with code compiled with GCC. - a) There may be missing source information concerning variables. - b) The client request mechanism may not work entirely correctly. - c) Code that uses OpenMP will generate spurious errors. -2. There are some limitations specific to i386 - a) In some cases signals are mishandled causing Valgrind to terminate and - report a SIGSEGV. - b) Applications that create and join many threads may crash. + a) There may be missing source information concerning variables due + to DWARF extensions ised by GCC. + b) Code that uses OpenMP will generate spurious errors. Notes for Developers ~~~~~~~~~~~~~~~~~~~~ diff --git a/coregrind/m_syswrap/syswrap-x86-freebsd.c b/coregrind/m_syswrap/syswrap-x86-freebsd.c index 4abd44cda6..fe46e1eabd 100644 --- a/coregrind/m_syswrap/syswrap-x86-freebsd.c +++ b/coregrind/m_syswrap/syswrap-x86-freebsd.c @@ -351,7 +351,6 @@ static VexGuestX86SegDescr* alloc_zeroed_x86_GDT ( void ) return VG_(arena_calloc)(VG_AR_CORE, "di.syswrap-x86.azxG.1", nbytes, 1); } -#if 0 /* Create a zeroed-out LDT. */ static VexGuestX86SegDescr* alloc_zeroed_x86_LDT ( void ) { @@ -408,7 +407,6 @@ static void deallocate_LGDTs_for_thread ( VexGuestX86State* vex ) vex->guest_GDT = (HWord)NULL; } } -#endif static SysRes sys_set_thread_area ( ThreadId tid, Int *idxptr, void *base) { @@ -475,6 +473,36 @@ static SysRes sys_get_thread_area ( ThreadId tid, Int idx, void ** basep ) return VG_(mk_SysRes_Success)( 0 ); } +static +void x86_setup_LDT_GDT ( /*OUT*/ ThreadArchState *child, + /*IN*/ ThreadArchState *parent ) +{ + /* We inherit our parent's LDT. */ + if (parent->vex.guest_LDT == (HWord)NULL) { + /* We hope this is the common case. */ + child->vex.guest_LDT = (HWord)NULL; + } else { + /* No luck .. we have to take a copy of the parent's. */ + child->vex.guest_LDT = (HWord)alloc_zeroed_x86_LDT(); + copy_LDT_from_to( (VexGuestX86SegDescr*)(HWord)parent->vex.guest_LDT, + (VexGuestX86SegDescr*)(HWord)child->vex.guest_LDT ); + } + + /* Either we start with an empty GDT (the usual case) or inherit a + copy of our parents' one (Quadrics Elan3 driver -style clone + only). */ + child->vex.guest_GDT = (HWord)NULL; + + if (parent->vex.guest_GDT != (HWord)NULL) { + //child->vex.guest_GDT = (HWord)alloc_system_x86_GDT(); + child->vex.guest_GDT = (HWord)alloc_zeroed_x86_GDT(); + copy_GDT_from_to( (VexGuestX86SegDescr*)(HWord)parent->vex.guest_GDT, + (VexGuestX86SegDescr*)(HWord)child->vex.guest_GDT ); + } +} + + + /* --------------------------------------------------------------------- More thread stuff ------------------------------------------------------------------ */ @@ -488,19 +516,7 @@ void VG_(cleanup_thread) ( ThreadArchState* arch ) * Alternatively the rtld use is after the start of the next thread and we haven't * reallocated this memory */ - /*deallocate_LGDTs_for_thread( &arch->vex );*/ - - /* - * This was plan B, just recycle the slot - * It fixes none/tests/manythreads - * but it breaks drd/tests/fork-parallel - */ -#if 0 - VexGuestX86SegDescr* gdt = (VexGuestX86SegDescr*) arch->vex.guest_GDT; - if (gdt) - translate_to_hw_format(0, &gdt[arch->vex.guest_GS >> 3]); -#endif - + deallocate_LGDTs_for_thread( &arch->vex ); } @@ -1068,6 +1084,8 @@ PRE(sys_thr_new) ctst->arch.vex.guest_EDX = 0; LibVEX_GuestX86_put_eflag_c(0, &ctst->arch.vex); + x86_setup_LDT_GDT(&ctst->arch, &ptst->arch); + ctst->os_state.parent = tid; /* inherit signal mask */ @@ -1087,7 +1105,9 @@ PRE(sys_thr_new) if (debug) VG_(printf)("clone child has SETTLS: tls at %#lx\n", (Addr)tp.tls_base); + sys_set_thread_area( ctid, &idx, tp.tls_base ); + ctst->arch.vex.guest_GS = (idx << 3) | 3; /* GSEL(GUGS_SEL, SEL_UPL) */ tp.tls_base = 0; /* Don't have the kernel do it too */ |