mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: kvm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Nitin A Kamble <nitin.a.kamble@intel.com>
Subject: [PATCH 08/44] KVM: Fix cpuid iteration on multiple leaves per eac
Date: Tue,  9 Dec 2008 22:22:23 +0200	[thread overview]
Message-ID: <1228854179-23002-9-git-send-email-avi@redhat.com> (raw)
In-Reply-To: <1228854179-23002-1-git-send-email-avi@redhat.com>

From: Nitin A Kamble <nitin.a.kamble@intel.com>

The code to traverse the cpuid data array list for counting type of leaves is
currently broken.

This patches fixes the 2 things in it.

 1. Set the 1st counting entry's flag KVM_CPUID_FLAG_STATE_READ_NEXT. Without
    it the code will never find a valid entry.

 2. Also the stop condition in the for loop while looking for the next unflaged
    entry is broken. It needs to stop when it find one matching entry;
    and in the case of count of 1, it will be the same entry found in this
    iteration.

Signed-Off-By: Nitin A Kamble <nitin.a.kamble@intel.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
---
 arch/x86/kvm/x86.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 2889a0f..7a2aeba 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1246,6 +1246,7 @@ static void do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
 		int t, times = entry->eax & 0xff;
 
 		entry->flags |= KVM_CPUID_FLAG_STATEFUL_FUNC;
+		entry->flags |= KVM_CPUID_FLAG_STATE_READ_NEXT;
 		for (t = 1; t < times && *nent < maxnent; ++t) {
 			do_cpuid_1_ent(&entry[t], function, 0);
 			entry[t].flags |= KVM_CPUID_FLAG_STATEFUL_FUNC;
@@ -2801,7 +2802,7 @@ static int move_to_next_stateful_cpuid_entry(struct kvm_vcpu *vcpu, int i)
 
 	e->flags &= ~KVM_CPUID_FLAG_STATE_READ_NEXT;
 	/* when no next entry is found, the current entry[i] is reselected */
-	for (j = i + 1; j == i; j = (j + 1) % nent) {
+	for (j = i + 1; ; j = (j + 1) % nent) {
 		struct kvm_cpuid_entry2 *ej = &vcpu->arch.cpuid_entries[j];
 		if (ej->function == e->function) {
 			ej->flags |= KVM_CPUID_FLAG_STATE_READ_NEXT;
-- 
1.6.0.3


  parent reply	other threads:[~2008-12-09 20:25 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-09 20:22 [PATCH 00/44] KVM Updates for 2.6.29 (part 2 of 3) Avi Kivity
2008-12-09 20:22 ` [PATCH 01/44] KVM: ppc: adjust vcpu types to support 64-bit cores Avi Kivity
2008-12-09 20:22 ` [PATCH 02/44] KVM: ppc: fix set regs to take care of msr change Avi Kivity
2008-12-09 20:22 ` [PATCH 03/44] KVM: ppc: optimize kvm stat handling Avi Kivity
2008-12-09 20:22 ` [PATCH 04/44] KVM: ppc: optimize find first bit Avi Kivity
2008-12-09 20:22 ` [PATCH 05/44] KVM: ppc: optimize irq delivery path Avi Kivity
2008-12-09 20:22 ` [PATCH 06/44] KVM: ppc: improve trap emulation Avi Kivity
2008-12-09 20:22 ` [PATCH 07/44] KVM: Fix cpuid leaf 0xb loop termination Avi Kivity
2008-12-09 20:22 ` Avi Kivity [this message]
2008-12-09 20:22 ` [PATCH 09/44] KVM: ensure that memslot userspace addresses are page-aligned Avi Kivity
2008-12-09 20:22 ` [PATCH 10/44] KVM: ppc: fix Kconfig constraints Avi Kivity
2008-12-09 20:22 ` [PATCH 11/44] KVM: ia64: Remove some macro definitions in asm-offsets.c Avi Kivity
2008-12-09 20:22 ` [PATCH 12/44] KVM: Fix kernel allocated memory slot Avi Kivity
2008-12-09 20:22 ` [PATCH 13/44] KVM: ppc: use MMUCR accessor to obtain TID Avi Kivity
2008-12-09 20:22 ` [PATCH 14/44] KVM: ppc: use prefetchable mappings for guest memory Avi Kivity
2008-12-09 20:22 ` [PATCH 15/44] KVM: ppc: fix userspace mapping invalidation on context switch Avi Kivity
2008-12-09 20:22 ` [PATCH 16/44] Merge branch 'x86/crashdump' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip Avi Kivity
2008-12-09 20:22 ` [PATCH 17/44] KVM: VMX: move vmx.h to include/asm Avi Kivity
2008-12-09 20:22 ` [PATCH 18/44] KVM: SVM: move svm.h " Avi Kivity
2008-12-09 20:22 ` [PATCH 19/44] KVM: VMX: move ASM_VMX_* definitions from asm/kvm_host.h to asm/vmx.h Avi Kivity
2008-12-09 20:22 ` [PATCH 20/44] KVM: VMX: move cpu_has_kvm_support() to an inline on asm/virtext.h Avi Kivity
2008-12-09 20:22 ` [PATCH 21/44] x86: asm/virtext.h: add cpu_vmxoff() inline function Avi Kivity
2008-12-09 20:22 ` [PATCH 22/44] KVM: VMX: extract kvm_cpu_vmxoff() from hardware_disable() Avi Kivity
2008-12-09 20:22 ` [PATCH 23/44] x86: cpu_emergency_vmxoff() function Avi Kivity
2008-12-09 20:22 ` [PATCH 24/44] KVM: SVM: move has_svm() code to asm/virtext.h Avi Kivity
2008-12-09 20:22 ` [PATCH 25/44] KVM: SVM: move svm_hardware_disable() " Avi Kivity
2008-12-09 20:22 ` [PATCH 26/44] x86: cpu_emergency_svm_disable() function Avi Kivity
2008-12-09 20:22 ` [PATCH 27/44] kdump: forcibly disable VMX and SVM on machine_crash_shutdown() Avi Kivity
2008-12-09 20:22 ` [PATCH 28/44] x86: disable VMX on all CPUs on reboot Avi Kivity
2008-12-09 20:22 ` [PATCH 29/44] KVM: ia64: Define printk function for kvm-intel module Avi Kivity
2008-12-09 20:22 ` [PATCH 30/44] KVM: ia64: Add some debug points to provide crash infomation Avi Kivity
2008-12-09 20:22 ` [PATCH 31/44] KVM: ia64: Add handler for crashed vmm Avi Kivity
2008-12-09 20:22 ` [PATCH 32/44] KVM: ia64: Clean up vmm_ivt.S using tab to indent every line Avi Kivity
2008-12-09 20:22 ` [PATCH 33/44] KVM: VMX: Conditionally request interrupt window after injecting irq Avi Kivity
2008-12-09 20:22 ` [PATCH 34/44] x86: KVM guest: sign kvmclock as paravirt Avi Kivity
2008-12-09 20:22 ` [PATCH 35/44] KVM: Move ack notifier register and IRQ sourcd ID request Avi Kivity
2008-12-09 20:22 ` [PATCH 36/44] KVM: Separate update irq to a single function Avi Kivity
2008-12-09 20:22 ` [PATCH 37/44] KVM: Replace irq_requested with more generic irq_requested_type Avi Kivity
2008-12-09 20:22 ` [PATCH 38/44] KVM: Clean up assigned_device_update_irq Avi Kivity
2008-12-09 20:22 ` [PATCH 39/44] KVM: Add fields for MSI device assignment Avi Kivity
2008-12-09 20:22 ` [PATCH 40/44] KVM: Export ioapic_get_delivery_bitmask Avi Kivity
2008-12-09 20:22 ` [PATCH 41/44] KVM: Add assigned_device_msi_dispatch() Avi Kivity
2008-12-09 20:22 ` [PATCH 42/44] KVM: Enable MSI for device assignment Avi Kivity
2008-12-09 20:22 ` [PATCH 43/44] KVM: MSI to INTx translate Avi Kivity
2008-12-09 20:22 ` [PATCH 44/44] KVM: MMU: optimize set_spte for page sync Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1228854179-23002-9-git-send-email-avi@redhat.com \
    --to=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nitin.a.kamble@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®