changeset 3f805b5c48ae in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=3f805b5c48ae
description:
        kvm: Add an option to force context sync on kvm entry/exit

        This changeset adds an option to force the kvm-based CPUs to always
        synchronize the gem5 thread context representation on entry/exit into
        the kernel. This is very useful for debugging. Unfortunately, it is
        also the only way to get reliable register contents when using remote
        gdb functionality. The long-term solution for the latter would be to
        implement a kvm-specific thread context.

        Signed-off-by: Andreas Sandberg <[email protected]>
        Reviewed-by: Curtis Dunham <[email protected]>
        Reviewed-by: Alexandru Dutu <[email protected]>

diffstat:

 src/cpu/kvm/BaseKvmCPU.py |  2 ++
 src/cpu/kvm/base.cc       |  7 +++++++
 src/cpu/kvm/base.hh       |  6 ++++++
 3 files changed, 15 insertions(+), 0 deletions(-)

diffs (59 lines):

diff -r 5f487c387e2e -r 3f805b5c48ae src/cpu/kvm/BaseKvmCPU.py
--- a/src/cpu/kvm/BaseKvmCPU.py Tue Mar 29 16:36:42 2016 +0100
+++ b/src/cpu/kvm/BaseKvmCPU.py Wed Mar 30 10:52:25 2016 +0100
@@ -71,6 +71,8 @@
     kvmVM = Param.KvmVM(Parent.any, 'KVM VM (i.e., shared memory domain)')
     useCoalescedMMIO = Param.Bool(False, "Use coalesced MMIO (EXPERIMENTAL)")
     usePerfOverflow = Param.Bool(False, "Use perf event overflow counters 
(EXPERIMENTAL)")
+    alwaysSyncTC = Param.Bool(False,
+                              "Always sync thread contexts on entry/exit")
 
     hostFreq = Param.Clock("2GHz", "Host clock frequency")
     hostFactor = Param.Float(1.0, "Cycle scale factor")
diff -r 5f487c387e2e -r 3f805b5c48ae src/cpu/kvm/base.cc
--- a/src/cpu/kvm/base.cc       Tue Mar 29 16:36:42 2016 +0100
+++ b/src/cpu/kvm/base.cc       Wed Mar 30 10:52:25 2016 +0100
@@ -69,6 +69,7 @@
       _status(Idle),
       dataPort(name() + ".dcache_port", this),
       instPort(name() + ".icache_port", this),
+      alwaysSyncTC(params->alwaysSyncTC),
       threadContextDirty(true),
       kvmStateDirty(false),
       vcpuID(vm.allocVCPUID()), vcpuFD(-1), vcpuMMapSize(0),
@@ -557,6 +558,9 @@
               nextInstEvent > ctrInsts ?
               curEventQueue()->nextTick() - curTick() : 0);
 
+          if (alwaysSyncTC)
+              threadContextDirty = true;
+
           // We might need to update the KVM state.
           syncKvmState();
 
@@ -588,6 +592,9 @@
           // dirty with respect to the cached thread context.
           kvmStateDirty = true;
 
+          if (alwaysSyncTC)
+              syncThreadContext();
+
           // Enter into the RunningService state unless the
           // simulation was stopped by a timer.
           if (_kvmRun->exit_reason !=  KVM_EXIT_INTR) {
diff -r 5f487c387e2e -r 3f805b5c48ae src/cpu/kvm/base.hh
--- a/src/cpu/kvm/base.hh       Tue Mar 29 16:36:42 2016 +0100
+++ b/src/cpu/kvm/base.hh       Wed Mar 30 10:52:25 2016 +0100
@@ -575,6 +575,12 @@
     KVMCpuPort instPort;
 
     /**
+     * Be conservative and always synchronize the thread context on
+     * KVM entry/exit.
+     */
+    const bool alwaysSyncTC;
+
+    /**
      * Is the gem5 context dirty? Set to true to force an update of
      * the KVM vCPU state upon the next call to kvmRun().
      */
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to