]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - arch/x86/kernel/cpu/mshyperv.c
2443b61cdb1725aa25d43f68dc0ee7bc4b46a212
[karo-tx-linux.git] / arch / x86 / kernel / cpu / mshyperv.c
1 /*
2  * HyperV  Detection code.
3  *
4  * Copyright (C) 2010, Novell, Inc.
5  * Author : K. Y. Srinivasan <ksrinivasan@novell.com>
6  *
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.
11  *
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
16  * details.
17  *
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.
21  *
22  */
23
24 #include <linux/types.h>
25 #include <asm/processor.h>
26 #include <asm/hyperv.h>
27 #include <asm/mshyperv.h>
28
29
30 int ms_hyperv_platform(void)
31 {
32         u32 eax, ebx, ecx, edx;
33         char hyp_signature[13];
34
35         cpuid(1, &eax, &ebx, &ecx, &edx);
36         if (!(ecx & HYPERV_HYPERVISOR_PRESENT_BIT))
37                 return 0;
38
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;
43
44         if ((eax < HYPERV_CPUID_MIN) || (memcmp("Microsoft Hv", hyp_signature, 12)))
45                 return 0;
46         return 1;
47 }
48
49 void __cpuinit ms_hyperv_set_feature_bits(struct cpuinfo_x86 *c)
50 {
51         u32 eax, ebx, ecx, edx;
52
53         c->x86_hyper_features = 0;
54         /*
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
58          * recommendations.
59          */
60         cpuid(HYPERV_CPUID_FEATURES, &eax, &ebx, &ecx, &edx);
61         c->x86_hyper_features |= (eax & 0x1ff);
62
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);
67 }