2 * HyperV Detection code.
4 * Copyright (C) 2010, Novell, Inc.
5 * Author : K. Y. Srinivasan <ksrinivasan@novell.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
15 * NON INFRINGEMENT. See the GNU General Public License for more
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24 #include <linux/types.h>
25 #include <asm/processor.h>
26 #include <asm/hyperv.h>
27 #include <asm/mshyperv.h>
30 int ms_hyperv_platform(void)
32 u32 eax, ebx, ecx, edx;
33 char hyp_signature[13];
35 cpuid(1, &eax, &ebx, &ecx, &edx);
36 if (!(ecx & HYPERV_HYPERVISOR_PRESENT_BIT))
39 cpuid(HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS, &eax, &ebx, &ecx, &edx);
40 *(u32 *)(hyp_signature + 0) = ebx;
41 *(u32 *)(hyp_signature + 4) = ecx;
42 *(u32 *)(hyp_signature + 8) = edx;
44 if ((eax < HYPERV_CPUID_MIN) || (memcmp("Microsoft Hv", hyp_signature, 12)))
49 void __cpuinit ms_hyperv_set_feature_bits(struct cpuinfo_x86 *c)
51 u32 eax, ebx, ecx, edx;
53 c->x86_hyper_features = 0;
55 * Extract the features, recommendations etc.
56 * The first 9 bits will be used to track hypervisor features.
57 * The next 6 bits will be used to track the hypervisor
60 cpuid(HYPERV_CPUID_FEATURES, &eax, &ebx, &ecx, &edx);
61 c->x86_hyper_features |= (eax & 0x1ff);
63 cpuid(HYPERV_CPUID_ENLIGHTMENT_INFO, &eax, &ebx, &ecx, &edx);
64 c->x86_hyper_features |= ((eax & 0x3f) << 9);
65 printk(KERN_INFO "Detected HyperV with features: %x\n",
66 c->x86_hyper_features);