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#6495: Handle invariant errors in x86 QEMU syscall templates #6718

Merged
merged 9 commits into from
Mar 28, 2024

Conversation

abhinav92003
Copy link
Contributor

@abhinav92003 abhinav92003 commented Mar 23, 2024

Handles various invariant errors seen in system call trace templates collected on x86 QEMU.

Modifies syscall trace template file format to use the TRACE_MARKER_TYPE_SYSCALL_TRACE_START and TRACE_MARKER_TYPE_SYSCALL_TRACE_END markers to show start and end respectively of each syscall trace template, instead of separating them using a TRACE_MARKER_TYPE_SYSCALL marker. This makes it easier to write invariant checks that also work for the syscall trace template file (in addition to an actual trace file injected with trace templates).

Handles cases where there are a different number of read/write records than expected by the decoder; after iret, variants of xrstor, variants of xsaves, and prefetch instrs.

Relaxes the PC discontinuity check after hlt, and within two instrs of sti (which enables interrupts, so there may be an interrupt shortly after, as seen in some QEMU syscall trace templates).

Makes other misc changes to make sure the syscall trace template file passes the invariant checker: add thread exit (since we already have a thread start), relaxation of various invariant checks.

Adds and implements the instr_is_xrstor API that identifies variants of the xrstor opcode, and adds supervisor versions of xsave to instr_is_xsave.

Adds unit tests for these new scenarios. Added a TODO to handle other arch equivalent versions of these scenarios.

Adds a new flag -abort_on_invariant_error which is true by default, to allow the user to instruct the invariant checker to continue past invariant errors (using -no_abort_on_invariant_error). This is helpful since there are still a few instances of some invariant errors in the syscall trace template that are harder to generalize and fix/ignore.

Issue: #6495

Handles various invariant errors seen in system call trace templates collected
on x86 QEMU.

Modifies syscall trace template file format to use the
TRACE_MARKER_TYPE_SYSCALL_TRACE_START and TRACE_MARKER_TYPE_SYSCALL_TRACE_END
markers to show start and end respectively of each syscall trace template,
instead of separating them using a TRACE_MARKER_TYPE_SYSCALL marker. This makes
it easier to write invariant checks that also work for the syscall trace
template file (in addition to an actual trace file injected with trace
templates).

Handles cases where there are a different number of read/write records than
expected; after iret, variants of xrstor, variants of xsaves, and prefetch
instrs.

Relaxes the PC discontinuity check after hlt, sysret, and within two instrs of
sti (which enables interrupts, so there may be an interrupt shortly after, as
seen in some QEMU syscall trace templates).

Makes other misc changes to make sure the syscall trace template file passes
the invariant checker: add thread exit (since we already have a thread start),
relaxation of various invariant checks.

Adds and implements the instr_is_xrstor API that identifies variants of the
xrstor opcode, and adds supervisor versions of xsave to instr_is_xsave.

Adds unit tests for these new scenarios. Added a TODO to handle other arch
equivalent versions of these scenarios.

Issue: #6495
@abhinav92003 abhinav92003 changed the title i#6495: Handle invariant errors in QEMU syscall trace templates i#6495: Handle invariant errors in x86 QEMU syscall trace templates Mar 23, 2024
@abhinav92003 abhinav92003 changed the title i#6495: Handle invariant errors in x86 QEMU syscall trace templates i#6495: Handle invariant errors in x86 QEMU syscall templates Mar 23, 2024
clients/drcachesim/common/options.cpp Outdated Show resolved Hide resolved
clients/drcachesim/tests/invariant_checker_test.cpp Outdated Show resolved Hide resolved
clients/drcachesim/tests/invariant_checker_test.cpp Outdated Show resolved Hide resolved
clients/drcachesim/tools/invariant_checker.h Show resolved Hide resolved
clients/drcachesim/tracer/raw2trace.cpp Show resolved Hide resolved
core/ir/instr_api.h Show resolved Hide resolved
core/ir/instr_api.h Outdated Show resolved Hide resolved
@abhinav92003 abhinav92003 merged commit 2c6069d into master Mar 28, 2024
16 checks passed
@abhinav92003 abhinav92003 deleted the i6495-syscall-templ-invariants branch March 28, 2024 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants