From: Glauber Costa <glommer@redhat.com>
To: kvm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, mingo@elte.hu, avi@redhat.com,
akataria@vmware.com, Glauber Costa <gcosta@redhat.com>
Subject: [PATCH 1/2] show hypervisor information on cpuinfo
Date: Thu, 5 Feb 2009 13:42:20 -0500 [thread overview]
Message-ID: <1233859341-10419-2-git-send-email-glommer@redhat.com> (raw)
In-Reply-To: <1233859341-10419-1-git-send-email-glommer@redhat.com>
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
next prev parent reply other threads:[~2009-02-05 18:42 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-05 18:42 [PATCH 0/2] expose hypervisor information on cpuid Glauber Costa
2009-02-05 18:42 ` Glauber Costa [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1233859341-10419-2-git-send-email-glommer@redhat.com \
--to=glommer@redhat.com \
--cc=akataria@vmware.com \
--cc=avi@redhat.com \
--cc=gcosta@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox