Skip to content

Commit

Permalink
KVM: remove NULL return path for vcpu ids >= KVM_MAX_VCPUS
Browse files Browse the repository at this point in the history
Commit c896939 ("KVM: use heuristic for fast VCPU lookup by id") added
a return path that prevents vcpu ids to exceed KVM_MAX_VCPUS. This is a
problem for powerpc where vcpu ids can grow up to 8*KVM_MAX_VCPUS.

This patch simply reverses the logic so that we only try fast path if the
vcpu id can be tried as an index in kvm->vcpus[]. The slow path is not
affected by the change.

Reviewed-by: David Hildenbrand <[email protected]>
Reviewed-by: Cornelia Huck <[email protected]>
Signed-off-by: Greg Kurz <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
gkurz authored and bonzini committed May 11, 2016
1 parent bdb4094 commit 9b9e3fc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions include/linux/kvm_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -447,12 +447,13 @@ static inline struct kvm_vcpu *kvm_get_vcpu(struct kvm *kvm, int i)

static inline struct kvm_vcpu *kvm_get_vcpu_by_id(struct kvm *kvm, int id)
{
struct kvm_vcpu *vcpu;
struct kvm_vcpu *vcpu = NULL;
int i;

if (id < 0 || id >= KVM_MAX_VCPUS)
if (id < 0)
return NULL;
vcpu = kvm_get_vcpu(kvm, id);
if (id < KVM_MAX_VCPUS)
vcpu = kvm_get_vcpu(kvm, id);
if (vcpu && vcpu->vcpu_id == id)
return vcpu;
kvm_for_each_vcpu(i, vcpu, kvm)
Expand Down

0 comments on commit 9b9e3fc

Please sign in to comment.