aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Brucker <jean-philippe.brucker@arm.com>2017-11-03 11:38:40 +0000
committerWill Deacon <will.deacon@arm.com>2017-11-03 14:35:51 +0000
commit37b8e06be3ce63d4b50a5066446ca0cb5c61ba43 (patch)
tree659aa7afb75f3aedfdfff90935bf3d6f349513b4
parent6c7239532b7db4490a1fbc67d5f288f20eac9c21 (diff)
downloadkvmtool-37b8e06be3ce63d4b50a5066446ca0cb5c61ba43.tar.gz
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 <jean-philippe.brucker@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com>
-rw-r--r--kvm.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/kvm.c b/kvm.c
index 665ed148..f8f2fdc2 100644
--- a/kvm.c
+++ b/kvm.c
@@ -443,7 +443,7 @@ void kvm__pause(struct kvm *kvm)
mutex_lock(&pause_lock);
/* 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)
return;
pause_event = eventfd(0, 0);