lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu,  5 Feb 2009 13:42:20 -0500
From:	Glauber Costa <glommer@...hat.com>
To:	kvm@...r.kernel.org
Cc:	linux-kernel@...r.kernel.org, mingo@...e.hu, avi@...hat.com,
	akataria@...are.com, Glauber Costa <gcosta@...hat.com>
Subject: [PATCH 1/2] show hypervisor information on cpuinfo

From: Glauber Costa <gcosta@...hat.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@...hat.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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ