From patchwork Fri Oct 12 19:56:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Don Slutz X-Patchwork-Id: 1588251 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 0323C3FC1A for ; Fri, 12 Oct 2012 19:57:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751435Ab2JLT5n (ORCPT ); Fri, 12 Oct 2012 15:57:43 -0400 Received: from hub021-nj-6.exch021.serverdata.net ([206.225.164.222]:62352 "EHLO hub021-nj-6.exch021.serverdata.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751246Ab2JLT5m (ORCPT ); Fri, 12 Oct 2012 15:57:42 -0400 Received: from localhost.localdomain (152.179.192.130) by east.exch021.serverdata.net (10.240.4.93) with Microsoft SMTP Server (TLS) id 14.2.309.2; Fri, 12 Oct 2012 12:57:49 -0700 From: Don Slutz To: , , , , , , , , CC: Don Slutz Subject: [PATCH v7 14/17] target-i386: Add vmare as a known name to Hypervisor vendor. Date: Fri, 12 Oct 2012 15:56:19 -0400 Message-ID: <1350071782-23078-15-git-send-email-Don@CloudSwitch.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1350071782-23078-1-git-send-email-Don@CloudSwitch.com> References: <1350071782-23078-1-git-send-email-Don@CloudSwitch.com> MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Part of "target-i386: Add way to expose VMWare CPUID" Also adds some other known names (kvm, hyperv) to Hypervisor vendor. This allows "hypervisor-vendor=vmware3" instead of "hypervisor-vendor=VMwareVMware,hypervisor-level=2,hypervisor-features=0". And "hypervisor-vendor=vmware" instead of "hypervisor-vendor=VMwareVMware,hypervisor-level=0x10,hypervisor-features=0". This is based on: VMware documention on CPUIDs (Mechanisms to determine if software is running in a VMware virtual machine): http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458 Signed-off-by: Don Slutz --- target-i386/cpu.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++- target-i386/cpu.h | 9 ++++++++ 2 files changed, 66 insertions(+), 1 deletions(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index f058add..c8466ec 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -1203,6 +1203,23 @@ static char *x86_cpuid_get_hv_vendor(Object *obj, Error **errp) } value[CPUID_VENDOR_SZ] = '\0'; + /* Convert known names */ + if (!strcmp(value, CPUID_HV_VENDOR_HYPERV) && + env->cpuid_hv_level == CPUID_HV_LEVEL_HYPERV_CPUID_MIN && + env->cpuid_hv_features_set == CPUID_HV_FEATURES_HYPERV) { + pstrcpy(value, sizeof(value), "hyperv"); + } else if (!strcmp(value, CPUID_HV_VENDOR_VMWARE) && + env->cpuid_hv_features_set == CPUID_HV_FEATURES_VMWARE) { + if (env->cpuid_hv_level == CPUID_HV_LEVEL_VMWARE_4) { + pstrcpy(value, sizeof(value), "vmware4"); + } else if (env->cpuid_hv_level == CPUID_HV_LEVEL_VMWARE_3) { + pstrcpy(value, sizeof(value), "vmware3"); + } + } else if (!strcmp(value, CPUID_HV_VENDOR_KVM) && + (env->cpuid_hv_level == CPUID_HV_LEVEL_KVM_0 || + env->cpuid_hv_level == CPUID_HV_LEVEL_KVM_1)) { + pstrcpy(value, sizeof(value), "kvm"); + } return value; } @@ -1216,7 +1233,46 @@ static void x86_cpuid_set_hv_vendor(Object *obj, const char *value, memset(adj_value, 0, sizeof(adj_value)); - pstrcpy(adj_value, sizeof(adj_value), value); + /* Convert known names */ + if (!strcmp(value, "hyperv")) { + if (!env->cpuid_hv_level_set) { + object_property_set_int(obj, CPUID_HV_LEVEL_HYPERV_CPUID_MIN, + "hypervisor-level", errp); + } + if (!env->cpuid_hv_features_set) { + object_property_set_int(obj, CPUID_HV_FEATURES_HYPERV, + "hypervisor-features", errp); + } + pstrcpy(adj_value, sizeof(adj_value), CPUID_HV_VENDOR_HYPERV); + } else if (!strcmp(value, "vmware") || !strcmp(value, "vmware4")) { + if (!env->cpuid_hv_level_set) { + object_property_set_int(obj, CPUID_HV_LEVEL_VMWARE_4, + "hypervisor-level", errp); + } + if (!env->cpuid_hv_features_set) { + object_property_set_int(obj, CPUID_HV_FEATURES_VMWARE, + "hypervisor-features", errp); + } + pstrcpy(adj_value, sizeof(adj_value), CPUID_HV_VENDOR_VMWARE); + } else if (!strcmp(value, "vmware3")) { + if (!env->cpuid_hv_level_set) { + object_property_set_int(obj, CPUID_HV_LEVEL_VMWARE_3, + "hypervisor-level", errp); + } + if (!env->cpuid_hv_features_set) { + object_property_set_int(obj, CPUID_HV_FEATURES_VMWARE, + "hypervisor-features", errp); + } + pstrcpy(adj_value, sizeof(adj_value), CPUID_HV_VENDOR_VMWARE); + } else if (!strcmp(value, "kvm")) { + if (!env->cpuid_hv_level_set) { + object_property_set_int(obj, CPUID_HV_LEVEL_KVM_1, + "hypervisor-level", errp); + } + pstrcpy(adj_value, sizeof(adj_value), CPUID_HV_VENDOR_KVM); + } else { + pstrcpy(adj_value, sizeof(adj_value), value); + } env->cpuid_hv_vendor1 = 0; env->cpuid_hv_vendor2 = 0; diff --git a/target-i386/cpu.h b/target-i386/cpu.h index 6ceef05..a387d82 100644 --- a/target-i386/cpu.h +++ b/target-i386/cpu.h @@ -498,6 +498,15 @@ #define CPUID_HV_VENDOR_HYPERV "Microsoft Hv" #define CPUID_HV_FEATURES_HYPERV 0x31237648 /* "Hv#1" */ +#define CPUID_HV_LEVEL_VMWARE_3 0x40000002 +#define CPUID_HV_LEVEL_VMWARE_4 0x40000010 +#define CPUID_HV_VENDOR_VMWARE "VMwareVMware" +#define CPUID_HV_FEATURES_VMWARE 0 + +#define CPUID_HV_LEVEL_KVM_0 0 +#define CPUID_HV_LEVEL_KVM_1 0x40000001 +#define CPUID_HV_VENDOR_KVM "KVMKVMKVM" + #define CPUID_MWAIT_IBE (1 << 1) /* Interrupts can exit capability */ #define CPUID_MWAIT_EMX (1 << 0) /* enumeration supported */