addon_cpuid_features.c 911 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * Routines to indentify additional cpu features that are scattered in
  3. * cpuid space.
  4. */
  5. #include <linux/cpu.h>
  6. #include <asm/processor.h>
  7. struct cpuid_bit {
  8. u16 feature;
  9. u8 reg;
  10. u8 bit;
  11. u32 level;
  12. };
  13. enum cpuid_regs {
  14. CR_EAX = 0,
  15. CR_ECX,
  16. CR_EDX,
  17. CR_EBX
  18. };
  19. void __cpuinit init_scattered_cpuid_features(struct cpuinfo_x86 *c)
  20. {
  21. u32 max_level;
  22. u32 regs[4];
  23. const struct cpuid_bit *cb;
  24. static const struct cpuid_bit cpuid_bits[] = {
  25. { X86_FEATURE_IDA, CR_EAX, 1, 0x00000006 },
  26. { 0, 0, 0, 0 }
  27. };
  28. for (cb = cpuid_bits; cb->feature; cb++) {
  29. /* Verify that the level is valid */
  30. max_level = cpuid_eax(cb->level & 0xffff0000);
  31. if (max_level < cb->level ||
  32. max_level > (cb->level | 0xffff))
  33. continue;
  34. cpuid(cb->level, &regs[CR_EAX], &regs[CR_EBX],
  35. &regs[CR_ECX], &regs[CR_EDX]);
  36. if (regs[cb->reg] & (1 << cb->bit))
  37. set_bit(cb->feature, c->x86_capability);
  38. }
  39. }