lkml.org 
[lkml]   [2009]   [Feb]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/2] tell cpuinfo if we're running on top of KVM
Date
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.

Signed-off-by: Glauber Costa <glommer@redhat.com>
---
arch/x86/include/asm/processor.h | 1 +
arch/x86/kernel/cpu/hypervisor.c | 3 +++
2 files changed, 4 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 fb5b86a..ee1b228 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;
}
--
1.5.6.5


\
 
 \ /
  Last update: 2009-02-06 16:51    [W:0.187 / U:0.168 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site