summaryrefslogtreecommitdiff
path: root/src/cpu
diff options
context:
space:
mode:
authorBrandon Potter <brandon.potter@amd.com>2017-02-27 14:10:15 -0500
committerBrandon Potter <brandon.potter@amd.com>2017-02-27 14:10:15 -0500
commit2367198921765848a4f5b3d020a7cc5776209f80 (patch)
tree00cff9357d9e5f2bec277cf937e8a73944ce1c98 /src/cpu
parent073cb266079edddec64ea8cd5169dd2cbef8f812 (diff)
downloadgem5-2367198921765848a4f5b3d020a7cc5776209f80.tar.xz
syscall_emul: [PATCH 15/22] add clone/execve for threading and multiprocess simulations
Modifies the clone system call and adds execve system call. Requires allowing processes to steal thread contexts from other processes in the same system object and the ability to detach pieces of process state (such as MemState) to allow dynamic sharing.
Diffstat (limited to 'src/cpu')
-rw-r--r--src/cpu/checker/thread_context.hh8
-rwxr-xr-xsrc/cpu/o3/thread_context.hh2
-rw-r--r--src/cpu/simple_thread.hh6
-rw-r--r--src/cpu/thread_context.hh12
-rw-r--r--src/cpu/thread_state.hh15
5 files changed, 43 insertions, 0 deletions
diff --git a/src/cpu/checker/thread_context.hh b/src/cpu/checker/thread_context.hh
index 0313d079b..7b09dde90 100644
--- a/src/cpu/checker/thread_context.hh
+++ b/src/cpu/checker/thread_context.hh
@@ -130,6 +130,8 @@ class CheckerThreadContext : public ThreadContext
Process *getProcessPtr() { return actualTC->getProcessPtr(); }
+ void setProcessPtr(Process *p) { actualTC->setProcessPtr(p); }
+
PortProxy &getPhysProxy() { return actualTC->getPhysProxy(); }
FSTranslatingPortProxy &getVirtProxy()
@@ -254,6 +256,12 @@ class CheckerThreadContext : public ThreadContext
return actualTC->pcState(val);
}
+ void setNPC(Addr val)
+ {
+ checkerTC->setNPC(val);
+ actualTC->setNPC(val);
+ }
+
void pcStateNoRecord(const TheISA::PCState &val)
{
return actualTC->pcState(val);
diff --git a/src/cpu/o3/thread_context.hh b/src/cpu/o3/thread_context.hh
index 0321f57f7..78b88ac2a 100755
--- a/src/cpu/o3/thread_context.hh
+++ b/src/cpu/o3/thread_context.hh
@@ -119,6 +119,8 @@ class O3ThreadContext : public ThreadContext
/** Returns a pointer to this thread's process. */
virtual Process *getProcessPtr() { return thread->getProcessPtr(); }
+ virtual void setProcessPtr(Process *p) { thread->setProcessPtr(p); }
+
virtual PortProxy &getPhysProxy() { return thread->getPhysProxy(); }
virtual FSTranslatingPortProxy &getVirtProxy();
diff --git a/src/cpu/simple_thread.hh b/src/cpu/simple_thread.hh
index 9ef00ab3f..bdf93b0e4 100644
--- a/src/cpu/simple_thread.hh
+++ b/src/cpu/simple_thread.hh
@@ -355,6 +355,12 @@ class SimpleThread : public ThreadState
return _pcState.nextInstAddr();
}
+ void
+ setNPC(Addr val)
+ {
+ _pcState.setNPC(val);
+ }
+
MicroPC
microPC()
{
diff --git a/src/cpu/thread_context.hh b/src/cpu/thread_context.hh
index ecbd1a41e..bb6b54c08 100644
--- a/src/cpu/thread_context.hh
+++ b/src/cpu/thread_context.hh
@@ -161,6 +161,8 @@ class ThreadContext
virtual Process *getProcessPtr() = 0;
+ virtual void setProcessPtr(Process *p) = 0;
+
virtual Status status() const = 0;
virtual void setStatus(Status new_status) = 0;
@@ -223,6 +225,14 @@ class ThreadContext
virtual void pcState(const TheISA::PCState &val) = 0;
+ void
+ setNPC(Addr val)
+ {
+ TheISA::PCState pc_state = pcState();
+ pc_state.setNPC(val);
+ pcState(pc_state);
+ }
+
virtual void pcStateNoRecord(const TheISA::PCState &val) = 0;
virtual Addr instAddr() = 0;
@@ -360,6 +370,8 @@ class ProxyThreadContext : public ThreadContext
Process *getProcessPtr() { return actualTC->getProcessPtr(); }
+ void setProcessPtr(Process *p) { actualTC->setProcessPtr(p); }
+
Status status() const { return actualTC->status(); }
void setStatus(Status new_status) { actualTC->setStatus(new_status); }
diff --git a/src/cpu/thread_state.hh b/src/cpu/thread_state.hh
index 3a35d444a..5cbc3322b 100644
--- a/src/cpu/thread_state.hh
+++ b/src/cpu/thread_state.hh
@@ -107,6 +107,21 @@ struct ThreadState : public Serializable {
Process *getProcessPtr() { return process; }
+ void setProcessPtr(Process *p)
+ {
+ process = p;
+ /**
+ * When the process pointer changes while operating in SE Mode,
+ * the se translating port proxy needs to be reinitialized since it
+ * holds a pointer to the process class.
+ */
+ if (proxy) {
+ delete proxy;
+ proxy = NULL;
+ initMemProxies(NULL);
+ }
+ }
+
SETranslatingPortProxy &getMemProxy();
/** Reads the number of instructions functionally executed and