From patchwork Thu Feb 5 18:42:21 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glauber Costa X-Patchwork-Id: 5698 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n15IggHr006260 for ; Thu, 5 Feb 2009 18:42:43 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755853AbZBESmk (ORCPT ); Thu, 5 Feb 2009 13:42:40 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755689AbZBESmk (ORCPT ); Thu, 5 Feb 2009 13:42:40 -0500 Received: from mx2.redhat.com ([66.187.237.31]:35674 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753908AbZBESmi (ORCPT ); Thu, 5 Feb 2009 13:42:38 -0500 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n15IgOAF030040; Thu, 5 Feb 2009 13:42:24 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n15IgOgP021840; Thu, 5 Feb 2009 13:42:24 -0500 Received: from localhost.localdomain (virtlab1.virt.bos.redhat.com [10.16.72.21]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n15IgMTs027915; Thu, 5 Feb 2009 13:42:24 -0500 From: Glauber Costa To: kvm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, mingo@elte.hu, avi@redhat.com, akataria@vmware.com, Glauber Costa Subject: [PATCH 2/2] tell cpuinfo if we're running on top of KVM Date: Thu, 5 Feb 2009 13:42:21 -0500 Message-Id: <1233859341-10419-3-git-send-email-glommer@redhat.com> In-Reply-To: <1233859341-10419-2-git-send-email-glommer@redhat.com> References: <1233859341-10419-1-git-send-email-glommer@redhat.com> <1233859341-10419-2-git-send-email-glommer@redhat.com> X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Glauber Costa 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 --- 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 #include +#include #include 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"; }