kvm: Add a helper method to access device event queues

The VM's event queue is normally used for devices in multi-core KVM
mode. Add a helper method, BaseKvmCPU::deviceEventQueue(), to access
this queue. This makes the intention of code migrating to device event
queues clearer.

Change-Id: Ifb10f553a6d7445c8d562f658cf9d0b1f4c577ff
Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/4287
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
This commit is contained in:
Andreas Sandberg
2017-07-27 09:24:22 +00:00
parent 9d6d3e5f7d
commit 1935cec529
3 changed files with 16 additions and 8 deletions

View File

@@ -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);
}

View File

@@ -418,6 +418,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.
*/

View File

@@ -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());