kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Use WARN_ON_ONCE for missing X86_FEATURE_NRIPS
@ 2015-10-01 11:43 Dirk Müller
  2015-10-01 12:25 ` Paolo Bonzini
  2015-10-01 12:31 ` Paolo Bonzini
  0 siblings, 2 replies; 27+ messages in thread
From: Dirk Müller @ 2015-10-01 11:43 UTC (permalink / raw)
  To: kvm; +Cc: Joerg Roedel

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

The cpu feature flags are not ever going to change, so warning
everytime can cause a lot of kernel log spam
(in our case more than 10GB/hour).

Signed-off-by: Dirk Mueller <dmueller@suse.com>

-- 
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, 
HRB 21284 (AG Nürnberg)

[-- Attachment #2: 0001-Use-WARN_ON_ONCE-for-missing-X86_FEATURE_NRIPS.patch --]
[-- Type: text/x-patch, Size: 943 bytes --]

>From 40c7213e34a1a1caf0b98db832c06c593f888b11 Mon Sep 17 00:00:00 2001
From: Dirk Mueller <dirk@dmllr.de>
Date: Thu, 1 Oct 2015 13:10:10 +0200
Subject: [PATCH] Use WARN_ON_ONCE for missing X86_FEATURE_NRIPS

The cpu feature flags are not ever going to change, so warning
everytime can cause a lot of kernel log spam
(in our case more than 10GB/hour).

Signed-off-by: Dirk Mueller <dmueller@suse.com>
---
 arch/x86/kvm/svm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 94b7d15..0a42859 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -514,7 +514,7 @@ static void skip_emulated_instruction(struct kvm_vcpu *vcpu)
 	struct vcpu_svm *svm = to_svm(vcpu);
 
 	if (svm->vmcb->control.next_rip != 0) {
-		WARN_ON(!static_cpu_has(X86_FEATURE_NRIPS));
+		WARN_ON_ONCE(!static_cpu_has(X86_FEATURE_NRIPS));
 		svm->next_rip = svm->vmcb->control.next_rip;
 	}
 
-- 
2.5.1


^ permalink raw reply related	[flat|nested] 27+ messages in thread
* [PATCH] kvm: svm: Only propagate next_rip when guest supports it
@ 2015-10-09  9:51 Joerg Roedel
  2015-10-09 11:15 ` Paolo Bonzini
  0 siblings, 1 reply; 27+ messages in thread
From: Joerg Roedel @ 2015-10-09  9:51 UTC (permalink / raw)
  To: Paolo Bonzini, Gleb Natapov
  Cc: kvm, linux-kernel, Joerg Roedel, Bandan Das, Dirk Mueller

From: Joerg Roedel <jroedel@suse.de>

Currently we always write the next_rip of the shadow vmcb to
the guests vmcb when we emulate a vmexit. This could confuse
the guest when its cpuid indicated no support for the
next_rip feature.

Fix this by only propagating next_rip if the guest actually
supports it.

Cc: Bandan Das <bsd@redhat.com>
Cc: Dirk Mueller <dmueller@suse.com>
Tested-by: Dirk Mueller <dmueller@suse.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
 arch/x86/kvm/cpuid.h | 21 +++++++++++++++++++++
 arch/x86/kvm/svm.c   |  4 +++-
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kvm/cpuid.h b/arch/x86/kvm/cpuid.h
index dd05b9c..effca1f 100644
--- a/arch/x86/kvm/cpuid.h
+++ b/arch/x86/kvm/cpuid.h
@@ -133,4 +133,25 @@ static inline bool guest_cpuid_has_mpx(struct kvm_vcpu *vcpu)
 	best = kvm_find_cpuid_entry(vcpu, 7, 0);
 	return best && (best->ebx & bit(X86_FEATURE_MPX));
 }
+
+/*
+ * NRIPS is provided through cpuidfn 0x8000000a.edx bit 3
+ */
+#define BIT_NRIPS	3
+
+static inline bool guest_cpuid_has_nrips(struct kvm_vcpu *vcpu)
+{
+	struct kvm_cpuid_entry2 *best;
+
+	best = kvm_find_cpuid_entry(vcpu, 0x8000000a, 0);
+
+	/*
+	 * NRIPS is a scattered cpuid feature, so we can't use
+	 * X86_FEATURE_NRIPS here (X86_FEATURE_NRIPS would be bit
+	 * position 8, not 3).
+	 */
+	return best && (best->edx & bit(BIT_NRIPS));
+}
+#undef BIT_NRIPS
+
 #endif
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 2f9ed1f..4084b33 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -2365,7 +2365,9 @@ static int nested_svm_vmexit(struct vcpu_svm *svm)
 	nested_vmcb->control.exit_info_2       = vmcb->control.exit_info_2;
 	nested_vmcb->control.exit_int_info     = vmcb->control.exit_int_info;
 	nested_vmcb->control.exit_int_info_err = vmcb->control.exit_int_info_err;
-	nested_vmcb->control.next_rip          = vmcb->control.next_rip;
+
+	if (guest_cpuid_has_nrips(&svm->vcpu))
+		nested_vmcb->control.next_rip  = vmcb->control.next_rip;
 
 	/*
 	 * If we emulate a VMRUN/#VMEXIT in the same host #vmexit cycle we have
-- 
1.9.1

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

end of thread, other threads:[~2015-10-09 11:15 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-01 11:43 [PATCH] Use WARN_ON_ONCE for missing X86_FEATURE_NRIPS Dirk Müller
2015-10-01 12:25 ` Paolo Bonzini
2015-10-01 12:45   ` Dirk Müller
2015-10-01 12:31 ` Paolo Bonzini
2015-10-01 22:31   ` Bandan Das
2015-10-02  6:43     ` Dirk Müller
2015-10-05  1:15       ` Bandan Das
2015-10-05  9:50     ` Joerg Roedel
2015-10-05 16:54       ` Bandan Das
2015-10-05 17:15         ` Joerg Roedel
2015-10-05 17:42           ` Bandan Das
2015-10-06 10:23             ` Joerg Roedel
2015-10-06 18:02               ` Bandan Das
2015-10-05 20:12           ` Dirk Müller
2015-10-05 22:00             ` Bandan Das
2015-10-06 10:28     ` Joerg Roedel
2015-10-06 17:59       ` Bandan Das
2015-10-07 11:03         ` Joerg Roedel
2015-10-07 12:47           ` [PATCH] kvm: svm: Only propagate next_rip when guest supports it Joerg Roedel
2015-10-07 12:57             ` kbuild test robot
2015-10-07 15:48             ` Bandan Das
2015-10-07 16:14               ` Joerg Roedel
2015-10-07 17:03                 ` Dirk Müller
2015-10-07 14:58           ` [PATCH] Use WARN_ON_ONCE for missing X86_FEATURE_NRIPS Bandan Das
2015-10-07 15:24             ` Joerg Roedel
  -- strict thread matches above, loose matches on Subject: below --
2015-10-09  9:51 [PATCH] kvm: svm: Only propagate next_rip when guest supports it Joerg Roedel
2015-10-09 11:15 ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).