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#5658 rseq drreg: Put native sequence by barrier #5664

Merged
merged 2 commits into from
Sep 30, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
2 changes: 1 addition & 1 deletion core/arch/interp.c
Original file line number Diff line number Diff line change
Expand Up @@ -3972,7 +3972,7 @@ build_bb_ilist(dcontext_t *dcontext, build_bb_t *bb)
if (TEST(FRAG_HAS_RSEQ_ENDPOINT, bb->flags)) {
instr_t *label = INSTR_CREATE_label(dcontext);
instr_set_note(label, (void *)DR_NOTE_REG_BARRIER);
instrlist_meta_preinsert(bb->ilist, bb->instr, label);
instrlist_meta_append(bb->ilist, label);
derekbruening marked this conversation as resolved.
Show resolved Hide resolved
}
#endif

Expand Down
23 changes: 22 additions & 1 deletion core/arch/mangle_shared.c
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,28 @@ mangle_rseq(dcontext_t *dcontext, instrlist_t *ilist, instr_t *instr,
ASSERT_NOT_REACHED();
}
rseq_set_final_instr_pc(start, pc);
mangle_rseq_insert_native_sequence(dcontext, ilist, instr, next_instr, flags,
/* We need to insert the native sequence before the barrier label,
* as that is where the app code has native values.
* It is possible a client inserted code in between so we have to go
* and find it.
*/
instr_t *find = *next_instr;
while (find != NULL &&
!(instr_is_label(find) &&
instr_get_note(find) == (void *)DR_NOTE_REG_BARRIER))
find = instr_get_next(find);
if (find == NULL) {
REPORT_FATAL_ERROR_AND_EXIT(
RSEQ_BEHAVIOR_UNSUPPORTED, 3, get_application_name(),
get_application_pid(),
"Rseq sequence DR_NOTE_REG_BARRIER must not be deleted");
ASSERT_NOT_REACHED();
}
instr_t *where_next = instr_get_next(find);
/* We actually don't need to set next_instr because the inserted native code
* is still beyond the next_instr of this app instr.
*/
mangle_rseq_insert_native_sequence(dcontext, ilist, find, &where_next, flags,
start, end, handler, scratch_reg, reg_written,
reg_written_count);
/* TODO i#2350: We should also invoke the native sequence on a midpoint exit
Expand Down