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