diff options
Diffstat (limited to 'arch/arm/kvm/arm.c')
-rw-r--r-- | arch/arm/kvm/arm.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c index 3a51ffca75e3..6fbfa5fff05d 100644 --- a/arch/arm/kvm/arm.c +++ b/arch/arm/kvm/arm.c | |||
@@ -132,6 +132,9 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type) | |||
132 | /* Mark the initial VMID generation invalid */ | 132 | /* Mark the initial VMID generation invalid */ |
133 | kvm->arch.vmid_gen = 0; | 133 | kvm->arch.vmid_gen = 0; |
134 | 134 | ||
135 | /* The maximum number of VCPUs is limited by the host's GIC model */ | ||
136 | kvm->arch.max_vcpus = kvm_vgic_get_max_vcpus(); | ||
137 | |||
135 | return ret; | 138 | return ret; |
136 | out_free_stage2_pgd: | 139 | out_free_stage2_pgd: |
137 | kvm_free_stage2_pgd(kvm); | 140 | kvm_free_stage2_pgd(kvm); |
@@ -218,6 +221,11 @@ struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id) | |||
218 | goto out; | 221 | goto out; |
219 | } | 222 | } |
220 | 223 | ||
224 | if (id >= kvm->arch.max_vcpus) { | ||
225 | err = -EINVAL; | ||
226 | goto out; | ||
227 | } | ||
228 | |||
221 | vcpu = kmem_cache_zalloc(kvm_vcpu_cache, GFP_KERNEL); | 229 | vcpu = kmem_cache_zalloc(kvm_vcpu_cache, GFP_KERNEL); |
222 | if (!vcpu) { | 230 | if (!vcpu) { |
223 | err = -ENOMEM; | 231 | err = -ENOMEM; |