sim: Add a new gem5 op for workload events.

This is a way to send a very generic poke to the workload so it can do
something. It's up to the workload to know what information to look for
to interpret an event, such as what PC it came from, what register
values are, or the context of the workload itself (is this SE mode? which
OS is running?).

Change-Id: Ifa4bdf3b5c5a934338c50600747d0b65f4b5eb2b
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/34162
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Gabe Black
2020-10-20 17:37:17 -07:00
parent 5a2a72bff4
commit 9fff55c93c
6 changed files with 33 additions and 1 deletions

View File

@@ -80,6 +80,8 @@
#define M5OP_SE_PAGE_FAULT 0x61
#define M5OP_DIST_TOGGLE_SYNC 0x62
#define M5OP_WORKLOAD 0x70
#define M5OP_FOREACH \
M5OP(m5_arm, M5OP_ARM) \
@@ -108,7 +110,8 @@
M5OP(m5_work_end, M5OP_WORK_END) \
M5OP(m5_se_syscall, M5OP_SE_SYSCALL) \
M5OP(m5_se_page_fault, M5OP_SE_PAGE_FAULT) \
M5OP(m5_dist_toggle_sync, M5OP_DIST_TOGGLE_SYNC)
M5OP(m5_dist_toggle_sync, M5OP_DIST_TOGGLE_SYNC) \
M5OP(m5_workload, M5OP_WORKLOAD) \
#define M5OP_MERGE_TOKENS_I(a, b) a##b
#define M5OP_MERGE_TOKENS(a, b) M5OP_MERGE_TOKENS_I(a, b)

View File

@@ -68,6 +68,14 @@ void m5_work_end(uint64_t workid, uint64_t threadid);
void m5_se_syscall();
void m5_se_page_fault();
/*
* Send a very generic poke to the workload so it can do something. It's up to
* the workload to know what information to look for to interpret an event,
* such as what PC it came from, what register values are, or the context of
* the workload itself (is this SE mode? which OS is running?).
*/
void m5_workload();
#ifdef __cplusplus
}
#endif

View File

@@ -489,6 +489,13 @@ togglesync(ThreadContext *tc)
DistIface::toggleSync(tc);
}
void
triggerWorkloadEvent(ThreadContext *tc)
{
DPRINTF(PseudoInst, "PseudoInst::triggerWorkloadEvent()\n");
tc->getSystemPtr()->workload->event(tc);
}
//
// This function is executed when annotated work items begin. Depending on
// what the user specified at the command line, the simulation may exit and/or

View File

@@ -113,6 +113,7 @@ void workbegin(ThreadContext *tc, uint64_t workid, uint64_t threadid);
void workend(ThreadContext *tc, uint64_t workid, uint64_t threadid);
void m5Syscall(ThreadContext *tc);
void togglesync(ThreadContext *tc);
void triggerWorkloadEvent(ThreadContext *tc);
/**
* Execute a decoded M5 pseudo instruction
@@ -254,6 +255,10 @@ pseudoInstWork(ThreadContext *tc, uint8_t func, uint64_t &result)
invokeSimcall<ABI>(tc, togglesync);
return true;
case M5OP_WORKLOAD:
invokeSimcall<ABI>(tc, triggerWorkloadEvent);
return true;
default:
warn("Unhandled m5 op: %#x\n", func);
return false;

View File

@@ -78,6 +78,9 @@ class SEWorkload : public Workload
}
void syscall(ThreadContext *tc) override;
// For now, assume the only type of events are system calls.
void event(ThreadContext *tc) override { syscall(tc); }
};
#endif // __SIM_SE_WORKLOAD_HH__

View File

@@ -75,6 +75,12 @@ class Workload : public SimObject
panic("syscall() not implemented.");
}
virtual void
event(ThreadContext *tc)
{
warn("Unhandled workload event.");
}
/** @{ */
/**
* Add a function-based event to the given function, to be looked