cpu, kvm: Fix deadlock issue when resuming a drained system
cpu, kvm: Fix deadlock issue when resuming a drained system

The KVM CPU sometimes needs to access devices when drain() is
called. This typically happens on ARM when synchronizing devices that
use the system register interface. When called from drain(), the event
queue isn't locked since drain is called from the outside when the
simulator isn't servicing any events. In such cases, performing a
migration to the device's queue will unlock a mutex that isn't
locked. This typically results in a deadlock when resuming the system
since the lock will be in an undefined state.

Change-Id: Ibdcc2e034e916a929124f297e72aae306cf66728
Signed-off-by: Andreas Sandberg <c9f5686ee5bd561c93f9de79681eee75bfa7f36e@arm.com>
Reviewed-by: Nikos Nikoleris <b6a1b3cd9d36c44e9eeb16bc870df3cb2a0cf469@arm.com>
Reviewed-by: Curtis Dunham <14490907fdc9c150c92157b82121c81003bbdc71@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/4286
Reviewed-by: Jason Lowe-Power <68c46a606457643eab92053c1c05574abb26f861@lowepower.com>

rallylee/gem5,rallylee/gem5,sobercoder/gem5,rallylee/gem5,gem5/gem5,rallylee/gem5,gem5/gem5,sobercoder/gem5,rallylee/gem5,gem5/gem5,TUD-OS/gem5-dtu,sobercoder/gem5,TUD-OS/gem5-dtu,gem5/gem5,TUD-OS/gem5-dtu,sobercoder/gem5,TUD-OS/gem5-dtu,TUD-OS/gem5-dtu,TUD-OS/gem5-dtu,sobercoder/gem5,gem5/gem5,rallylee/gem5,sobercoder/gem5,gem5/gem5,sobercoder/gem5,TUD-OS/gem5-dtu,gem5/gem5,rallylee/gem5