aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHuaitong Han <huaitong.han@intel.com>2016-03-22 04:51:14 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2016-03-22 11:21:04 -0400
commite0b18ef7189075676ac432954d7920eaa30d8e3e (patch)
treee8c377ca45efe9eb2c863b098d2b7291df2d3efb
parentf13577e8aa863cf3b4f17541bc74f8e9b0b40c90 (diff)
KVM: x86: remove magic number with enum cpuid_leafs
This patch removes magic number with enum cpuid_leafs. Signed-off-by: Huaitong Han <huaitong.han@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--arch/x86/kvm/cpuid.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 0029644bf09c..00a69ecdd401 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -305,7 +305,7 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
305 unsigned f_xsaves = kvm_x86_ops->xsaves_supported() ? F(XSAVES) : 0; 305 unsigned f_xsaves = kvm_x86_ops->xsaves_supported() ? F(XSAVES) : 0;
306 306
307 /* cpuid 1.edx */ 307 /* cpuid 1.edx */
308 const u32 kvm_supported_word0_x86_features = 308 const u32 kvm_cpuid_1_edx_x86_features =
309 F(FPU) | F(VME) | F(DE) | F(PSE) | 309 F(FPU) | F(VME) | F(DE) | F(PSE) |
310 F(TSC) | F(MSR) | F(PAE) | F(MCE) | 310 F(TSC) | F(MSR) | F(PAE) | F(MCE) |
311 F(CX8) | F(APIC) | 0 /* Reserved */ | F(SEP) | 311 F(CX8) | F(APIC) | 0 /* Reserved */ | F(SEP) |
@@ -315,7 +315,7 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
315 F(FXSR) | F(XMM) | F(XMM2) | F(SELFSNOOP) | 315 F(FXSR) | F(XMM) | F(XMM2) | F(SELFSNOOP) |
316 0 /* HTT, TM, Reserved, PBE */; 316 0 /* HTT, TM, Reserved, PBE */;
317 /* cpuid 0x80000001.edx */ 317 /* cpuid 0x80000001.edx */
318 const u32 kvm_supported_word1_x86_features = 318 const u32 kvm_cpuid_8000_0001_edx_x86_features =
319 F(FPU) | F(VME) | F(DE) | F(PSE) | 319 F(FPU) | F(VME) | F(DE) | F(PSE) |
320 F(TSC) | F(MSR) | F(PAE) | F(MCE) | 320 F(TSC) | F(MSR) | F(PAE) | F(MCE) |
321 F(CX8) | F(APIC) | 0 /* Reserved */ | F(SYSCALL) | 321 F(CX8) | F(APIC) | 0 /* Reserved */ | F(SYSCALL) |
@@ -325,7 +325,7 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
325 F(FXSR) | F(FXSR_OPT) | f_gbpages | f_rdtscp | 325 F(FXSR) | F(FXSR_OPT) | f_gbpages | f_rdtscp |
326 0 /* Reserved */ | f_lm | F(3DNOWEXT) | F(3DNOW); 326 0 /* Reserved */ | f_lm | F(3DNOWEXT) | F(3DNOW);
327 /* cpuid 1.ecx */ 327 /* cpuid 1.ecx */
328 const u32 kvm_supported_word4_x86_features = 328 const u32 kvm_cpuid_1_ecx_x86_features =
329 /* NOTE: MONITOR (and MWAIT) are emulated as NOP, 329 /* NOTE: MONITOR (and MWAIT) are emulated as NOP,
330 * but *not* advertised to guests via CPUID ! */ 330 * but *not* advertised to guests via CPUID ! */
331 F(XMM3) | F(PCLMULQDQ) | 0 /* DTES64, MONITOR */ | 331 F(XMM3) | F(PCLMULQDQ) | 0 /* DTES64, MONITOR */ |
@@ -337,27 +337,27 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
337 0 /* Reserved*/ | F(AES) | F(XSAVE) | 0 /* OSXSAVE */ | F(AVX) | 337 0 /* Reserved*/ | F(AES) | F(XSAVE) | 0 /* OSXSAVE */ | F(AVX) |
338 F(F16C) | F(RDRAND); 338 F(F16C) | F(RDRAND);
339 /* cpuid 0x80000001.ecx */ 339 /* cpuid 0x80000001.ecx */
340 const u32 kvm_supported_word6_x86_features = 340 const u32 kvm_cpuid_8000_0001_ecx_x86_features =
341 F(LAHF_LM) | F(CMP_LEGACY) | 0 /*SVM*/ | 0 /* ExtApicSpace */ | 341 F(LAHF_LM) | F(CMP_LEGACY) | 0 /*SVM*/ | 0 /* ExtApicSpace */ |
342 F(CR8_LEGACY) | F(ABM) | F(SSE4A) | F(MISALIGNSSE) | 342 F(CR8_LEGACY) | F(ABM) | F(SSE4A) | F(MISALIGNSSE) |
343 F(3DNOWPREFETCH) | F(OSVW) | 0 /* IBS */ | F(XOP) | 343 F(3DNOWPREFETCH) | F(OSVW) | 0 /* IBS */ | F(XOP) |
344 0 /* SKINIT, WDT, LWP */ | F(FMA4) | F(TBM); 344 0 /* SKINIT, WDT, LWP */ | F(FMA4) | F(TBM);
345 345
346 /* cpuid 0xC0000001.edx */ 346 /* cpuid 0xC0000001.edx */
347 const u32 kvm_supported_word5_x86_features = 347 const u32 kvm_cpuid_C000_0001_edx_x86_features =
348 F(XSTORE) | F(XSTORE_EN) | F(XCRYPT) | F(XCRYPT_EN) | 348 F(XSTORE) | F(XSTORE_EN) | F(XCRYPT) | F(XCRYPT_EN) |
349 F(ACE2) | F(ACE2_EN) | F(PHE) | F(PHE_EN) | 349 F(ACE2) | F(ACE2_EN) | F(PHE) | F(PHE_EN) |
350 F(PMM) | F(PMM_EN); 350 F(PMM) | F(PMM_EN);
351 351
352 /* cpuid 7.0.ebx */ 352 /* cpuid 7.0.ebx */
353 const u32 kvm_supported_word9_x86_features = 353 const u32 kvm_cpuid_7_0_ebx_x86_features =
354 F(FSGSBASE) | F(BMI1) | F(HLE) | F(AVX2) | F(SMEP) | 354 F(FSGSBASE) | F(BMI1) | F(HLE) | F(AVX2) | F(SMEP) |
355 F(BMI2) | F(ERMS) | f_invpcid | F(RTM) | f_mpx | F(RDSEED) | 355 F(BMI2) | F(ERMS) | f_invpcid | F(RTM) | f_mpx | F(RDSEED) |
356 F(ADX) | F(SMAP) | F(AVX512F) | F(AVX512PF) | F(AVX512ER) | 356 F(ADX) | F(SMAP) | F(AVX512F) | F(AVX512PF) | F(AVX512ER) |
357 F(AVX512CD) | F(CLFLUSHOPT) | F(CLWB) | F(PCOMMIT); 357 F(AVX512CD) | F(CLFLUSHOPT) | F(CLWB) | F(PCOMMIT);
358 358
359 /* cpuid 0xD.1.eax */ 359 /* cpuid 0xD.1.eax */
360 const u32 kvm_supported_word10_x86_features = 360 const u32 kvm_cpuid_D_1_eax_x86_features =
361 F(XSAVEOPT) | F(XSAVEC) | F(XGETBV1) | f_xsaves; 361 F(XSAVEOPT) | F(XSAVEC) | F(XGETBV1) | f_xsaves;
362 362
363 /* all calls to cpuid_count() should be made on the same cpu */ 363 /* all calls to cpuid_count() should be made on the same cpu */
@@ -376,10 +376,10 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
376 entry->eax = min(entry->eax, (u32)0xd); 376 entry->eax = min(entry->eax, (u32)0xd);
377 break; 377 break;
378 case 1: 378 case 1:
379 entry->edx &= kvm_supported_word0_x86_features; 379 entry->edx &= kvm_cpuid_1_edx_x86_features;
380 cpuid_mask(&entry->edx, 0); 380 cpuid_mask(&entry->edx, CPUID_1_EDX);
381 entry->ecx &= kvm_supported_word4_x86_features; 381 entry->ecx &= kvm_cpuid_1_ecx_x86_features;
382 cpuid_mask(&entry->ecx, 4); 382 cpuid_mask(&entry->ecx, CPUID_1_ECX);
383 /* we support x2apic emulation even if host does not support 383 /* we support x2apic emulation even if host does not support
384 * it since we emulate x2apic in software */ 384 * it since we emulate x2apic in software */
385 entry->ecx |= F(X2APIC); 385 entry->ecx |= F(X2APIC);
@@ -433,8 +433,8 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
433 entry->flags |= KVM_CPUID_FLAG_SIGNIFCANT_INDEX; 433 entry->flags |= KVM_CPUID_FLAG_SIGNIFCANT_INDEX;
434 /* Mask ebx against host capability word 9 */ 434 /* Mask ebx against host capability word 9 */
435 if (index == 0) { 435 if (index == 0) {
436 entry->ebx &= kvm_supported_word9_x86_features; 436 entry->ebx &= kvm_cpuid_7_0_ebx_x86_features;
437 cpuid_mask(&entry->ebx, 9); 437 cpuid_mask(&entry->ebx, CPUID_7_0_EBX);
438 // TSC_ADJUST is emulated 438 // TSC_ADJUST is emulated
439 entry->ebx |= F(TSC_ADJUST); 439 entry->ebx |= F(TSC_ADJUST);
440 } else 440 } else
@@ -514,7 +514,7 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
514 514
515 do_cpuid_1_ent(&entry[i], function, idx); 515 do_cpuid_1_ent(&entry[i], function, idx);
516 if (idx == 1) { 516 if (idx == 1) {
517 entry[i].eax &= kvm_supported_word10_x86_features; 517 entry[i].eax &= kvm_cpuid_D_1_eax_x86_features;
518 entry[i].ebx = 0; 518 entry[i].ebx = 0;
519 if (entry[i].eax & (F(XSAVES)|F(XSAVEC))) 519 if (entry[i].eax & (F(XSAVES)|F(XSAVEC)))
520 entry[i].ebx = 520 entry[i].ebx =
@@ -564,10 +564,10 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
564 entry->eax = min(entry->eax, 0x8000001a); 564 entry->eax = min(entry->eax, 0x8000001a);
565 break; 565 break;
566 case 0x80000001: 566 case 0x80000001:
567 entry->edx &= kvm_supported_word1_x86_features; 567 entry->edx &= kvm_cpuid_8000_0001_edx_x86_features;
568 cpuid_mask(&entry->edx, 1); 568 cpuid_mask(&entry->edx, CPUID_8000_0001_EDX);
569 entry->ecx &= kvm_supported_word6_x86_features; 569 entry->ecx &= kvm_cpuid_8000_0001_ecx_x86_features;
570 cpuid_mask(&entry->ecx, 6); 570 cpuid_mask(&entry->ecx, CPUID_8000_0001_ECX);
571 break; 571 break;
572 case 0x80000007: /* Advanced power management */ 572 case 0x80000007: /* Advanced power management */
573 /* invariant TSC is CPUID.80000007H:EDX[8] */ 573 /* invariant TSC is CPUID.80000007H:EDX[8] */
@@ -600,8 +600,8 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
600 entry->eax = min(entry->eax, 0xC0000004); 600 entry->eax = min(entry->eax, 0xC0000004);
601 break; 601 break;
602 case 0xC0000001: 602 case 0xC0000001:
603 entry->edx &= kvm_supported_word5_x86_features; 603 entry->edx &= kvm_cpuid_C000_0001_edx_x86_features;
604 cpuid_mask(&entry->edx, 5); 604 cpuid_mask(&entry->edx, CPUID_C000_0001_EDX);
605 break; 605 break;
606 case 3: /* Processor serial number */ 606 case 3: /* Processor serial number */
607 case 5: /* MONITOR/MWAIT */ 607 case 5: /* MONITOR/MWAIT */