summaryrefslogtreecommitdiff
path: root/src/cpu/kvm
diff options
context:
space:
mode:
Diffstat (limited to 'src/cpu/kvm')
-rw-r--r--src/cpu/kvm/base.cc7
-rw-r--r--src/cpu/kvm/base.hh10
-rw-r--r--src/cpu/kvm/x86_cpu.cc7
3 files changed, 16 insertions, 8 deletions
diff --git a/src/cpu/kvm/base.cc b/src/cpu/kvm/base.cc
index 6ea99ce4a..d0f7515de 100644
--- a/src/cpu/kvm/base.cc
+++ b/src/cpu/kvm/base.cc
@@ -1147,10 +1147,9 @@ BaseKvmCPU::doMMIOAccess(Addr paddr, void *data, int size, bool write)
delete pkt;
return clockPeriod() * ipr_delay;
} else {
- // Temporarily lock and migrate to the event queue of the
- // VM. This queue is assumed to "own" all devices we need to
- // access if running in multi-core mode.
- EventQueue::ScopedMigration migrate(vm.eventQueue());
+ // Temporarily lock and migrate to the device event queue to
+ // prevent races in multi-core mode.
+ EventQueue::ScopedMigration migrate(deviceEventQueue());
return dataPort.submitIO(pkt);
}
diff --git a/src/cpu/kvm/base.hh b/src/cpu/kvm/base.hh
index 29872e744..a22637f98 100644
--- a/src/cpu/kvm/base.hh
+++ b/src/cpu/kvm/base.hh
@@ -419,6 +419,16 @@ class BaseKvmCPU : public BaseCPU
void syncThreadContext();
/**
+ * Get a pointer to the event queue owning devices.
+ *
+ * Devices always live in a separate device event queue when
+ * running in multi-core mode. We need to temporarily migrate to
+ * this queue when accessing devices. By convention, devices and
+ * the VM use the same event queue.
+ */
+ EventQueue *deviceEventQueue() { return vm.eventQueue(); }
+
+ /**
* Update the KVM if the thread context is dirty.
*/
void syncKvmState();
diff --git a/src/cpu/kvm/x86_cpu.cc b/src/cpu/kvm/x86_cpu.cc
index bdbdadf71..467e1baaf 100644
--- a/src/cpu/kvm/x86_cpu.cc
+++ b/src/cpu/kvm/x86_cpu.cc
@@ -1346,10 +1346,9 @@ X86KvmCPU::handleKvmExitIO()
}
const MemCmd cmd(isWrite ? MemCmd::WriteReq : MemCmd::ReadReq);
- // Temporarily lock and migrate to the event queue of the
- // VM. This queue is assumed to "own" all devices we need to
- // access if running in multi-core mode.
- EventQueue::ScopedMigration migrate(vm.eventQueue());
+ // Temporarily lock and migrate to the device event queue to
+ // prevent races in multi-core mode.
+ EventQueue::ScopedMigration migrate(deviceEventQueue());
for (int i = 0; i < count; ++i) {
RequestPtr io_req = new Request(pAddr, kvm_run.io.size,
Request::UNCACHEABLE, dataMasterId());