summaryrefslogtreecommitdiff
path: root/src/cpu/kvm/base.hh
diff options
context:
space:
mode:
authorAndreas Sandberg <andreas@sandberg.pp.se>2014-03-16 17:40:58 +0100
committerAndreas Sandberg <andreas@sandberg.pp.se>2014-03-16 17:40:58 +0100
commit11ffa379ab6c9b8a477e45a3ac390f7d60ef6b19 (patch)
tree6308ab1cc8b328f9b6c6f3c7906aadd3a72ba6ed /src/cpu/kvm/base.hh
parent5db547bca46f23aa5cf25aa5d38efae9ef1eabc2 (diff)
downloadgem5-11ffa379ab6c9b8a477e45a3ac390f7d60ef6b19.tar.xz
kvm: Clean up signal handling
KVM used to use two signals, one for instruction count exits and one for timer exits. There is really no need to distinguish between the two since they only trigger exits from KVM. This changeset unifies and renames the signals and adds a method, kick(), that can be used to raise the control signal in the vCPU thread. It also removes the early timer warning since we do not normally see if the signal was delivered. --HG-- extra : rebase_source : cd0e45ca90894c3d6f6aa115b9b06a1d8f0fda4d
Diffstat (limited to 'src/cpu/kvm/base.hh')
-rw-r--r--src/cpu/kvm/base.hh22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/cpu/kvm/base.hh b/src/cpu/kvm/base.hh
index 8191d9d92..b987f6a3e 100644
--- a/src/cpu/kvm/base.hh
+++ b/src/cpu/kvm/base.hh
@@ -40,8 +40,10 @@
#ifndef __CPU_KVM_BASE_HH__
#define __CPU_KVM_BASE_HH__
-#include <memory>
+#include <pthread.h>
+
#include <csignal>
+#include <memory>
#include "base/statistics.hh"
#include "cpu/kvm/perfevent.hh"
@@ -50,11 +52,8 @@
#include "cpu/base.hh"
#include "cpu/simple_thread.hh"
-/** Signal to use to trigger time-based exits from KVM */
-#define KVM_TIMER_SIGNAL SIGRTMIN
-
-/** Signal to use to trigger instruction-based exits from KVM */
-#define KVM_INST_SIGNAL (SIGRTMIN+1)
+/** Signal to use to trigger exits from KVM */
+#define KVM_KICK_SIGNAL SIGRTMIN
// forward declarations
class ThreadContext;
@@ -115,6 +114,14 @@ class BaseKvmCPU : public BaseCPU
virtual void dump();
/**
+ * Force an exit from KVM.
+ *
+ * Send a signal to the thread owning this vCPU to get it to exit
+ * from KVM. Ignored if the vCPU is not executing.
+ */
+ void kick() const { pthread_kill(vcpuThread, KVM_KICK_SIGNAL); }
+
+ /**
* A cached copy of a thread's state in the form of a SimpleThread
* object.
*
@@ -585,6 +592,9 @@ class BaseKvmCPU : public BaseCPU
/** KVM internal ID of the vCPU */
const long vcpuID;
+ /** ID of the vCPU thread */
+ pthread_t vcpuThread;
+
private:
struct TickEvent : public Event
{