Commit 37b8e06b authored by Jean-Philippe Brucker's avatar Jean-Philippe Brucker Committed by Will Deacon
Browse files

Prevent segfault when kvm_pause is called too early

When kvm_pause is called early (from taking the rwlock), it segfaults
because the CPU array is initialized slightly later. Fix this.

This doesn't happen at the moment but the gicv2m patch will register an
MMIO region, which requires br_write_lock. gicv2m is instantiated by
kvm__arch_init from within core_init (level 0). The CPU array is
initialized later in base_init (level 1).

Signed-off-by: Jean-Philippe Brucker's avatarJean-Philippe Brucker <>
Signed-off-by: default avatarWill Deacon <>
parent 6c723953
......@@ -443,7 +443,7 @@ void kvm__pause(struct kvm *kvm)
/* Check if the guest is running */
if (!kvm->cpus[0] || kvm->cpus[0]->thread == 0)
if (!kvm->cpus || !kvm->cpus[0] || kvm->cpus[0]->thread == 0)
pause_event = eventfd(0, 0);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment