Gabe Black has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/56263 )
Change subject: cpu-kvm: Move the validKvmEnvironment method into KvmVM.
......................................................................
cpu-kvm: Move the validKvmEnvironment method into KvmVM.
This makes the generic System class consistent whether you have KVM
enabled or not.
Change-Id: Ie6928961200943d1d4e3bd129a4e4269e9f12950
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/56263
Reviewed-by: Andreas Sandberg <andreas.sandb...@arm.com>
Maintainer: Gabe Black <gabe.bl...@gmail.com>
Tested-by: kokoro <noreply+kok...@google.com>
---
M src/arch/arm/kvm/gic.cc
M src/cpu/kvm/SConsopts
M src/cpu/kvm/vm.cc
M src/cpu/kvm/vm.hh
M src/dev/arm/generic_timer.cc
M src/dev/arm/generic_timer.hh
M src/sim/system.cc
M src/sim/system.hh
8 files changed, 50 insertions(+), 27 deletions(-)
Approvals:
Andreas Sandberg: Looks good to me, approved
Gabe Black: Looks good to me, approved
kokoro: Regressions pass
diff --git a/src/arch/arm/kvm/gic.cc b/src/arch/arm/kvm/gic.cc
index 5ce148e..4cc49cc 100644
--- a/src/arch/arm/kvm/gic.cc
+++ b/src/arch/arm/kvm/gic.cc
@@ -188,7 +188,7 @@
MuxingKvmGic::startup()
{
GicV2::startup();
- usingKvm = (kernelGic != nullptr) && system.validKvmEnvironment();
+ usingKvm = kernelGic && vm && vm->validEnvironment();
if (usingKvm)
fromGicV2ToKvm();
}
@@ -205,7 +205,7 @@
MuxingKvmGic::drainResume()
{
GicV2::drainResume();
- bool use_kvm = (kernelGic != nullptr) && system.validKvmEnvironment();
+ bool use_kvm = kernelGic && vm && vm->validEnvironment();
if (use_kvm != usingKvm) {
// Should only occur due to CPU switches
if (use_kvm) // from simulation to KVM emulation
diff --git a/src/cpu/kvm/SConsopts b/src/cpu/kvm/SConsopts
index 4117736..be413e1 100644
--- a/src/cpu/kvm/SConsopts
+++ b/src/cpu/kvm/SConsopts
@@ -79,3 +79,4 @@
warning("Can not enable KVM, host seems to lack KVM support")
export_vars.append('USE_KVM')
+export_vars.append('KVM_ISA')
diff --git a/src/cpu/kvm/vm.cc b/src/cpu/kvm/vm.cc
index 1347c75..d58439b 100644
--- a/src/cpu/kvm/vm.cc
+++ b/src/cpu/kvm/vm.cc
@@ -542,6 +542,17 @@
#endif
}
+bool
+KvmVM::validEnvironment() const
+{
+ for (auto *tc: system->threads) {
+ if (!dynamic_cast<BaseKvmCPU *>(tc->getCpuPtr()))
+ return false;
+ }
+
+ return true;
+}
+
void
KvmVM::setSystem(System *s)
{
diff --git a/src/cpu/kvm/vm.hh b/src/cpu/kvm/vm.hh
index 2eb1909..083c2b2 100644
--- a/src/cpu/kvm/vm.hh
+++ b/src/cpu/kvm/vm.hh
@@ -416,6 +416,9 @@
/** Global KVM interface */
Kvm *kvm;
+ /** Verify gem5 configuration will support KVM emulation */
+ bool validEnvironment() const;
+
/**
* Initialize system pointer. Invoked by system object.
*/
diff --git a/src/dev/arm/generic_timer.cc b/src/dev/arm/generic_timer.cc
index 20aaf82..8377b94 100644
--- a/src/dev/arm/generic_timer.cc
+++ b/src/dev/arm/generic_timer.cc
@@ -38,13 +38,17 @@
#include "dev/arm/generic_timer.hh"
#include <cmath>
+#include <string_view>
#include "arch/arm/page_size.hh"
#include "arch/arm/system.hh"
#include "arch/arm/utility.hh"
#include "base/logging.hh"
#include "base/trace.hh"
+#include "config/kvm_isa.hh"
+#include "config/use_kvm.hh"
#include "cpu/base.hh"
+#include "cpu/kvm/vm.hh"
#include "debug/Timer.hh"
#include "dev/arm/base_gic.hh"
#include "mem/packet_access.hh"
@@ -403,6 +407,18 @@
updateCounter();
}
+bool
+ArchTimerKvm::scheduleEvents()
+{
+ if constexpr (USE_KVM &&
+ std::string_view(KVM_ISA) == std::string_view("arm")) {
+ auto *vm = system.getKvmVM();
+ return !vm || !vm->validEnvironment();
+ } else {
+ return true;
+ }
+}
+
GenericTimer::GenericTimer(const GenericTimerParams &p)
: SimObject(p),
systemCounter(*p.counter),
diff --git a/src/dev/arm/generic_timer.hh b/src/dev/arm/generic_timer.hh
index 9cccef6..cf04dad 100644
--- a/src/dev/arm/generic_timer.hh
+++ b/src/dev/arm/generic_timer.hh
@@ -280,9 +280,7 @@
// For ArchTimer's in a GenericTimerISA with Kvm execution about
// to begin, skip rescheduling the event.
// Otherwise, we should reschedule the event (if necessary).
- bool scheduleEvents() override {
- return !system.validKvmEnvironment();
- }
+ bool scheduleEvents() override;
};
class GenericTimer : public SimObject
diff --git a/src/sim/system.cc b/src/sim/system.cc
index 86ba3be..4829b58 100644
--- a/src/sim/system.cc
+++ b/src/sim/system.cc
@@ -52,7 +52,6 @@
#include "config/the_isa.hh"
#include "config/use_kvm.hh"
#if USE_KVM
-#include "cpu/kvm/base.hh"
#include "cpu/kvm/vm.hh"
#endif
#if !IS_NULL_ISA
@@ -316,24 +315,6 @@
}
}
-bool
-System::validKvmEnvironment() const
-{
-#if USE_KVM
- if (threads.empty())
- return false;
-
- for (auto *tc: threads) {
- if (!dynamic_cast<BaseKvmCPU *>(tc->getCpuPtr()))
- return false;
- }
-
- return true;
-#else
- return false;
-#endif
-}
-
Addr
System::memSize() const
{
diff --git a/src/sim/system.hh b/src/sim/system.hh
index 8f09b96..de030f0 100644
--- a/src/sim/system.hh
+++ b/src/sim/system.hh
@@ -336,9 +336,6 @@
*/
KvmVM *getKvmVM() { return kvmVM; }
- /** Verify gem5 configuration will support KVM emulation */
- bool validKvmEnvironment() const;
-
/** Get a pointer to access the physical memory of the system */
memory::PhysicalMemory& getPhysMem() { return physmem; }
const memory::PhysicalMemory& getPhysMem() const { return physmem; }
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/56263
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Ie6928961200943d1d4e3bd129a4e4269e9f12950
Gerrit-Change-Number: 56263
Gerrit-PatchSet: 2
Gerrit-Owner: Gabe Black <gabe.bl...@gmail.com>
Gerrit-Reviewer: Andreas Sandberg <andreas.sandb...@arm.com>
Gerrit-Reviewer: Gabe Black <gabe.bl...@gmail.com>
Gerrit-Reviewer: Jason Lowe-Power <ja...@lowepower.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-CC: Jason Lowe-Power <power...@gmail.com>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s