Commit | Line | Data |
---|---|---|
a2a47c6c KS |
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 | |
9fa02317 | 9 | * the Free Software Foundation; version 2 of the License. |
a2a47c6c KS |
10 | * |
11 | */ | |
12 | ||
13 | #include <linux/types.h> | |
14 | #include <asm/processor.h> | |
15 | #include <asm/hyperv.h> | |
16 | #include <asm/mshyperv.h> | |
17 | ||
18 | ||
19 | int ms_hyperv_platform(void) | |
20 | { | |
21 | u32 eax, ebx, ecx, edx; | |
22 | char hyp_signature[13]; | |
23 | ||
24 | cpuid(1, &eax, &ebx, &ecx, &edx); | |
25 | if (!(ecx & HYPERV_HYPERVISOR_PRESENT_BIT)) | |
26 | return 0; | |
27 | ||
28 | cpuid(HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS, &eax, &ebx, &ecx, &edx); | |
29 | *(u32 *)(hyp_signature + 0) = ebx; | |
30 | *(u32 *)(hyp_signature + 4) = ecx; | |
31 | *(u32 *)(hyp_signature + 8) = edx; | |
32 | ||
33 | if ((eax < HYPERV_CPUID_MIN) || (memcmp("Microsoft Hv", hyp_signature, 12))) | |
34 | return 0; | |
35 | return 1; | |
36 | } | |
37 | ||
38 | void __cpuinit ms_hyperv_set_feature_bits(struct cpuinfo_x86 *c) | |
39 | { | |
40 | u32 eax, ebx, ecx, edx; | |
41 | ||
42 | c->x86_hyper_features = 0; | |
43 | /* | |
44 | * Extract the features, recommendations etc. | |
45 | * The first 9 bits will be used to track hypervisor features. | |
46 | * The next 6 bits will be used to track the hypervisor | |
47 | * recommendations. | |
48 | */ | |
49 | cpuid(HYPERV_CPUID_FEATURES, &eax, &ebx, &ecx, &edx); | |
50 | c->x86_hyper_features |= (eax & 0x1ff); | |
51 | ||
52 | cpuid(HYPERV_CPUID_ENLIGHTMENT_INFO, &eax, &ebx, &ecx, &edx); | |
53 | c->x86_hyper_features |= ((eax & 0x3f) << 9); | |
54 | printk(KERN_INFO "Detected HyperV with features: %x\n", | |
55 | c->x86_hyper_features); | |
56 | } |