From: Glauber Costa <gcosta@xxxxxxxxxx> 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@xxxxxxxxxx> --- 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 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html