public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] expose hypervisor information on cpuid
@ 2009-02-05 18:42 Glauber Costa
  2009-02-05 18:42 ` [PATCH 1/2] show hypervisor information on cpuinfo Glauber Costa
  2009-02-05 18:52 ` [PATCH 0/2] expose hypervisor information on cpuid Chris Wright
  0 siblings, 2 replies; 9+ messages in thread
From: Glauber Costa @ 2009-02-05 18:42 UTC (permalink / raw)
  To: kvm; +Cc: linux-kernel, mingo, avi, akataria

This discussion happened some days ago in kvm list.
We believe it's useful to advertise hypervisor information
somewhere. /proc/cpuinfo appears as one good candidate.

This patch shows this information for vmware, kvm, and the
string "none", otherwise. (someone would have to do it for xen,
and possibly others, if this patch is to be accepted).



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

* [PATCH 1/2] show hypervisor information on cpuinfo
  2009-02-05 18:42 [PATCH 0/2] expose hypervisor information on cpuid Glauber Costa
@ 2009-02-05 18:42 ` Glauber Costa
  2009-02-05 18:42   ` [PATCH 2/2] tell cpuinfo if we're running on top of KVM Glauber Costa
                     ` (2 more replies)
  2009-02-05 18:52 ` [PATCH 0/2] expose hypervisor information on cpuid Chris Wright
  1 sibling, 3 replies; 9+ messages in thread
From: Glauber Costa @ 2009-02-05 18:42 UTC (permalink / raw)
  To: kvm; +Cc: linux-kernel, mingo, avi, akataria, Glauber Costa

From: Glauber Costa <gcosta@redhat.com>

It is useful to easily grab information about whether or not
we're running on top of a hypervisor. And in case affirmative,
which one.

This patch shows it in a newly added "hypervisor" field to cpuinfo.
This seems to me like the best suited place for this.

We currently differentiate between vmware and none.

Signed-off-by: Glauber Costa <gcosta@redhat.com>
---
 arch/x86/include/asm/hypervisor.h |    1 +
 arch/x86/kernel/cpu/hypervisor.c  |    8 ++++++++
 arch/x86/kernel/cpu/proc.c        |    8 ++++++--
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/hypervisor.h b/arch/x86/include/asm/hypervisor.h
index 369f5c5..a0c0b0f 100644
--- a/arch/x86/include/asm/hypervisor.h
+++ b/arch/x86/include/asm/hypervisor.h
@@ -22,5 +22,6 @@
 
 extern unsigned long get_hypervisor_tsc_freq(void);
 extern void init_hypervisor(struct cpuinfo_x86 *c);
+extern char *hypervisor_str(struct cpuinfo_x86 *c);
 
 #endif
diff --git a/arch/x86/kernel/cpu/hypervisor.c b/arch/x86/kernel/cpu/hypervisor.c
index fb5b86a..8c3fca7 100644
--- a/arch/x86/kernel/cpu/hypervisor.c
+++ b/arch/x86/kernel/cpu/hypervisor.c
@@ -51,6 +51,14 @@ hypervisor_set_feature_bits(struct cpuinfo_x86 *c)
 	}
 }
 
+char * __cpuinit hypervisor_str(struct cpuinfo_x86 *c)
+{
+	if (c->x86_hyper_vendor == X86_HYPER_VENDOR_VMWARE)
+		return "VMWare";
+	else
+		return "none";
+}
+
 void __cpuinit init_hypervisor(struct cpuinfo_x86 *c)
 {
 	detect_hypervisor_vendor(c);
diff --git a/arch/x86/kernel/cpu/proc.c b/arch/x86/kernel/cpu/proc.c
index 01b1244..3700607 100644
--- a/arch/x86/kernel/cpu/proc.c
+++ b/arch/x86/kernel/cpu/proc.c
@@ -4,6 +4,8 @@
 #include <linux/seq_file.h>
 #include <linux/cpufreq.h>
 
+#include <asm/hypervisor.h>
+
 /*
  *	Get CPU information for use by the procfs.
  */
@@ -90,12 +92,14 @@ static int show_cpuinfo(struct seq_file *m, void *v)
 		   "vendor_id\t: %s\n"
 		   "cpu family\t: %d\n"
 		   "model\t\t: %u\n"
-		   "model name\t: %s\n",
+		   "model name\t: %s\n"
+		   "hypervisor\t: %s\n",
 		   cpu,
 		   c->x86_vendor_id[0] ? c->x86_vendor_id : "unknown",
 		   c->x86,
 		   c->x86_model,
-		   c->x86_model_id[0] ? c->x86_model_id : "unknown");
+		   c->x86_model_id[0] ? c->x86_model_id : "unknown",
+		   hypervisor_str(c));
 
 	if (c->x86_mask || c->cpuid_level >= 0)
 		seq_printf(m, "stepping\t: %d\n", c->x86_mask);
-- 
1.5.6.5


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

* [PATCH 2/2] tell cpuinfo if we're running on top of KVM
  2009-02-05 18:42 ` [PATCH 1/2] show hypervisor information on cpuinfo Glauber Costa
@ 2009-02-05 18:42   ` Glauber Costa
  2009-02-05 18:53   ` [PATCH 1/2] show hypervisor information on cpuinfo Alok Kataria
  2009-02-05 19:02   ` Ingo Molnar
  2 siblings, 0 replies; 9+ messages in thread
From: Glauber Costa @ 2009-02-05 18:42 UTC (permalink / raw)
  To: kvm; +Cc: linux-kernel, mingo, avi, akataria, Glauber Costa

From: Glauber Costa <gcosta@redhat.com>

KVM has a specific cpuid signature, for a long time now. It's currently
used in the kernel to advertise the possible availability of paravirt
functions, but it's safe to assume that any reasonably recent kvm
hypervisor will sign cpuid this way, regardless of any pv capability.

Use this information to fill in the hypervisor field in cpuinfo.

Signed-off-by: Glauber Costa <gcosta@redhat.com>
---
 arch/x86/include/asm/processor.h |    1 +
 arch/x86/kernel/cpu/hypervisor.c |    5 +++++
 2 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index 091cd88..919c08d 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -126,6 +126,7 @@ struct cpuinfo_x86 {
 
 #define X86_HYPER_VENDOR_NONE  0
 #define X86_HYPER_VENDOR_VMWARE 1
+#define X86_HYPER_VENDOR_KVM	2
 
 /*
  * capabilities of CPUs
diff --git a/arch/x86/kernel/cpu/hypervisor.c b/arch/x86/kernel/cpu/hypervisor.c
index 8c3fca7..251817a 100644
--- a/arch/x86/kernel/cpu/hypervisor.c
+++ b/arch/x86/kernel/cpu/hypervisor.c
@@ -23,6 +23,7 @@
 
 #include <asm/processor.h>
 #include <asm/vmware.h>
+#include <asm/kvm_para.h>
 #include <asm/hypervisor.h>
 
 static inline void __cpuinit
@@ -30,6 +31,8 @@ detect_hypervisor_vendor(struct cpuinfo_x86 *c)
 {
 	if (vmware_platform()) {
 		c->x86_hyper_vendor = X86_HYPER_VENDOR_VMWARE;
+	} else if (kvm_para_available()) {
+		c->x86_hyper_vendor = X86_HYPER_VENDOR_KVM;
 	} else {
 		c->x86_hyper_vendor = X86_HYPER_VENDOR_NONE;
 	}
@@ -55,6 +58,8 @@ char * __cpuinit hypervisor_str(struct cpuinfo_x86 *c)
 {
 	if (c->x86_hyper_vendor == X86_HYPER_VENDOR_VMWARE)
 		return "VMWare";
+	else if (c->x86_hyper_vendor == X86_HYPER_VENDOR_KVM)
+		return "KVM";
 	else
 		return "none";
 }
-- 
1.5.6.5


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

* Re: [PATCH 0/2] expose hypervisor information on cpuid
  2009-02-05 18:42 [PATCH 0/2] expose hypervisor information on cpuid Glauber Costa
  2009-02-05 18:42 ` [PATCH 1/2] show hypervisor information on cpuinfo Glauber Costa
@ 2009-02-05 18:52 ` Chris Wright
  2009-02-05 19:04   ` Glauber Costa
  1 sibling, 1 reply; 9+ messages in thread
From: Chris Wright @ 2009-02-05 18:52 UTC (permalink / raw)
  To: Glauber Costa; +Cc: kvm, linux-kernel, mingo, avi, akataria

* Glauber Costa (glommer@redhat.com) wrote:
> This discussion happened some days ago in kvm list.
> We believe it's useful to advertise hypervisor information
> somewhere. /proc/cpuinfo appears as one good candidate.

What's wrong with /sys/hypervisor?  That's what it's there for.

thanks,
-chris

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

* Re: [PATCH 1/2] show hypervisor information on cpuinfo
  2009-02-05 18:42 ` [PATCH 1/2] show hypervisor information on cpuinfo Glauber Costa
  2009-02-05 18:42   ` [PATCH 2/2] tell cpuinfo if we're running on top of KVM Glauber Costa
@ 2009-02-05 18:53   ` Alok Kataria
  2009-02-05 19:02   ` Ingo Molnar
  2 siblings, 0 replies; 9+ messages in thread
From: Alok Kataria @ 2009-02-05 18:53 UTC (permalink / raw)
  To: Glauber Costa
  Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, mingo@elte.hu,
	avi@redhat.com, Glauber Costa

I am all for it.

Just one nit, below.

>  
> +char * __cpuinit hypervisor_str(struct cpuinfo_x86 *c)
> +{
> +	if (c->x86_hyper_vendor == X86_HYPER_VENDOR_VMWARE)
> +		return "VMWare";

Better to have "VMware" string instead.

Thanks,
Alok


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

* Re: [PATCH 1/2] show hypervisor information on cpuinfo
  2009-02-05 18:42 ` [PATCH 1/2] show hypervisor information on cpuinfo Glauber Costa
  2009-02-05 18:42   ` [PATCH 2/2] tell cpuinfo if we're running on top of KVM Glauber Costa
  2009-02-05 18:53   ` [PATCH 1/2] show hypervisor information on cpuinfo Alok Kataria
@ 2009-02-05 19:02   ` Ingo Molnar
  2009-02-05 19:05     ` Chris Wright
  2009-02-05 19:08     ` Anthony Liguori
  2 siblings, 2 replies; 9+ messages in thread
From: Ingo Molnar @ 2009-02-05 19:02 UTC (permalink / raw)
  To: Glauber Costa; +Cc: kvm, linux-kernel, avi, akataria, Glauber Costa


* Glauber Costa <glommer@redhat.com> wrote:

> +char * __cpuinit hypervisor_str(struct cpuinfo_x86 *c)
> +{
> +	if (c->x86_hyper_vendor == X86_HYPER_VENDOR_VMWARE)
> +		return "VMWare";
> +	else
> +		return "none";
> +}

i'd suggest these variants instead:

 virtualization:	native kernel
 virtualization:	KVM guest
 virtualization:	VMWare guest
 virtualization:	Linux guest

	Ingo

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

* Re: [PATCH 0/2] expose hypervisor information on cpuid
  2009-02-05 18:52 ` [PATCH 0/2] expose hypervisor information on cpuid Chris Wright
@ 2009-02-05 19:04   ` Glauber Costa
  0 siblings, 0 replies; 9+ messages in thread
From: Glauber Costa @ 2009-02-05 19:04 UTC (permalink / raw)
  To: Chris Wright; +Cc: kvm, linux-kernel, mingo, avi, akataria

On Thu, Feb 05, 2009 at 10:52:07AM -0800, Chris Wright wrote:
> * Glauber Costa (glommer@redhat.com) wrote:
> > This discussion happened some days ago in kvm list.
> > We believe it's useful to advertise hypervisor information
> > somewhere. /proc/cpuinfo appears as one good candidate.
> 
> What's wrong with /sys/hypervisor?  That's what it's there for.
> 
I believe cpuinfo provides a more standard interface for that.
But I'm not opposed to your suggestion.

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

* Re: [PATCH 1/2] show hypervisor information on cpuinfo
  2009-02-05 19:02   ` Ingo Molnar
@ 2009-02-05 19:05     ` Chris Wright
  2009-02-05 19:08     ` Anthony Liguori
  1 sibling, 0 replies; 9+ messages in thread
From: Chris Wright @ 2009-02-05 19:05 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Glauber Costa, kvm, linux-kernel, avi, akataria, Glauber Costa

* Ingo Molnar (mingo@elte.hu) wrote:
>  virtualization:	Linux guest

That's confusing.  Meaning lguest?  These are all Linux guests ;-)

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

* Re: [PATCH 1/2] show hypervisor information on cpuinfo
  2009-02-05 19:02   ` Ingo Molnar
  2009-02-05 19:05     ` Chris Wright
@ 2009-02-05 19:08     ` Anthony Liguori
  1 sibling, 0 replies; 9+ messages in thread
From: Anthony Liguori @ 2009-02-05 19:08 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Glauber Costa, kvm, linux-kernel, avi, akataria, Glauber Costa

Ingo Molnar wrote:
> * Glauber Costa <glommer@redhat.com> wrote:
>
>   
>> +char * __cpuinit hypervisor_str(struct cpuinfo_x86 *c)
>> +{
>> +	if (c->x86_hyper_vendor == X86_HYPER_VENDOR_VMWARE)
>> +		return "VMWare";
>> +	else
>> +		return "none";
>> +}
>>     
>
> i'd suggest these variants instead:
>
>  virtualization:	native kernel
>   

I don't think "native kernel" really ports well to other architectures 
(like s390 or PPC) that always have hypervisors present in some form.  I 
think "none" makes more sense in the case of bare metal x86.

Regards,

Anthony Liguori

>  virtualization:	KVM guest
>  virtualization:	VMWare guest
>  virtualization:	Linux guest
>
> 	Ingo
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>   


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

end of thread, other threads:[~2009-02-05 19:53 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-05 18:42 [PATCH 0/2] expose hypervisor information on cpuid Glauber Costa
2009-02-05 18:42 ` [PATCH 1/2] show hypervisor information on cpuinfo Glauber Costa
2009-02-05 18:42   ` [PATCH 2/2] tell cpuinfo if we're running on top of KVM Glauber Costa
2009-02-05 18:53   ` [PATCH 1/2] show hypervisor information on cpuinfo Alok Kataria
2009-02-05 19:02   ` Ingo Molnar
2009-02-05 19:05     ` Chris Wright
2009-02-05 19:08     ` Anthony Liguori
2009-02-05 18:52 ` [PATCH 0/2] expose hypervisor information on cpuid Chris Wright
2009-02-05 19:04   ` Glauber Costa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox