|
@@ -132,8 +132,10 @@ static struct kvm_vcpu *get_vcpu_by_vpidx(struct kvm *kvm, u32 vpidx)
|
|
|
struct kvm_vcpu *vcpu = NULL;
|
|
|
int i;
|
|
|
|
|
|
- if (vpidx < KVM_MAX_VCPUS)
|
|
|
- vcpu = kvm_get_vcpu(kvm, vpidx);
|
|
|
+ if (vpidx >= KVM_MAX_VCPUS)
|
|
|
+ return NULL;
|
|
|
+
|
|
|
+ vcpu = kvm_get_vcpu(kvm, vpidx);
|
|
|
if (vcpu && vcpu_to_hv_vcpu(vcpu)->vp_index == vpidx)
|
|
|
return vcpu;
|
|
|
kvm_for_each_vcpu(i, vcpu, kvm)
|
|
@@ -1044,7 +1046,7 @@ static int kvm_hv_set_msr(struct kvm_vcpu *vcpu, u32 msr, u64 data, bool host)
|
|
|
|
|
|
switch (msr) {
|
|
|
case HV_X64_MSR_VP_INDEX:
|
|
|
- if (!host)
|
|
|
+ if (!host || (u32)data >= KVM_MAX_VCPUS)
|
|
|
return 1;
|
|
|
hv->vp_index = (u32)data;
|
|
|
break;
|