Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i#6919: Fix XMM saving after synchall #6920

Merged
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
cc2db9f
i#6919 fix XMM saving after synch-all
ndrewh Aug 16, 2024
7d3f352
appease clang-format, locally at least
ndrewh Aug 16, 2024
0fa0640
link_with_pthread to fix ci
ndrewh Aug 16, 2024
a05990a
threadset is a X64 test only
ndrewh Aug 16, 2024
55e3e83
DR_HOST_X64
ndrewh Aug 16, 2024
53b6d8b
X64 AND DR_HOST_X64\?
ndrewh Aug 16, 2024
3468fb2
appease test gods
ndrewh Aug 16, 2024
a79fe71
PLEASE CI
ndrewh Aug 17, 2024
e94b012
Merge remote-tracking branch 'origin/master' into i6919-set-self-cont…
ndrewh Aug 17, 2024
22e5724
move test and client into separate file
ndrewh Aug 17, 2024
1153dfd
cleanup comments
ndrewh Aug 17, 2024
357d45c
clang-format
ndrewh Aug 17, 2024
11086ed
i would like to apologize to the CI runner
ndrewh Aug 17, 2024
2826345
Merge remote-tracking branch 'origin/master' into i6919-set-self-cont…
ndrewh Aug 19, 2024
cfc8fd6
nits
ndrewh Aug 19, 2024
b016209
rename test, remove sleep, use print, nits
ndrewh Aug 22, 2024
0a10a73
clang-format
ndrewh Aug 22, 2024
9b8486c
Merge remote-tracking branch 'origin/master' into i6919-set-self-cont…
ndrewh Aug 22, 2024
0359c62
switch to condvar to wait for thread
ndrewh Aug 22, 2024
be4716f
Merge branch 'master' into i6919-set-self-context-fp-restore
derekbruening Aug 23, 2024
63e26f1
save_fpstate already saves xmm state from mcontext
ndrewh Aug 23, 2024
9786f8f
fix comment
ndrewh Aug 23, 2024
43e8ecf
fix comment again (sorry, CI runner)
ndrewh Aug 23, 2024
77e5919
linux-only
ndrewh Aug 23, 2024
dfd9291
fuck macos
ndrewh Aug 23, 2024
cc1effd
remove duplicate dcontext
ndrewh Aug 23, 2024
a1ca49e
Merge branch 'master' into i6919-set-self-context-fp-restore
derekbruening Aug 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion core/unix/os.c
Original file line number Diff line number Diff line change
Expand Up @@ -3792,7 +3792,8 @@ os_thread_sleep(uint64 milliseconds)
* routine sleep forever
*/
if (count++ > 3 && !IS_CLIENT_THREAD(get_thread_private_dcontext())) {
ASSERT_NOT_REACHED();
ASSERT_CURIOSITY_ONCE(
false && "os_thread_sleep interrupted by signal more than 3 times.");
break; /* paranoid */
}
req = remain;
Expand Down
19 changes: 9 additions & 10 deletions core/unix/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -3235,20 +3235,18 @@ thread_set_self_context(void *cxt, bool is_detach_external)
ASSERT_NOT_IMPLEMENTED(false); /* PR 405694: can't use regular sigreturn! */
ndrewh marked this conversation as resolved.
Show resolved Hide resolved
ndrewh marked this conversation as resolved.
Show resolved Hide resolved
#endif
memset(&frame, 0, sizeof(frame));
#if defined(X86)
dcontext_t *dcontext = get_thread_private_dcontext();
#endif
#ifdef LINUX
# ifdef X86
byte *xstate = get_and_initialize_xstate_buffer(dcontext);
frame.uc.uc_mcontext.fpstate = &((kernel_xstate_t *)xstate)->fpstate;
# endif /* X86 */
frame.uc.uc_mcontext = *sc;
#endif
IF_ARM(ASSERT_NOT_TESTED());
#if defined(X86)
dcontext_t *dcontext = get_thread_private_dcontext();

/* This only saves X87 state. XMM state is saved in mcontext_to_sigcontext
* (called by thread_set_self_mcontext).
*/
save_fpstate(dcontext, &frame);
derekbruening marked this conversation as resolved.
Show resolved Hide resolved
#endif
IF_ARM(ASSERT_NOT_TESTED());
/* The kernel calls do_sigaltstack on sys_rt_sigreturn primarily to ensure
* the frame is ok, but the side effect is we can mess up our own altstack
* settings if we're not careful. Having invalid ss_size looks good for
Expand Down Expand Up @@ -3341,14 +3339,15 @@ thread_set_self_mcontext(priv_mcontext_t *mc, bool is_detach_external)
sig_full_cxt_t sc_full;
sig_full_initialize(&sc_full, &ucxt);
#if defined(LINUX) && defined(X86)
sc_full.sc->fpstate = NULL; /* for mcontext_to_sigcontext */
/* For mcontext_to_sigcontext to fill in with saved fp state */
sc_full.sc->fpstate = (kernel_fpstate_t *)get_and_initialize_xstate_buffer(
get_thread_private_dcontext());
#endif
mcontext_to_sigcontext(&sc_full, mc, DR_MC_ALL);
thread_set_segment_registers(sc_full.sc);
/* sigreturn takes the mode from cpsr */
IF_ARM(
set_pc_mode_in_cpsr(sc_full.sc, dr_get_isa_mode(get_thread_private_dcontext())));
/* thread_set_self_context will fill in the real fp/simd state for x86 */
thread_set_self_context((void *)sc_full.sc, is_detach_external);
ASSERT_NOT_REACHED();
}
Expand Down
7 changes: 7 additions & 0 deletions suite/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5401,6 +5401,13 @@ if (UNIX)
if (NOT APPLE)
tobuild(linux.thread linux/thread.c)
tobuild(linux.threadexit linux/threadexit.c)

if (X86 AND X64 AND DR_HOST_X86 AND DR_HOST_X64)
tobuild_ci(linux.synchall-restore linux/synchall-restore.c "" "" "")
set_avx_flags(linux.synchall-restore)
link_with_pthread(linux.synchall-restore)
endif ()

if (NOT ANDROID)
tobuild(linux.threadexit2 linux/threadexit2.c) # XXX i#1874: hangs on Android
tobuild(linux.signalfd linux/signalfd.c) # XXX i#1874: fails natively on Android
Expand Down
Loading
Loading