Skip to content

Commit

Permalink
Fix windows build issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinav92003 committed Mar 24, 2024
1 parent af04498 commit ddacd60
Showing 1 changed file with 109 additions and 105 deletions.
214 changes: 109 additions & 105 deletions clients/drcachesim/tests/invariant_checker_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3191,104 +3191,106 @@ check_kernel_syscall_trace(void)
instr_t *nop5 = XINST_CREATE_nop(GLOBAL_DCONTEXT);
instr_t *sys2 = instr_clone(GLOBAL_DCONTEXT, sys);
instr_t *nop6 = XINST_CREATE_nop(GLOBAL_DCONTEXT);
instrlist_t *ilist = instrlist_create(GLOBAL_DCONTEXT);
instrlist_append(ilist, move1);
instrlist_append(ilist, iret);
instrlist_append(ilist, sti);
instrlist_append(ilist, nop1);
instrlist_append(ilist, nop2);
instrlist_append(ilist, xrstors);
instrlist_append(ilist, xsaves);
instrlist_append(ilist, hlt);
instrlist_append(ilist, nop3);
instrlist_append(ilist, prefetch);
instrlist_append(ilist, sysret);
instrlist_append(ilist, nop4);
instrlist_append(ilist, sys1);
instrlist_append(ilist, nop5);
instrlist_append(ilist, sys2);
instrlist_append(ilist, nop6);

instrlist_t *ilist2 = instrlist_create(GLOBAL_DCONTEXT);
instrlist_append(ilist2, move1);
instrlist_append(ilist2, iret);
instrlist_append(ilist2, sti);
instrlist_append(ilist2, nop1);
instrlist_append(ilist2, nop2);
instrlist_append(ilist2, xrstors);
instrlist_append(ilist2, xsaves);
instrlist_append(ilist2, hlt);
instrlist_append(ilist2, nop3);
instrlist_append(ilist2, prefetch);
instrlist_append(ilist2, sysret);
instrlist_append(ilist2, nop4);
instrlist_append(ilist2, sys1);
instrlist_append(ilist2, nop5);
instrlist_append(ilist2, sys2);
instrlist_append(ilist2, nop6);
{
std::vector<memref_with_IR_t> memref_instr_vec = {
{ gen_marker(TID_A, TRACE_MARKER_TYPE_FILETYPE,
OFFLINE_FILE_TYPE_ENCODINGS |
OFFLINE_FILE_TYPE_SYSCALL_NUMBERS |
OFFLINE_FILE_TYPE_KERNEL_SYSCALLS),
nullptr },
{ gen_marker(TID_A, TRACE_MARKER_TYPE_CACHE_LINE_SIZE, 64), nullptr },
{ gen_marker(TID_A, TRACE_MARKER_TYPE_PAGE_SIZE, 4096), nullptr },
{ gen_instr(TID_A), sys1 },
{ gen_marker(TID_A, TRACE_MARKER_TYPE_SYSCALL, 42), nullptr },
{ gen_marker(TID_A, TRACE_MARKER_TYPE_SYSCALL_TRACE_START, 42), nullptr },
{ gen_instr(TID_A), move1 },
{ gen_instr(TID_A), iret },
// Multiple reads.
{ gen_data(TID_A, true, 42, 8), nullptr },
{ gen_data(TID_A, true, 42, 8), nullptr },
{ gen_data(TID_A, true, 42, 8), nullptr },
{ gen_data(TID_A, true, 42, 8), nullptr },
{ gen_instr(TID_A), sti },
{ gen_instr(TID_A), nop1 },
// Missing nop2. Acceptable because of the recent sti.
{ gen_instr(TID_A), xrstors },
// Multiple reads.
{ gen_data(TID_A, true, 42, 8), nullptr },
{ gen_data(TID_A, true, 42, 8), nullptr },
{ gen_data(TID_A, true, 42, 8), nullptr },
{ gen_data(TID_A, true, 42, 8), nullptr },
{ gen_instr(TID_A), xsaves },
// Multiple writes.
{ gen_data(TID_A, false, 42, 8), nullptr },
{ gen_data(TID_A, false, 42, 8), nullptr },
{ gen_data(TID_A, false, 42, 8), nullptr },
{ gen_data(TID_A, false, 42, 8), nullptr },
{ gen_instr(TID_A), hlt },
// Missing nop3.
{ gen_instr(TID_A), prefetch },
// Missing reads.
{ gen_instr(TID_A), sysret },
{ gen_marker(TID_A, TRACE_MARKER_TYPE_SYSCALL_TRACE_END, 42), nullptr },
// Continues after sys1.
{ gen_instr(TID_A), nop5 },
{ gen_instr(TID_A), sys2 },
{ gen_marker(TID_A, TRACE_MARKER_TYPE_SYSCALL, 41), nullptr },
{ gen_marker(TID_A, TRACE_MARKER_TYPE_SYSCALL_TRACE_START, 41), nullptr },
{ gen_instr(TID_A), move1 },
{ gen_marker(TID_A, TRACE_MARKER_TYPE_SYSCALL_TRACE_END, 41), nullptr },
// Continues after sys2.
{ gen_instr(TID_A), nop6 },
{ gen_exit(TID_A), nullptr }
};
auto memrefs = add_encodings_to_memrefs(ilist2, memref_instr_vec, BASE_ADDR);
if (!run_checker(memrefs, false))
res = false;
}
{
std::vector<memref_with_IR_t> memref_instr_vec = {
{ gen_marker(TID_A, TRACE_MARKER_TYPE_FILETYPE,
OFFLINE_FILE_TYPE_ENCODINGS |
OFFLINE_FILE_TYPE_SYSCALL_NUMBERS |
OFFLINE_FILE_TYPE_KERNEL_SYSCALLS),
nullptr },
{ gen_marker(TID_A, TRACE_MARKER_TYPE_CACHE_LINE_SIZE, 64), nullptr },
{ gen_marker(TID_A, TRACE_MARKER_TYPE_PAGE_SIZE, 4096), nullptr },
{ gen_instr(TID_A), sys1 },
{ gen_marker(TID_A, TRACE_MARKER_TYPE_SYSCALL, 42), nullptr },
{ gen_marker(TID_A, TRACE_MARKER_TYPE_SYSCALL_TRACE_START, 42), nullptr },
{ gen_instr(TID_A), move1 },
{ gen_marker(TID_A, TRACE_MARKER_TYPE_SYSCALL_TRACE_END, 42), nullptr },
// Missing instrs.
{ gen_instr(TID_A), nop6 },
{ gen_exit(TID_A), nullptr }
};
auto memrefs = add_encodings_to_memrefs(ilist2, memref_instr_vec, BASE_ADDR);
if (!run_checker(memrefs, true,
{ "Non-explicit control flow has no marker",
/*tid=*/TID_A,
/*ref_ordinal=*/9, /*last_timestamp=*/0,
/*instrs_since_last_timestamp=*/3 },
"Failed to catch discontinuity on return from syscall"))
res = false;
}
std::vector<memref_with_IR_t> memref_instr_vec = {
{ gen_marker(TID_A, TRACE_MARKER_TYPE_FILETYPE,
OFFLINE_FILE_TYPE_ENCODINGS | OFFLINE_FILE_TYPE_SYSCALL_NUMBERS |
OFFLINE_FILE_TYPE_KERNEL_SYSCALLS),
nullptr },
{ gen_marker(TID_A, TRACE_MARKER_TYPE_CACHE_LINE_SIZE, 64), nullptr },
{ gen_marker(TID_A, TRACE_MARKER_TYPE_PAGE_SIZE, 4096), nullptr },
{ gen_instr(TID_A), sys1 },
{ gen_marker(TID_A, TRACE_MARKER_TYPE_SYSCALL, 42), nullptr },
{ gen_marker(TID_A, TRACE_MARKER_TYPE_SYSCALL_TRACE_START, 42), nullptr },
{ gen_instr(TID_A), move1 },
{ gen_instr(TID_A), iret },
// Multiple reads.
{ gen_data(TID_A, true, 42, 8), nullptr },
{ gen_data(TID_A, true, 42, 8), nullptr },
{ gen_data(TID_A, true, 42, 8), nullptr },
{ gen_data(TID_A, true, 42, 8), nullptr },
{ gen_instr(TID_A), sti },
{ gen_instr(TID_A), nop1 },
// Missing nop2. Acceptable because of the recent sti.
{ gen_instr(TID_A), xrstors },
// Multiple reads.
{ gen_data(TID_A, true, 42, 8), nullptr },
{ gen_data(TID_A, true, 42, 8), nullptr },
{ gen_data(TID_A, true, 42, 8), nullptr },
{ gen_data(TID_A, true, 42, 8), nullptr },
{ gen_instr(TID_A), xsaves },
// Multiple writes.
{ gen_data(TID_A, false, 42, 8), nullptr },
{ gen_data(TID_A, false, 42, 8), nullptr },
{ gen_data(TID_A, false, 42, 8), nullptr },
{ gen_data(TID_A, false, 42, 8), nullptr },
{ gen_instr(TID_A), hlt },
// Missing nop3.
{ gen_instr(TID_A), prefetch },
// Missing reads.
{ gen_instr(TID_A), sysret },
{ gen_marker(TID_A, TRACE_MARKER_TYPE_SYSCALL_TRACE_END, 42), nullptr },
// Continues after sys1.
{ gen_instr(TID_A), nop5 },
{ gen_instr(TID_A), sys2 },
{ gen_marker(TID_A, TRACE_MARKER_TYPE_SYSCALL, 41), nullptr },
{ gen_marker(TID_A, TRACE_MARKER_TYPE_SYSCALL_TRACE_START, 41), nullptr },
{ gen_instr(TID_A), move1 },
{ gen_marker(TID_A, TRACE_MARKER_TYPE_SYSCALL_TRACE_END, 41), nullptr },
// Continues after sys2.
{ gen_instr(TID_A), nop6 },
{ gen_exit(TID_A), nullptr }
};
static constexpr addr_t BASE_ADDR = 0xeba4ad4;
auto memrefs = add_encodings_to_memrefs(ilist, memref_instr_vec, BASE_ADDR);
if (!run_checker(memrefs, false))
res = false;

memref_instr_vec = {
{ gen_marker(TID_A, TRACE_MARKER_TYPE_FILETYPE,
OFFLINE_FILE_TYPE_ENCODINGS | OFFLINE_FILE_TYPE_SYSCALL_NUMBERS |
OFFLINE_FILE_TYPE_KERNEL_SYSCALLS),
nullptr },
{ gen_marker(TID_A, TRACE_MARKER_TYPE_CACHE_LINE_SIZE, 64), nullptr },
{ gen_marker(TID_A, TRACE_MARKER_TYPE_PAGE_SIZE, 4096), nullptr },
{ gen_instr(TID_A), sys1 },
{ gen_marker(TID_A, TRACE_MARKER_TYPE_SYSCALL, 42), nullptr },
{ gen_marker(TID_A, TRACE_MARKER_TYPE_SYSCALL_TRACE_START, 42), nullptr },
{ gen_instr(TID_A), move1 },
{ gen_marker(TID_A, TRACE_MARKER_TYPE_SYSCALL_TRACE_END, 42), nullptr },
// Missing instrs.
{ gen_instr(TID_A), nop6 },
{ gen_exit(TID_A), nullptr }
};
memrefs = add_encodings_to_memrefs(ilist, memref_instr_vec, BASE_ADDR);
if (!run_checker(memrefs, true,
{ "Non-explicit control flow has no marker",
/*tid=*/TID_A,
/*ref_ordinal=*/9, /*last_timestamp=*/0,
/*instrs_since_last_timestamp=*/3 },
"Failed to catch discontinuity on return from syscall"))
res = false;

memref_instr_vec = {
{ gen_marker(TID_A, TRACE_MARKER_TYPE_FILETYPE,
OFFLINE_FILE_TYPE_ENCODINGS | OFFLINE_FILE_TYPE_SYSCALL_NUMBERS |
OFFLINE_FILE_TYPE_KERNEL_SYSCALLS),
Expand All @@ -3305,14 +3307,16 @@ check_kernel_syscall_trace(void)
{ gen_instr(TID_A), nop5 },
{ gen_exit(TID_A), nullptr }
};
memrefs = add_encodings_to_memrefs(ilist, memref_instr_vec, BASE_ADDR);
if (!run_checker(memrefs, true,
{ "Non-explicit control flow has no marker",
/*tid=*/TID_A,
/*ref_ordinal=*/8, /*last_timestamp=*/0,
/*instrs_since_last_timestamp=*/3 },
"Failed to catch discontinuity inside syscall trace"))
res = false;
{
auto memrefs = add_encodings_to_memrefs(ilist2, memref_instr_vec, BASE_ADDR);
if (!run_checker(memrefs, true,
{ "Non-explicit control flow has no marker",
/*tid=*/TID_A,
/*ref_ordinal=*/8, /*last_timestamp=*/0,
/*instrs_since_last_timestamp=*/3 },
"Failed to catch discontinuity inside syscall trace"))
res = false;
}
}
# endif
return res;
Expand Down

0 comments on commit ddacd60

Please sign in to comment.