summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCurtis Dunham <Curtis.Dunham@arm.com>2017-02-14 15:09:18 -0600
committerCurtis Dunham <Curtis.Dunham@arm.com>2017-02-14 15:09:18 -0600
commit41beacce088e8f682a0e8ac48f22a3fa4805a43b (patch)
tree3cd96b36acb9b38a2010eeae07f193a9d2292c73 /src
parentd3bfc03688e164c02e9c25730ada11b669c01eda (diff)
downloadgem5-41beacce088e8f682a0e8ac48f22a3fa4805a43b.tar.xz
sim, kvm: make KvmVM a System parameter
A KVM VM is typically a child of the System object already, but for solving future issues with configuration graph resolution, the most logical way to keep track of this object is for it to be an actual parameter of the System object. Change-Id: I965ded22203ff8667db9ca02de0042ff1c772220 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Diffstat (limited to 'src')
-rw-r--r--src/arch/arm/kvm/KvmGic.py1
-rw-r--r--src/arch/arm/kvm/gic.cc3
-rw-r--r--src/cpu/kvm/BaseKvmCPU.py1
-rw-r--r--src/cpu/kvm/KvmVM.py5
-rw-r--r--src/cpu/kvm/base.cc2
-rw-r--r--src/cpu/kvm/vm.cc10
-rw-r--r--src/cpu/kvm/vm.hh5
-rw-r--r--src/sim/System.py4
-rw-r--r--src/sim/system.cc15
-rw-r--r--src/sim/system.hh11
10 files changed, 49 insertions, 8 deletions
diff --git a/src/arch/arm/kvm/KvmGic.py b/src/arch/arm/kvm/KvmGic.py
index 74bfe1e0b..9ae52db22 100644
--- a/src/arch/arm/kvm/KvmGic.py
+++ b/src/arch/arm/kvm/KvmGic.py
@@ -52,4 +52,3 @@ class KvmGic(BaseGic):
system = Param.System(Parent.any,
'System this interrupt controller belongs to')
- kvmVM = Param.KvmVM(Parent.any, 'KVM VM (i.e., shared memory domain)')
diff --git a/src/arch/arm/kvm/gic.cc b/src/arch/arm/kvm/gic.cc
index 684f026f0..c5a30879c 100644
--- a/src/arch/arm/kvm/gic.cc
+++ b/src/arch/arm/kvm/gic.cc
@@ -106,7 +106,8 @@ KvmKernelGicV2::setIntState(unsigned type, unsigned vcpu, unsigned irq,
KvmGic::KvmGic(const KvmGicParams *p)
: BaseGic(p),
system(*p->system),
- kernelGic(*p->kvmVM, p->cpu_addr, p->dist_addr, p->it_lines),
+ kernelGic(*system.getKvmVM(),
+ p->cpu_addr, p->dist_addr, p->it_lines),
addrRanges{kernelGic.distRange, kernelGic.cpuRange}
{
}
diff --git a/src/cpu/kvm/BaseKvmCPU.py b/src/cpu/kvm/BaseKvmCPU.py
index 4c64f24ed..cc0b28fe9 100644
--- a/src/cpu/kvm/BaseKvmCPU.py
+++ b/src/cpu/kvm/BaseKvmCPU.py
@@ -64,7 +64,6 @@ class BaseKvmCPU(BaseCPU):
def support_take_over(cls):
return True
- 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,
diff --git a/src/cpu/kvm/KvmVM.py b/src/cpu/kvm/KvmVM.py
index 478a91682..cbc92ca0d 100644
--- a/src/cpu/kvm/KvmVM.py
+++ b/src/cpu/kvm/KvmVM.py
@@ -44,6 +44,5 @@ class KvmVM(SimObject):
type = 'KvmVM'
cxx_header = "cpu/kvm/vm.hh"
- system = Param.System(Parent.any, "system object")
-
- coalescedMMIO = VectorParam.AddrRange([], "memory ranges for coalesced MMIO")
+ coalescedMMIO = \
+ VectorParam.AddrRange([], "memory ranges for coalesced MMIO")
diff --git a/src/cpu/kvm/base.cc b/src/cpu/kvm/base.cc
index 723feda44..6ae3c7dff 100644
--- a/src/cpu/kvm/base.cc
+++ b/src/cpu/kvm/base.cc
@@ -64,7 +64,7 @@
BaseKvmCPU::BaseKvmCPU(BaseKvmCPUParams *params)
: BaseCPU(params),
- vm(*params->kvmVM),
+ vm(*params->system->getKvmVM()),
_status(Idle),
dataPort(name() + ".dcache_port", this),
instPort(name() + ".icache_port", this),
diff --git a/src/cpu/kvm/vm.cc b/src/cpu/kvm/vm.cc
index d3ab8c45a..604d182ab 100644
--- a/src/cpu/kvm/vm.cc
+++ b/src/cpu/kvm/vm.cc
@@ -292,7 +292,7 @@ Kvm::createVM()
KvmVM::KvmVM(KvmVMParams *params)
: SimObject(params),
- kvm(new Kvm()), system(params->system),
+ kvm(new Kvm()), system(nullptr),
vmFD(kvm->createVM()),
started(false),
nextVCPUID(0)
@@ -342,6 +342,7 @@ KvmVM::cpuStartup()
void
KvmVM::delayedStartup()
{
+ assert(system); // set by the system during its construction
const std::vector<BackingStoreEntry> &memories(
system->getPhysMem().getBackingStore());
@@ -526,6 +527,13 @@ KvmVM::createDevice(uint32_t type, uint32_t flags)
#endif
}
+void
+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;
+}
+
int
KvmVM::createVCPU(long vcpuID)
{
diff --git a/src/cpu/kvm/vm.hh b/src/cpu/kvm/vm.hh
index 560efb606..dbd46aa3c 100644
--- a/src/cpu/kvm/vm.hh
+++ b/src/cpu/kvm/vm.hh
@@ -400,6 +400,11 @@ class KvmVM : public SimObject
/** Global KVM interface */
Kvm *kvm;
+ /**
+ * Initialize system pointer. Invoked by system object.
+ */
+ void setSystem(System *s);
+
#if defined(__aarch64__)
public: // ARM-specific
/**
diff --git a/src/sim/System.py b/src/sim/System.py
index 34b1fd127..e3e42d862 100644
--- a/src/sim/System.py
+++ b/src/sim/System.py
@@ -29,6 +29,7 @@
# Rick Strong
from m5.SimObject import SimObject
+from m5.defines import buildEnv
from m5.params import *
from m5.proxy import *
@@ -106,3 +107,6 @@ class System(MemObject):
# Dynamic voltage and frequency handler for the system, disabled by default
# Provide list of domains that need to be controlled by the handler
dvfs_handler = DVFSHandler()
+
+ if buildEnv['USE_KVM']:
+ kvm_vm = Param.KvmVM(NULL, 'KVM VM (i.e., shared memory domain)')
diff --git a/src/sim/system.cc b/src/sim/system.cc
index 09be232a7..9315882b7 100644
--- a/src/sim/system.cc
+++ b/src/sim/system.cc
@@ -53,6 +53,10 @@
#include "base/loader/symtab.hh"
#include "base/str.hh"
#include "base/trace.hh"
+#include "config/use_kvm.hh"
+#if USE_KVM
+#include "cpu/kvm/vm.hh"
+#endif
#include "cpu/thread_context.hh"
#include "debug/Loader.hh"
#include "debug/WorkItems.hh"
@@ -90,6 +94,11 @@ System::System(Params *p)
kernel(nullptr),
loadAddrMask(p->load_addr_mask),
loadAddrOffset(p->load_offset),
+#if USE_KVM
+ kvmVM(p->kvm_vm),
+#else
+ kvmVM(nullptr),
+#endif
physmem(name() + ".physmem", p->memories, p->mmap_using_noreserve),
memoryMode(p->mem_mode),
_cacheLineSize(p->cache_line_size),
@@ -104,6 +113,12 @@ System::System(Params *p)
// add self to global system list
systemList.push_back(this);
+#if USE_KVM
+ if (kvmVM) {
+ kvmVM->setSystem(this);
+ }
+#endif
+
if (FullSystem) {
kernelSymtab = new SymbolTable;
if (!debugSymbolTable)
diff --git a/src/sim/system.hh b/src/sim/system.hh
index 1bbd37d9d..c3667fe09 100644
--- a/src/sim/system.hh
+++ b/src/sim/system.hh
@@ -72,6 +72,7 @@
class BaseRemoteGDB;
class GDBListener;
+class KvmVM;
class ObjectFile;
class ThreadContext;
@@ -249,6 +250,14 @@ class System : public MemObject
Addr loadAddrOffset;
public:
+ /**
+ * Get a pointer to the Kernel Virtual Machine (KVM) SimObject,
+ * if present.
+ */
+ KvmVM* getKvmVM() {
+ return kvmVM;
+ }
+
/** Get a pointer to access the physical memory of the system */
PhysicalMemory& getPhysMem() { return physmem; }
@@ -289,6 +298,8 @@ class System : public MemObject
protected:
+ KvmVM *const kvmVM;
+
PhysicalMemory physmem;
Enums::MemoryMode memoryMode;