All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2 1/4] x86: introduce hypervisor_cpuid_base()
@ 2013-07-25  8:54 Jason Wang
  2013-07-25  8:54   ` Jason Wang
                   ` (3 more replies)
  0 siblings, 4 replies; 21+ messages in thread
From: Jason Wang @ 2013-07-25  8:54 UTC (permalink / raw)
  To: tglx, mingo, hpa, x86, linux-kernel, pbonzini
  Cc: kvm, Jason Wang, Gleb Natapov

This patch introduce hypervisor_cpuid_base() which loop test the hypervisor
existence function until the signature match and check the number of leaves if
required. This could be used by Xen/KVM guest to detect the existence of
hypervisor.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Gleb Natapov <gleb@redhat.com>
Cc: x86@kernel.org
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
Changes from V1:
- use memcpy() and uint32_t instead of strcmp()
---
 arch/x86/include/asm/processor.h |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index 24cf5ae..7763307 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -971,6 +971,21 @@ unsigned long calc_aperfmperf_ratio(struct aperfmperf *old,
 	return ratio;
 }
 
+static inline uint32_t hypervisor_cpuid_base(const char *sig, uint32_t leaves)
+{
+	uint32_t base, eax, signature[3];
+
+	for (base = 0x40000000; base < 0x40010000; base += 0x100) {
+		cpuid(base, &eax, &signature[0], &signature[1], &signature[2]);
+
+		if (!memcmp(sig, signature, 12) &&
+		    (leaves == 0 || ((eax - base) >= leaves)))
+			return base;
+	}
+
+	return 0;
+}
+
 extern unsigned long arch_align_stack(unsigned long sp);
 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
 
-- 
1.7.1


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

* [PATCH V2 2/4] xen: switch to use hypervisor_cpuid_base()
  2013-07-25  8:54 [PATCH V2 1/4] x86: introduce hypervisor_cpuid_base() Jason Wang
@ 2013-07-25  8:54   ` Jason Wang
  2013-07-25  8:54 ` [PATCH V2 3/4] kvm: switch " Jason Wang
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 21+ messages in thread
From: Jason Wang @ 2013-07-25  8:54 UTC (permalink / raw)
  To: tglx, mingo, hpa, x86, linux-kernel, pbonzini
  Cc: kvm, Jason Wang, Konrad Rzeszutek Wilk, Jeremy Fitzhardinge,
	xen-devel, virtualization

Switch to use hypervisor_cpuid_base() to detect Xen.

Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: x86@kernel.org
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: xen-devel@lists.xensource.com
Cc: virtualization@lists.linux-foundation.org
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 arch/x86/include/asm/xen/hypervisor.h |   16 +---------------
 1 files changed, 1 insertions(+), 15 deletions(-)

diff --git a/arch/x86/include/asm/xen/hypervisor.h b/arch/x86/include/asm/xen/hypervisor.h
index 125f344..d866959 100644
--- a/arch/x86/include/asm/xen/hypervisor.h
+++ b/arch/x86/include/asm/xen/hypervisor.h
@@ -40,21 +40,7 @@ extern struct start_info *xen_start_info;
 
 static inline uint32_t xen_cpuid_base(void)
 {
-	uint32_t base, eax, ebx, ecx, edx;
-	char signature[13];
-
-	for (base = 0x40000000; base < 0x40010000; base += 0x100) {
-		cpuid(base, &eax, &ebx, &ecx, &edx);
-		*(uint32_t *)(signature + 0) = ebx;
-		*(uint32_t *)(signature + 4) = ecx;
-		*(uint32_t *)(signature + 8) = edx;
-		signature[12] = 0;
-
-		if (!strcmp("XenVMMXenVMM", signature) && ((eax - base) >= 2))
-			return base;
-	}
-
-	return 0;
+	return hypervisor_cpuid_base("XenVMMXenVMM", 2);
 }
 
 #ifdef CONFIG_XEN
-- 
1.7.1


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

* [PATCH V2 2/4] xen: switch to use hypervisor_cpuid_base()
@ 2013-07-25  8:54   ` Jason Wang
  0 siblings, 0 replies; 21+ messages in thread
From: Jason Wang @ 2013-07-25  8:54 UTC (permalink / raw)
  To: tglx, mingo, hpa, x86, linux-kernel, pbonzini
  Cc: Jeremy Fitzhardinge, xen-devel, kvm, Konrad Rzeszutek Wilk,
	virtualization

Switch to use hypervisor_cpuid_base() to detect Xen.

Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: x86@kernel.org
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: xen-devel@lists.xensource.com
Cc: virtualization@lists.linux-foundation.org
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 arch/x86/include/asm/xen/hypervisor.h |   16 +---------------
 1 files changed, 1 insertions(+), 15 deletions(-)

diff --git a/arch/x86/include/asm/xen/hypervisor.h b/arch/x86/include/asm/xen/hypervisor.h
index 125f344..d866959 100644
--- a/arch/x86/include/asm/xen/hypervisor.h
+++ b/arch/x86/include/asm/xen/hypervisor.h
@@ -40,21 +40,7 @@ extern struct start_info *xen_start_info;
 
 static inline uint32_t xen_cpuid_base(void)
 {
-	uint32_t base, eax, ebx, ecx, edx;
-	char signature[13];
-
-	for (base = 0x40000000; base < 0x40010000; base += 0x100) {
-		cpuid(base, &eax, &ebx, &ecx, &edx);
-		*(uint32_t *)(signature + 0) = ebx;
-		*(uint32_t *)(signature + 4) = ecx;
-		*(uint32_t *)(signature + 8) = edx;
-		signature[12] = 0;
-
-		if (!strcmp("XenVMMXenVMM", signature) && ((eax - base) >= 2))
-			return base;
-	}
-
-	return 0;
+	return hypervisor_cpuid_base("XenVMMXenVMM", 2);
 }
 
 #ifdef CONFIG_XEN
-- 
1.7.1

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

* [PATCH V2 3/4] kvm: switch to use hypervisor_cpuid_base()
  2013-07-25  8:54 [PATCH V2 1/4] x86: introduce hypervisor_cpuid_base() Jason Wang
  2013-07-25  8:54   ` Jason Wang
@ 2013-07-25  8:54 ` Jason Wang
  2013-08-05 13:58   ` [tip:x86/paravirt] x86, kvm: Switch to use hypervisor_cpuid_base( ) tip-bot for Jason Wang
  2013-07-25  8:54   ` Jason Wang
  2013-08-05 13:57 ` [tip:x86/paravirt] x86: Introduce hypervisor_cpuid_base() tip-bot for Jason Wang
  3 siblings, 1 reply; 21+ messages in thread
From: Jason Wang @ 2013-07-25  8:54 UTC (permalink / raw)
  To: tglx, mingo, hpa, x86, linux-kernel, pbonzini
  Cc: kvm, Jason Wang, Gleb Natapov

Switch to use hypervisor_cpuid_base() to detect KVM.

Cc: Gleb Natapov <gleb@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Cc: kvm@vger.kernel.org
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
Changes from V1:
- Introduce kvm_cpuid_base() which will be used by next patch.
---
 arch/x86/include/asm/kvm_para.h |   24 +++++++++---------------
 1 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/arch/x86/include/asm/kvm_para.h b/arch/x86/include/asm/kvm_para.h
index 695399f..0644129 100644
--- a/arch/x86/include/asm/kvm_para.h
+++ b/arch/x86/include/asm/kvm_para.h
@@ -85,26 +85,20 @@ static inline long kvm_hypercall4(unsigned int nr, unsigned long p1,
 	return ret;
 }
 
-static inline bool kvm_para_available(void)
+static inline uint32_t kvm_cpuid_base(void)
 {
-	unsigned int eax, ebx, ecx, edx;
-	char signature[13];
-
 	if (boot_cpu_data.cpuid_level < 0)
-		return false;	/* So we don't blow up on old processors */
+		return 0;	/* So we don't blow up on old processors */
 
-	if (cpu_has_hypervisor) {
-		cpuid(KVM_CPUID_SIGNATURE, &eax, &ebx, &ecx, &edx);
-		memcpy(signature + 0, &ebx, 4);
-		memcpy(signature + 4, &ecx, 4);
-		memcpy(signature + 8, &edx, 4);
-		signature[12] = 0;
+	if (cpu_has_hypervisor)
+		return hypervisor_cpuid_base("KVMKVMKVM\0\0\0", 0);
 
-		if (strcmp(signature, "KVMKVMKVM") == 0)
-			return true;
-	}
+	return 0;
+}
 
-	return false;
+static inline bool kvm_para_available(void)
+{
+	return kvm_cpuid_base() != 0;
 }
 
 static inline unsigned int kvm_arch_para_features(void)
-- 
1.7.1


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

* [PATCH V2 4/4] x86: correctly detect hypervisor
  2013-07-25  8:54 [PATCH V2 1/4] x86: introduce hypervisor_cpuid_base() Jason Wang
@ 2013-07-25  8:54   ` Jason Wang
  2013-07-25  8:54 ` [PATCH V2 3/4] kvm: switch " Jason Wang
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 21+ messages in thread
From: Jason Wang @ 2013-07-25  8:54 UTC (permalink / raw)
  To: tglx, mingo, hpa, x86, linux-kernel, pbonzini
  Cc: kvm, Jason Wang, K. Y. Srinivasan, Haiyang Zhang,
	Konrad Rzeszutek Wilk, Jeremy Fitzhardinge, Doug Covelli,
	Borislav Petkov, Dan Hecht, Paul Gortmaker, Marcelo Tosatti,
	Gleb Natapov, Frederic Weisbecker, devel, xen-devel,
	virtualization

We try to handle the hypervisor compatibility mode by detecting hypervisor
through a specific order. This is not robust, since hypervisors may implement
each others features.

This patch tries to handle this situation by always choosing the last one in the
CPUID leaves. This is done by letting .detect() returns a priority instead of
true/false and just re-using the CPUID leaf where the signature were found as
the priority (or 1 if it was found by DMI). Then we can just pick hypervisor who
has the highest priority. Other sophisticated detection method could also be
implemented on top.

Suggested by H. Peter Anvin and Paolo Bonzini.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: x86@kernel.org
Cc: K. Y. Srinivasan <kys@microsoft.com>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Doug Covelli <dcovelli@vmware.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: Dan Hecht <dhecht@vmware.com>
Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Gleb Natapov <gleb@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: linux-kernel@vger.kernel.org
Cc: devel@linuxdriverproject.org
Cc: kvm@vger.kernel.org
Cc: xen-devel@lists.xensource.com
Cc: virtualization@lists.linux-foundation.org
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 arch/x86/include/asm/hypervisor.h |    2 +-
 arch/x86/kernel/cpu/hypervisor.c  |   15 +++++++--------
 arch/x86/kernel/cpu/mshyperv.c    |   13 ++++++++-----
 arch/x86/kernel/cpu/vmware.c      |    8 ++++----
 arch/x86/kernel/kvm.c             |    6 ++----
 arch/x86/xen/enlighten.c          |    9 +++------
 6 files changed, 25 insertions(+), 28 deletions(-)

diff --git a/arch/x86/include/asm/hypervisor.h b/arch/x86/include/asm/hypervisor.h
index 2d4b5e6..e42f758 100644
--- a/arch/x86/include/asm/hypervisor.h
+++ b/arch/x86/include/asm/hypervisor.h
@@ -33,7 +33,7 @@ struct hypervisor_x86 {
 	const char	*name;
 
 	/* Detection routine */
-	bool		(*detect)(void);
+	uint32_t	(*detect)(void);
 
 	/* Adjust CPU feature bits (run once per CPU) */
 	void		(*set_cpu_features)(struct cpuinfo_x86 *);
diff --git a/arch/x86/kernel/cpu/hypervisor.c b/arch/x86/kernel/cpu/hypervisor.c
index 8727921..36ce402 100644
--- a/arch/x86/kernel/cpu/hypervisor.c
+++ b/arch/x86/kernel/cpu/hypervisor.c
@@ -25,11 +25,6 @@
 #include <asm/processor.h>
 #include <asm/hypervisor.h>
 
-/*
- * Hypervisor detect order.  This is specified explicitly here because
- * some hypervisors might implement compatibility modes for other
- * hypervisors and therefore need to be detected in specific sequence.
- */
 static const __initconst struct hypervisor_x86 * const hypervisors[] =
 {
 #ifdef CONFIG_XEN_PVHVM
@@ -49,15 +44,19 @@ static inline void __init
 detect_hypervisor_vendor(void)
 {
 	const struct hypervisor_x86 *h, * const *p;
+	uint32_t pri, max_pri = 0;
 
 	for (p = hypervisors; p < hypervisors + ARRAY_SIZE(hypervisors); p++) {
 		h = *p;
-		if (h->detect()) {
+		pri = h->detect();
+		if (pri != 0 && pri > max_pri) {
+			max_pri = pri;
 			x86_hyper = h;
-			printk(KERN_INFO "Hypervisor detected: %s\n", h->name);
-			break;
 		}
 	}
+
+	if (max_pri)
+		printk(KERN_INFO "Hypervisor detected: %s\n", x86_hyper->name);
 }
 
 void init_hypervisor(struct cpuinfo_x86 *c)
diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
index 8f4be53..71a39f3 100644
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -27,20 +27,23 @@
 struct ms_hyperv_info ms_hyperv;
 EXPORT_SYMBOL_GPL(ms_hyperv);
 
-static bool __init ms_hyperv_platform(void)
+static uint32_t  __init ms_hyperv_platform(void)
 {
 	u32 eax;
 	u32 hyp_signature[3];
 
 	if (!boot_cpu_has(X86_FEATURE_HYPERVISOR))
-		return false;
+		return 0;
 
 	cpuid(HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS,
 	      &eax, &hyp_signature[0], &hyp_signature[1], &hyp_signature[2]);
 
-	return eax >= HYPERV_CPUID_MIN &&
-		eax <= HYPERV_CPUID_MAX &&
-		!memcmp("Microsoft Hv", hyp_signature, 12);
+	if (eax >= HYPERV_CPUID_MIN &&
+	    eax <= HYPERV_CPUID_MAX &&
+	    !memcmp("Microsoft Hv", hyp_signature, 12))
+		return HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS;
+
+	return 0;
 }
 
 static cycle_t read_hv_clock(struct clocksource *arg)
diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c
index 7076878..628a059 100644
--- a/arch/x86/kernel/cpu/vmware.c
+++ b/arch/x86/kernel/cpu/vmware.c
@@ -93,7 +93,7 @@ static void __init vmware_platform_setup(void)
  * serial key should be enough, as this will always have a VMware
  * specific string when running under VMware hypervisor.
  */
-static bool __init vmware_platform(void)
+static uint32_t __init vmware_platform(void)
 {
 	if (cpu_has_hypervisor) {
 		unsigned int eax;
@@ -102,12 +102,12 @@ static bool __init vmware_platform(void)
 		cpuid(CPUID_VMWARE_INFO_LEAF, &eax, &hyper_vendor_id[0],
 		      &hyper_vendor_id[1], &hyper_vendor_id[2]);
 		if (!memcmp(hyper_vendor_id, "VMwareVMware", 12))
-			return true;
+			return CPUID_VMWARE_INFO_LEAF;
 	} else if (dmi_available && dmi_name_in_serial("VMware") &&
 		   __vmware_platform())
-		return true;
+		return 1;
 
-	return false;
+	return 0;
 }
 
 /*
diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index a96d32c..7817afd 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -498,11 +498,9 @@ void __init kvm_guest_init(void)
 #endif
 }
 
-static bool __init kvm_detect(void)
+static uint32_t __init kvm_detect(void)
 {
-	if (!kvm_para_available())
-		return false;
-	return true;
+	return kvm_cpuid_base();
 }
 
 const struct hypervisor_x86 x86_hyper_kvm __refconst = {
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 193097e..2fcaedc 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -1720,15 +1720,12 @@ static void __init xen_hvm_guest_init(void)
 	xen_hvm_init_mmu_ops();
 }
 
-static bool __init xen_hvm_platform(void)
+static uint32_t __init xen_hvm_platform(void)
 {
 	if (xen_pv_domain())
-		return false;
-
-	if (!xen_cpuid_base())
-		return false;
+		return 0;
 
-	return true;
+	return xen_cpuid_base();
 }
 
 bool xen_hvm_need_lapic(void)
-- 
1.7.1


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

* [PATCH V2 4/4] x86: correctly detect hypervisor
@ 2013-07-25  8:54   ` Jason Wang
  0 siblings, 0 replies; 21+ messages in thread
From: Jason Wang @ 2013-07-25  8:54 UTC (permalink / raw)
  To: tglx, mingo, hpa, x86, linux-kernel, pbonzini
  Cc: Jeremy Fitzhardinge, Borislav Petkov, kvm, Konrad Rzeszutek Wilk,
	Frederic Weisbecker, Dan Hecht, virtualization, Doug Covelli,
	Paul Gortmaker, xen-devel, devel, Haiyang Zhang

We try to handle the hypervisor compatibility mode by detecting hypervisor
through a specific order. This is not robust, since hypervisors may implement
each others features.

This patch tries to handle this situation by always choosing the last one in the
CPUID leaves. This is done by letting .detect() returns a priority instead of
true/false and just re-using the CPUID leaf where the signature were found as
the priority (or 1 if it was found by DMI). Then we can just pick hypervisor who
has the highest priority. Other sophisticated detection method could also be
implemented on top.

Suggested by H. Peter Anvin and Paolo Bonzini.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: x86@kernel.org
Cc: K. Y. Srinivasan <kys@microsoft.com>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Doug Covelli <dcovelli@vmware.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: Dan Hecht <dhecht@vmware.com>
Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Gleb Natapov <gleb@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: linux-kernel@vger.kernel.org
Cc: devel@linuxdriverproject.org
Cc: kvm@vger.kernel.org
Cc: xen-devel@lists.xensource.com
Cc: virtualization@lists.linux-foundation.org
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 arch/x86/include/asm/hypervisor.h |    2 +-
 arch/x86/kernel/cpu/hypervisor.c  |   15 +++++++--------
 arch/x86/kernel/cpu/mshyperv.c    |   13 ++++++++-----
 arch/x86/kernel/cpu/vmware.c      |    8 ++++----
 arch/x86/kernel/kvm.c             |    6 ++----
 arch/x86/xen/enlighten.c          |    9 +++------
 6 files changed, 25 insertions(+), 28 deletions(-)

diff --git a/arch/x86/include/asm/hypervisor.h b/arch/x86/include/asm/hypervisor.h
index 2d4b5e6..e42f758 100644
--- a/arch/x86/include/asm/hypervisor.h
+++ b/arch/x86/include/asm/hypervisor.h
@@ -33,7 +33,7 @@ struct hypervisor_x86 {
 	const char	*name;
 
 	/* Detection routine */
-	bool		(*detect)(void);
+	uint32_t	(*detect)(void);
 
 	/* Adjust CPU feature bits (run once per CPU) */
 	void		(*set_cpu_features)(struct cpuinfo_x86 *);
diff --git a/arch/x86/kernel/cpu/hypervisor.c b/arch/x86/kernel/cpu/hypervisor.c
index 8727921..36ce402 100644
--- a/arch/x86/kernel/cpu/hypervisor.c
+++ b/arch/x86/kernel/cpu/hypervisor.c
@@ -25,11 +25,6 @@
 #include <asm/processor.h>
 #include <asm/hypervisor.h>
 
-/*
- * Hypervisor detect order.  This is specified explicitly here because
- * some hypervisors might implement compatibility modes for other
- * hypervisors and therefore need to be detected in specific sequence.
- */
 static const __initconst struct hypervisor_x86 * const hypervisors[] =
 {
 #ifdef CONFIG_XEN_PVHVM
@@ -49,15 +44,19 @@ static inline void __init
 detect_hypervisor_vendor(void)
 {
 	const struct hypervisor_x86 *h, * const *p;
+	uint32_t pri, max_pri = 0;
 
 	for (p = hypervisors; p < hypervisors + ARRAY_SIZE(hypervisors); p++) {
 		h = *p;
-		if (h->detect()) {
+		pri = h->detect();
+		if (pri != 0 && pri > max_pri) {
+			max_pri = pri;
 			x86_hyper = h;
-			printk(KERN_INFO "Hypervisor detected: %s\n", h->name);
-			break;
 		}
 	}
+
+	if (max_pri)
+		printk(KERN_INFO "Hypervisor detected: %s\n", x86_hyper->name);
 }
 
 void init_hypervisor(struct cpuinfo_x86 *c)
diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
index 8f4be53..71a39f3 100644
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -27,20 +27,23 @@
 struct ms_hyperv_info ms_hyperv;
 EXPORT_SYMBOL_GPL(ms_hyperv);
 
-static bool __init ms_hyperv_platform(void)
+static uint32_t  __init ms_hyperv_platform(void)
 {
 	u32 eax;
 	u32 hyp_signature[3];
 
 	if (!boot_cpu_has(X86_FEATURE_HYPERVISOR))
-		return false;
+		return 0;
 
 	cpuid(HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS,
 	      &eax, &hyp_signature[0], &hyp_signature[1], &hyp_signature[2]);
 
-	return eax >= HYPERV_CPUID_MIN &&
-		eax <= HYPERV_CPUID_MAX &&
-		!memcmp("Microsoft Hv", hyp_signature, 12);
+	if (eax >= HYPERV_CPUID_MIN &&
+	    eax <= HYPERV_CPUID_MAX &&
+	    !memcmp("Microsoft Hv", hyp_signature, 12))
+		return HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS;
+
+	return 0;
 }
 
 static cycle_t read_hv_clock(struct clocksource *arg)
diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c
index 7076878..628a059 100644
--- a/arch/x86/kernel/cpu/vmware.c
+++ b/arch/x86/kernel/cpu/vmware.c
@@ -93,7 +93,7 @@ static void __init vmware_platform_setup(void)
  * serial key should be enough, as this will always have a VMware
  * specific string when running under VMware hypervisor.
  */
-static bool __init vmware_platform(void)
+static uint32_t __init vmware_platform(void)
 {
 	if (cpu_has_hypervisor) {
 		unsigned int eax;
@@ -102,12 +102,12 @@ static bool __init vmware_platform(void)
 		cpuid(CPUID_VMWARE_INFO_LEAF, &eax, &hyper_vendor_id[0],
 		      &hyper_vendor_id[1], &hyper_vendor_id[2]);
 		if (!memcmp(hyper_vendor_id, "VMwareVMware", 12))
-			return true;
+			return CPUID_VMWARE_INFO_LEAF;
 	} else if (dmi_available && dmi_name_in_serial("VMware") &&
 		   __vmware_platform())
-		return true;
+		return 1;
 
-	return false;
+	return 0;
 }
 
 /*
diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index a96d32c..7817afd 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -498,11 +498,9 @@ void __init kvm_guest_init(void)
 #endif
 }
 
-static bool __init kvm_detect(void)
+static uint32_t __init kvm_detect(void)
 {
-	if (!kvm_para_available())
-		return false;
-	return true;
+	return kvm_cpuid_base();
 }
 
 const struct hypervisor_x86 x86_hyper_kvm __refconst = {
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 193097e..2fcaedc 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -1720,15 +1720,12 @@ static void __init xen_hvm_guest_init(void)
 	xen_hvm_init_mmu_ops();
 }
 
-static bool __init xen_hvm_platform(void)
+static uint32_t __init xen_hvm_platform(void)
 {
 	if (xen_pv_domain())
-		return false;
-
-	if (!xen_cpuid_base())
-		return false;
+		return 0;
 
-	return true;
+	return xen_cpuid_base();
 }
 
 bool xen_hvm_need_lapic(void)
-- 
1.7.1

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

* RE: [PATCH V2 4/4] x86: correctly detect hypervisor
  2013-07-25  8:54   ` Jason Wang
@ 2013-07-25 10:56     ` KY Srinivasan
  -1 siblings, 0 replies; 21+ messages in thread
From: KY Srinivasan @ 2013-07-25 10:56 UTC (permalink / raw)
  To: Jason Wang, tglx, mingo, hpa, x86, linux-kernel, pbonzini
  Cc: kvm, Haiyang Zhang, Konrad Rzeszutek Wilk, Jeremy Fitzhardinge,
	Doug Covelli, Borislav Petkov, Dan Hecht, Paul Gortmaker,
	Marcelo Tosatti, Gleb Natapov, Frederic Weisbecker, devel,
	xen-devel, virtualization



> -----Original Message-----
> From: Jason Wang [mailto:jasowang@redhat.com]
> Sent: Thursday, July 25, 2013 4:55 AM
> To: tglx@linutronix.de; mingo@redhat.com; hpa@zytor.com; x86@kernel.org;
> linux-kernel@vger.kernel.org; pbonzini@redhat.com
> Cc: kvm@vger.kernel.org; Jason Wang; KY Srinivasan; Haiyang Zhang; Konrad
> Rzeszutek Wilk; Jeremy Fitzhardinge; Doug Covelli; Borislav Petkov; Dan Hecht;
> Paul Gortmaker; Marcelo Tosatti; Gleb Natapov; Frederic Weisbecker;
> devel@linuxdriverproject.org; xen-devel@lists.xensource.com;
> virtualization@lists.linux-foundation.org
> Subject: [PATCH V2 4/4] x86: correctly detect hypervisor
> 
> We try to handle the hypervisor compatibility mode by detecting hypervisor
> through a specific order. This is not robust, since hypervisors may implement
> each others features.
> 
> This patch tries to handle this situation by always choosing the last one in the
> CPUID leaves. This is done by letting .detect() returns a priority instead of
> true/false and just re-using the CPUID leaf where the signature were found as
> the priority (or 1 if it was found by DMI). Then we can just pick hypervisor who
> has the highest priority. Other sophisticated detection method could also be
> implemented on top.
> 
> Suggested by H. Peter Anvin and Paolo Bonzini.
> 
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: H. Peter Anvin <hpa@zytor.com>
> Cc: x86@kernel.org
> Cc: K. Y. Srinivasan <kys@microsoft.com>
> Cc: Haiyang Zhang <haiyangz@microsoft.com>
> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> Cc: Jeremy Fitzhardinge <jeremy@goop.org>
> Cc: Doug Covelli <dcovelli@vmware.com>
> Cc: Borislav Petkov <bp@suse.de>
> Cc: Dan Hecht <dhecht@vmware.com>
> Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
> Cc: Marcelo Tosatti <mtosatti@redhat.com>
> Cc: Gleb Natapov <gleb@redhat.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: linux-kernel@vger.kernel.org
> Cc: devel@linuxdriverproject.org
> Cc: kvm@vger.kernel.org
> Cc: xen-devel@lists.xensource.com
> Cc: virtualization@lists.linux-foundation.org
> Signed-off-by: Jason Wang <jasowang@redhat.com>
Acked-by:  K. Y. Srinivasan <kys@microsoft.com>

> ---
>  arch/x86/include/asm/hypervisor.h |    2 +-
>  arch/x86/kernel/cpu/hypervisor.c  |   15 +++++++--------
>  arch/x86/kernel/cpu/mshyperv.c    |   13 ++++++++-----
>  arch/x86/kernel/cpu/vmware.c      |    8 ++++----
>  arch/x86/kernel/kvm.c             |    6 ++----
>  arch/x86/xen/enlighten.c          |    9 +++------
>  6 files changed, 25 insertions(+), 28 deletions(-)
> 
> diff --git a/arch/x86/include/asm/hypervisor.h
> b/arch/x86/include/asm/hypervisor.h
> index 2d4b5e6..e42f758 100644
> --- a/arch/x86/include/asm/hypervisor.h
> +++ b/arch/x86/include/asm/hypervisor.h
> @@ -33,7 +33,7 @@ struct hypervisor_x86 {
>  	const char	*name;
> 
>  	/* Detection routine */
> -	bool		(*detect)(void);
> +	uint32_t	(*detect)(void);
> 
>  	/* Adjust CPU feature bits (run once per CPU) */
>  	void		(*set_cpu_features)(struct cpuinfo_x86 *);
> diff --git a/arch/x86/kernel/cpu/hypervisor.c b/arch/x86/kernel/cpu/hypervisor.c
> index 8727921..36ce402 100644
> --- a/arch/x86/kernel/cpu/hypervisor.c
> +++ b/arch/x86/kernel/cpu/hypervisor.c
> @@ -25,11 +25,6 @@
>  #include <asm/processor.h>
>  #include <asm/hypervisor.h>
> 
> -/*
> - * Hypervisor detect order.  This is specified explicitly here because
> - * some hypervisors might implement compatibility modes for other
> - * hypervisors and therefore need to be detected in specific sequence.
> - */
>  static const __initconst struct hypervisor_x86 * const hypervisors[] =
>  {
>  #ifdef CONFIG_XEN_PVHVM
> @@ -49,15 +44,19 @@ static inline void __init
>  detect_hypervisor_vendor(void)
>  {
>  	const struct hypervisor_x86 *h, * const *p;
> +	uint32_t pri, max_pri = 0;
> 
>  	for (p = hypervisors; p < hypervisors + ARRAY_SIZE(hypervisors); p++) {
>  		h = *p;
> -		if (h->detect()) {
> +		pri = h->detect();
> +		if (pri != 0 && pri > max_pri) {
> +			max_pri = pri;
>  			x86_hyper = h;
> -			printk(KERN_INFO "Hypervisor detected: %s\n", h-
> >name);
> -			break;
>  		}
>  	}
> +
> +	if (max_pri)
> +		printk(KERN_INFO "Hypervisor detected: %s\n", x86_hyper-
> >name);
>  }
> 
>  void init_hypervisor(struct cpuinfo_x86 *c)
> diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
> index 8f4be53..71a39f3 100644
> --- a/arch/x86/kernel/cpu/mshyperv.c
> +++ b/arch/x86/kernel/cpu/mshyperv.c
> @@ -27,20 +27,23 @@
>  struct ms_hyperv_info ms_hyperv;
>  EXPORT_SYMBOL_GPL(ms_hyperv);
> 
> -static bool __init ms_hyperv_platform(void)
> +static uint32_t  __init ms_hyperv_platform(void)
>  {
>  	u32 eax;
>  	u32 hyp_signature[3];
> 
>  	if (!boot_cpu_has(X86_FEATURE_HYPERVISOR))
> -		return false;
> +		return 0;
> 
>  	cpuid(HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS,
>  	      &eax, &hyp_signature[0], &hyp_signature[1], &hyp_signature[2]);
> 
> -	return eax >= HYPERV_CPUID_MIN &&
> -		eax <= HYPERV_CPUID_MAX &&
> -		!memcmp("Microsoft Hv", hyp_signature, 12);
> +	if (eax >= HYPERV_CPUID_MIN &&
> +	    eax <= HYPERV_CPUID_MAX &&
> +	    !memcmp("Microsoft Hv", hyp_signature, 12))
> +		return HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS;
> +
> +	return 0;
>  }
> 
>  static cycle_t read_hv_clock(struct clocksource *arg)
> diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c
> index 7076878..628a059 100644
> --- a/arch/x86/kernel/cpu/vmware.c
> +++ b/arch/x86/kernel/cpu/vmware.c
> @@ -93,7 +93,7 @@ static void __init vmware_platform_setup(void)
>   * serial key should be enough, as this will always have a VMware
>   * specific string when running under VMware hypervisor.
>   */
> -static bool __init vmware_platform(void)
> +static uint32_t __init vmware_platform(void)
>  {
>  	if (cpu_has_hypervisor) {
>  		unsigned int eax;
> @@ -102,12 +102,12 @@ static bool __init vmware_platform(void)
>  		cpuid(CPUID_VMWARE_INFO_LEAF, &eax,
> &hyper_vendor_id[0],
>  		      &hyper_vendor_id[1], &hyper_vendor_id[2]);
>  		if (!memcmp(hyper_vendor_id, "VMwareVMware", 12))
> -			return true;
> +			return CPUID_VMWARE_INFO_LEAF;
>  	} else if (dmi_available && dmi_name_in_serial("VMware") &&
>  		   __vmware_platform())
> -		return true;
> +		return 1;
> 
> -	return false;
> +	return 0;
>  }
> 
>  /*
> diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
> index a96d32c..7817afd 100644
> --- a/arch/x86/kernel/kvm.c
> +++ b/arch/x86/kernel/kvm.c
> @@ -498,11 +498,9 @@ void __init kvm_guest_init(void)
>  #endif
>  }
> 
> -static bool __init kvm_detect(void)
> +static uint32_t __init kvm_detect(void)
>  {
> -	if (!kvm_para_available())
> -		return false;
> -	return true;
> +	return kvm_cpuid_base();
>  }
> 
>  const struct hypervisor_x86 x86_hyper_kvm __refconst = {
> diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
> index 193097e..2fcaedc 100644
> --- a/arch/x86/xen/enlighten.c
> +++ b/arch/x86/xen/enlighten.c
> @@ -1720,15 +1720,12 @@ static void __init xen_hvm_guest_init(void)
>  	xen_hvm_init_mmu_ops();
>  }
> 
> -static bool __init xen_hvm_platform(void)
> +static uint32_t __init xen_hvm_platform(void)
>  {
>  	if (xen_pv_domain())
> -		return false;
> -
> -	if (!xen_cpuid_base())
> -		return false;
> +		return 0;
> 
> -	return true;
> +	return xen_cpuid_base();
>  }
> 
>  bool xen_hvm_need_lapic(void)
> --
> 1.7.1
> 
> 
> 




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

* RE: [PATCH V2 4/4] x86: correctly detect hypervisor
@ 2013-07-25 10:56     ` KY Srinivasan
  0 siblings, 0 replies; 21+ messages in thread
From: KY Srinivasan @ 2013-07-25 10:56 UTC (permalink / raw)
  To: Jason Wang, tglx, mingo, hpa, x86, linux-kernel, pbonzini
  Cc: kvm, Haiyang Zhang, Konrad Rzeszutek Wilk, Jeremy Fitzhardinge,
	Doug Covelli, Borislav Petkov, Dan Hecht, Paul Gortmaker,
	Marcelo Tosatti, Gleb Natapov, Frederic Weisbecker, devel,
	xen-devel, virtualization



> -----Original Message-----
> From: Jason Wang [mailto:jasowang@redhat.com]
> Sent: Thursday, July 25, 2013 4:55 AM
> To: tglx@linutronix.de; mingo@redhat.com; hpa@zytor.com; x86@kernel.org;
> linux-kernel@vger.kernel.org; pbonzini@redhat.com
> Cc: kvm@vger.kernel.org; Jason Wang; KY Srinivasan; Haiyang Zhang; Konrad
> Rzeszutek Wilk; Jeremy Fitzhardinge; Doug Covelli; Borislav Petkov; Dan Hecht;
> Paul Gortmaker; Marcelo Tosatti; Gleb Natapov; Frederic Weisbecker;
> devel@linuxdriverproject.org; xen-devel@lists.xensource.com;
> virtualization@lists.linux-foundation.org
> Subject: [PATCH V2 4/4] x86: correctly detect hypervisor
> 
> We try to handle the hypervisor compatibility mode by detecting hypervisor
> through a specific order. This is not robust, since hypervisors may implement
> each others features.
> 
> This patch tries to handle this situation by always choosing the last one in the
> CPUID leaves. This is done by letting .detect() returns a priority instead of
> true/false and just re-using the CPUID leaf where the signature were found as
> the priority (or 1 if it was found by DMI). Then we can just pick hypervisor who
> has the highest priority. Other sophisticated detection method could also be
> implemented on top.
> 
> Suggested by H. Peter Anvin and Paolo Bonzini.
> 
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: H. Peter Anvin <hpa@zytor.com>
> Cc: x86@kernel.org
> Cc: K. Y. Srinivasan <kys@microsoft.com>
> Cc: Haiyang Zhang <haiyangz@microsoft.com>
> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> Cc: Jeremy Fitzhardinge <jeremy@goop.org>
> Cc: Doug Covelli <dcovelli@vmware.com>
> Cc: Borislav Petkov <bp@suse.de>
> Cc: Dan Hecht <dhecht@vmware.com>
> Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
> Cc: Marcelo Tosatti <mtosatti@redhat.com>
> Cc: Gleb Natapov <gleb@redhat.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: linux-kernel@vger.kernel.org
> Cc: devel@linuxdriverproject.org
> Cc: kvm@vger.kernel.org
> Cc: xen-devel@lists.xensource.com
> Cc: virtualization@lists.linux-foundation.org
> Signed-off-by: Jason Wang <jasowang@redhat.com>
Acked-by:  K. Y. Srinivasan <kys@microsoft.com>

> ---
>  arch/x86/include/asm/hypervisor.h |    2 +-
>  arch/x86/kernel/cpu/hypervisor.c  |   15 +++++++--------
>  arch/x86/kernel/cpu/mshyperv.c    |   13 ++++++++-----
>  arch/x86/kernel/cpu/vmware.c      |    8 ++++----
>  arch/x86/kernel/kvm.c             |    6 ++----
>  arch/x86/xen/enlighten.c          |    9 +++------
>  6 files changed, 25 insertions(+), 28 deletions(-)
> 
> diff --git a/arch/x86/include/asm/hypervisor.h
> b/arch/x86/include/asm/hypervisor.h
> index 2d4b5e6..e42f758 100644
> --- a/arch/x86/include/asm/hypervisor.h
> +++ b/arch/x86/include/asm/hypervisor.h
> @@ -33,7 +33,7 @@ struct hypervisor_x86 {
>  	const char	*name;
> 
>  	/* Detection routine */
> -	bool		(*detect)(void);
> +	uint32_t	(*detect)(void);
> 
>  	/* Adjust CPU feature bits (run once per CPU) */
>  	void		(*set_cpu_features)(struct cpuinfo_x86 *);
> diff --git a/arch/x86/kernel/cpu/hypervisor.c b/arch/x86/kernel/cpu/hypervisor.c
> index 8727921..36ce402 100644
> --- a/arch/x86/kernel/cpu/hypervisor.c
> +++ b/arch/x86/kernel/cpu/hypervisor.c
> @@ -25,11 +25,6 @@
>  #include <asm/processor.h>
>  #include <asm/hypervisor.h>
> 
> -/*
> - * Hypervisor detect order.  This is specified explicitly here because
> - * some hypervisors might implement compatibility modes for other
> - * hypervisors and therefore need to be detected in specific sequence.
> - */
>  static const __initconst struct hypervisor_x86 * const hypervisors[] =
>  {
>  #ifdef CONFIG_XEN_PVHVM
> @@ -49,15 +44,19 @@ static inline void __init
>  detect_hypervisor_vendor(void)
>  {
>  	const struct hypervisor_x86 *h, * const *p;
> +	uint32_t pri, max_pri = 0;
> 
>  	for (p = hypervisors; p < hypervisors + ARRAY_SIZE(hypervisors); p++) {
>  		h = *p;
> -		if (h->detect()) {
> +		pri = h->detect();
> +		if (pri != 0 && pri > max_pri) {
> +			max_pri = pri;
>  			x86_hyper = h;
> -			printk(KERN_INFO "Hypervisor detected: %s\n", h-
> >name);
> -			break;
>  		}
>  	}
> +
> +	if (max_pri)
> +		printk(KERN_INFO "Hypervisor detected: %s\n", x86_hyper-
> >name);
>  }
> 
>  void init_hypervisor(struct cpuinfo_x86 *c)
> diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
> index 8f4be53..71a39f3 100644
> --- a/arch/x86/kernel/cpu/mshyperv.c
> +++ b/arch/x86/kernel/cpu/mshyperv.c
> @@ -27,20 +27,23 @@
>  struct ms_hyperv_info ms_hyperv;
>  EXPORT_SYMBOL_GPL(ms_hyperv);
> 
> -static bool __init ms_hyperv_platform(void)
> +static uint32_t  __init ms_hyperv_platform(void)
>  {
>  	u32 eax;
>  	u32 hyp_signature[3];
> 
>  	if (!boot_cpu_has(X86_FEATURE_HYPERVISOR))
> -		return false;
> +		return 0;
> 
>  	cpuid(HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS,
>  	      &eax, &hyp_signature[0], &hyp_signature[1], &hyp_signature[2]);
> 
> -	return eax >= HYPERV_CPUID_MIN &&
> -		eax <= HYPERV_CPUID_MAX &&
> -		!memcmp("Microsoft Hv", hyp_signature, 12);
> +	if (eax >= HYPERV_CPUID_MIN &&
> +	    eax <= HYPERV_CPUID_MAX &&
> +	    !memcmp("Microsoft Hv", hyp_signature, 12))
> +		return HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS;
> +
> +	return 0;
>  }
> 
>  static cycle_t read_hv_clock(struct clocksource *arg)
> diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c
> index 7076878..628a059 100644
> --- a/arch/x86/kernel/cpu/vmware.c
> +++ b/arch/x86/kernel/cpu/vmware.c
> @@ -93,7 +93,7 @@ static void __init vmware_platform_setup(void)
>   * serial key should be enough, as this will always have a VMware
>   * specific string when running under VMware hypervisor.
>   */
> -static bool __init vmware_platform(void)
> +static uint32_t __init vmware_platform(void)
>  {
>  	if (cpu_has_hypervisor) {
>  		unsigned int eax;
> @@ -102,12 +102,12 @@ static bool __init vmware_platform(void)
>  		cpuid(CPUID_VMWARE_INFO_LEAF, &eax,
> &hyper_vendor_id[0],
>  		      &hyper_vendor_id[1], &hyper_vendor_id[2]);
>  		if (!memcmp(hyper_vendor_id, "VMwareVMware", 12))
> -			return true;
> +			return CPUID_VMWARE_INFO_LEAF;
>  	} else if (dmi_available && dmi_name_in_serial("VMware") &&
>  		   __vmware_platform())
> -		return true;
> +		return 1;
> 
> -	return false;
> +	return 0;
>  }
> 
>  /*
> diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
> index a96d32c..7817afd 100644
> --- a/arch/x86/kernel/kvm.c
> +++ b/arch/x86/kernel/kvm.c
> @@ -498,11 +498,9 @@ void __init kvm_guest_init(void)
>  #endif
>  }
> 
> -static bool __init kvm_detect(void)
> +static uint32_t __init kvm_detect(void)
>  {
> -	if (!kvm_para_available())
> -		return false;
> -	return true;
> +	return kvm_cpuid_base();
>  }
> 
>  const struct hypervisor_x86 x86_hyper_kvm __refconst = {
> diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
> index 193097e..2fcaedc 100644
> --- a/arch/x86/xen/enlighten.c
> +++ b/arch/x86/xen/enlighten.c
> @@ -1720,15 +1720,12 @@ static void __init xen_hvm_guest_init(void)
>  	xen_hvm_init_mmu_ops();
>  }
> 
> -static bool __init xen_hvm_platform(void)
> +static uint32_t __init xen_hvm_platform(void)
>  {
>  	if (xen_pv_domain())
> -		return false;
> -
> -	if (!xen_cpuid_base())
> -		return false;
> +		return 0;
> 
> -	return true;
> +	return xen_cpuid_base();
>  }
> 
>  bool xen_hvm_need_lapic(void)
> --
> 1.7.1
> 
> 
> 

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

* RE: [PATCH V2 4/4] x86: correctly detect hypervisor
  2013-07-25  8:54   ` Jason Wang
  (?)
  (?)
@ 2013-07-25 10:56   ` KY Srinivasan
  -1 siblings, 0 replies; 21+ messages in thread
From: KY Srinivasan @ 2013-07-25 10:56 UTC (permalink / raw)
  To: Jason Wang, tglx, mingo, hpa, x86, linux-kernel, pbonzini
  Cc: Jeremy Fitzhardinge, xen-devel, kvm, Konrad Rzeszutek Wilk,
	Frederic Weisbecker, Haiyang Zhang, Dan Hecht, virtualization,
	Doug Covelli, Paul Gortmaker, devel, Borislav Petkov



> -----Original Message-----
> From: Jason Wang [mailto:jasowang@redhat.com]
> Sent: Thursday, July 25, 2013 4:55 AM
> To: tglx@linutronix.de; mingo@redhat.com; hpa@zytor.com; x86@kernel.org;
> linux-kernel@vger.kernel.org; pbonzini@redhat.com
> Cc: kvm@vger.kernel.org; Jason Wang; KY Srinivasan; Haiyang Zhang; Konrad
> Rzeszutek Wilk; Jeremy Fitzhardinge; Doug Covelli; Borislav Petkov; Dan Hecht;
> Paul Gortmaker; Marcelo Tosatti; Gleb Natapov; Frederic Weisbecker;
> devel@linuxdriverproject.org; xen-devel@lists.xensource.com;
> virtualization@lists.linux-foundation.org
> Subject: [PATCH V2 4/4] x86: correctly detect hypervisor
> 
> We try to handle the hypervisor compatibility mode by detecting hypervisor
> through a specific order. This is not robust, since hypervisors may implement
> each others features.
> 
> This patch tries to handle this situation by always choosing the last one in the
> CPUID leaves. This is done by letting .detect() returns a priority instead of
> true/false and just re-using the CPUID leaf where the signature were found as
> the priority (or 1 if it was found by DMI). Then we can just pick hypervisor who
> has the highest priority. Other sophisticated detection method could also be
> implemented on top.
> 
> Suggested by H. Peter Anvin and Paolo Bonzini.
> 
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: H. Peter Anvin <hpa@zytor.com>
> Cc: x86@kernel.org
> Cc: K. Y. Srinivasan <kys@microsoft.com>
> Cc: Haiyang Zhang <haiyangz@microsoft.com>
> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> Cc: Jeremy Fitzhardinge <jeremy@goop.org>
> Cc: Doug Covelli <dcovelli@vmware.com>
> Cc: Borislav Petkov <bp@suse.de>
> Cc: Dan Hecht <dhecht@vmware.com>
> Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
> Cc: Marcelo Tosatti <mtosatti@redhat.com>
> Cc: Gleb Natapov <gleb@redhat.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: linux-kernel@vger.kernel.org
> Cc: devel@linuxdriverproject.org
> Cc: kvm@vger.kernel.org
> Cc: xen-devel@lists.xensource.com
> Cc: virtualization@lists.linux-foundation.org
> Signed-off-by: Jason Wang <jasowang@redhat.com>
Acked-by:  K. Y. Srinivasan <kys@microsoft.com>

> ---
>  arch/x86/include/asm/hypervisor.h |    2 +-
>  arch/x86/kernel/cpu/hypervisor.c  |   15 +++++++--------
>  arch/x86/kernel/cpu/mshyperv.c    |   13 ++++++++-----
>  arch/x86/kernel/cpu/vmware.c      |    8 ++++----
>  arch/x86/kernel/kvm.c             |    6 ++----
>  arch/x86/xen/enlighten.c          |    9 +++------
>  6 files changed, 25 insertions(+), 28 deletions(-)
> 
> diff --git a/arch/x86/include/asm/hypervisor.h
> b/arch/x86/include/asm/hypervisor.h
> index 2d4b5e6..e42f758 100644
> --- a/arch/x86/include/asm/hypervisor.h
> +++ b/arch/x86/include/asm/hypervisor.h
> @@ -33,7 +33,7 @@ struct hypervisor_x86 {
>  	const char	*name;
> 
>  	/* Detection routine */
> -	bool		(*detect)(void);
> +	uint32_t	(*detect)(void);
> 
>  	/* Adjust CPU feature bits (run once per CPU) */
>  	void		(*set_cpu_features)(struct cpuinfo_x86 *);
> diff --git a/arch/x86/kernel/cpu/hypervisor.c b/arch/x86/kernel/cpu/hypervisor.c
> index 8727921..36ce402 100644
> --- a/arch/x86/kernel/cpu/hypervisor.c
> +++ b/arch/x86/kernel/cpu/hypervisor.c
> @@ -25,11 +25,6 @@
>  #include <asm/processor.h>
>  #include <asm/hypervisor.h>
> 
> -/*
> - * Hypervisor detect order.  This is specified explicitly here because
> - * some hypervisors might implement compatibility modes for other
> - * hypervisors and therefore need to be detected in specific sequence.
> - */
>  static const __initconst struct hypervisor_x86 * const hypervisors[] =
>  {
>  #ifdef CONFIG_XEN_PVHVM
> @@ -49,15 +44,19 @@ static inline void __init
>  detect_hypervisor_vendor(void)
>  {
>  	const struct hypervisor_x86 *h, * const *p;
> +	uint32_t pri, max_pri = 0;
> 
>  	for (p = hypervisors; p < hypervisors + ARRAY_SIZE(hypervisors); p++) {
>  		h = *p;
> -		if (h->detect()) {
> +		pri = h->detect();
> +		if (pri != 0 && pri > max_pri) {
> +			max_pri = pri;
>  			x86_hyper = h;
> -			printk(KERN_INFO "Hypervisor detected: %s\n", h-
> >name);
> -			break;
>  		}
>  	}
> +
> +	if (max_pri)
> +		printk(KERN_INFO "Hypervisor detected: %s\n", x86_hyper-
> >name);
>  }
> 
>  void init_hypervisor(struct cpuinfo_x86 *c)
> diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
> index 8f4be53..71a39f3 100644
> --- a/arch/x86/kernel/cpu/mshyperv.c
> +++ b/arch/x86/kernel/cpu/mshyperv.c
> @@ -27,20 +27,23 @@
>  struct ms_hyperv_info ms_hyperv;
>  EXPORT_SYMBOL_GPL(ms_hyperv);
> 
> -static bool __init ms_hyperv_platform(void)
> +static uint32_t  __init ms_hyperv_platform(void)
>  {
>  	u32 eax;
>  	u32 hyp_signature[3];
> 
>  	if (!boot_cpu_has(X86_FEATURE_HYPERVISOR))
> -		return false;
> +		return 0;
> 
>  	cpuid(HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS,
>  	      &eax, &hyp_signature[0], &hyp_signature[1], &hyp_signature[2]);
> 
> -	return eax >= HYPERV_CPUID_MIN &&
> -		eax <= HYPERV_CPUID_MAX &&
> -		!memcmp("Microsoft Hv", hyp_signature, 12);
> +	if (eax >= HYPERV_CPUID_MIN &&
> +	    eax <= HYPERV_CPUID_MAX &&
> +	    !memcmp("Microsoft Hv", hyp_signature, 12))
> +		return HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS;
> +
> +	return 0;
>  }
> 
>  static cycle_t read_hv_clock(struct clocksource *arg)
> diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c
> index 7076878..628a059 100644
> --- a/arch/x86/kernel/cpu/vmware.c
> +++ b/arch/x86/kernel/cpu/vmware.c
> @@ -93,7 +93,7 @@ static void __init vmware_platform_setup(void)
>   * serial key should be enough, as this will always have a VMware
>   * specific string when running under VMware hypervisor.
>   */
> -static bool __init vmware_platform(void)
> +static uint32_t __init vmware_platform(void)
>  {
>  	if (cpu_has_hypervisor) {
>  		unsigned int eax;
> @@ -102,12 +102,12 @@ static bool __init vmware_platform(void)
>  		cpuid(CPUID_VMWARE_INFO_LEAF, &eax,
> &hyper_vendor_id[0],
>  		      &hyper_vendor_id[1], &hyper_vendor_id[2]);
>  		if (!memcmp(hyper_vendor_id, "VMwareVMware", 12))
> -			return true;
> +			return CPUID_VMWARE_INFO_LEAF;
>  	} else if (dmi_available && dmi_name_in_serial("VMware") &&
>  		   __vmware_platform())
> -		return true;
> +		return 1;
> 
> -	return false;
> +	return 0;
>  }
> 
>  /*
> diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
> index a96d32c..7817afd 100644
> --- a/arch/x86/kernel/kvm.c
> +++ b/arch/x86/kernel/kvm.c
> @@ -498,11 +498,9 @@ void __init kvm_guest_init(void)
>  #endif
>  }
> 
> -static bool __init kvm_detect(void)
> +static uint32_t __init kvm_detect(void)
>  {
> -	if (!kvm_para_available())
> -		return false;
> -	return true;
> +	return kvm_cpuid_base();
>  }
> 
>  const struct hypervisor_x86 x86_hyper_kvm __refconst = {
> diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
> index 193097e..2fcaedc 100644
> --- a/arch/x86/xen/enlighten.c
> +++ b/arch/x86/xen/enlighten.c
> @@ -1720,15 +1720,12 @@ static void __init xen_hvm_guest_init(void)
>  	xen_hvm_init_mmu_ops();
>  }
> 
> -static bool __init xen_hvm_platform(void)
> +static uint32_t __init xen_hvm_platform(void)
>  {
>  	if (xen_pv_domain())
> -		return false;
> -
> -	if (!xen_cpuid_base())
> -		return false;
> +		return 0;
> 
> -	return true;
> +	return xen_cpuid_base();
>  }
> 
>  bool xen_hvm_need_lapic(void)
> --
> 1.7.1
> 
> 
> 

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

* Re: [PATCH V2 4/4] x86: correctly detect hypervisor
  2013-07-25  8:54   ` Jason Wang
@ 2013-08-05  3:38     ` Jason Wang
  -1 siblings, 0 replies; 21+ messages in thread
From: Jason Wang @ 2013-08-05  3:38 UTC (permalink / raw)
  To: Jason Wang
  Cc: tglx, mingo, hpa, x86, linux-kernel, pbonzini, kvm,
	K. Y. Srinivasan, Haiyang Zhang, Konrad Rzeszutek Wilk,
	Jeremy Fitzhardinge, Doug Covelli, Borislav Petkov, Dan Hecht,
	Paul Gortmaker, Marcelo Tosatti, Gleb Natapov,
	Frederic Weisbecker, devel, xen-devel, virtualization

On 07/25/2013 04:54 PM, Jason Wang wrote:
> We try to handle the hypervisor compatibility mode by detecting hypervisor
> through a specific order. This is not robust, since hypervisors may implement
> each others features.
>
> This patch tries to handle this situation by always choosing the last one in the
> CPUID leaves. This is done by letting .detect() returns a priority instead of
> true/false and just re-using the CPUID leaf where the signature were found as
> the priority (or 1 if it was found by DMI). Then we can just pick hypervisor who
> has the highest priority. Other sophisticated detection method could also be
> implemented on top.
>
> Suggested by H. Peter Anvin and Paolo Bonzini.
>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: H. Peter Anvin <hpa@zytor.com>
> Cc: x86@kernel.org
> Cc: K. Y. Srinivasan <kys@microsoft.com>
> Cc: Haiyang Zhang <haiyangz@microsoft.com>
> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> Cc: Jeremy Fitzhardinge <jeremy@goop.org>
> Cc: Doug Covelli <dcovelli@vmware.com>
> Cc: Borislav Petkov <bp@suse.de>
> Cc: Dan Hecht <dhecht@vmware.com>
> Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
> Cc: Marcelo Tosatti <mtosatti@redhat.com>
> Cc: Gleb Natapov <gleb@redhat.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: linux-kernel@vger.kernel.org
> Cc: devel@linuxdriverproject.org
> Cc: kvm@vger.kernel.org
> Cc: xen-devel@lists.xensource.com
> Cc: virtualization@lists.linux-foundation.org
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---

Ping, any comments and acks for this series?

Thanks
>  arch/x86/include/asm/hypervisor.h |    2 +-
>  arch/x86/kernel/cpu/hypervisor.c  |   15 +++++++--------
>  arch/x86/kernel/cpu/mshyperv.c    |   13 ++++++++-----
>  arch/x86/kernel/cpu/vmware.c      |    8 ++++----
>  arch/x86/kernel/kvm.c             |    6 ++----
>  arch/x86/xen/enlighten.c          |    9 +++------
>  6 files changed, 25 insertions(+), 28 deletions(-)
>
> diff --git a/arch/x86/include/asm/hypervisor.h b/arch/x86/include/asm/hypervisor.h
> index 2d4b5e6..e42f758 100644
> --- a/arch/x86/include/asm/hypervisor.h
> +++ b/arch/x86/include/asm/hypervisor.h
> @@ -33,7 +33,7 @@ struct hypervisor_x86 {
>  	const char	*name;
>  
>  	/* Detection routine */
> -	bool		(*detect)(void);
> +	uint32_t	(*detect)(void);
>  
>  	/* Adjust CPU feature bits (run once per CPU) */
>  	void		(*set_cpu_features)(struct cpuinfo_x86 *);
> diff --git a/arch/x86/kernel/cpu/hypervisor.c b/arch/x86/kernel/cpu/hypervisor.c
> index 8727921..36ce402 100644
> --- a/arch/x86/kernel/cpu/hypervisor.c
> +++ b/arch/x86/kernel/cpu/hypervisor.c
> @@ -25,11 +25,6 @@
>  #include <asm/processor.h>
>  #include <asm/hypervisor.h>
>  
> -/*
> - * Hypervisor detect order.  This is specified explicitly here because
> - * some hypervisors might implement compatibility modes for other
> - * hypervisors and therefore need to be detected in specific sequence.
> - */
>  static const __initconst struct hypervisor_x86 * const hypervisors[] =
>  {
>  #ifdef CONFIG_XEN_PVHVM
> @@ -49,15 +44,19 @@ static inline void __init
>  detect_hypervisor_vendor(void)
>  {
>  	const struct hypervisor_x86 *h, * const *p;
> +	uint32_t pri, max_pri = 0;
>  
>  	for (p = hypervisors; p < hypervisors + ARRAY_SIZE(hypervisors); p++) {
>  		h = *p;
> -		if (h->detect()) {
> +		pri = h->detect();
> +		if (pri != 0 && pri > max_pri) {
> +			max_pri = pri;
>  			x86_hyper = h;
> -			printk(KERN_INFO "Hypervisor detected: %s\n", h->name);
> -			break;
>  		}
>  	}
> +
> +	if (max_pri)
> +		printk(KERN_INFO "Hypervisor detected: %s\n", x86_hyper->name);
>  }
>  
>  void init_hypervisor(struct cpuinfo_x86 *c)
> diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
> index 8f4be53..71a39f3 100644
> --- a/arch/x86/kernel/cpu/mshyperv.c
> +++ b/arch/x86/kernel/cpu/mshyperv.c
> @@ -27,20 +27,23 @@
>  struct ms_hyperv_info ms_hyperv;
>  EXPORT_SYMBOL_GPL(ms_hyperv);
>  
> -static bool __init ms_hyperv_platform(void)
> +static uint32_t  __init ms_hyperv_platform(void)
>  {
>  	u32 eax;
>  	u32 hyp_signature[3];
>  
>  	if (!boot_cpu_has(X86_FEATURE_HYPERVISOR))
> -		return false;
> +		return 0;
>  
>  	cpuid(HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS,
>  	      &eax, &hyp_signature[0], &hyp_signature[1], &hyp_signature[2]);
>  
> -	return eax >= HYPERV_CPUID_MIN &&
> -		eax <= HYPERV_CPUID_MAX &&
> -		!memcmp("Microsoft Hv", hyp_signature, 12);
> +	if (eax >= HYPERV_CPUID_MIN &&
> +	    eax <= HYPERV_CPUID_MAX &&
> +	    !memcmp("Microsoft Hv", hyp_signature, 12))
> +		return HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS;
> +
> +	return 0;
>  }
>  
>  static cycle_t read_hv_clock(struct clocksource *arg)
> diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c
> index 7076878..628a059 100644
> --- a/arch/x86/kernel/cpu/vmware.c
> +++ b/arch/x86/kernel/cpu/vmware.c
> @@ -93,7 +93,7 @@ static void __init vmware_platform_setup(void)
>   * serial key should be enough, as this will always have a VMware
>   * specific string when running under VMware hypervisor.
>   */
> -static bool __init vmware_platform(void)
> +static uint32_t __init vmware_platform(void)
>  {
>  	if (cpu_has_hypervisor) {
>  		unsigned int eax;
> @@ -102,12 +102,12 @@ static bool __init vmware_platform(void)
>  		cpuid(CPUID_VMWARE_INFO_LEAF, &eax, &hyper_vendor_id[0],
>  		      &hyper_vendor_id[1], &hyper_vendor_id[2]);
>  		if (!memcmp(hyper_vendor_id, "VMwareVMware", 12))
> -			return true;
> +			return CPUID_VMWARE_INFO_LEAF;
>  	} else if (dmi_available && dmi_name_in_serial("VMware") &&
>  		   __vmware_platform())
> -		return true;
> +		return 1;
>  
> -	return false;
> +	return 0;
>  }
>  
>  /*
> diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
> index a96d32c..7817afd 100644
> --- a/arch/x86/kernel/kvm.c
> +++ b/arch/x86/kernel/kvm.c
> @@ -498,11 +498,9 @@ void __init kvm_guest_init(void)
>  #endif
>  }
>  
> -static bool __init kvm_detect(void)
> +static uint32_t __init kvm_detect(void)
>  {
> -	if (!kvm_para_available())
> -		return false;
> -	return true;
> +	return kvm_cpuid_base();
>  }
>  
>  const struct hypervisor_x86 x86_hyper_kvm __refconst = {
> diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
> index 193097e..2fcaedc 100644
> --- a/arch/x86/xen/enlighten.c
> +++ b/arch/x86/xen/enlighten.c
> @@ -1720,15 +1720,12 @@ static void __init xen_hvm_guest_init(void)
>  	xen_hvm_init_mmu_ops();
>  }
>  
> -static bool __init xen_hvm_platform(void)
> +static uint32_t __init xen_hvm_platform(void)
>  {
>  	if (xen_pv_domain())
> -		return false;
> -
> -	if (!xen_cpuid_base())
> -		return false;
> +		return 0;
>  
> -	return true;
> +	return xen_cpuid_base();
>  }
>  
>  bool xen_hvm_need_lapic(void)


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

* Re: [PATCH V2 4/4] x86: correctly detect hypervisor
@ 2013-08-05  3:38     ` Jason Wang
  0 siblings, 0 replies; 21+ messages in thread
From: Jason Wang @ 2013-08-05  3:38 UTC (permalink / raw)
  To: Jason Wang
  Cc: Jeremy Fitzhardinge, Borislav Petkov, kvm, Konrad Rzeszutek Wilk,
	devel, Frederic Weisbecker, Haiyang Zhang, x86, Dan Hecht,
	linux-kernel, Doug Covelli, Paul Gortmaker, mingo, hpa, pbonzini,
	tglx, virtualization, xen-devel

On 07/25/2013 04:54 PM, Jason Wang wrote:
> We try to handle the hypervisor compatibility mode by detecting hypervisor
> through a specific order. This is not robust, since hypervisors may implement
> each others features.
>
> This patch tries to handle this situation by always choosing the last one in the
> CPUID leaves. This is done by letting .detect() returns a priority instead of
> true/false and just re-using the CPUID leaf where the signature were found as
> the priority (or 1 if it was found by DMI). Then we can just pick hypervisor who
> has the highest priority. Other sophisticated detection method could also be
> implemented on top.
>
> Suggested by H. Peter Anvin and Paolo Bonzini.
>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: H. Peter Anvin <hpa@zytor.com>
> Cc: x86@kernel.org
> Cc: K. Y. Srinivasan <kys@microsoft.com>
> Cc: Haiyang Zhang <haiyangz@microsoft.com>
> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> Cc: Jeremy Fitzhardinge <jeremy@goop.org>
> Cc: Doug Covelli <dcovelli@vmware.com>
> Cc: Borislav Petkov <bp@suse.de>
> Cc: Dan Hecht <dhecht@vmware.com>
> Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
> Cc: Marcelo Tosatti <mtosatti@redhat.com>
> Cc: Gleb Natapov <gleb@redhat.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: linux-kernel@vger.kernel.org
> Cc: devel@linuxdriverproject.org
> Cc: kvm@vger.kernel.org
> Cc: xen-devel@lists.xensource.com
> Cc: virtualization@lists.linux-foundation.org
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---

Ping, any comments and acks for this series?

Thanks
>  arch/x86/include/asm/hypervisor.h |    2 +-
>  arch/x86/kernel/cpu/hypervisor.c  |   15 +++++++--------
>  arch/x86/kernel/cpu/mshyperv.c    |   13 ++++++++-----
>  arch/x86/kernel/cpu/vmware.c      |    8 ++++----
>  arch/x86/kernel/kvm.c             |    6 ++----
>  arch/x86/xen/enlighten.c          |    9 +++------
>  6 files changed, 25 insertions(+), 28 deletions(-)
>
> diff --git a/arch/x86/include/asm/hypervisor.h b/arch/x86/include/asm/hypervisor.h
> index 2d4b5e6..e42f758 100644
> --- a/arch/x86/include/asm/hypervisor.h
> +++ b/arch/x86/include/asm/hypervisor.h
> @@ -33,7 +33,7 @@ struct hypervisor_x86 {
>  	const char	*name;
>  
>  	/* Detection routine */
> -	bool		(*detect)(void);
> +	uint32_t	(*detect)(void);
>  
>  	/* Adjust CPU feature bits (run once per CPU) */
>  	void		(*set_cpu_features)(struct cpuinfo_x86 *);
> diff --git a/arch/x86/kernel/cpu/hypervisor.c b/arch/x86/kernel/cpu/hypervisor.c
> index 8727921..36ce402 100644
> --- a/arch/x86/kernel/cpu/hypervisor.c
> +++ b/arch/x86/kernel/cpu/hypervisor.c
> @@ -25,11 +25,6 @@
>  #include <asm/processor.h>
>  #include <asm/hypervisor.h>
>  
> -/*
> - * Hypervisor detect order.  This is specified explicitly here because
> - * some hypervisors might implement compatibility modes for other
> - * hypervisors and therefore need to be detected in specific sequence.
> - */
>  static const __initconst struct hypervisor_x86 * const hypervisors[] =
>  {
>  #ifdef CONFIG_XEN_PVHVM
> @@ -49,15 +44,19 @@ static inline void __init
>  detect_hypervisor_vendor(void)
>  {
>  	const struct hypervisor_x86 *h, * const *p;
> +	uint32_t pri, max_pri = 0;
>  
>  	for (p = hypervisors; p < hypervisors + ARRAY_SIZE(hypervisors); p++) {
>  		h = *p;
> -		if (h->detect()) {
> +		pri = h->detect();
> +		if (pri != 0 && pri > max_pri) {
> +			max_pri = pri;
>  			x86_hyper = h;
> -			printk(KERN_INFO "Hypervisor detected: %s\n", h->name);
> -			break;
>  		}
>  	}
> +
> +	if (max_pri)
> +		printk(KERN_INFO "Hypervisor detected: %s\n", x86_hyper->name);
>  }
>  
>  void init_hypervisor(struct cpuinfo_x86 *c)
> diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
> index 8f4be53..71a39f3 100644
> --- a/arch/x86/kernel/cpu/mshyperv.c
> +++ b/arch/x86/kernel/cpu/mshyperv.c
> @@ -27,20 +27,23 @@
>  struct ms_hyperv_info ms_hyperv;
>  EXPORT_SYMBOL_GPL(ms_hyperv);
>  
> -static bool __init ms_hyperv_platform(void)
> +static uint32_t  __init ms_hyperv_platform(void)
>  {
>  	u32 eax;
>  	u32 hyp_signature[3];
>  
>  	if (!boot_cpu_has(X86_FEATURE_HYPERVISOR))
> -		return false;
> +		return 0;
>  
>  	cpuid(HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS,
>  	      &eax, &hyp_signature[0], &hyp_signature[1], &hyp_signature[2]);
>  
> -	return eax >= HYPERV_CPUID_MIN &&
> -		eax <= HYPERV_CPUID_MAX &&
> -		!memcmp("Microsoft Hv", hyp_signature, 12);
> +	if (eax >= HYPERV_CPUID_MIN &&
> +	    eax <= HYPERV_CPUID_MAX &&
> +	    !memcmp("Microsoft Hv", hyp_signature, 12))
> +		return HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS;
> +
> +	return 0;
>  }
>  
>  static cycle_t read_hv_clock(struct clocksource *arg)
> diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c
> index 7076878..628a059 100644
> --- a/arch/x86/kernel/cpu/vmware.c
> +++ b/arch/x86/kernel/cpu/vmware.c
> @@ -93,7 +93,7 @@ static void __init vmware_platform_setup(void)
>   * serial key should be enough, as this will always have a VMware
>   * specific string when running under VMware hypervisor.
>   */
> -static bool __init vmware_platform(void)
> +static uint32_t __init vmware_platform(void)
>  {
>  	if (cpu_has_hypervisor) {
>  		unsigned int eax;
> @@ -102,12 +102,12 @@ static bool __init vmware_platform(void)
>  		cpuid(CPUID_VMWARE_INFO_LEAF, &eax, &hyper_vendor_id[0],
>  		      &hyper_vendor_id[1], &hyper_vendor_id[2]);
>  		if (!memcmp(hyper_vendor_id, "VMwareVMware", 12))
> -			return true;
> +			return CPUID_VMWARE_INFO_LEAF;
>  	} else if (dmi_available && dmi_name_in_serial("VMware") &&
>  		   __vmware_platform())
> -		return true;
> +		return 1;
>  
> -	return false;
> +	return 0;
>  }
>  
>  /*
> diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
> index a96d32c..7817afd 100644
> --- a/arch/x86/kernel/kvm.c
> +++ b/arch/x86/kernel/kvm.c
> @@ -498,11 +498,9 @@ void __init kvm_guest_init(void)
>  #endif
>  }
>  
> -static bool __init kvm_detect(void)
> +static uint32_t __init kvm_detect(void)
>  {
> -	if (!kvm_para_available())
> -		return false;
> -	return true;
> +	return kvm_cpuid_base();
>  }
>  
>  const struct hypervisor_x86 x86_hyper_kvm __refconst = {
> diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
> index 193097e..2fcaedc 100644
> --- a/arch/x86/xen/enlighten.c
> +++ b/arch/x86/xen/enlighten.c
> @@ -1720,15 +1720,12 @@ static void __init xen_hvm_guest_init(void)
>  	xen_hvm_init_mmu_ops();
>  }
>  
> -static bool __init xen_hvm_platform(void)
> +static uint32_t __init xen_hvm_platform(void)
>  {
>  	if (xen_pv_domain())
> -		return false;
> -
> -	if (!xen_cpuid_base())
> -		return false;
> +		return 0;
>  
> -	return true;
> +	return xen_cpuid_base();
>  }
>  
>  bool xen_hvm_need_lapic(void)

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

* [tip:x86/paravirt] x86: Introduce hypervisor_cpuid_base()
  2013-07-25  8:54 [PATCH V2 1/4] x86: introduce hypervisor_cpuid_base() Jason Wang
                   ` (2 preceding siblings ...)
  2013-07-25  8:54   ` Jason Wang
@ 2013-08-05 13:57 ` tip-bot for Jason Wang
  3 siblings, 0 replies; 21+ messages in thread
From: tip-bot for Jason Wang @ 2013-08-05 13:57 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, jasowang, gleb, pbonzini, tglx, hpa

Commit-ID:  96e39ac0e9d18020c8c5a41b64b8fe86c26575ab
Gitweb:     http://git.kernel.org/tip/96e39ac0e9d18020c8c5a41b64b8fe86c26575ab
Author:     Jason Wang <jasowang@redhat.com>
AuthorDate: Thu, 25 Jul 2013 16:54:32 +0800
Committer:  H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Mon, 5 Aug 2013 06:33:54 -0700

x86: Introduce hypervisor_cpuid_base()

This patch introduce hypervisor_cpuid_base() which loop test the hypervisor
existence function until the signature match and check the number of leaves if
required. This could be used by Xen/KVM guest to detect the existence of
hypervisor.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Link: http://lkml.kernel.org/r/1374742475-2485-1-git-send-email-jasowang@redhat.com
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
 arch/x86/include/asm/processor.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index 24cf5ae..7763307 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -971,6 +971,21 @@ unsigned long calc_aperfmperf_ratio(struct aperfmperf *old,
 	return ratio;
 }
 
+static inline uint32_t hypervisor_cpuid_base(const char *sig, uint32_t leaves)
+{
+	uint32_t base, eax, signature[3];
+
+	for (base = 0x40000000; base < 0x40010000; base += 0x100) {
+		cpuid(base, &eax, &signature[0], &signature[1], &signature[2]);
+
+		if (!memcmp(sig, signature, 12) &&
+		    (leaves == 0 || ((eax - base) >= leaves)))
+			return base;
+	}
+
+	return 0;
+}
+
 extern unsigned long arch_align_stack(unsigned long sp);
 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
 

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

* [tip:x86/paravirt] xen: Switch to use hypervisor_cpuid_base()
  2013-07-25  8:54   ` Jason Wang
  (?)
@ 2013-08-05 13:57   ` tip-bot for Jason Wang
  -1 siblings, 0 replies; 21+ messages in thread
From: tip-bot for Jason Wang @ 2013-08-05 13:57 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, konrad.wilk, jasowang, jeremy,
	pbonzini, tglx, hpa

Commit-ID:  448ac44d561f0aba5baac54bac62fe40d07230b6
Gitweb:     http://git.kernel.org/tip/448ac44d561f0aba5baac54bac62fe40d07230b6
Author:     Jason Wang <jasowang@redhat.com>
AuthorDate: Thu, 25 Jul 2013 16:54:33 +0800
Committer:  H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Mon, 5 Aug 2013 06:34:09 -0700

xen: Switch to use hypervisor_cpuid_base()

Switch to use hypervisor_cpuid_base() to detect Xen.

Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Link: http://lkml.kernel.org/r/1374742475-2485-2-git-send-email-jasowang@redhat.com
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
 arch/x86/include/asm/xen/hypervisor.h | 16 +---------------
 1 file changed, 1 insertion(+), 15 deletions(-)

diff --git a/arch/x86/include/asm/xen/hypervisor.h b/arch/x86/include/asm/xen/hypervisor.h
index 125f344..d866959 100644
--- a/arch/x86/include/asm/xen/hypervisor.h
+++ b/arch/x86/include/asm/xen/hypervisor.h
@@ -40,21 +40,7 @@ extern struct start_info *xen_start_info;
 
 static inline uint32_t xen_cpuid_base(void)
 {
-	uint32_t base, eax, ebx, ecx, edx;
-	char signature[13];
-
-	for (base = 0x40000000; base < 0x40010000; base += 0x100) {
-		cpuid(base, &eax, &ebx, &ecx, &edx);
-		*(uint32_t *)(signature + 0) = ebx;
-		*(uint32_t *)(signature + 4) = ecx;
-		*(uint32_t *)(signature + 8) = edx;
-		signature[12] = 0;
-
-		if (!strcmp("XenVMMXenVMM", signature) && ((eax - base) >= 2))
-			return base;
-	}
-
-	return 0;
+	return hypervisor_cpuid_base("XenVMMXenVMM", 2);
 }
 
 #ifdef CONFIG_XEN

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

* [tip:x86/paravirt] x86, kvm: Switch to use hypervisor_cpuid_base( )
  2013-07-25  8:54 ` [PATCH V2 3/4] kvm: switch " Jason Wang
@ 2013-08-05 13:58   ` tip-bot for Jason Wang
  0 siblings, 0 replies; 21+ messages in thread
From: tip-bot for Jason Wang @ 2013-08-05 13:58 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, jasowang, gleb, pbonzini, tglx, hpa

Commit-ID:  1085ba7f552d84aa8ac0ae903fa8d0cc2ff9f79d
Gitweb:     http://git.kernel.org/tip/1085ba7f552d84aa8ac0ae903fa8d0cc2ff9f79d
Author:     Jason Wang <jasowang@redhat.com>
AuthorDate: Thu, 25 Jul 2013 16:54:34 +0800
Committer:  H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Mon, 5 Aug 2013 06:34:33 -0700

x86, kvm: Switch to use hypervisor_cpuid_base()

Switch to use hypervisor_cpuid_base() to detect KVM.

Cc: Gleb Natapov <gleb@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Link: http://lkml.kernel.org/r/1374742475-2485-3-git-send-email-jasowang@redhat.com
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
 arch/x86/include/asm/kvm_para.h | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/arch/x86/include/asm/kvm_para.h b/arch/x86/include/asm/kvm_para.h
index 695399f..0644129 100644
--- a/arch/x86/include/asm/kvm_para.h
+++ b/arch/x86/include/asm/kvm_para.h
@@ -85,26 +85,20 @@ static inline long kvm_hypercall4(unsigned int nr, unsigned long p1,
 	return ret;
 }
 
-static inline bool kvm_para_available(void)
+static inline uint32_t kvm_cpuid_base(void)
 {
-	unsigned int eax, ebx, ecx, edx;
-	char signature[13];
-
 	if (boot_cpu_data.cpuid_level < 0)
-		return false;	/* So we don't blow up on old processors */
+		return 0;	/* So we don't blow up on old processors */
 
-	if (cpu_has_hypervisor) {
-		cpuid(KVM_CPUID_SIGNATURE, &eax, &ebx, &ecx, &edx);
-		memcpy(signature + 0, &ebx, 4);
-		memcpy(signature + 4, &ecx, 4);
-		memcpy(signature + 8, &edx, 4);
-		signature[12] = 0;
+	if (cpu_has_hypervisor)
+		return hypervisor_cpuid_base("KVMKVMKVM\0\0\0", 0);
 
-		if (strcmp(signature, "KVMKVMKVM") == 0)
-			return true;
-	}
+	return 0;
+}
 
-	return false;
+static inline bool kvm_para_available(void)
+{
+	return kvm_cpuid_base() != 0;
 }
 
 static inline unsigned int kvm_arch_para_features(void)

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

* [tip:x86/paravirt] x86: Correctly detect hypervisor
  2013-07-25  8:54   ` Jason Wang
                     ` (3 preceding siblings ...)
  (?)
@ 2013-08-05 13:58   ` tip-bot for Jason Wang
  -1 siblings, 0 replies; 21+ messages in thread
From: tip-bot for Jason Wang @ 2013-08-05 13:58 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: dhecht, mingo, konrad.wilk, dcovelli, jasowang, jeremy, fweisbec,
	pbonzini, mtosatti, tglx, linux-kernel, hpa, kys, haiyangz, gleb,
	hpa, bp, paul.gortmaker

Commit-ID:  9df56f19a500bea90d160be1bf77e4fbcd204d3f
Gitweb:     http://git.kernel.org/tip/9df56f19a500bea90d160be1bf77e4fbcd204d3f
Author:     Jason Wang <jasowang@redhat.com>
AuthorDate: Thu, 25 Jul 2013 16:54:35 +0800
Committer:  H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Mon, 5 Aug 2013 06:35:33 -0700

x86: Correctly detect hypervisor

We try to handle the hypervisor compatibility mode by detecting hypervisor
through a specific order. This is not robust, since hypervisors may implement
each others features.

This patch tries to handle this situation by always choosing the last one in the
CPUID leaves. This is done by letting .detect() return a priority instead of
true/false and just re-using the CPUID leaf where the signature were found as
the priority (or 1 if it was found by DMI). Then we can just pick hypervisor who
has the highest priority. Other sophisticated detection method could also be
implemented on top.

Suggested by H. Peter Anvin and Paolo Bonzini.

Acked-by: K. Y. Srinivasan <kys@microsoft.com>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Doug Covelli <dcovelli@vmware.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: Dan Hecht <dhecht@vmware.com>
Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Gleb Natapov <gleb@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Link: http://lkml.kernel.org/r/1374742475-2485-4-git-send-email-jasowang@redhat.com
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
 arch/x86/include/asm/hypervisor.h |  2 +-
 arch/x86/kernel/cpu/hypervisor.c  | 15 +++++++--------
 arch/x86/kernel/cpu/mshyperv.c    | 13 ++++++++-----
 arch/x86/kernel/cpu/vmware.c      |  8 ++++----
 arch/x86/kernel/kvm.c             |  6 ++----
 arch/x86/xen/enlighten.c          |  9 +++------
 6 files changed, 25 insertions(+), 28 deletions(-)

diff --git a/arch/x86/include/asm/hypervisor.h b/arch/x86/include/asm/hypervisor.h
index 2d4b5e6..e42f758 100644
--- a/arch/x86/include/asm/hypervisor.h
+++ b/arch/x86/include/asm/hypervisor.h
@@ -33,7 +33,7 @@ struct hypervisor_x86 {
 	const char	*name;
 
 	/* Detection routine */
-	bool		(*detect)(void);
+	uint32_t	(*detect)(void);
 
 	/* Adjust CPU feature bits (run once per CPU) */
 	void		(*set_cpu_features)(struct cpuinfo_x86 *);
diff --git a/arch/x86/kernel/cpu/hypervisor.c b/arch/x86/kernel/cpu/hypervisor.c
index 8727921..36ce402 100644
--- a/arch/x86/kernel/cpu/hypervisor.c
+++ b/arch/x86/kernel/cpu/hypervisor.c
@@ -25,11 +25,6 @@
 #include <asm/processor.h>
 #include <asm/hypervisor.h>
 
-/*
- * Hypervisor detect order.  This is specified explicitly here because
- * some hypervisors might implement compatibility modes for other
- * hypervisors and therefore need to be detected in specific sequence.
- */
 static const __initconst struct hypervisor_x86 * const hypervisors[] =
 {
 #ifdef CONFIG_XEN_PVHVM
@@ -49,15 +44,19 @@ static inline void __init
 detect_hypervisor_vendor(void)
 {
 	const struct hypervisor_x86 *h, * const *p;
+	uint32_t pri, max_pri = 0;
 
 	for (p = hypervisors; p < hypervisors + ARRAY_SIZE(hypervisors); p++) {
 		h = *p;
-		if (h->detect()) {
+		pri = h->detect();
+		if (pri != 0 && pri > max_pri) {
+			max_pri = pri;
 			x86_hyper = h;
-			printk(KERN_INFO "Hypervisor detected: %s\n", h->name);
-			break;
 		}
 	}
+
+	if (max_pri)
+		printk(KERN_INFO "Hypervisor detected: %s\n", x86_hyper->name);
 }
 
 void init_hypervisor(struct cpuinfo_x86 *c)
diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
index 8f4be53..71a39f3 100644
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -27,20 +27,23 @@
 struct ms_hyperv_info ms_hyperv;
 EXPORT_SYMBOL_GPL(ms_hyperv);
 
-static bool __init ms_hyperv_platform(void)
+static uint32_t  __init ms_hyperv_platform(void)
 {
 	u32 eax;
 	u32 hyp_signature[3];
 
 	if (!boot_cpu_has(X86_FEATURE_HYPERVISOR))
-		return false;
+		return 0;
 
 	cpuid(HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS,
 	      &eax, &hyp_signature[0], &hyp_signature[1], &hyp_signature[2]);
 
-	return eax >= HYPERV_CPUID_MIN &&
-		eax <= HYPERV_CPUID_MAX &&
-		!memcmp("Microsoft Hv", hyp_signature, 12);
+	if (eax >= HYPERV_CPUID_MIN &&
+	    eax <= HYPERV_CPUID_MAX &&
+	    !memcmp("Microsoft Hv", hyp_signature, 12))
+		return HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS;
+
+	return 0;
 }
 
 static cycle_t read_hv_clock(struct clocksource *arg)
diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c
index 7076878..628a059 100644
--- a/arch/x86/kernel/cpu/vmware.c
+++ b/arch/x86/kernel/cpu/vmware.c
@@ -93,7 +93,7 @@ static void __init vmware_platform_setup(void)
  * serial key should be enough, as this will always have a VMware
  * specific string when running under VMware hypervisor.
  */
-static bool __init vmware_platform(void)
+static uint32_t __init vmware_platform(void)
 {
 	if (cpu_has_hypervisor) {
 		unsigned int eax;
@@ -102,12 +102,12 @@ static bool __init vmware_platform(void)
 		cpuid(CPUID_VMWARE_INFO_LEAF, &eax, &hyper_vendor_id[0],
 		      &hyper_vendor_id[1], &hyper_vendor_id[2]);
 		if (!memcmp(hyper_vendor_id, "VMwareVMware", 12))
-			return true;
+			return CPUID_VMWARE_INFO_LEAF;
 	} else if (dmi_available && dmi_name_in_serial("VMware") &&
 		   __vmware_platform())
-		return true;
+		return 1;
 
-	return false;
+	return 0;
 }
 
 /*
diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index a96d32c..7817afd 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -498,11 +498,9 @@ void __init kvm_guest_init(void)
 #endif
 }
 
-static bool __init kvm_detect(void)
+static uint32_t __init kvm_detect(void)
 {
-	if (!kvm_para_available())
-		return false;
-	return true;
+	return kvm_cpuid_base();
 }
 
 const struct hypervisor_x86 x86_hyper_kvm __refconst = {
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 193097e..2fcaedc 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -1720,15 +1720,12 @@ static void __init xen_hvm_guest_init(void)
 	xen_hvm_init_mmu_ops();
 }
 
-static bool __init xen_hvm_platform(void)
+static uint32_t __init xen_hvm_platform(void)
 {
 	if (xen_pv_domain())
-		return false;
-
-	if (!xen_cpuid_base())
-		return false;
+		return 0;
 
-	return true;
+	return xen_cpuid_base();
 }
 
 bool xen_hvm_need_lapic(void)

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

* Re: [PATCH V2 4/4] x86: correctly detect hypervisor
  2013-08-05  3:38     ` Jason Wang
@ 2013-08-05 14:34       ` Konrad Rzeszutek Wilk
  -1 siblings, 0 replies; 21+ messages in thread
From: Konrad Rzeszutek Wilk @ 2013-08-05 14:34 UTC (permalink / raw)
  To: Jason Wang
  Cc: tglx, mingo, hpa, x86, linux-kernel, pbonzini, kvm,
	K. Y. Srinivasan, Haiyang Zhang, Jeremy Fitzhardinge,
	Doug Covelli, Borislav Petkov, Dan Hecht, Paul Gortmaker,
	Marcelo Tosatti, Gleb Natapov, Frederic Weisbecker, devel,
	xen-devel, virtualization

On Mon, Aug 05, 2013 at 11:38:14AM +0800, Jason Wang wrote:
> On 07/25/2013 04:54 PM, Jason Wang wrote:
> > We try to handle the hypervisor compatibility mode by detecting hypervisor
> > through a specific order. This is not robust, since hypervisors may implement
> > each others features.
> >
> > This patch tries to handle this situation by always choosing the last one in the
> > CPUID leaves. This is done by letting .detect() returns a priority instead of
> > true/false and just re-using the CPUID leaf where the signature were found as
> > the priority (or 1 if it was found by DMI). Then we can just pick hypervisor who
> > has the highest priority. Other sophisticated detection method could also be
> > implemented on top.
> >
> > Suggested by H. Peter Anvin and Paolo Bonzini.
> >
> > Cc: Thomas Gleixner <tglx@linutronix.de>
> > Cc: Ingo Molnar <mingo@redhat.com>
> > Cc: H. Peter Anvin <hpa@zytor.com>
> > Cc: x86@kernel.org
> > Cc: K. Y. Srinivasan <kys@microsoft.com>
> > Cc: Haiyang Zhang <haiyangz@microsoft.com>
> > Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> > Cc: Jeremy Fitzhardinge <jeremy@goop.org>
> > Cc: Doug Covelli <dcovelli@vmware.com>
> > Cc: Borislav Petkov <bp@suse.de>
> > Cc: Dan Hecht <dhecht@vmware.com>
> > Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
> > Cc: Marcelo Tosatti <mtosatti@redhat.com>
> > Cc: Gleb Natapov <gleb@redhat.com>
> > Cc: Paolo Bonzini <pbonzini@redhat.com>
> > Cc: Frederic Weisbecker <fweisbec@gmail.com>
> > Cc: linux-kernel@vger.kernel.org
> > Cc: devel@linuxdriverproject.org
> > Cc: kvm@vger.kernel.org
> > Cc: xen-devel@lists.xensource.com
> > Cc: virtualization@lists.linux-foundation.org
> > Signed-off-by: Jason Wang <jasowang@redhat.com>
> > ---
> 
> Ping, any comments and acks for this series?

Could you provide me with a git branch so I can test it overnight please?

> 
> Thanks
> >  arch/x86/include/asm/hypervisor.h |    2 +-
> >  arch/x86/kernel/cpu/hypervisor.c  |   15 +++++++--------
> >  arch/x86/kernel/cpu/mshyperv.c    |   13 ++++++++-----
> >  arch/x86/kernel/cpu/vmware.c      |    8 ++++----
> >  arch/x86/kernel/kvm.c             |    6 ++----
> >  arch/x86/xen/enlighten.c          |    9 +++------
> >  6 files changed, 25 insertions(+), 28 deletions(-)
> >
> > diff --git a/arch/x86/include/asm/hypervisor.h b/arch/x86/include/asm/hypervisor.h
> > index 2d4b5e6..e42f758 100644
> > --- a/arch/x86/include/asm/hypervisor.h
> > +++ b/arch/x86/include/asm/hypervisor.h
> > @@ -33,7 +33,7 @@ struct hypervisor_x86 {
> >  	const char	*name;
> >  
> >  	/* Detection routine */
> > -	bool		(*detect)(void);
> > +	uint32_t	(*detect)(void);
> >  
> >  	/* Adjust CPU feature bits (run once per CPU) */
> >  	void		(*set_cpu_features)(struct cpuinfo_x86 *);
> > diff --git a/arch/x86/kernel/cpu/hypervisor.c b/arch/x86/kernel/cpu/hypervisor.c
> > index 8727921..36ce402 100644
> > --- a/arch/x86/kernel/cpu/hypervisor.c
> > +++ b/arch/x86/kernel/cpu/hypervisor.c
> > @@ -25,11 +25,6 @@
> >  #include <asm/processor.h>
> >  #include <asm/hypervisor.h>
> >  
> > -/*
> > - * Hypervisor detect order.  This is specified explicitly here because
> > - * some hypervisors might implement compatibility modes for other
> > - * hypervisors and therefore need to be detected in specific sequence.
> > - */
> >  static const __initconst struct hypervisor_x86 * const hypervisors[] =
> >  {
> >  #ifdef CONFIG_XEN_PVHVM
> > @@ -49,15 +44,19 @@ static inline void __init
> >  detect_hypervisor_vendor(void)
> >  {
> >  	const struct hypervisor_x86 *h, * const *p;
> > +	uint32_t pri, max_pri = 0;
> >  
> >  	for (p = hypervisors; p < hypervisors + ARRAY_SIZE(hypervisors); p++) {
> >  		h = *p;
> > -		if (h->detect()) {
> > +		pri = h->detect();
> > +		if (pri != 0 && pri > max_pri) {
> > +			max_pri = pri;
> >  			x86_hyper = h;
> > -			printk(KERN_INFO "Hypervisor detected: %s\n", h->name);
> > -			break;
> >  		}
> >  	}
> > +
> > +	if (max_pri)
> > +		printk(KERN_INFO "Hypervisor detected: %s\n", x86_hyper->name);
> >  }
> >  
> >  void init_hypervisor(struct cpuinfo_x86 *c)
> > diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
> > index 8f4be53..71a39f3 100644
> > --- a/arch/x86/kernel/cpu/mshyperv.c
> > +++ b/arch/x86/kernel/cpu/mshyperv.c
> > @@ -27,20 +27,23 @@
> >  struct ms_hyperv_info ms_hyperv;
> >  EXPORT_SYMBOL_GPL(ms_hyperv);
> >  
> > -static bool __init ms_hyperv_platform(void)
> > +static uint32_t  __init ms_hyperv_platform(void)
> >  {
> >  	u32 eax;
> >  	u32 hyp_signature[3];
> >  
> >  	if (!boot_cpu_has(X86_FEATURE_HYPERVISOR))
> > -		return false;
> > +		return 0;
> >  
> >  	cpuid(HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS,
> >  	      &eax, &hyp_signature[0], &hyp_signature[1], &hyp_signature[2]);
> >  
> > -	return eax >= HYPERV_CPUID_MIN &&
> > -		eax <= HYPERV_CPUID_MAX &&
> > -		!memcmp("Microsoft Hv", hyp_signature, 12);
> > +	if (eax >= HYPERV_CPUID_MIN &&
> > +	    eax <= HYPERV_CPUID_MAX &&
> > +	    !memcmp("Microsoft Hv", hyp_signature, 12))
> > +		return HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS;
> > +
> > +	return 0;
> >  }
> >  
> >  static cycle_t read_hv_clock(struct clocksource *arg)
> > diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c
> > index 7076878..628a059 100644
> > --- a/arch/x86/kernel/cpu/vmware.c
> > +++ b/arch/x86/kernel/cpu/vmware.c
> > @@ -93,7 +93,7 @@ static void __init vmware_platform_setup(void)
> >   * serial key should be enough, as this will always have a VMware
> >   * specific string when running under VMware hypervisor.
> >   */
> > -static bool __init vmware_platform(void)
> > +static uint32_t __init vmware_platform(void)
> >  {
> >  	if (cpu_has_hypervisor) {
> >  		unsigned int eax;
> > @@ -102,12 +102,12 @@ static bool __init vmware_platform(void)
> >  		cpuid(CPUID_VMWARE_INFO_LEAF, &eax, &hyper_vendor_id[0],
> >  		      &hyper_vendor_id[1], &hyper_vendor_id[2]);
> >  		if (!memcmp(hyper_vendor_id, "VMwareVMware", 12))
> > -			return true;
> > +			return CPUID_VMWARE_INFO_LEAF;
> >  	} else if (dmi_available && dmi_name_in_serial("VMware") &&
> >  		   __vmware_platform())
> > -		return true;
> > +		return 1;
> >  
> > -	return false;
> > +	return 0;
> >  }
> >  
> >  /*
> > diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
> > index a96d32c..7817afd 100644
> > --- a/arch/x86/kernel/kvm.c
> > +++ b/arch/x86/kernel/kvm.c
> > @@ -498,11 +498,9 @@ void __init kvm_guest_init(void)
> >  #endif
> >  }
> >  
> > -static bool __init kvm_detect(void)
> > +static uint32_t __init kvm_detect(void)
> >  {
> > -	if (!kvm_para_available())
> > -		return false;
> > -	return true;
> > +	return kvm_cpuid_base();
> >  }
> >  
> >  const struct hypervisor_x86 x86_hyper_kvm __refconst = {
> > diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
> > index 193097e..2fcaedc 100644
> > --- a/arch/x86/xen/enlighten.c
> > +++ b/arch/x86/xen/enlighten.c
> > @@ -1720,15 +1720,12 @@ static void __init xen_hvm_guest_init(void)
> >  	xen_hvm_init_mmu_ops();
> >  }
> >  
> > -static bool __init xen_hvm_platform(void)
> > +static uint32_t __init xen_hvm_platform(void)
> >  {
> >  	if (xen_pv_domain())
> > -		return false;
> > -
> > -	if (!xen_cpuid_base())
> > -		return false;
> > +		return 0;
> >  
> > -	return true;
> > +	return xen_cpuid_base();
> >  }
> >  
> >  bool xen_hvm_need_lapic(void)
> 

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

* Re: [PATCH V2 4/4] x86: correctly detect hypervisor
@ 2013-08-05 14:34       ` Konrad Rzeszutek Wilk
  0 siblings, 0 replies; 21+ messages in thread
From: Konrad Rzeszutek Wilk @ 2013-08-05 14:34 UTC (permalink / raw)
  To: Jason Wang
  Cc: Jeremy Fitzhardinge, Borislav Petkov, kvm, devel,
	Frederic Weisbecker, Haiyang Zhang, x86, Dan Hecht, linux-kernel,
	Doug Covelli, Paul Gortmaker, mingo, hpa, pbonzini, tglx,
	virtualization, xen-devel

On Mon, Aug 05, 2013 at 11:38:14AM +0800, Jason Wang wrote:
> On 07/25/2013 04:54 PM, Jason Wang wrote:
> > We try to handle the hypervisor compatibility mode by detecting hypervisor
> > through a specific order. This is not robust, since hypervisors may implement
> > each others features.
> >
> > This patch tries to handle this situation by always choosing the last one in the
> > CPUID leaves. This is done by letting .detect() returns a priority instead of
> > true/false and just re-using the CPUID leaf where the signature were found as
> > the priority (or 1 if it was found by DMI). Then we can just pick hypervisor who
> > has the highest priority. Other sophisticated detection method could also be
> > implemented on top.
> >
> > Suggested by H. Peter Anvin and Paolo Bonzini.
> >
> > Cc: Thomas Gleixner <tglx@linutronix.de>
> > Cc: Ingo Molnar <mingo@redhat.com>
> > Cc: H. Peter Anvin <hpa@zytor.com>
> > Cc: x86@kernel.org
> > Cc: K. Y. Srinivasan <kys@microsoft.com>
> > Cc: Haiyang Zhang <haiyangz@microsoft.com>
> > Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> > Cc: Jeremy Fitzhardinge <jeremy@goop.org>
> > Cc: Doug Covelli <dcovelli@vmware.com>
> > Cc: Borislav Petkov <bp@suse.de>
> > Cc: Dan Hecht <dhecht@vmware.com>
> > Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
> > Cc: Marcelo Tosatti <mtosatti@redhat.com>
> > Cc: Gleb Natapov <gleb@redhat.com>
> > Cc: Paolo Bonzini <pbonzini@redhat.com>
> > Cc: Frederic Weisbecker <fweisbec@gmail.com>
> > Cc: linux-kernel@vger.kernel.org
> > Cc: devel@linuxdriverproject.org
> > Cc: kvm@vger.kernel.org
> > Cc: xen-devel@lists.xensource.com
> > Cc: virtualization@lists.linux-foundation.org
> > Signed-off-by: Jason Wang <jasowang@redhat.com>
> > ---
> 
> Ping, any comments and acks for this series?

Could you provide me with a git branch so I can test it overnight please?

> 
> Thanks
> >  arch/x86/include/asm/hypervisor.h |    2 +-
> >  arch/x86/kernel/cpu/hypervisor.c  |   15 +++++++--------
> >  arch/x86/kernel/cpu/mshyperv.c    |   13 ++++++++-----
> >  arch/x86/kernel/cpu/vmware.c      |    8 ++++----
> >  arch/x86/kernel/kvm.c             |    6 ++----
> >  arch/x86/xen/enlighten.c          |    9 +++------
> >  6 files changed, 25 insertions(+), 28 deletions(-)
> >
> > diff --git a/arch/x86/include/asm/hypervisor.h b/arch/x86/include/asm/hypervisor.h
> > index 2d4b5e6..e42f758 100644
> > --- a/arch/x86/include/asm/hypervisor.h
> > +++ b/arch/x86/include/asm/hypervisor.h
> > @@ -33,7 +33,7 @@ struct hypervisor_x86 {
> >  	const char	*name;
> >  
> >  	/* Detection routine */
> > -	bool		(*detect)(void);
> > +	uint32_t	(*detect)(void);
> >  
> >  	/* Adjust CPU feature bits (run once per CPU) */
> >  	void		(*set_cpu_features)(struct cpuinfo_x86 *);
> > diff --git a/arch/x86/kernel/cpu/hypervisor.c b/arch/x86/kernel/cpu/hypervisor.c
> > index 8727921..36ce402 100644
> > --- a/arch/x86/kernel/cpu/hypervisor.c
> > +++ b/arch/x86/kernel/cpu/hypervisor.c
> > @@ -25,11 +25,6 @@
> >  #include <asm/processor.h>
> >  #include <asm/hypervisor.h>
> >  
> > -/*
> > - * Hypervisor detect order.  This is specified explicitly here because
> > - * some hypervisors might implement compatibility modes for other
> > - * hypervisors and therefore need to be detected in specific sequence.
> > - */
> >  static const __initconst struct hypervisor_x86 * const hypervisors[] =
> >  {
> >  #ifdef CONFIG_XEN_PVHVM
> > @@ -49,15 +44,19 @@ static inline void __init
> >  detect_hypervisor_vendor(void)
> >  {
> >  	const struct hypervisor_x86 *h, * const *p;
> > +	uint32_t pri, max_pri = 0;
> >  
> >  	for (p = hypervisors; p < hypervisors + ARRAY_SIZE(hypervisors); p++) {
> >  		h = *p;
> > -		if (h->detect()) {
> > +		pri = h->detect();
> > +		if (pri != 0 && pri > max_pri) {
> > +			max_pri = pri;
> >  			x86_hyper = h;
> > -			printk(KERN_INFO "Hypervisor detected: %s\n", h->name);
> > -			break;
> >  		}
> >  	}
> > +
> > +	if (max_pri)
> > +		printk(KERN_INFO "Hypervisor detected: %s\n", x86_hyper->name);
> >  }
> >  
> >  void init_hypervisor(struct cpuinfo_x86 *c)
> > diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
> > index 8f4be53..71a39f3 100644
> > --- a/arch/x86/kernel/cpu/mshyperv.c
> > +++ b/arch/x86/kernel/cpu/mshyperv.c
> > @@ -27,20 +27,23 @@
> >  struct ms_hyperv_info ms_hyperv;
> >  EXPORT_SYMBOL_GPL(ms_hyperv);
> >  
> > -static bool __init ms_hyperv_platform(void)
> > +static uint32_t  __init ms_hyperv_platform(void)
> >  {
> >  	u32 eax;
> >  	u32 hyp_signature[3];
> >  
> >  	if (!boot_cpu_has(X86_FEATURE_HYPERVISOR))
> > -		return false;
> > +		return 0;
> >  
> >  	cpuid(HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS,
> >  	      &eax, &hyp_signature[0], &hyp_signature[1], &hyp_signature[2]);
> >  
> > -	return eax >= HYPERV_CPUID_MIN &&
> > -		eax <= HYPERV_CPUID_MAX &&
> > -		!memcmp("Microsoft Hv", hyp_signature, 12);
> > +	if (eax >= HYPERV_CPUID_MIN &&
> > +	    eax <= HYPERV_CPUID_MAX &&
> > +	    !memcmp("Microsoft Hv", hyp_signature, 12))
> > +		return HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS;
> > +
> > +	return 0;
> >  }
> >  
> >  static cycle_t read_hv_clock(struct clocksource *arg)
> > diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c
> > index 7076878..628a059 100644
> > --- a/arch/x86/kernel/cpu/vmware.c
> > +++ b/arch/x86/kernel/cpu/vmware.c
> > @@ -93,7 +93,7 @@ static void __init vmware_platform_setup(void)
> >   * serial key should be enough, as this will always have a VMware
> >   * specific string when running under VMware hypervisor.
> >   */
> > -static bool __init vmware_platform(void)
> > +static uint32_t __init vmware_platform(void)
> >  {
> >  	if (cpu_has_hypervisor) {
> >  		unsigned int eax;
> > @@ -102,12 +102,12 @@ static bool __init vmware_platform(void)
> >  		cpuid(CPUID_VMWARE_INFO_LEAF, &eax, &hyper_vendor_id[0],
> >  		      &hyper_vendor_id[1], &hyper_vendor_id[2]);
> >  		if (!memcmp(hyper_vendor_id, "VMwareVMware", 12))
> > -			return true;
> > +			return CPUID_VMWARE_INFO_LEAF;
> >  	} else if (dmi_available && dmi_name_in_serial("VMware") &&
> >  		   __vmware_platform())
> > -		return true;
> > +		return 1;
> >  
> > -	return false;
> > +	return 0;
> >  }
> >  
> >  /*
> > diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
> > index a96d32c..7817afd 100644
> > --- a/arch/x86/kernel/kvm.c
> > +++ b/arch/x86/kernel/kvm.c
> > @@ -498,11 +498,9 @@ void __init kvm_guest_init(void)
> >  #endif
> >  }
> >  
> > -static bool __init kvm_detect(void)
> > +static uint32_t __init kvm_detect(void)
> >  {
> > -	if (!kvm_para_available())
> > -		return false;
> > -	return true;
> > +	return kvm_cpuid_base();
> >  }
> >  
> >  const struct hypervisor_x86 x86_hyper_kvm __refconst = {
> > diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
> > index 193097e..2fcaedc 100644
> > --- a/arch/x86/xen/enlighten.c
> > +++ b/arch/x86/xen/enlighten.c
> > @@ -1720,15 +1720,12 @@ static void __init xen_hvm_guest_init(void)
> >  	xen_hvm_init_mmu_ops();
> >  }
> >  
> > -static bool __init xen_hvm_platform(void)
> > +static uint32_t __init xen_hvm_platform(void)
> >  {
> >  	if (xen_pv_domain())
> > -		return false;
> > -
> > -	if (!xen_cpuid_base())
> > -		return false;
> > +		return 0;
> >  
> > -	return true;
> > +	return xen_cpuid_base();
> >  }
> >  
> >  bool xen_hvm_need_lapic(void)
> 

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

* Re: [PATCH V2 4/4] x86: correctly detect hypervisor
  2013-08-05 14:34       ` Konrad Rzeszutek Wilk
@ 2013-08-05 15:20         ` H. Peter Anvin
  -1 siblings, 0 replies; 21+ messages in thread
From: H. Peter Anvin @ 2013-08-05 15:20 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk
  Cc: Jason Wang, tglx, mingo, x86, linux-kernel, pbonzini, kvm,
	K. Y. Srinivasan, Haiyang Zhang, Jeremy Fitzhardinge,
	Doug Covelli, Borislav Petkov, Dan Hecht, Paul Gortmaker,
	Marcelo Tosatti, Gleb Natapov, Frederic Weisbecker, devel,
	xen-devel, virtualization

On 08/05/2013 07:34 AM, Konrad Rzeszutek Wilk wrote:
> 
> Could you provide me with a git branch so I can test it overnight please?
> 

Pull tip:x86/paravirt.

	-hpa



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

* Re: [PATCH V2 4/4] x86: correctly detect hypervisor
@ 2013-08-05 15:20         ` H. Peter Anvin
  0 siblings, 0 replies; 21+ messages in thread
From: H. Peter Anvin @ 2013-08-05 15:20 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk
  Cc: xen-devel, Jeremy Fitzhardinge, Borislav Petkov, kvm,
	Frederic Weisbecker, x86, Dan Hecht, linux-kernel, Doug Covelli,
	Paul Gortmaker, mingo, devel, pbonzini, tglx, virtualization,
	Haiyang Zhang

On 08/05/2013 07:34 AM, Konrad Rzeszutek Wilk wrote:
> 
> Could you provide me with a git branch so I can test it overnight please?
> 

Pull tip:x86/paravirt.

	-hpa

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

* Re: [PATCH V2 4/4] x86: correctly detect hypervisor
  2013-08-05 15:20         ` H. Peter Anvin
@ 2013-08-05 16:50           ` Konrad Rzeszutek Wilk
  -1 siblings, 0 replies; 21+ messages in thread
From: Konrad Rzeszutek Wilk @ 2013-08-05 16:50 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: Jason Wang, tglx, mingo, x86, linux-kernel, pbonzini, kvm,
	K. Y. Srinivasan, Haiyang Zhang, Jeremy Fitzhardinge,
	Doug Covelli, Borislav Petkov, Dan Hecht, Paul Gortmaker,
	Marcelo Tosatti, Gleb Natapov, Frederic Weisbecker, devel,
	xen-devel, virtualization

On Mon, Aug 05, 2013 at 08:20:53AM -0700, H. Peter Anvin wrote:
> On 08/05/2013 07:34 AM, Konrad Rzeszutek Wilk wrote:
> > 
> > Could you provide me with a git branch so I can test it overnight please?
> > 
> 
> Pull tip:x86/paravirt.

It works for me. Thanks.
> 
> 	-hpa
> 
> 

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

* Re: [PATCH V2 4/4] x86: correctly detect hypervisor
@ 2013-08-05 16:50           ` Konrad Rzeszutek Wilk
  0 siblings, 0 replies; 21+ messages in thread
From: Konrad Rzeszutek Wilk @ 2013-08-05 16:50 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: xen-devel, Jeremy Fitzhardinge, Borislav Petkov, kvm,
	Frederic Weisbecker, x86, Dan Hecht, linux-kernel, Doug Covelli,
	Paul Gortmaker, mingo, devel, pbonzini, tglx, virtualization,
	Haiyang Zhang

On Mon, Aug 05, 2013 at 08:20:53AM -0700, H. Peter Anvin wrote:
> On 08/05/2013 07:34 AM, Konrad Rzeszutek Wilk wrote:
> > 
> > Could you provide me with a git branch so I can test it overnight please?
> > 
> 
> Pull tip:x86/paravirt.

It works for me. Thanks.
> 
> 	-hpa
> 
> 

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

end of thread, other threads:[~2013-08-05 16:50 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-25  8:54 [PATCH V2 1/4] x86: introduce hypervisor_cpuid_base() Jason Wang
2013-07-25  8:54 ` [PATCH V2 2/4] xen: switch to use hypervisor_cpuid_base() Jason Wang
2013-07-25  8:54   ` Jason Wang
2013-08-05 13:57   ` [tip:x86/paravirt] xen: Switch " tip-bot for Jason Wang
2013-07-25  8:54 ` [PATCH V2 3/4] kvm: switch " Jason Wang
2013-08-05 13:58   ` [tip:x86/paravirt] x86, kvm: Switch to use hypervisor_cpuid_base( ) tip-bot for Jason Wang
2013-07-25  8:54 ` [PATCH V2 4/4] x86: correctly detect hypervisor Jason Wang
2013-07-25  8:54   ` Jason Wang
2013-07-25 10:56   ` KY Srinivasan
2013-07-25 10:56     ` KY Srinivasan
2013-07-25 10:56   ` KY Srinivasan
2013-08-05  3:38   ` Jason Wang
2013-08-05  3:38     ` Jason Wang
2013-08-05 14:34     ` Konrad Rzeszutek Wilk
2013-08-05 14:34       ` Konrad Rzeszutek Wilk
2013-08-05 15:20       ` H. Peter Anvin
2013-08-05 15:20         ` H. Peter Anvin
2013-08-05 16:50         ` Konrad Rzeszutek Wilk
2013-08-05 16:50           ` Konrad Rzeszutek Wilk
2013-08-05 13:58   ` [tip:x86/paravirt] x86: Correctly " tip-bot for Jason Wang
2013-08-05 13:57 ` [tip:x86/paravirt] x86: Introduce hypervisor_cpuid_base() tip-bot for Jason Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.