From 11ffa379ab6c9b8a477e45a3ac390f7d60ef6b19 Mon Sep 17 00:00:00 2001 From: Andreas Sandberg Date: Sun, 16 Mar 2014 17:40:58 +0100 Subject: 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 --- src/cpu/kvm/base.hh | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'src/cpu/kvm/base.hh') 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 +#include + #include +#include #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; @@ -114,6 +113,14 @@ class BaseKvmCPU : public BaseCPU /** Dump the internal state to the terminal. */ 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 { -- cgit v1.2.3