Skip to content

Commit

Permalink
i#6662 public traces: add signal and uncompleted instr invariants
Browse files Browse the repository at this point in the history
Public traces should not have TRACE_MARKER_TYPE_SIGNAL_NUMBER and
TRACE_MARKER_TYPE_UNCOMPLETED_INSTRUCTION markers.
We add two invariants in invariant_checker to detect the presence
of these markers in REGDEPS traces and raise an invariant error
if necessary.

Updated unit tests and end-to-end tests.

Issue #6662
  • Loading branch information
edeiana committed Dec 18, 2024
1 parent 9481855 commit 0546b56
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 9 deletions.
42 changes: 42 additions & 0 deletions clients/drcachesim/tests/invariant_checker_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3581,6 +3581,48 @@ check_regdeps(void)
{
std::cerr << "Testing regdeps traces\n";

// Incorrect: TRACE_MARKER_TYPE_SIGNAL_NUMBER not allowed.
{
std::vector<memref_t> memrefs = {
gen_marker(TID_A, TRACE_MARKER_TYPE_FILETYPE, OFFLINE_FILE_TYPE_ARCH_REGDEPS),
gen_marker(TID_A, TRACE_MARKER_TYPE_CACHE_LINE_SIZE, 64),
gen_marker(TID_A, TRACE_MARKER_TYPE_PAGE_SIZE, 4096),
gen_marker(TID_A, TRACE_MARKER_TYPE_SIGNAL_NUMBER, 42),
gen_instr(TID_A),
gen_exit(TID_A),
};
if (!run_checker(
memrefs, true,
{ "OFFLINE_FILE_TYPE_ARCH_REGDEPS traces cannot have "
"TRACE_MARKER_TYPE_SIGNAL_NUMBER markers",
/*tid=*/TID_A,
/*ref_ordinal=*/4, /*last_timestamp=*/0,
/*instrs_since_last_timestamp=*/0 },
"Failed to catch non-allowed TRACE_MARKER_TYPE_SIGNAL_NUMBER marker"))
return false;
}

// Incorrect: TRACE_MARKER_TYPE_UNCOMPLETED_INSTRUCTION not allowed.
{
std::vector<memref_t> memrefs = {
gen_marker(TID_A, TRACE_MARKER_TYPE_FILETYPE, OFFLINE_FILE_TYPE_ARCH_REGDEPS),
gen_marker(TID_A, TRACE_MARKER_TYPE_CACHE_LINE_SIZE, 64),
gen_marker(TID_A, TRACE_MARKER_TYPE_PAGE_SIZE, 4096),
gen_marker(TID_A, TRACE_MARKER_TYPE_UNCOMPLETED_INSTRUCTION, 42),
gen_instr(TID_A),
gen_exit(TID_A),
};
if (!run_checker(memrefs, true,
{ "OFFLINE_FILE_TYPE_ARCH_REGDEPS traces cannot have "
"TRACE_MARKER_TYPE_UNCOMPLETED_INSTRUCTION markers",
/*tid=*/TID_A,
/*ref_ordinal=*/4, /*last_timestamp=*/0,
/*instrs_since_last_timestamp=*/0 },
"Failed to catch non-allowed "
"TRACE_MARKER_TYPE_UNCOMPLETED_INSTRUCTION marker"))
return false;
}

// Incorrect: OFFLINE_FILE_TYPE_ARCH_AARCH64 not allowed.
{
std::vector<memref_t> memrefs = {
Expand Down
10 changes: 10 additions & 0 deletions clients/drcachesim/tools/invariant_checker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1707,6 +1707,16 @@ invariant_checker_t::check_regdeps_invariants(per_shard_t *shard, const memref_t
"was not built on a Linux platform.\n";
#endif
} break;
case TRACE_MARKER_TYPE_SIGNAL_NUMBER:
report_if_false(shard, false,
"OFFLINE_FILE_TYPE_ARCH_REGDEPS traces cannot have "
"TRACE_MARKER_TYPE_SIGNAL_NUMBER markers");
break;
case TRACE_MARKER_TYPE_UNCOMPLETED_INSTRUCTION:
report_if_false(shard, false,
"OFFLINE_FILE_TYPE_ARCH_REGDEPS traces cannot have "
"TRACE_MARKER_TYPE_UNCOMPLETED_INSTRUCTION markers");
break;
default:
// All other markers are allowed.
break;
Expand Down
20 changes: 11 additions & 9 deletions suite/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4849,10 +4849,11 @@ if (BUILD_CLIENTS)
# -filter_marker_types 19,25,27,28,30 (which correspond to
# TRACE_MARKER_TYPE_SYSCALL_IDX, TRACE_MARKER_TYPE_SYSCALL,
# TRACE_MARKER_TYPE_SYSCALL_TRACE_START, TRACE_MARKER_TYPE_SYSCALL_TRACE_END,
# TRACE_MARKER_TYPE_SYSCALL_FAILED), and -filter_modify_marker_value 3,-1
# (which changes the value of TRACE_MARKER_TYPE_CPU_ID == 3 to
# INVALID_CPU_MARKER_VALUE == (uintptr_t)-1).
"${drcachesim_path}@-simulator_type@record_filter@-filter_encodings2regdeps@-indir@${testname}.${ci_shared_app}.*.dir/trace@-outdir@${testname}.filtered.dir@-filter_marker_types@19,25,27,28,30@-filter_keep_func_ids@4294967498@-filter_modify_marker_value@3,-1"
# TRACE_MARKER_TYPE_SYSCALL_FAILED, TRACE_MARKER_TYPE_SIGNAL_NUMBER,
# TRACE_MARKER_TYPE_UNCOMPLETED_INSTRUCTION), and
# -filter_modify_marker_value 3,-1 (which changes the value of
# TRACE_MARKER_TYPE_CPU_ID == 3 to INVALID_CPU_MARKER_VALUE == (uintptr_t)-1).
"${drcachesim_path}@-simulator_type@record_filter@-filter_encodings2regdeps@-indir@${testname}.${ci_shared_app}.*.dir/trace@-outdir@${testname}.filtered.dir@-filter_marker_types@19,25,27,28,30,40,41@-filter_keep_func_ids@4294967498@-filter_modify_marker_value@3,-1"
# We run the invariant_checker analyzer on the REGDEPS filtered trace.
# We expect no invariant errors.
"invariant_checker")
Expand All @@ -4866,13 +4867,14 @@ if (BUILD_CLIENTS)
# with -filter_encodings2regdeps to change instruction encodings,
# -filter_keep_func_ids 4294967498 (which is SYS_futex, associated to the only
# TRACE_MARKER_TYPE_FUNC_ markers we want to keep),
# -filter_marker_types 19,25,27,28,30 (which correspond to
# -filter_marker_types 19,25,27,28,30,40,41 (which correspond to
# TRACE_MARKER_TYPE_SYSCALL_IDX, TRACE_MARKER_TYPE_SYSCALL,
# TRACE_MARKER_TYPE_SYSCALL_TRACE_START, TRACE_MARKER_TYPE_SYSCALL_TRACE_END,
# TRACE_MARKER_TYPE_SYSCALL_FAILED), and -filter_modify_marker_value 3,-1
# (which changes the value of TRACE_MARKER_TYPE_CPU_ID == 3 to
# INVALID_CPU_MARKER_VALUE == (uintptr_t)-1).
"${drcachesim_path}@-simulator_type@record_filter@-filter_encodings2regdeps@-indir@${testname}.${kernel_xfer_app}.*.dir/trace@-outdir@${testname}.filtered.dir@-filter_marker_types@19,25,27,28,30@-filter_keep_func_ids@4294967498@-filter_modify_marker_value@3,-1"
# TRACE_MARKER_TYPE_SYSCALL_FAILED, TRACE_MARKER_TYPE_SIGNAL_NUMBER,
# TRACE_MARKER_TYPE_UNCOMPLETED_INSTRUCTION), and
# -filter_modify_marker_value 3,-1 (which changes the value of
# TRACE_MARKER_TYPE_CPU_ID == 3 to INVALID_CPU_MARKER_VALUE == (uintptr_t)-1).
"${drcachesim_path}@-simulator_type@record_filter@-filter_encodings2regdeps@-indir@${testname}.${kernel_xfer_app}.*.dir/trace@-outdir@${testname}.filtered.dir@-filter_marker_types@19,25,27,28,30,40,41@-filter_keep_func_ids@4294967498@-filter_modify_marker_value@3,-1"
# We run the invariant_checker analyzer on the REGDEPS filtered trace.
# We expect no invariant errors.
"invariant_checker")
Expand Down

0 comments on commit 0546b56

Please sign in to comment.