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 2/2] tell cpuinfo if we're running on top of KVM
Date: Thu, 5 Feb 2009 13:42:21 -0500 [thread overview]
Message-ID: <1233859341-10419-3-git-send-email-glommer@redhat.com> (raw)
In-Reply-To: <1233859341-10419-2-git-send-email-glommer@redhat.com>
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
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 ` [PATCH 1/2] show hypervisor information on cpuinfo Glauber Costa
2009-02-05 18:42 ` Glauber Costa [this message]
2009-02-05 18:53 ` 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-3-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