addon_cpuid_features.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Routines to indentify additional cpu features that are scattered in
  3. * cpuid space.
  4. */
  5. #include <linux/cpu.h>
  6. #include <asm/pat.h>
  7. #include <asm/processor.h>
  8. struct cpuid_bit {
  9. u16 feature;
  10. u8 reg;
  11. u8 bit;
  12. u32 level;
  13. };
  14. enum cpuid_regs {
  15. CR_EAX = 0,
  16. CR_ECX,
  17. CR_EDX,
  18. CR_EBX
  19. };
  20. void __cpuinit init_scattered_cpuid_features(struct cpuinfo_x86 *c)
  21. {
  22. u32 max_level;
  23. u32 regs[4];
  24. const struct cpuid_bit *cb;
  25. static const struct cpuid_bit cpuid_bits[] = {
  26. { X86_FEATURE_IDA, CR_EAX, 1, 0x00000006 },
  27. { 0, 0, 0, 0 }
  28. };
  29. for (cb = cpuid_bits; cb->feature; cb++) {
  30. /* Verify that the level is valid */
  31. max_level = cpuid_eax(cb->level & 0xffff0000);
  32. if (max_level < cb->level ||
  33. max_level > (cb->level | 0xffff))
  34. continue;
  35. cpuid(cb->level, &regs[CR_EAX], &regs[CR_EBX],
  36. &regs[CR_ECX], &regs[CR_EDX]);
  37. if (regs[cb->reg] & (1 << cb->bit))
  38. set_cpu_cap(c, cb->feature);
  39. }
  40. }
  41. #ifdef CONFIG_X86_PAT
  42. void __cpuinit validate_pat_support(struct cpuinfo_x86 *c)
  43. {
  44. if (!cpu_has_pat)
  45. pat_disable("PAT not supported by CPU.");
  46. switch (c->x86_vendor) {
  47. case X86_VENDOR_INTEL:
  48. /*
  49. * There is a known erratum on Pentium III and Core Solo
  50. * and Core Duo CPUs.
  51. * " Page with PAT set to WC while associated MTRR is UC
  52. * may consolidate to UC "
  53. * Because of this erratum, it is better to stick with
  54. * setting WC in MTRR rather than using PAT on these CPUs.
  55. *
  56. * Enable PAT WC only on P4, Core 2 or later CPUs.
  57. */
  58. if (c->x86 > 0x6 || (c->x86 == 6 && c->x86_model >= 15))
  59. return;
  60. pat_disable("PAT WC disabled due to known CPU erratum.");
  61. return;
  62. case X86_VENDOR_AMD:
  63. case X86_VENDOR_CENTAUR:
  64. case X86_VENDOR_TRANSMETA:
  65. return;
  66. }
  67. pat_disable("PAT disabled. Not yet verified on this CPU type.");
  68. }
  69. #endif