Linux MIPS Architecture development
 help / color / mirror / Atom feed
* [PATCH v6 1/2] KVM: remove NULL return path for vcpu ids >= KVM_MAX_VCPUS
@ 2016-05-09 16:11 Greg Kurz
  2016-05-09 16:13 ` [PATCH v6 2/2] kvm: introduce KVM_MAX_VCPU_ID Greg Kurz
  0 siblings, 1 reply; 4+ messages in thread
From: Greg Kurz @ 2016-05-09 16:11 UTC (permalink / raw)
  To: Paolo Bonzini, james.hogan, mingo
  Cc: linux-mips, kvm, rkrcmar, linux-kernel, David Hildenbrand,
	qemu-ppc, Cornelia Huck, Paul Mackerras, David Gibson

Commit c896939f7cff ("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 <dahi@linux.vnet.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
---
 include/linux/kvm_host.h |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 5276fe0916fc..23bfe1bd159c 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -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)

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-05-10 17:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-09 16:11 [PATCH v6 1/2] KVM: remove NULL return path for vcpu ids >= KVM_MAX_VCPUS Greg Kurz
2016-05-09 16:13 ` [PATCH v6 2/2] kvm: introduce KVM_MAX_VCPU_ID Greg Kurz
2016-05-09 16:23   ` Cornelia Huck
2016-05-10 17:17     ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox