diff options
| -rw-r--r-- | arch/x86/kernel/cpu/intel.c | 41 | ||||
| -rw-r--r-- | include/asm-x86/cpufeature.h | 9 |
2 files changed, 49 insertions, 1 deletions
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c index 5f76bf139fda..99468dbd08da 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c | |||
| @@ -196,6 +196,44 @@ static int __cpuinit intel_num_cpu_cores(struct cpuinfo_x86 *c) | |||
| 196 | return 1; | 196 | return 1; |
| 197 | } | 197 | } |
| 198 | 198 | ||
| 199 | static void __cpuinit detect_vmx_virtcap(struct cpuinfo_x86 *c) | ||
| 200 | { | ||
| 201 | /* Intel VMX MSR indicated features */ | ||
| 202 | #define X86_VMX_FEATURE_PROC_CTLS_TPR_SHADOW 0x00200000 | ||
| 203 | #define X86_VMX_FEATURE_PROC_CTLS_VNMI 0x00400000 | ||
| 204 | #define X86_VMX_FEATURE_PROC_CTLS_2ND_CTLS 0x80000000 | ||
| 205 | #define X86_VMX_FEATURE_PROC_CTLS2_VIRT_APIC 0x00000001 | ||
| 206 | #define X86_VMX_FEATURE_PROC_CTLS2_EPT 0x00000002 | ||
| 207 | #define X86_VMX_FEATURE_PROC_CTLS2_VPID 0x00000020 | ||
| 208 | |||
| 209 | u32 vmx_msr_low, vmx_msr_high, msr_ctl, msr_ctl2; | ||
| 210 | |||
| 211 | clear_cpu_cap(c, X86_FEATURE_TPR_SHADOW); | ||
| 212 | clear_cpu_cap(c, X86_FEATURE_VNMI); | ||
| 213 | clear_cpu_cap(c, X86_FEATURE_FLEXPRIORITY); | ||
| 214 | clear_cpu_cap(c, X86_FEATURE_EPT); | ||
| 215 | clear_cpu_cap(c, X86_FEATURE_VPID); | ||
| 216 | |||
| 217 | rdmsr(MSR_IA32_VMX_PROCBASED_CTLS, vmx_msr_low, vmx_msr_high); | ||
| 218 | msr_ctl = vmx_msr_high | vmx_msr_low; | ||
| 219 | if (msr_ctl & X86_VMX_FEATURE_PROC_CTLS_TPR_SHADOW) | ||
| 220 | set_cpu_cap(c, X86_FEATURE_TPR_SHADOW); | ||
| 221 | if (msr_ctl & X86_VMX_FEATURE_PROC_CTLS_VNMI) | ||
| 222 | set_cpu_cap(c, X86_FEATURE_VNMI); | ||
| 223 | if (msr_ctl & X86_VMX_FEATURE_PROC_CTLS_2ND_CTLS) { | ||
| 224 | rdmsr(MSR_IA32_VMX_PROCBASED_CTLS2, | ||
| 225 | vmx_msr_low, vmx_msr_high); | ||
| 226 | msr_ctl2 = vmx_msr_high | vmx_msr_low; | ||
| 227 | if ((msr_ctl2 & X86_VMX_FEATURE_PROC_CTLS2_VIRT_APIC) && | ||
| 228 | (msr_ctl & X86_VMX_FEATURE_PROC_CTLS_TPR_SHADOW)) | ||
| 229 | set_cpu_cap(c, X86_FEATURE_FLEXPRIORITY); | ||
| 230 | if (msr_ctl2 & X86_VMX_FEATURE_PROC_CTLS2_EPT) | ||
| 231 | set_cpu_cap(c, X86_FEATURE_EPT); | ||
| 232 | if (msr_ctl2 & X86_VMX_FEATURE_PROC_CTLS2_VPID) | ||
| 233 | set_cpu_cap(c, X86_FEATURE_VPID); | ||
| 234 | } | ||
| 235 | } | ||
| 236 | |||
| 199 | static void __cpuinit init_intel(struct cpuinfo_x86 *c) | 237 | static void __cpuinit init_intel(struct cpuinfo_x86 *c) |
| 200 | { | 238 | { |
| 201 | unsigned int l2 = 0; | 239 | unsigned int l2 = 0; |
| @@ -289,6 +327,9 @@ static void __cpuinit init_intel(struct cpuinfo_x86 *c) | |||
| 289 | 327 | ||
| 290 | /* Work around errata */ | 328 | /* Work around errata */ |
| 291 | srat_detect_node(); | 329 | srat_detect_node(); |
| 330 | |||
| 331 | if (cpu_has(c, X86_FEATURE_VMX)) | ||
| 332 | detect_vmx_virtcap(c); | ||
| 292 | } | 333 | } |
| 293 | 334 | ||
| 294 | #ifdef CONFIG_X86_32 | 335 | #ifdef CONFIG_X86_32 |
diff --git a/include/asm-x86/cpufeature.h b/include/asm-x86/cpufeature.h index 7ac4d93d20ed..8d45690bef5f 100644 --- a/include/asm-x86/cpufeature.h +++ b/include/asm-x86/cpufeature.h | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | #include <asm/required-features.h> | 7 | #include <asm/required-features.h> |
| 8 | 8 | ||
| 9 | #define NCAPINTS 8 /* N 32-bit words worth of info */ | 9 | #define NCAPINTS 9 /* N 32-bit words worth of info */ |
| 10 | 10 | ||
| 11 | /* | 11 | /* |
| 12 | * Note: If the comment begins with a quoted string, that string is used | 12 | * Note: If the comment begins with a quoted string, that string is used |
| @@ -150,6 +150,13 @@ | |||
| 150 | */ | 150 | */ |
| 151 | #define X86_FEATURE_IDA (7*32+ 0) /* Intel Dynamic Acceleration */ | 151 | #define X86_FEATURE_IDA (7*32+ 0) /* Intel Dynamic Acceleration */ |
| 152 | 152 | ||
| 153 | /* Virtualization flags: Linux defined */ | ||
| 154 | #define X86_FEATURE_TPR_SHADOW (8*32+ 0) /* Intel TPR Shadow */ | ||
| 155 | #define X86_FEATURE_VNMI (8*32+ 1) /* Intel Virtual NMI */ | ||
| 156 | #define X86_FEATURE_FLEXPRIORITY (8*32+ 2) /* Intel FlexPriority */ | ||
| 157 | #define X86_FEATURE_EPT (8*32+ 3) /* Intel Extended Page Table */ | ||
| 158 | #define X86_FEATURE_VPID (8*32+ 4) /* Intel Virtual Processor ID */ | ||
| 159 | |||
| 153 | #if defined(__KERNEL__) && !defined(__ASSEMBLY__) | 160 | #if defined(__KERNEL__) && !defined(__ASSEMBLY__) |
| 154 | 161 | ||
| 155 | #include <linux/bitops.h> | 162 | #include <linux/bitops.h> |
