From ffb4b625e8b2f0ce0f31433564973eb2c80a7ef5 Mon Sep 17 00:00:00 2001
From: Alexey Makhalov <amakhalov@vmware.com>
Date: Tue, 9 May 2017 12:41:17 -0700
Subject: [PATCH] vmware only

Signed-off-by: Bo Gan <ganb@vmware.com>
---
 arch/x86/kernel/cpu/Makefile | 5 +++++
 arch/x86/kernel/cpu/common.c | 3 +++
 arch/x86/kernel/cpu/vmware.c | 5 +++++
 arch/x86/kernel/smpboot.c    | 1 -
 4 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
index 89c96c936083..6656e7e10214 100644
--- a/arch/x86/kernel/cpu/Makefile
+++ b/arch/x86/kernel/cpu/Makefile
@@ -21,7 +21,12 @@ CFLAGS_common.o		:= -fno-stack-protector
 
 obj-y			:= cacheinfo.o scattered.o topology.o
 obj-y			+= common.o
+
+# Trust rdrand on VMware platform
+ifndef CONFIG_HYPERVISOR_GUEST
 obj-y			+= rdrand.o
+endif
+
 obj-y			+= match.o
 obj-y			+= bugs.o
 obj-y			+= aperfmperf.o
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 3e508f239098..24e73f7700d5 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -1858,7 +1858,10 @@ static void identify_cpu(struct cpuinfo_x86 *c)
 	detect_ht(c);
 #endif
 
+	/* Trust rdrand on VMware platform */
+#ifndef CONFIG_HYPERVISOR_GUEST
 	x86_init_rdrand(c);
+#endif
 	setup_pku(c);
 	setup_cet(c);
 
diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c
index 9d6183624f4f..a5b1bb90af21 100644
--- a/arch/x86/kernel/cpu/vmware.c
+++ b/arch/x86/kernel/cpu/vmware.c
@@ -30,6 +30,7 @@
 #include <linux/static_call.h>
 #include <linux/kmsg_dump.h>
 #include <linux/objtool.h>
+#include <asm/pci_x86.h>
 #include <asm/div64.h>
 #include <asm/x86_init.h>
 #include <asm/hypervisor.h>
@@ -475,6 +476,10 @@ static void __init vmware_platform_setup(void)
 	vmware_set_capabilities();
 
 	kmsg_dump_register(&kmsg_dumper);
+#ifdef CONFIG_PCI
+	/* PCI BIOS service won't work from a PV guest. */
+	pci_probe &= ~PCI_PROBE_BIOS;
+#endif
 }
 
 static u8 __init vmware_select_hypercall(void)
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index f24227bc3220..1fa1edec6545 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -810,7 +810,6 @@ wakeup_secondary_cpu_via_nmi(int apicid, unsigned long start_eip)
 	/*
 	 * Give the other CPU some time to accept the IPI.
 	 */
-	udelay(200);
 	if (APIC_INTEGRATED(boot_cpu_apic_version)) {
 		maxlvt = lapic_get_maxlvt();
 		if (maxlvt > 3)			/* Due to the Pentium erratum 3AP.  */
-- 
2.25.1