Skip to content

Commit

Permalink
i#7111 cache opcodes: Add CLFLUSHOPT handling to drmemtrace
Browse files Browse the repository at this point in the history
Adds handling to drmemtrace for the x86 CLFLUSHOPT opcode to treat it
just like CLFLUSH; the two are similar enough for most uses.

Augments the existing CLFLUSH invariant_checker test as a sanity test
of the new opcode handling.

Issue: #7111
  • Loading branch information
derekbruening committed Dec 10, 2024
1 parent e24dbb0 commit 011a69d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 6 additions & 0 deletions clients/drcachesim/tests/invariant_checker_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2825,15 +2825,21 @@ check_read_write_records_match_operands()
{
instr_t *clflush = INSTR_CREATE_clflush(
GLOBAL_DCONTEXT, OPND_CREATE_MEM_clflush(REG1, REG_NULL, 0, 0));
instr_t *clflushopt = INSTR_CREATE_clflushopt(
GLOBAL_DCONTEXT, OPND_CREATE_MEM_clflush(REG1, REG_NULL, 0, 0));
instrlist_t *ilist = instrlist_create(GLOBAL_DCONTEXT);
instrlist_append(ilist, clflush);
instrlist_append(ilist, clflushopt);
static constexpr addr_t BASE_ADDR = 0xeba4ad4;
std::vector<memref_with_IR_t> memref_setup = {
{ gen_marker(TID_A, TRACE_MARKER_TYPE_FILETYPE, OFFLINE_FILE_TYPE_ENCODINGS),
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), clflush },
{ gen_addr(TID_A, /*type=*/TRACE_TYPE_DATA_FLUSH, /*addr=*/0, /*size=*/0),
nullptr },
{ gen_instr(TID_A), clflushopt },
{ gen_addr(TID_A, /*type=*/TRACE_TYPE_DATA_FLUSH, /*addr=*/0, /*size=*/0),
nullptr },
{ gen_exit(TID_A), nullptr },
Expand Down
10 changes: 5 additions & 5 deletions clients/drcachesim/tracer/instru.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* **********************************************************
* Copyright (c) 2016-2023 Google, Inc. All rights reserved.
* Copyright (c) 2016-2024 Google, Inc. All rights reserved.
* **********************************************************/

/*
Expand Down Expand Up @@ -224,7 +224,7 @@ instru_t::instr_is_flush(instr_t *instr)
{
// Assuming we won't see any privileged instructions.
#ifdef X86
if (instr_get_opcode(instr) == OP_clflush)
if (instr_get_opcode(instr) == OP_clflush || instr_get_opcode(instr) == OP_clflushopt)
return true;
#endif
#ifdef AARCH64
Expand All @@ -239,9 +239,9 @@ instru_t::instr_to_flush_type(instr_t *instr)
{
DR_ASSERT(instr_is_flush(instr));
#ifdef X86
// XXX: OP_clflush invalidates all levels of the processor cache
// hierarchy (data and instruction)
if (instr_get_opcode(instr) == OP_clflush)
// XXX: OP_clflush* invalidates all levels of the processor cache
// hierarchy (data and instruction).
if (instr_get_opcode(instr) == OP_clflush || instr_get_opcode(instr) == OP_clflushopt)
return TRACE_TYPE_DATA_FLUSH;
#endif
#ifdef AARCH64
Expand Down

0 comments on commit 011a69d

Please sign in to comment.