summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSteve Reinhardt <steve.reinhardt@amd.com>2014-09-02 16:07:50 -0500
committerSteve Reinhardt <steve.reinhardt@amd.com>2014-09-02 16:07:50 -0500
commit6ab4eddb9f5fbd30db0dccbef4a60c46b7053de3 (patch)
tree475fdf0cb41ce8b1ec463509fa6527e6c4046932 /src
parent9ac7f14fc021075af458404096e76225b1ea59df (diff)
downloadgem5-6ab4eddb9f5fbd30db0dccbef4a60c46b7053de3.tar.xz
syscall_emul: add retry flag to SyscallReturn
This hook allows blocking emulated system calls to indicate that they would block, but return control to the simulator so that the simulation does not hang. The actual retry functionality requires additional support, to be provided in a future changeset.
Diffstat (limited to 'src')
-rw-r--r--src/sim/syscall_emul.cc11
-rw-r--r--src/sim/syscallreturn.hh15
2 files changed, 22 insertions, 4 deletions
diff --git a/src/sim/syscall_emul.cc b/src/sim/syscall_emul.cc
index d8df891dd..cb592e338 100644
--- a/src/sim/syscall_emul.cc
+++ b/src/sim/syscall_emul.cc
@@ -71,10 +71,15 @@ SyscallDesc::doSyscall(int callnum, LiveProcess *process, ThreadContext *tc)
SyscallReturn retval = (*funcPtr)(this, callnum, process, tc);
- DPRINTFR(SyscallVerbose, "%d: %s: syscall %s returns %d\n",
- curTick(), tc->getCpuPtr()->name(), name, retval.encodedValue());
+ if (retval.needsRetry()) {
+ DPRINTFS(SyscallVerbose, tc->getCpuPtr(), "syscall %s needs retry\n",
+ name);
+ } else {
+ DPRINTFS(SyscallVerbose, tc->getCpuPtr(), "syscall %s returns %d\n",
+ name, retval.encodedValue());
+ }
- if (!(flags & SyscallDesc::SuppressReturnValue))
+ if (!(flags & SyscallDesc::SuppressReturnValue) && !retval.needsRetry())
process->setSyscallReturn(tc, retval);
}
diff --git a/src/sim/syscallreturn.hh b/src/sim/syscallreturn.hh
index 547d76610..fdd740775 100644
--- a/src/sim/syscallreturn.hh
+++ b/src/sim/syscallreturn.hh
@@ -64,9 +64,17 @@ class SyscallReturn
/// value is expected, e.g., as the return value from a system
/// call emulation function ('return 0;' or 'return -EFAULT;').
SyscallReturn(int64_t v)
- : value(v)
+ : value(v), retryFlag(false)
{}
+ /// Pseudo-constructor to create an instance with the retry flag set.
+ static SyscallReturn retry()
+ {
+ SyscallReturn s(0);
+ s.retryFlag = true;
+ return s;
+ }
+
~SyscallReturn() {}
/// Was the system call successful?
@@ -75,6 +83,9 @@ class SyscallReturn
return (value >= 0 || value <= -4096);
}
+ /// Does the syscall need to be retried?
+ bool needsRetry() const { return retryFlag; }
+
/// The return value
int64_t returnValue() const
{
@@ -98,6 +109,8 @@ class SyscallReturn
private:
int64_t value;
+
+ bool retryFlag;
};
#endif