public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org,
	linux-rt-users <linux-rt-users@vger.kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Carsten Emde <C.Emde@osadl.org>, John Kacur <jkacur@redhat.com>,
	Andre Przywara <andre.przywara@amd.com>,
	Avi Kivity <avi@redhat.com>
Subject: [PATCH 05/11] KVM: fix XSAVE bit scanning (now properly)
Date: Sun, 04 Dec 2011 13:54:49 -0500	[thread overview]
Message-ID: <20111204190013.224839960@goodmis.org> (raw)
In-Reply-To: 20111204185444.411298317@goodmis.org

[-- Attachment #1: Type: text/plain, Size: 1463 bytes --]

From: Andre Przywara <andre.przywara@amd.com>

commit 123108f1c1aafd51d6a5c79cc04d7999dd88a930 tried to fix KVMs
XSAVE valid feature scanning, but it was wrong. It was not considering
the sparse nature of this bitfield, instead reading values from
uninitialized members of the entries array.
This patch now separates subleaf indicies from KVM's array indicies
and fills the entry before querying it's value.
This fixes AVX support in KVM guests.

Signed-off-by: Andre Przywara <andre.przywara@amd.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
---
 arch/x86/kvm/x86.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index f168c61..3567c76 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2419,16 +2419,17 @@ static void do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
 		break;
 	}
 	case 0xd: {
-		int i;
+		int idx, i;
 
 		entry->flags |= KVM_CPUID_FLAG_SIGNIFCANT_INDEX;
-		for (i = 1; *nent < maxnent && i < 64; ++i) {
-			if (entry[i].eax == 0 || !supported_xcr0_bit(i))
+		for (idx = 1, i = 1; *nent < maxnent && idx < 64; ++idx) {
+			do_cpuid_1_ent(&entry[i], function, idx);
+			if (entry[i].eax == 0 || !supported_xcr0_bit(idx))
 				continue;
-			do_cpuid_1_ent(&entry[i], function, i);
 			entry[i].flags |=
 			       KVM_CPUID_FLAG_SIGNIFCANT_INDEX;
 			++*nent;
+			++i;
 		}
 		break;
 	}
-- 
1.7.7.1



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  parent reply	other threads:[~2011-12-04 19:02 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-04 18:54 [PATCH 00/11] [ANNOUNCE] 3.0.12-rt30-rc2 Steven Rostedt
2011-12-04 18:54 ` [PATCH 01/11] tasklet/rt: Prevent tasklets from going into infinite spin in RT Steven Rostedt
2011-12-04 18:54 ` [PATCH 02/11] genirq: fix regression in irqfixup, irqpoll Steven Rostedt
2011-12-04 18:54 ` [PATCH 03/11] intel-iommu: Fix AB-BA lockdep report Steven Rostedt
2012-11-14  2:25   ` Shuah Khan
2012-11-14  3:04     ` Steven Rostedt
2012-11-14  3:34       ` Greg Kroah-Hartman
2012-11-14  3:43         ` Steven Rostedt
2012-11-14 15:58         ` Shuah Khan
2011-12-04 18:54 ` [PATCH 04/11] KVM: Sanitize cpuid Steven Rostedt
2011-12-04 18:54 ` Steven Rostedt [this message]
2011-12-04 18:54 ` [PATCH 06/11] wait: Provide __wake_up_all_locked Steven Rostedt
2011-12-04 18:54 ` [PATCH 07/11] pci: Use __wake_up_all_locked pci_unblock_user_cfg_access() Steven Rostedt
2011-12-04 18:54 ` [PATCH 08/11] acpi: Make gbl_[hardware|gpe]_lock raw Steven Rostedt
2011-12-04 18:54 ` [PATCH 09/11] slab, lockdep: Fix silly bug Steven Rostedt
2011-12-05 13:04   ` Pekka Enberg
2011-12-05 13:15     ` Steven Rostedt
2011-12-04 18:54 ` [PATCH 10/11] slab, lockdep: Annotate all slab caches Steven Rostedt
2011-12-04 18:54 ` [PATCH 11/11] Linux v3.0.12-rt30-rc2 Steven Rostedt
2011-12-04 20:13 ` [PATCH 00/11] [ANNOUNCE] 3.0.12-rt30-rc2 Tim Sander
2011-12-04 20:46   ` Thomas Gleixner
2011-12-05  9:11     ` Tim Sander
2011-12-05 13:23       ` Steven Rostedt
2011-12-07  8:09         ` Tim Sander
2011-12-05  2:58   ` Mike Galbraith
2011-12-05 15:12 ` Georgiewskiy Yuriy
2011-12-05 16:57   ` Thomas Gleixner
2011-12-05 20:01     ` Georgiewskiy Yuriy

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=20111204190013.224839960@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=C.Emde@osadl.org \
    --cc=andre.przywara@amd.com \
    --cc=avi@redhat.com \
    --cc=jkacur@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /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