1dfa3b
From: Andy Lutomirski <luto@amacapital.net>
1dfa3b
Date: Fri, 5 Dec 2014 19:03:28 -0800
1dfa3b
Subject: [PATCH] x86, kvm: Clear paravirt_enabled on KVM guests for espfix32's
1dfa3b
 benefit
1dfa3b
1dfa3b
paravirt_enabled has the following effects:
1dfa3b
1dfa3b
 - Disables the F00F bug workaround warning.  There is no F00F bug
1dfa3b
   workaround any more because Linux's standard IDT handling already
1dfa3b
   works around the F00F bug, but the warning still exists.  This
1dfa3b
   is only cosmetic, and, in any event, there is no such thing as
1dfa3b
   KVM on a CPU with the F00F bug.
1dfa3b
1dfa3b
 - Disables 32-bit APM BIOS detection.  On a KVM paravirt system,
1dfa3b
   there should be no APM BIOS anyway.
1dfa3b
1dfa3b
 - Disables tboot.  I think that the tboot code should check the
1dfa3b
   CPUID hypervisor bit directly if it matters.
1dfa3b
1dfa3b
 - paravirt_enabled disables espfix32.  espfix32 should *not* be
1dfa3b
   disabled under KVM paravirt.
1dfa3b
1dfa3b
The last point is the purpose of this patch.  It fixes a leak of the
1dfa3b
high 16 bits of the kernel stack address on 32-bit KVM paravirt
1dfa3b
guests.
1dfa3b
1dfa3b
While I'm at it, this removes pv_info setup from kvmclock.  That
1dfa3b
code seems to serve no purpose.
1dfa3b
1dfa3b
Cc: stable@vger.kernel.org
1dfa3b
Signed-off-by: Andy Lutomirski <luto@amacapital.net>
1dfa3b
---
1dfa3b
 arch/x86/kernel/kvm.c      | 9 ++++++++-
1dfa3b
 arch/x86/kernel/kvmclock.c | 2 --
1dfa3b
 2 files changed, 8 insertions(+), 3 deletions(-)
1dfa3b
1dfa3b
diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
1dfa3b
index 3dd8e2c4d74a..07de51f66deb 100644
1dfa3b
--- a/arch/x86/kernel/kvm.c
1dfa3b
+++ b/arch/x86/kernel/kvm.c
1dfa3b
@@ -282,7 +282,14 @@ NOKPROBE_SYMBOL(do_async_page_fault);
1dfa3b
 static void __init paravirt_ops_setup(void)
1dfa3b
 {
1dfa3b
 	pv_info.name = "KVM";
1dfa3b
-	pv_info.paravirt_enabled = 1;
1dfa3b
+
1dfa3b
+	/*
1dfa3b
+	 * KVM isn't paravirt in the sense of paravirt_enabled.  A KVM
1dfa3b
+	 * guest kernel works like a bare metal kernel with additional
1dfa3b
+	 * features, and paravirt_enabled is about features that are
1dfa3b
+	 * missing.
1dfa3b
+	 */
1dfa3b
+	pv_info.paravirt_enabled = 0;
1dfa3b
 
1dfa3b
 	if (kvm_para_has_feature(KVM_FEATURE_NOP_IO_DELAY))
1dfa3b
 		pv_cpu_ops.io_delay = kvm_io_delay;
1dfa3b
diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
1dfa3b
index d9156ceecdff..d4d9a8ad7893 100644
1dfa3b
--- a/arch/x86/kernel/kvmclock.c
1dfa3b
+++ b/arch/x86/kernel/kvmclock.c
1dfa3b
@@ -263,8 +263,6 @@ void __init kvmclock_init(void)
1dfa3b
 #endif
1dfa3b
 	kvm_get_preset_lpj();
1dfa3b
 	clocksource_register_hz(&kvm_clock, NSEC_PER_SEC);
1dfa3b
-	pv_info.paravirt_enabled = 1;
1dfa3b
-	pv_info.name = "KVM";
1dfa3b
 
1dfa3b
 	if (kvm_para_has_feature(KVM_FEATURE_CLOCKSOURCE_STABLE_BIT))
1dfa3b
 		pvclock_set_flags(PVCLOCK_TSC_STABLE_BIT);
1dfa3b
-- 
1dfa3b
2.1.0
1dfa3b