summaryrefslogtreecommitdiff
path: root/src/cpu
diff options
context:
space:
mode:
Diffstat (limited to 'src/cpu')
-rw-r--r--src/cpu/kvm/base.hh1
-rw-r--r--src/cpu/kvm/vm.cc12
-rw-r--r--src/cpu/kvm/vm.hh6
3 files changed, 18 insertions, 1 deletions
diff --git a/src/cpu/kvm/base.hh b/src/cpu/kvm/base.hh
index ef500974f..6f30c55e4 100644
--- a/src/cpu/kvm/base.hh
+++ b/src/cpu/kvm/base.hh
@@ -106,6 +106,7 @@ class BaseKvmCPU : public BaseCPU
void deallocateContext(ThreadID thread_num);
void haltContext(ThreadID thread_num) override;
+ long getVCpuID() const { return vcpuID; }
ThreadContext *getContext(int tn) override;
Counter totalInsts() const override;
diff --git a/src/cpu/kvm/vm.cc b/src/cpu/kvm/vm.cc
index 604d182ab..47e749247 100644
--- a/src/cpu/kvm/vm.cc
+++ b/src/cpu/kvm/vm.cc
@@ -50,6 +50,7 @@
#include <cerrno>
#include <memory>
+#include "cpu/kvm/base.hh"
#include "debug/Kvm.hh"
#include "params/KvmVM.hh"
#include "sim/system.hh"
@@ -528,12 +529,21 @@ KvmVM::createDevice(uint32_t type, uint32_t flags)
}
void
-KvmVM::setSystem(System *s) {
+KvmVM::setSystem(System *s)
+{
panic_if(system != nullptr, "setSystem() can only be called once");
panic_if(s == nullptr, "setSystem() called with null System*");
system = s;
}
+long
+KvmVM::contextIdToVCpuId(ContextID ctx) const
+{
+ assert(system != nullptr);
+ return dynamic_cast<BaseKvmCPU*>
+ (system->getThreadContext(ctx)->getCpuPtr())->getVCpuID();
+}
+
int
KvmVM::createVCPU(long vcpuID)
{
diff --git a/src/cpu/kvm/vm.hh b/src/cpu/kvm/vm.hh
index dbd46aa3c..df2e4119a 100644
--- a/src/cpu/kvm/vm.hh
+++ b/src/cpu/kvm/vm.hh
@@ -48,6 +48,7 @@
// forward declarations
struct KvmVMParams;
+class BaseKvmCPU;
class System;
/**
@@ -405,6 +406,11 @@ class KvmVM : public SimObject
*/
void setSystem(System *s);
+ /**
+ * Get the VCPUID for a given context
+ */
+ long contextIdToVCpuId(ContextID ctx) const;
+
#if defined(__aarch64__)
public: // ARM-specific
/**